Orbital library

orbital.math
Class NumericalAlgorithms

java.lang.Object
  extended by orbital.math.NumericalAlgorithms

public final class NumericalAlgorithms
extends java.lang.Object

This class contains numerical algorithms.

The implementation algorithms for the methods of this class are free to vary in order to increase performance or accuracy. Nevertheless, the signatures and assertions must be fulfilled by every implementation.

Author:
André Platzer
See Also:
MathUtilities, LUDecomposition
Stereotype:
Utilities, Module

Field Summary
static int COMPLETE_SPLINE_INTERPOLATION
          complete spline interpolation with border conditions s'(a)=f'(a) and s'(b)=f'(b).
static int NATURAL_SPLINE_INTERPOLATION
          natural spline interpolation with natural decay conditions s''(a)=0 and s''(b)=0.
static int PERIODICAL_SPLINE_INTERPOLATION
          periodical spline interpolation with periodicity conditions s'(a)=s'(b) and s''(a)=s''(b).
 
Method Summary
static Function bezierCurve(double t0, double tz, Matrix bezierNodes)
          Bezier curve.
static Vector cgSolve(Matrix A, Vector x0, Vector b)
          cg-algorithm for solving A∙x=b iteratively starting with x0.
static Matrix decomposeCholesky(Matrix A)
          Cholesky-decomposition of positive definite matrices implementation.
static Function dSolve(BinaryFunction f, Real tau, Real eta, Real a, Real b, int steps, int order)
          Returns a numerical solution x of the one-dimensional differential equation x'(t) = f(t,x(t)), x(τ)=η on [a,b].
static Function dSolve(BinaryFunction f, Real tau, Real eta, Real min, Real max, int steps, Matrix butcher)
          Returns a numerical solution x of the one-dimensional differential equation x'(t) = f(t,x(t)), x(τ)=η on [a,b].
static Function dSolve(BinaryFunction f, Real tau, Vector eta, Real a, Real b, int steps, int order)
          Returns a numerical solution x of the differential equation x'(t) = f(t,x(t)), x(τ)=η on [a,b].
static Function dSolve(BinaryFunction f, Real tau, Vector eta, Real min, Real max, int steps, Matrix butcher)
          Returns a numerical solution x of the differential equation x'(t) = f(t,x(t)), x(τ)=η on [a,b].
static Arithmetic integrate(Function f, Arithmetic a, Arithmetic b)
          Returns ≈ ∫ab f dx.
static Function polynomialInterpolation(Matrix A)
          Polynomial interpolation.
static Function splineInterpolation(int k, Matrix A, int interpolationType)
          Spline interpolation.
static Function splineInterpolation(int k, Matrix A, int interpolationType, java.lang.Object[] config)
          Deprecated. Use splineInterpolation(int,Matrix,int,Real,Real), or splineInterpolation(int,Matrix,int) instead since they have a more reasonable argument list.
static Function splineInterpolation(int k, Matrix A, int interpolationType, Real fp_a, Real fp_b)
          Spline interpolation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPLETE_SPLINE_INTERPOLATION

public static final int COMPLETE_SPLINE_INTERPOLATION
complete spline interpolation with border conditions s'(a)=f'(a) and s'(b)=f'(b).

See Also:
Constant Field Values

NATURAL_SPLINE_INTERPOLATION

public static final int NATURAL_SPLINE_INTERPOLATION
natural spline interpolation with natural decay conditions s''(a)=0 and s''(b)=0.

See Also:
Constant Field Values

PERIODICAL_SPLINE_INTERPOLATION

public static final int PERIODICAL_SPLINE_INTERPOLATION
periodical spline interpolation with periodicity conditions s'(a)=s'(b) and s''(a)=s''(b). The length of the period is b-a.

See Also:
Constant Field Values
Method Detail

decomposeCholesky

public static Matrix decomposeCholesky(Matrix A)
                                throws java.lang.ArithmeticException
Cholesky-decomposition of positive definite matrices implementation. Such that A = L.LT.

#Multiplications = 1/6*n3, #Square Roots = n

The implementation is numerically stable.

Throws:
java.lang.ArithmeticException
Preconditions:
A.isPositiveDefinite()
Postconditions:
L*L^T == A

cgSolve

public static Vector cgSolve(Matrix A,
                             Vector x0,
                             Vector b)
cg-algorithm for solving A∙x=b iteratively starting with x0. Conjugate gradients algorithm.

Returns:
the solution vector x solving Ax=b.
Preconditions:
A.isPositiveDefinite() && b.dimension()==A.dimension().width && x0.dimension() == A.dimension().width
Postconditions:
A.multiply(x) == b

polynomialInterpolation

public static Function polynomialInterpolation(Matrix A)
Polynomial interpolation.

Currently implemented as polynomial interpolation with Neville.

Parameters:
A - the matrix with supporting nodes. These are row vectors (x,y) of width 2.
See Also:
UnivariatePolynomial
Preconditions:
A.dimension().width == 2

splineInterpolation

public static Function splineInterpolation(int k,
                                           Matrix A,
                                           int interpolationType)
Spline interpolation. For a grid Δ={t0,...,tl+1}∈Part([a,b]), the space of splines of grade k-1 is Sk,Δ⊂Ck-2([a,b],R). Where ∀s∈Sk,Δ s|[ti,ti+1]Rk-1[x].

This method is currently only implemented for cubical spline with k=4.

