This section contains some functions for numerical analysis, taken from Pari.
There are three functions for evaluating infinite sums of real numbers. The sum should be specified as a map m from the integers to the real field, such that m(n) is the n th term of the sum. The summation begins at term i. The precision of the result will be the default precision of the real field.
An approximation to the infinite sum m(i) + m(i + 1) + m(i + 2) + ... . This function also works for maps to the complex field.
An approximation to the infinite sum m(i) + m(i + 1) + m(i + 2) + ... . Designed for series in which every term is positive, it uses van Wijngaarden's trick for converting the series into an alternating one. Due to the stopping criterion, terms equal to 0 will create problems and should be removed.
Al: MonStgElt Default: "Villegas"
An approximation to the infinite sum m(i) + m(i + 1) + m(i + 2) + ... . Designed for series in which the terms alternate in sign. The optional argument Al can be used to specify the algorithm used. The possible values are "Villegas" (the default), and "EulerVanWijngaarden". Due to the stopping criterion, terms equal to 0 will create problems and should be removed.
A number of `Romberg-like' integration methods have been taken from Pari. The precision should not be made too large for this, and singularities are not allowed in the interval of integration (including its boundaries).
Using Neville's algorithm, interpolate the value of x under a polynomial p such that p(P[i]) = V[i]. An estimate of the error is also returned.
Precision: FldReElt Default: 1.0e-6
MaxSteps: RngIntElt Default: 20
K: RngIntElt Default: 5
Using Romberg's method of order 2K, approximate the integral of f from a to b. The desired accuracy may be specified by setting the Precision parameter, and the order of the algorithm by changing K. The algorithm ceases after MaxSteps iterations if the desired accuracy has not been achieved.
Using Simpson's rule on n sub-intervals, approximate the integral of f from a to b.
Using the trapezoidal rule on n sub-intervals, approximate the integral of f from a to b.
There is also a function to compute the NumericalDerivative of a function. This works via computing enough interpolation points and using a Taylor expansion.
Given a suitably nice function f, compute a numerical approximation to the nth derivative at the point z.
> f := func<x|Exp(2*x)>; > NumericalDerivative(f, 10, ComplexField(30)! 1.0) / f (1.0); 1024.00000000000000000000000000 > NumericalDerivative(func<x|LogGamma(x)>,1,ComplexField()!3.0); 0.922784335098467139393487909918 > Psi(3.0); // Psi is Gamma'/Gamma 0.922784335098467139393487909918[Next][Prev] [Right] [Left] [Up] [Index] [Root]