1. Go to this page and download the library: Download filmtools/polynomial library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
filmtools / polynomial example snippets
$ composer
+HTML
public function findX( float $y ) : float;
use FilmTools\PolynomialModel\FromCoefficientsInterpolator;
// Use these X values every time:
$x_iterable = array(1,2,3);
$fci = new FromCoefficientsInterpolator( $x_iterable );
// Now find Y for each X
$coefficients_iterable = [
0 => 2,
1 => 3
];
$interpolated = $fci( $coefficients_iterable );
// SplFixedArray [ 5, 8, 11 ]
$fci = new FromCoefficientsInterpolator;
$coefficients = array(2,3);
$x_values = array(1,2,3);
// Now find Y for each X
$interpolated = $fci( $coefficients, $x_values);
// SplFixedArray [ 5, 8, 11 ]
use FilmTools\PolynomialModel\CoefficientsProviderInterface;
use FilmTools\PolynomialModel\FromCoefficientsInterpolator;
class MyModel implements CoefficientsProviderInterface
{
public function getCoefficients(): \SplFixedArray
{
return \SplFixedArray::fromArray(array(2,3));
}
}
$x_values = array(1,2,3);
$fci = new FromCoefficientsInterpolator( $x_values );
$interpolated = $fci( new MyModel );
// SplFixedArray [ 5, 8, 11 ]