用二分法求在(a,b)上单调的函数近似值 第八行的表达式可更改,第三行的kexi决定的精度,小数值计算可将第五行的extended更为real或double PROGRAM EQUANTION (input,output); CONST kexi=0.0000001; VAR a,b,c:extended; FUNCTION fx(x:extended):extended; BEGIN fx:=ln(x)/ln(2); END; BEGIN writeln('Please input a a…
+二分法求平方根 x = float(raw_input('Enter the number')) low = 0 high = x guess = (low + high ) / 2 if x < 0: print 'Number Error' while abs(guess**2 - x) > 1e-5: if guess**2 < x: low = guess else: high = guess guess = (low + high) / 2 print 'The root o…