正在加载图片...
水中浮球问题:x3-30x2+2552=0 delta =5e-6;eps 1e-6 def f(x): return x*x*x-30*x*x+2552 def MyBicection(f,a,b): n=1;fa=f(a);fb=f(b) while True: c=(a+b)/2; fc=f(c) print((三分次数 ,"0:.0f".format(n),"10:.4f".format(a),"0:.4f".format(a),"0:.4f".format(b)) n=n+1 if abs(fc)<delta: break elif fa*fc <0: b=c; fb=fc else: a=c; fa=fc if b-a<eps: break return c x=MyBicection(f,0,20) 11.861501 print(方程的根为x=',"{0:.6f".format(x)》 9/149/14 水中浮球问题: x 3 – 30 x 2 + 2552 = 0 x delta =5e-6;eps = 1e-6 def f(x): return x*x*x-30*x*x+2552 def MyBicection(f, a, b): n=1; fa= f(a); fb= f(b) while True: c=(a+b)/2; fc=f(c) print('二分次数 ' , "{0:.0f}".format(n), "{0:.4f}".format(a), "{0:.4f}".format(a), "{0:.4f}".format(b)) n=n+1 if abs(fc)<delta: break elif fa*fc <0: b=c; fb=fc else: a=c; fa=fc if b-a<eps: break return c x=MyBicection(f,0,20) print('方程的根为x=' , "{0:.6f}".format(x)) 11.861501
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有