PHP Class MathPHP\NumericalAnalysis\NumericalDifferentiation\NumericalDifferentiation

Numerical differentiation techniques are used to approximate the derivative of a function at an input value. This class gives each technique a set of common tools, and requires each technique to define a differentiate() method to approximate the derivative of a function at an input value.
Afficher le fichier Open project: markrogoyski/math-php

Méthodes publiques

Méthode Description
differentiate ( $target, $source, $args )
getPoints ( $source, array $args = [] ) : array Determine where the input $source argument is a callback function, a set of arrays, or neither. If $source is a callback function, run it through the functionToPoints() method with the input $args, and set $points to output array. If $source is a set of arrays, simply set $points to $source. If $source is neither, throw an Exception.
isSpacingConstant ( array $sorted ) Ensures that the length of each subinterval is equal, or equivalently, that the spacing between each point is equal
isTargetInPoints ( number $target, array $sorted ) Ensures that our target is the x-component of one of the points we supply
validate ( array $points, number $degree ) : boolean Validate that there are a set number of input arrays (points), that each point array has precisely two numbers, and that no two points share the same first number (x-component)

Méthodes protégées

Méthode Description
functionToPoints ( callable $function, number $start, number $end, number $n ) : array Evaluate our callback function at n evenly spaced points on the interval between start and end
sort ( array $points ) : array Sorts our coordinates (arrays) by their x-component (first number) such that consecutive coordinates have an increasing x-component.

Method Details

differentiate() abstract public static méthode

abstract public static differentiate ( $target, $source, $args )

functionToPoints() protected static méthode

Evaluate our callback function at n evenly spaced points on the interval between start and end
protected static functionToPoints ( callable $function, number $start, number $end, number $n ) : array
$function callable f(x) callback function
$start number the start of the interval
$end number the end of the interval
$n number the number of function evaluations
Résultat array

getPoints() public static méthode

Determine where the input $source argument is a callback function, a set of arrays, or neither. If $source is a callback function, run it through the functionToPoints() method with the input $args, and set $points to output array. If $source is a set of arrays, simply set $points to $source. If $source is neither, throw an Exception.
public static getPoints ( $source, array $args = [] ) : array
$source The source of our approximation. Should be either a callback function or a set of arrays.
$args array The arguments of our callback function: start, end, and n. Example: [0, 8, 5]. If $source is a set of arrays, $args will default to [].
Résultat array

isSpacingConstant() public static méthode

Ensures that the length of each subinterval is equal, or equivalently, that the spacing between each point is equal
public static isSpacingConstant ( array $sorted )
$sorted array Points sorted by (increasing) x-component

isTargetInPoints() public static méthode

Ensures that our target is the x-component of one of the points we supply
public static isTargetInPoints ( number $target, array $sorted )
$target number The value at which we are approximating the derivative
$sorted array Points sorted by (increasing) x-component

sort() protected static méthode

Sorts our coordinates (arrays) by their x-component (first number) such that consecutive coordinates have an increasing x-component.
protected static sort ( array $points ) : array
$points array
Résultat array

validate() public static méthode

Validate that there are a set number of input arrays (points), that each point array has precisely two numbers, and that no two points share the same first number (x-component)
public static validate ( array $points, number $degree ) : boolean
$points array Array of arrays (points)
$degree number The number of input arrays
Résultat boolean