/* ** NL2.E ** ** This example compares the use of the Hookstep/Analytic Jacobian ** strategy with the Line Search/Secant Update strategy. ** ** Using the former strategy, the value of the system at the final ** solution is of magnitude of 1e-11; using the latter strategy ** that value is of magnitude 1e-6. */ library nlsys; nlset; proc f(x); local f1,f2,f3; f1 = 3*x[1]^3 + 2*x[2]^2 + 5*x[3] - 10; f2 = -x[1]^3 - 3*x[2]^2 + x[3] + 5; f3 = 3*x[1]^3 + 2*x[2]^2 -4*x[3]; retp(f1|f2|f3); endp; proc fjc(x); local fjc1,fjc2, fjc3; fjc1 = 9*x[1]^2~4*x[2]~5; fjc2 = -3*x[1]^2~-6*x[2]~1; fjc3 = 9*x[1]^2~4*x[2]~-4; retp(fjc1|fjc2|fjc3); endp; x0 = zeros(3,1); x0[1] = -1; x0[2] = 12; x0[3] = -1; _nlalgr = 2; _nlchpf = 1; _nlajac = &fjc; output file = nl2.out reset; __title = "NL2.E - Using Analytic Jacobian with Hook Step"; { x,fvp,jc,tcode } = nlprt(nlsys(&f,x0)); nlset; _nlalgr = 1; _nlchpf = 0; __title = "NL2.E - Using Secant Update with Line Search"; { x,fvp,jc,tcode } = nlprt(nlsys(&f,x0)); output off;