Secant Method Python Program (with Output)
www.codesansar.com › numerical-methods › secantPython Source Code: Secant Method. # Defining Function def f( x): return x **3 - 5* x - 9 # Implementing Secant Method def secant( x0, x1, e, N): print(' *** SECANT METHOD IMPLEMENTATION ***') step = 1 condition = True while condition: if f ( x0) == f ( x1): print('Divide by zero error!') break x2 = x0 - ( x1 - x0)* f ( x0)/( f ( x1) - f ( x0) ) print('Iteration-%d, x2 = %0.6f and f (x2) = %0.6f' % ( step, x2, f ( x2))) x0 = x1 x1 = x2 step = step + 1 if step > N: print('Not Convergent!') ...
Octave, The secant method - Stack Overflow
stackoverflow.com › octave-the-secant-methodDec 30, 2021 · I used the while-loop for calculate the root of a function and I think the problem is in the loop. But the result that I get, it is not what I expect. The correct answer is x=0,49438. tol = 10.^ (-5); # tolerance x0 = 0.4; # initial point x1 = 0.6; # initial point syms x; fun = @ (x) exp (sin (x)) - 2/ (1+x.^2); # f (x) = exp (sin (x)) - 2/ (1 ...