find the 0 of a function by Wang, Kou and Gu (2011) method
[xs,fs,maxfs]=newton_WKG11_sp(x0,func,Jac,indJac,ftol,itermax,alphamin)
* x0 = a (n x 1) vector of starting values
* func = a function, whose 0 is searched
* Jac = a function, performing the non zero values of the Jacobian of this function (with the rhs as an output)
* indJac = a (K x 2) matrix, collecting the non zero indexes of the Jacobian
* ftol = the convergence criterion for the function value
* itermax = the maxmimum number for the function calls
* alphamin = the minimum value used to dampen the step when convergence is not acheived
* xs = the value of the parameter at solution
* fs = the value of the function at solution
* maxfs = the maximum value of the absolute function at solution
// Search the zero of function test_func in the optsci folder. The function codes the problem 7 provided by // Sharma, Sharma and Bahl (2016), An improved Newton–Traub composition for solving systems of nonlinear equations, // Applied Mathematics and Computation, N. 290, p. 98-110. // The function to minimize is: // x(i)x(i+1)=1 for i=1:98 // x(99)x(1)=1 // The corresponding Jacobian function is coded in function test_Jac_sp // Starting values are the ones provided in the paper: -4*ones(99,1) // Convergence criterion is set to 1e-10, maximum # of iterations is set to 1000, minimum value used to dampen the step is set to ind_sp=[[1:99 1:99]' , [1:99 2:99 1]']; [x0,f0,maxf0]=newton_WKG11_sp(-4*ones(99,1),newton_test_sp,newton_testJac_sp,ind_sp,1e-8,100,0.05) // Provides the expected result x0 =-1*ones(99,1) and f0=0 | ![]() | ![]() |