The more I learn about people, the more I like dogs and I don’t even have a dog, Apocalypse, Anawim, #justtothepoint.
Antiderivatives are fundamental concepts in calculus. They are the inverse operation of derivatives.
Given a function f(x), an antiderivative, also known as indefinite integral, F, is the function that can be differentiated to obtain the original function, that is, F’ = f, e.g., 3x2 -1 is the antiderivative of x3 -x +7 because $\frac{d}{dx} (x^3-x+7) = 3x^2 -1$. Symbolically, we write F(x) = $\int f(x)dx$.
The process of finding antiderivatives is called integration.
The Fundamental Theorem of Calculus states roughly that the integral of a function f over an interval is equal to the change of any antiderivate F (F'(x) = f(x)) between the ends of the interval, i.e., $\int_{a}^{b} f(x)dx = F(b)-F(a)=F(x) \bigg|_{a}^{b}$
In analysis, numerical integration comprises a broad family of algorithms for calculating the numerical value of a definite integral when analytical solutions are challenging.
All numerical approximations of the integral $\int_{a}^{b} f(x)dx$ will start with a partition of the interval [a, b] into n equal parts, a = x0 < x1 < ··· < xn = b, Δx = xi-xi-1, y0 = f(x0), y1 = f(x1), ···, yn = f(xn).
We define the left Riemann sum as follows = (y0 + y1 + ··· + yn-1)Δx = f(x0)Δx + f(x1)Δx + ··· + f(xn-1)Δx = $\sum_{k=0}^{n-1} f(x_k)Δx$ where the chosen point of each subinterval (xi-1, xi) of the partition is the left-hand point xi-1. The right Riemann sum is defined similarly = (y1 + y2 + ··· + yn)Δx = f(x1)Δx + f(x2)Δx + ··· + f(xn)Δx = $\sum_{k=1}^{n} f(x_k)Δx$ -Figure 1.b.- where the chosen point of each subinterval (xi-1, xi) of the partition is the right-hand point xi.
If the function is continuous and monotonically decreasing/increasing, then the left Riemann sum overestimates/underestimates the integral and the right Riemann sum underestimates/overestimates it.
A trapezoid is a four-sided region with two opposite sides parallel. Given a partition of [a, b] as above, we can define the associated trapezoid sum to correspond to the area shown below (Figure 1.c.). The area of a trapezoid is the average length of the parallel sides times the distance between them, e.g., base * average_height = Δx(y2+y3⁄2). Adding all the areas of the individual trapezoids together, gives the trapezoid sum: $Δx(\frac{y_0+y_1}{2} + \frac{y_1+y_2}{2} + ··· + \frac{y_{n-1}+y_n}{2}) = Δx(\frac{y_0}{2} + y_1 + y_2 + ··· y_{n-1}+\frac{y_n}{2})$ = $\frac{left Riemann Sum + Right Riemann Sum}{2}$ -Figure 1.c.-. The trapezoid sum is the average of the left- and right-hand Riemann sums.
Simpson’s rule gives us another approximation of the integral. Again, we start by partitioning [a, b] into intervals all of the same width, but this time we must use an even number of intervals, so n needs to be even. We are going to use a parabola through the three points (xk-1, f(xk-1)), (xk, f(xk)), and (xk+1, f(xk+1)), and the area under the parabola (Figure 1.d., it is left as an exercise) equals base*average height = $2Δx(\frac{y_{k-1}+4y_k+y_{k+1}}{6})=\frac{b-a}{3n}[f(x_{k-1})+4f(x_k)+f(x_{k+1})]$, and the total sum is $\frac{Δx}{3}((y_0+4y_1+y_2) + (y_2+4y_3+y_4) + ··· (y_{n-2}+4y_{n-1}+y_n))$ = 🚀
=[🚀] $\frac{Δx}{3}(y_0 +4y_1 +2y_2 +4y_3 + ··· + 2y_{n-2}+4y_{n-1}+y_n)$ -Figure 1.d.- Here, the coefficients 1, 4, and 2 alternate. Simpson's Rule is more accurate than the trapezoidal rule for approximating integrals because it uses a quadratic interpolation to model the curve. It provides a good balance between simplicity and accuracy for numerical integration. Futhermore, it is exact when integrating polynomials of degree 3 or less.
Trapezoidal rule. $\Delta x(\frac{1}{2}y_0 + y_1 + \frac{1}{2}y_2)=\frac{1}{2}(\frac{1}{2}·1 + \frac{2}{3} + \frac{1}{2}·\frac{1}{2}) = \frac{1}{2}(\frac{6}{12}+\frac{8}{12}+\frac{3}{12}) = \frac{1}{2}·\frac{17}{12} = \frac{17}{24}$ ≈ 0.7083 it is obviously not a very good approximation 😞, but it was expected we should split the interval into more subintervals.
Sympson’s rule. $\frac{\Delta x}{3}(y_0 +4y_1 +y_2) = \frac{1}{6}(1 + 4·\frac{2}{3}+\frac{1}{2}) ≈ 0.69444$ that is surprisingly a relatively good approximation of the correct value.
Now, we need to compute the function values at the endpoints of the subintervals. For n = 4, the endpoints are: $x_0 = 0, x_1 = \frac{1}{4}, x_2 = \frac{1}{2}, x_3 = \frac{3}{4}, x_4 = 1, f(x_0)=\sqrt{1−0^2} =1, f(x_1) = \sqrt{1 - \left(\frac{1}{4}\right)^2} = \sqrt{\frac{15}{16}}, f(x_2) = \sqrt{1 - \left(\frac{1}{2}\right)^2} = \sqrt{\frac{4}{4}-\frac{1}{4}} = \sqrt{\frac{3}{4}}, f(x_3) = \sqrt{1 - \left(\frac{3}{4}\right)^2} = \sqrt{\frac{16}{16}-\frac{9}{16}} = \sqrt{\frac{7}{16}}, f(x_4) = \sqrt{1 - 1^2} = 0$
Trapezoidal rule. $\Delta x(\frac{1}{2}y_0 + y_1 + y_2 + y_3 + \frac{1}{2}y_4)=\frac{1}{4}(\frac{1}{2} + \sqrt{\frac{15}{16}} + \sqrt{\frac{3}{4}} + \sqrt{\frac{7}{16}} + 0) ≈ 0.748927$
Sympson’s rule. $\frac{\Delta x}{3}(y_0 +4y_1 + 2y_2 + 4y_3 + y_3) = \frac{1}{12}(1 + 4·\sqrt{\frac{15}{16}} + 2·\sqrt{\frac{3}{4}} + 4·\sqrt{\frac{7}{16}} + 0) ≈ 0.77089878 $