2 %> Algorithm 8.2: Newton
's secant method, one variable. Implementation of algorithm 8.2 of \cite Bier15-book 4 %> @author <a href="http://people.epfl.ch/michel.bierlaire">Michel Bierlaire</a> 5 %> @date Thu Mar 19 09:53:09 2015 9 %> @note Tested with \ref run0703sec.m 11 %> Applies Newton's secant algorithm to solve \f$F(x)=0\f$ where \f$F:\mathbb{R}\to\mathbb{R} \f$
12 %> @param obj the name of the Octave
function defining F(x)
13 %> @param x0 the starting point
14 %> @param a0 the first approximation of the derivative
15 %> @param eps algorithm stops if \f$|F(x)| \leq \varepsilon \f$.
16 %> @param maxiter maximum number of iterations (Default: 100)
17 %> @
return root of the
function 23 printf("%d %15.8e %15.8e %15.8e\n",k,xk,f,ak) ;
29 ak = (fold - f) / (xold - xk) ;
31 printf("%d %15.8e %15.8e %15.8e\n",k,xk,f,ak) ;
32 until (abs(f) <= eps || k >= maxiter)
function secantOneVariable(in obj, in x0, in a0, in eps, in maxiter)
Applies Newton's secant algorithm to solve where .