protected static functionToSplinePoints ( callable $function, callable $derivative, number $start, number $end, number $n ) : array | ||
$function | callable | f(x) callback function |
$derivative | 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 |
return | array |
protected static function functionToSplinePoints(callable $function, callable $derivative, $start, $end, $n) : array
{
$points = [];
$h = ($end - $start) / ($n - 1);
for ($i = 0; $i < $n; $i++) {
$xᵢ = $start + $i * $h;
$f⟮xᵢ⟯ = $function($xᵢ);
$f’⟮xᵢ⟯ = $derivative($xᵢ);
$points[$i] = [$xᵢ, $f⟮xᵢ⟯, $f’⟮xᵢ⟯];
}
return $points;
}