See examples in Calculus.mw
fZero(f,r,/iniguess,{relerror,abserror,maxiter,output::name:=undefined},$)
robust numerical procedure for finding zero of a function
when fsolve command fails,
where
f::procedure continuous function;r::range(realcons) search range x1..x2;iniguess::realcons:=infinity initial guess;relerror,abserror::nonnegative:=0 relative or absolute error,
if abserror=0 then abserror=max(relerror,10^(2-Digits));maxiter::posint:=100 maximum number of iterations;output::name:=undefined name of variable to which will be assigned output of FZERO function.r the function <f should have a single zero where the function changes its sign.
The algorithm uses bisection and linear interpolation and extrapolation until |x1-x2|<abserror.fDblZero(f,r,{relerror,abserror,maxiter,rootnumber,noerror},$)
find two close zeros, where rootnumber::posint:=0 is interpreted as follows:
if 1 then the left root is returned, if 2 then the right root is returned, otherwise both of them.fZeros(f,r,/n,GridF,{relerror,abserror,maxiter},$)
find all zeros within specified range by dividing it into n::posint:=20 subintervals.
Here GridF::procedure:=(x->x) is a grid function (see Grid).FZERO(f,x1,x2,iniguess,relerror,abserror,maxiter)::[flag,x0,x2,iter]
core routine based on FORTRAN subroutine of SLATEC package.
Here x0 is the location of zero
and x2 is the other boundary of interval after iter iterations.
The flag can take the following values:
1 success;2 success, f(x0)=0 "occasionally", though the interval x0..x2 is large as in example below;3 success, but the function seems to have singularity instead of zero;4 fail, either function has no zero or its zero has even multiplicity
(nevertheless in the last case the routine can sometimes find zero as illustrated in example);5 fail, the number of iterations exceeded the maximum allowed.NLPSolve2(n,f,/g,dx,{onesidegradient},_rest)
patch to NLPSolve with gradient,
where
n::posint number of variables;f::procedure function to minimize;g::{0,procedure}:=0 gradient;dx::positive:=10^(-iquo(Digits,2)) if the gradient is not provided it is calculated as (f(x+e_i*dx)-f(x-e_i*dx))/2/dx;onesidegradient::boolean:=false if true the gradient is calculated as (f(x+e_i*dx)-f(x))/dx;_rest passed to matrix NLPSolve command
(see Optimization/Methods).HessianByGradient(n,g,x,/dx,{printout},$)::Matrix
compute Hessian numerically by known gradient, where
n::posint number of variables;g::procedure gradient, it takes an indexable object as its input and returns an indexable object as its output;x::indexable point at which Hessian will be calculated;dx::positive:=10^(-iquo(Digits,3)) grid spacing.PolynomialInterpolation1der(xydata,x,k,ypk)
interpolating polynomial with fixed derivatives at one point, where
xydata::list of points [xi,yi] to be interpolated,
x is the polynom variable,
and k::nonnegint is the index of the point at which derivative ypk is given.
See also PolynomialInterpolation.BezierControlPoints(x1,y1,p1,q1,k1,x4,y4,p4,q4,k4::realcons)
find control points of a cubic Bezier curve, where
x,y is the endpoint,
p,q is the unit vector of velocity direction at endpoint (a velocity is [xp,yp]=v*[p,q]),
k is the curvature at endpoint k=(xp*ypp-yp*xpp)/v^3.
If the equation for absolute value of velocities at endpoints can not be solved,
then the "1/3" rule is applied: distance from endpoint to the nearest control point is set to 1/3 of distance between endpoints.BezierNodes(points,/B)::nodes
interpolate derivative and curvature at points::list of [x,y]
with left and right boundary conditions B::list:=[0,0] encoded as follows:
0 end point is interpolated by polynomial of order 3 and its neighbor – by order 4;1 one boundary point is removed from nodes;2 two boundary points are removed from nodes;3 derivative is provided as args[3], end point is interpolated by polynomial of order 4;4 derivative and curvature are provided as args[3] and args[4].nodes is the list of [x,y,p,q,k] as defined in BezierControlPoints.
Currently only curves defined by a single-valued function y(x) are implemented.
General parametric curves are not supported.
Internal points are interpolated by the fifth-order polynomial.
Thus two points at the left end and two points at the right end are boundaries.
To resolve boundary problem completely use either two extra points (code 2) or provide the derivative and curvature (code 4).
See also Spline Continuity and End Conditions.ExtrapolateMPE(X,$)::Vector
minimal polynomial extrapolation of vector sequence given as columns of X::Matrix,
the output is the estimated limit of the sequence,
see [K Jbilou, H Sadok, IMA J Numer Anal 19, 549 (1999)] and references therein.
Pearson4approx(mu,sigma,gamma,delta,output::string:="f",$)
Pearson type IV distribution
defined by the four moments: mean value mu,
variance sigma^2, skewness gamma, and excess kurtosis delta.
The output is either distribution function or its parameters.