2 %> Algorithm 8.3: Newton
's method with finite differences, n variables. Implementation of algorithm 8.3 of \cite Bier15-book 4 %> @author <a href="http://people.epfl.ch/michel.bierlaire">Michel Bierlaire</a> 5 %> @date Thu Mar 19 18:26:50 2015 9 %> @note Tested with \ref run0711df.m 11 %> Applies Newton's algorithm with finite differences to solve \f$F(x)=0\f$ where \f$F:\mathbb{R}^n\to\mathbb{R}^n \f$
12 %> @param obj the name of the Octave
function defining F(x) and its Jacobian
13 %> @param x0 the starting point
14 %> @param tau step
for the finite difference approximation
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 system
22 printf("%2d %+15.8e %+15.8e %+15.8e\n",k,xk(1),f(1),norm(f)) ;
23 printf(" %+15.8e %+15.8e\n",xk(2),f(2)) ;
37 fp = feval(obj,xk+s * ei) ;
38 A(:,i) = (fp - f) / s ;
43 printf("%2d %+15.8e %+15.8e %+15.8e\n",k,xk(1),f(1),norm(f)) ;
44 printf(" %+15.8e %+15.8e\n",xk(2),f(2)) ;
45 until (norm(f) <= eps || k >= maxiter)
function newtonFinDiffNVariables(in obj, in x0, in tau, in eps, in maxiter)
Applies Newton's algorithm with finite differences to solve where .