Note: Simpson's 3/8 rule requires that our number of subintervals is a factor
of three (we must supply an n points such that n-1 is a multiple of three)
and also that the size of each subinterval is equal (spacing between each
point is equal).
The bounds of the definite integral to which we are approximating is
determined by the our inputs.
Example: approximate([0, 10], [2, 5], [4, 7], [6,3]) will approximate the
definite integral of the function that produces these coordinates with a
lower bound of 0, and an upper bound of 6.
Example: approximate(function($x) {return $x**2;}, [0, 3 ,4]) will produce
a set of arrays by evaluating the callback at 4 evenly spaced points
between 0 and 3. Then, this array will be used in our approximation.
Simpson's 3/8 Rule:
xn ⁿ⁻¹ xᵢ₊₁
∫ f(x)dx = ∑ ∫ f(x)dx
x₁ ⁱ⁼¹ xᵢ
⁽ⁿ⁻¹⁾/³ 3h
= ∑ - [f⟮x₂ᵢ₋₁⟯ + 3f⟮x₂ᵢ⟯ + 3f⟮x₂ᵢ₊₁⟯ + f⟮x₂ᵢ₊₂⟯] + O(h⁵f⁗(x))
ⁱ⁼¹ 8
where h = (xn - x₁) / (n - 1)