- tools for root finding and minimizing in Xi -
( 1)>double [] f(double x[]) {return 4*pow(x,2)-3*x-10;}
Function f defined
( 2)>[x,f]=find_root([x->z:z=f(x);],{-1,1});
Message: algorithm estimates that the relative error between x and the solution
is at most tol in function find_root
( 3)>print(x,f);
<dblarr>
-1.25 2
<dblarr>
-2.9345415e-12 -5.1318949e-12
Checking this result yields
( 4)>print(f(x));-2.9345415e-12 -5.1318949e-12
The purpose of minimize(func,x[,tol][,fcn_calls]) is to minimize the sum of the squares of the nonlinear function func (double vector), where x contains an initial estimate of the solution vector. tol is a tolerance parameter: termination of the routine occurs when the algorithm estimates either that the relative error in the sum of squares is at most tol or that the relative error between x and the solution is at most tol. fcn_calls lays down the maximum number of calls to func within an iteration.
Example: minimize the function f(x,y)={cos(x),exp(-x^2)}.
( 1)>double[] f(double x[]) {return {cos(x),exp(-x*x)};}
Function f defined
( 2)>[x,f]=minimize([x->y:y=f(x);],{1},\fcn_calls=1000)
Message: algorithm estimates that the relative error between x and the solutionis at most tol in function minimize
( 3)>print(x,f);
1.5909477
-0.020149981 0.07957029