2 %> Algorithm 8.1: Newton
's method with finite differences, one variable. Implementation of algorithm 8.1 of \cite Bier15-book 4 %> @author <a href="http://people.epfl.ch/michel.bierlaire">Michel Bierlaire</a> 5 %> @date Thu Mar 19 09:44:05 2015 9 %> @note Tested with \ref run0703df.m 11 %> Applies Newton's algorithm with finite differences 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 eps algorithm stops if \f$|F(x)| \leq \varepsilon \f$.
15 %> @param tau step
for the finite difference approximation
16 %> @param maxiter maximum number of iterations (Default: 100)
17 %> @
return root of the
function 22 printf("%d %15.8e %15.8e\n",k,xk,f) ;
29 fs = feval(objop,xk+s) ;
30 xk = xk - s * f / (fs - f) ;
33 printf("%d %15.8e %15.8e\n",k,xk,f) ;
34 until (abs(f) <= eps || k >= maxiter)
function newtonFinDiffOneVariable(in obj, in x0, in eps, in tau, in maxiter)
Applies Newton's algorithm with finite differences to solve where .