编程语言
首页 > 编程语言> > 欧拉算法

欧拉算法

作者:互联网


import matplotlib.pyplot as plt
targetX = 10.0
step = 0.1
axis1, axis2 = 0.0, 1.0
X, Y = [axis1], [axis2]

def fun(axis1:float, axis2:float):
    return axis2 - 2 * axis1 / axis2

while axis1 <= targetX:
    t1 = fun(axis1, axis2)
    t2 = fun(x + step, axis2 + t1 * step)
    axis2 = axis2 + 0.5 * (t1 + t2) * step
    axis1 = axis1 + step
    X.append(axis1)
    Y.append(axis2)

标签:10.0,plt,1.0,axis1,axis2,float,算法,欧拉
来源: https://blog.csdn.net/qsrkkkkkk/article/details/120448979