The Five Point Formula requires we supply 5 points that are evenly spaced
apart, and that our target equals the x-components of one of our 5 points.
Example: differentiation(2, function($x) {return $x**2;}, 0, 4 ,5) will produce
a set of arrays by evaluating the callback at 5 evenly spaced points
between 0 and 4. Then, this array will be used in our approximation.
Five Point Formula:
- If the 3rd point is our $target, use the Midpoint Formula:
1 h⁴
f′(x₀) = - [f(x₀-2h)-8f(x₀-h)+8f(x₀+h)-f(x₀+2h)] - - f⁽⁵⁾(ζ₁)
12h 30
where ζ₁ lies between x₀ - 2h and x₀ + 2h
- If the 1st or 5th point is our $target, use the Endpoint Formula:
- Note that when the 3rd point is our $target, we use a negative h.
1 h⁴
f′(x₀) = - [-25f(x₀)+48f(x₀+h)-36f(x₀+2h)+16f(x₀+3h)-3f(x₀+4h)] + - f⁽⁵⁾(ζ₀)
12h 5
where ζ₀ lies between x₀ and x₀ + 4h