[Next][Prev] [Right] [Left] [Up] [Index] [Root]

Numerical Functions

This section contains some functions for numerical analysis, taken from Pari.

Subsections

Summation of Infinite Series

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.

InfiniteSum(m, i) : Map, RngIntElt -> FldReElt
An approximation to the infinite sum m(i) + m(i + 1) + m(i + 2) + ... . This function also works for maps to the complex field.
PositiveSum(m, i) : Map, RngIntElt -> FldReElt
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.
AlternatingSum(m, i) : Map, RngIntElt -> FldReElt
    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.

Integration

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).

Interpolation(P, V, x) : [FldReElt], [FldReElt], FldReElt -> FldReElt, FldReElt
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.
RombergQuadrature(f, a, b: parameters) : Program, FldReElt, FldReElt -> FldReElt
    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.
SimpsonQuadrature(f, a, b, n) : Program, FldReElt, FldReElt, RngIntElt -> FldReElt
Using Simpson's rule on n sub-intervals, approximate the integral of f from a to b.
TrapezoidalQuadrature(f, a, b, n) : Program, FldReElt, FldReElt, RngIntElt -> FldReElt
Using the trapezoidal rule on n sub-intervals, approximate the integral of f from a to b.

Numerical Derivatives

There is also a function to compute the NumericalDerivative of a function. This works via computing enough interpolation points and using a Taylor expansion.

NumericalDerivative(f, n, z) : UserProgram, RngIntElt, FldComElt -> FldComElt
Given a suitably nice function f, compute a numerical approximation to the nth derivative at the point z.

Example FldRe_NumericalDerivative (H25E9)

> 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]

Version: V2.19 of Wed Apr 24 15:09:57 EST 2013