Compute $$I=\int_{0}^{3}e^{x}dx$$ using
Compute the error for each case.
The exact value of the integral $I$ is
$$ I =\int_{0}^{3}e^x\,dx = \left(e^x\right)_0^3 = e^3-e^0= 20.0855-1=19.0855$$The midpoint rule is
$$\int_{a}^{b}f(x)\,dx\approx (b-a)\;f\left( \frac{a+b}{2}\right)$$Using the midpoint formula to integrate a function in an interval is equivalent to substituting, within the integral, the function to be integrated by the interpolation polynomial of degree zero, that is, a horizontal line that passes through the midpoint of the function. We replace the function with a line and integrate. We are then calculating the area of a rectangle.
This formula is of the form
$$ \int_{a}^{b}f(x)\,dx\approx \omega_{0}\;f(x_{0}) $$In this case
$$I = \int_{0}^{3}e^x\,dx\approx (3-0)\,e^{1.5}=3\,(4.4816)=13.4451$$and the absolute error is
$$Error =\left| I-I_{aprox}\right|=19.0855-13.4451=5.6404$$The trapezoidal rule is
$$\int_{a}^{b}f(x)dx\approx (b-a)\; \frac{f\left( a\right) +f\left( b\right)}{2}$$Using the formula of trapezoids to integrate a function in an interval is equivalent to substituting, within the integral, the function to be integrated by the interpolation polynomial of degree one, which passes through the points of the function at the ends of the interval. That is, we replace the function with a line and integrate. We are then calculating the area of a trapezoid.
If we compare this formula with the initial and general quadrature formula
$$ \int_{a}^{b}f(x)\,dx\approx \omega_{0}\;f(x_{0})+\omega_{1}\;f(x_{1}) $$If we write the formula this way
$$\int_{a}^{b}f(x)\, dx\approx\frac{h}{2}f(a)+\frac{h}{2}f(b)= (b-a)\left(0.5\,f(a)+0.5\,f(b)\right)$$The approximate value of the integral is
And the error is
$$Error =\left| I-I_{aprox}\right|=\left|19.0855-31.6283\right|=12.5427$$The Simpson's rule is
$$\int_{a}^{b}f(x)dx\approx \frac{b-a}{6}\left( f\left( a\right) +4f\left( \frac{a+b}{2}\right) +f\left( b\right) \right)$$Using Simpson's rule to integrate a function in an interval is equivalent to substituting, within the integral, the function to be integrated by the interpolation polynomial of degree two, which passes through the points of the function at the borders and the midpoint of the interval. That is, we replace the function with a parabola and integrate.
Let us compare it with the initial definition of quadrature formula
$$ \int_{a}^{b}f(x)\,dx\approx \omega_{0}\;f(x_{0})+\omega_{1}\;f(x_{1}) +\omega_{2}\;f(x_{2}) $$And if we write the formula this way
$$\int_{a}^{b}f(x)dx\approx \frac{b-a}{6} f\left( a\right) + \frac{4(b-a)}{6}f\left( \frac{a+b}{2}\right) +\frac{b-a}{6}f\left( b\right)$$Also
$$\int_{a}^{b}f(x)dx\approx (b-a)\left(\frac{1}{6} f\left( a\right) + \frac{4}{6}f\left( \frac{a+b}{2}\right) +\frac{1}{6}f\left( b\right)\right)$$The approximate integral is
$$I = \int_{0}^{3}e^xdx\approx \frac{3}{6}( e^0+4e^{1.5}+e^3)= 0.5(1+4.4817+20.0855)=19.5061$$And the absolute error is
$$Error =\left| I-I_{aprox}\right|=\left|19.0855-19.5061\right|=0.4206$$