Euler公式

Euler公式

系统:win11

开发环境: VS code

实验代码

#若vs code未安装matplotlib需要终端输入pip install matplotlib

import matplotlib.pyplot as plt

x=0
y=1
X=[0]
Y=[1]
h=0.1

for i in range(1,11):
    x=x+h
    X.append(x)
    y=y+h*(y-2*x/y)
    Y.append(y)

print(X)
print(Y)

plt.plot(X,Y)
plt.show()

实验结果

Euler公式_第1张图片

你可能感兴趣的:(python,开发语言)