代码:
import matplotlib.pyplot as plt
xx=[0]
yy=[1]
x=0
y=1
h=0.1
for i in range(1,11):
x=x+h
xx.append(x)
y=y+h*(y-2*x/y)
yy.append(y)
print(xx)
print(yy)
plt.plot(xx,yy)
plt.show()
结果:
代码:
import matplotlib.pyplot as plt
xx=[0]
yy=[1]
x=0
y=1
h=0.1
for i in range(1,11):
x=x+h
xx.append(x)
y=y+h*(y-2*x/y)
yy.append(y)
print(xx)
print(yy)
plt.plot(xx,yy)
plt.show()
结果: