integrate(); $approximation += $integral($xᵢ₊₁) - $integral($xᵢ); // definite integral of lagrange polynomial } return $approximation; } }