PHP Class MathPHP\NumericalAnalysis\Interpolation\LagrangePolynomial

In numerical analysis, the Lagrange Polynomials are used for polynomial interpolation. "Given a set of distinct points {xⱼ,yⱼ}, the Lagrange Polynomial is the [unique] polynomial of least degree such that at each point xⱼ assumes the corresponding value yⱼ (i.e. the functions coincide at each point)." The lagrange polynomials belong to a collection of techniques that interpolate a function or a set of values, producing a continuous polynomial. We can either directly supply a set of inputs and their corresponding outputs for said function, or if we explicitly know the function, we can define it as a callback function and then generate a set of points by evaluating that function at n points between a start and end point. We then use these values to interpolate a Lagrange polynomial. https://en.wikipedia.org/wiki/Lagrange_polynomial http://mathworld.wolfram.com/LagrangeInterpolatingPolynomial.html
Inheritance: extends Interpolation
Exibir arquivo Open project: markrogoyski/math-php Class Usage Examples

Public Methods

Method Description
interpolate ( $source, $args ) : callable Interpolate

Method Details

interpolate() public static method

Interpolate
public static interpolate ( $source, $args ) : callable
$source The source of our approximation. Should be either a callback function or a set of arrays. Each array (point) contains precisely two numbers, an x and y. Example array: [[1,2], [2,3], [3,4]]. Example callback: function($x) {return $x**2;}
return callable The lagrange polynomial p(x)