标签:play 0.00 return ica 二分 lam color spl pre
PART1 <求解方程>
1,二分法
def bisect(f,a,b,TOL=0.000004): u_a = a u_b = b while(u_b-u_a)/2.0 > TOL: c = (u_a+u_b)/2.0 if f(c) == 0: break if f(u_a)*f(c) < 0: u_b = c else: u_a = c u_c = (u_a + u_b) / 2.0 return u_c f = lambda x: x*x*x + x - 1 ret = bisect(f,-1.0,1.0) print(ret) print(f(ret))
标签:play 0.00 return ica 二分 lam color spl pre
原文地址:https://www.cnblogs.com/gearslogy/p/10306643.html