#P233 例题1 import numpy as np x=0 y=0 yn=0 for i in range(0,11): x1=round(x+0.1,6) y1=round(y+0.1*(x-y),6) yn=round(x+np.e**(-x)-1,6) ans=round(yn-y,6) print(i,x,y,yn,ans) x=x1 y=y1 #P264 习题九 1.(2) import numpy as np x=0 y=1 yn=1 for i in range(0,11): x1=round(x+0.1,4) #y1=round(y+0.1*(x-y),6) y1=round(y+0.1*(y-2*x/y),4) #yn=round(x+np.e**(-x)-1,6) yn=round((2*x+1)**0.5,4) ans=round(yn-y,4) print(x,y,yn,ans,sep='\t\t') x=x1 y=y1 #P264 习题九 2 import numpy as np x=0 y=0 yn=0 h=0.5 for i in range(0,5): x1=round(x+h,5) #y1=round(y+0.1*(x-y),6) y1=round(y+h*(1-2*x*y/(1+x**2)),5) #yn=round(x+np.e**(-x)-1,6) yn=round(x*(3+x**2)/3/(1+x**2),5) ans=round(yn-y,6) print(i,x,y,yn,ans,sep='\t\t') x=x1 y=y1