Parameters:
k - the order of splines desired. k-1 is the grade of the piecewise interpolating polynoms.
A - the matrix with supporting nodes (the first column is the grid Δ of x-values, second column are y-values). A must be ordered by ascending x-values.
interpolationType - specifies which type of interpolation to do (see config).
Returns:
the interpolating spline s of grade k-1 that is minimally crooked (κ globally minimized). κ(t) = s''(t) / (1 + s'(t)2)3/2.
See Also:
NATURAL_SPLINE_INTERPOLATION, PERIODICAL_SPLINE_INTERPOLATION, splineInterpolation(int,Matrix,int,Real,Real), COMPLETE_SPLINE_INTERPOLATION
Preconditions:
A is ordered by ascending x-values. ∀i A.get(i, 0) < A.get(i+1, 0)

splineInterpolation

public static Function splineInterpolation(int k,
                                           Matrix A,
                                           int interpolationType,
                                           Real fp_a,
                                           Real fp_b)
Spline interpolation. For a grid Δ={t0,...,tl+1}∈Part([a,b]), the space of splines of grade k-1 is Sk,Δ⊂Ck-2([a,b],R). Where ∀s∈Sk,Δ s|[ti,ti+1]Rk-1[x].

This method is currently only implemented for cubical spline with k=4.

Parameters:
k - the order of splines desired. k-1 is the grade of the piecewise interpolating polynoms.
A - the matrix with supporting nodes (the first column is the grid Δ of x-values, second column are y-values). A must be ordered by ascending x-values.
interpolationType - specifies which type of interpolation to do
fp_a - the value f'(a) of the derivative of f at a.
fp_b - the value f'(b) of the derivative of f at b.
Returns:
the interpolating spline s of grade k-1 that is minimally crooked (κ globally minimized). κ(t) = s''(t) / (1 + s'(t)2)3/2.
See Also:
COMPLETE_SPLINE_INTERPOLATION, splineInterpolation(int,Matrix,int), NATURAL_SPLINE_INTERPOLATION, PERIODICAL_SPLINE_INTERPOLATION
Preconditions:
A is ordered by ascending x-values. ∀i A.get(i, 0) < A.get(i+1, 0)

splineInterpolation

public static Function splineInterpolation(int k,
                                           Matrix A,
                                           int interpolationType,
                                           java.lang.Object[] config)
Deprecated. Use splineInterpolation(int,Matrix,int,Real,Real), or splineInterpolation(int,Matrix,int) instead since they have a more reasonable argument list.

Implementation method.


bezierCurve

public static Function bezierCurve(double t0,
                                   double tz,
                                   Matrix bezierNodes)
Bezier curve.

Currently implemented with de Casteljau.

Parameters:
t0 - the starting point in the parameter interval [t0,..tz].
tz - the ending point in the parameter interval [t0,..tz].
bezierNodes - the row-vectors specify the bezier nodes in the given order.
Returns:
a vectorial bezier curve with the specified bezier nodes and a parameter from t0 to tz.

integrate

public static Arithmetic integrate(Function f,
                                   Arithmetic a,
                                   Arithmetic b)
Returns ≈ ∫ab f dx.

Currently implemented as Newton-Cotes numerical integration.

See Also:
MathUtilities.integrate(orbital.math.functional.Function, Arithmetic, Arithmetic)

dSolve

public static Function dSolve(BinaryFunction f,
                              Real tau,
                              Vector eta,
                              Real a,
                              Real b,
                              int steps,
                              int order)
Returns a numerical solution x of the differential equation x'(t) = f(t,x(t)), x(τ)=η on [a,b].

Currently implemented as an explicit Runge-Kutta method.

Parameters:
f - the right-hand side of the differential equation.
tau - the initial time τ of the initial values η.
eta - the vector η of initial values.
steps - the number m of discretisation steps defining h=(a-b)/m.
order - the desired order p of the global discretisation error, i.e., with errors in O(hp).
Returns:
a numerical solution x of the differential equation system
x'(t)=f(t,x(t)) on [a,b]
x(τ)=η
See Also:
AlgebraicAlgorithms.dSolve(Matrix,Vector,Real,Vector)

dSolve

public static Function dSolve(BinaryFunction f,
                              Real tau,
                              Vector eta,
                              Real min,
                              Real max,
                              int steps,
                              Matrix butcher)
Returns a numerical solution x of the differential equation x'(t) = f(t,x(t)), x(τ)=η on [a,b].

Implements the explicit Runge-Kutta with given Butcher tableau.

xn+1 = xn + h∑i=1s biki
with
ki = f(tn+cih, yn + h∑j=1i-1 ai,jhkj
and discretisation step defined as in dSolve(orbital.math.functional.BinaryFunction,Real,Vector,Real,Real,int,int).

Parameters:
butcher - is a consistent Butcher tableau
c1
c2 a2,1
c3 a3,1a3,2
... ...
cs as,1as,2...as,s-1
See Also:
dSolve(orbital.math.functional.BinaryFunction,Real,Vector,Real,Real,int,int)

dSolve

public static Function dSolve(BinaryFunction f,
                              Real tau,
                              Real eta,
                              Real a,
                              Real b,
                              int steps,
                              int order)
Returns a numerical solution x of the one-dimensional differential equation x'(t) = f(t,x(t)), x(τ)=η on [a,b].

See Also:
dSolve(orbital.math.functional.BinaryFunction,Real,Vector,Real,Real,int,int)

dSolve

public static Function dSolve(BinaryFunction f,
                              Real tau,
                              Real eta,
                              Real min,
                              Real max,
                              int steps,
                              Matrix butcher)
Returns a numerical solution x of the one-dimensional differential equation x'(t) = f(t,x(t)), x(τ)=η on [a,b].

See Also:
dSolve(orbital.math.functional.BinaryFunction,Real,Vector,Real,Real,int,int)

Orbital library
1.3.0: 11 Apr 2009

Copyright © 1996-2009 André Platzer
All Rights Reserved.