import numpy as np import math a=1 b=2 for x in range(0,20): #Xn=(a+b)/2 Xn=round((a+b)/2,8) fxn=round(Xn**3+4*Xn**2-10,8) Xn=(a+b)/2 fxn=Xn**3+4*Xn**2-10 #fxn=Xn**3+4*Xn**2-10 #习题八 1.(3) #fxn=Xn**3+10*Xn-20 #例题 print(x,':',a,b,Xn,fxn,sep='\t\t',end='\n') if(fxn<0): a=Xn if(fxn>0): b=Xn import numpy as np import math x=1.5 print('8.2题') for i in range(0,50): y=round(1+1/x**2,6) err=round(abs(x-y),6) print(i,x,err) x=y import numpy as np import math x=2.5 print('8.3.3题') for i in range(0,12): y=round((5/x+2)**0.5,7) err=round(abs(x-y),7) print(i,x,err,sep='\t\t') x=y