Numerical Integration (Numerical Method)

Lets define a function
$$\text{Let }f(x)=|x^{2}-2x|+\frac{1}{1+x}\text{ and find }\int_0^{3}f(x)dx\text{  and let }a=0,b=3$$
by using
$$\text{Composite Midpoint Rule||Composite Trapezoidal Rule||Composite Simpson's Rule||Romberg Method}$$

Composite Midpoint Rule

Formula: $$\text{Let }x_i = a+ih \text{ and there is a number } \mu \in (a,b) \text{ such that}$$ $$\int_a^{b}f(x)dx=\underbrace{h\sum_{j=0}^{n-1}f(\frac{x_j + x_{j+1}}{2})}_{M^{n}_{[a,b]}(f)}+\underbrace{\frac{(b-a)h^2}{6}f''(\mu)}_{\text{Error Term}}$$

With $n=6$,

$h=\frac{b-a}{n}=\frac{3-0}{6}=\frac{1}{2}$

$$\begin{align}M^{n=6}_{[0,3]}(f)&=\frac{1}{2}\Biggl[f(\frac{0+0.5}{2})+f(\frac{0.5+1}{2})+f(\frac{1+1.5}{2})+f(\frac{1.5+2}{2})+f(\frac{2+2.5}{2})+f(\frac{2.5+3}{2})\Biggl]\\&=\frac{1}{2}\Biggl[f(\frac{1}{4})+f(\frac{3}{4})+f(\frac{5}{4})+f(\frac{7}{4})+f(\frac{9}{4})+f(\frac{11}{4})\Biggl]\\&=4.0644195\end{align}$$



Composite Trapezoidal Rule


Formula: $$\text{Let }x_i = a+ih \text{ and there is a number } \mu \in (a,b) \text{ such that}$$ $$\int_a^{b}f(x)dx=\underbrace{\frac{h}{2}\Biggl[f(a)+2\sum_{j=1}^{n-1}f(x_j)+f(b)\Biggl]}_{T^{n}_{[a,b]}(f)}+\underbrace{\frac{(b-a)h^2}{12}f''(\mu)}_{\text{Error Term}}$$

With $n=6$,

$h=\frac{b-a}{n}=\frac{3-0}{6}=\frac{1}{2}$

$$\begin{align}T^{n=6}_{[0,3]}(f)&=\frac{(\frac{1}{2})}{2}\Biggl[f(0)+2\Bigl[f(\frac{1}{2})+f(1)+f(\frac{3}{2})+f(2)+f(\frac{5}{2})\Bigl]+f(3)\Biggl]\\&=4.030357143\end{align}$$




Composite Simpson's Rule

Formula: $$\text{Let }x_i = a+ih \text{ and there is a number } \mu \in (a,b) \text{ such that}$$ $$\int_a^{b}f(x)dx=\underbrace{\frac{h}{3}\Biggl[f(a)+\overbrace{2\sum_{j=1}^{n/2-1}\color{yellow}{f(x_{2j})}}^{\color{yellow}{\text{even term}}(x_2,x_4,...)}+\overbrace{4\sum_{j=1}^{n/2}\color{fuchsia}{f(x_{2j-1})}}^{\color{fuchsia}{\text{odd term}}(x_1,x_3,...)}+f(b)\Biggl]}_{S^{n}_{[a,b]}(f)}+\underbrace{\frac{(b-a)h^4}{180}f^{(4)}(\mu)}_{\text{Error Term}}$$

With $n=6$,

$h=\frac{b-a}{n}=\frac{3-0}{6}=\frac{1}{2}$

$$\begin{align}S^{n=6}_{[0,3]}(f)&=\frac{(\frac{1}{2})}{3}\Biggl[f(0)+4\color{fuchsia}{f(\frac{1}{2})}+2\color{yellow}{f(1)}+4\color{fuchsia}{f(\frac{3}{2})}+2\color{yellow}{f(2)}+4\color{fuchsia}{f(\frac{5}{2})}+f(3)\Biggl]\\&=4.054365079\end{align}$$


Romberg Method

Use Romberg Method to compute $R_{4,4}$, of order $O(h^8)$ for the $\int_0^{3}f(x)dx$

Solution:

$$\begin{array}{c|c|c}h\\\hline \frac{3-0}{2^0}=3 & R_{1,1} & \frac{(3)}{2}\Bigl[f(0)+f(3)\Bigl]=6.375\\\frac{3-0}{2^{1}}=\frac{3}{2} & R_{1,2}&\frac{(\frac{3}{2})}{2}\Bigl[f(0)+2f(\frac{3}{2})+f(3)\Bigl]=4.9125\\\frac{3-0}{2^2}=\frac{3}{4} & R_{1,3} &\frac{(\frac{3}{4})}{2}\Bigl[f(0)+2\bigl(f(\frac{3}{4})+f(\frac{3}{2})+f(\frac{9}{4})\bigl)+f(3)\Bigl]=4.240591\\\frac{3-0}{2^{3}}=\frac{3}{8} & R_{1,4}& \frac{(\frac{3}{8})}{2}\Bigl[f(0)+2\bigl(f(\frac{3}{8})+f(\frac{3}{4})+f(\frac{9}{8})+f(\frac{3}{2})+f(\frac{15}{8})+f(\frac{9}{4})+f(\frac{21}{8})\bigl)+f(3)\Bigl]=4.104157\end{array}$$
$$\downarrow$$

$$\begin{array}O(h^2) & O(h^{4}) & O(h^6) & O(h^8)\\\hline 6.375 \\4.9125 & \frac{4(4.9125)-6.375}{4-1}=4.425\\4.240591 & \frac{4(4.240591)-4.9125}{4-1}=4.016621\\ 4.104157 & \frac{4(4.104157)-4.240591}{4-1}=4.058679\end{array}$$
$$\downarrow$$

$$\begin{array}O(h^2) & O(h^{4}) & O(h^6) & O(h^8)\\\hline 6.375 \\4.9125 & 4.425\\4.240591 & 4.016621 & \frac{4^2(4.016621)-4.425}{4^2-1}=3.989396\\ 4.104157 & 4.058679 & \frac{4^2(4.058679)-4.016621}{4^2-1}=4.061483\end{array}$$
$$\downarrow$$

$$\begin{array}O(h^2) & O(h^{4}) & O(h^6) & O(h^8)\\\hline 6.375 \\4.9125 & 4.425\\4.240591 & 4.016621 & 3.989396\\ 4.104157 & 4.058679 & 4.061483 & \frac{4^3(4.061483)-3.989396}{4^3-1}=4.062627\end{array}$$
$$\downarrow$$

$$\begin{array}O(h^2) & O(h^{4}) & O(h^6) & O(h^8)\\\hline 6.375 \\4.9125 & 4.425\\4.240591 & 4.016621 & 3.989396\\ 4.104157 & 4.058679 & 4.061483 & 4.062627\end{array}$$

$\therefore \int_0^3 f(x)dx \approx 4.062627$


Gaussian Quadrature

Using the properties of Lengendre polynomial, the results are shown below:

$$\begin{array} \text{n} & t_i & w_i & Degree\\\hline 1 & 0 & 2 & 1\\ 2 & \pm\sqrt{\frac{1}{3}} & 1 & 3\\3 & \pm\sqrt{\frac{3}{5}},0 & \frac{5}{9},\frac{8}{9} & 5\\4 & \pm\sqrt{\frac{(3-2\sqrt{\frac{6}{5}})}{7}},\pm\sqrt{\frac{(3+2\sqrt{\frac{6}{5}})}{7}} & \frac{18+\sqrt{30}}{36},\frac{18-\sqrt{30}}{36} & 7\\ 5 & 0,\pm\frac{1}{3}\sqrt{5-2\sqrt{\frac{10}{7}}},\pm\frac{1}{3}\sqrt{5+2\sqrt{\frac{10}{7}}} & \frac{128}{255},\frac{322+13\sqrt{70}}{900},\frac{322-13\sqrt{70}}{900} &  9\end{array}$$

and apply the following formula:

$$\int_a^b f(x)dx=\frac{b-a}{2}\int_{-1}^1 f\Bigl(\frac{(b-a)t+(b+a)}{2}\Bigl) \approx \frac{b-a}{2}\sum_{i=1}^{n} w_i f\Bigl(\frac{(b-a)t_i +(b+a)}{2}\Bigl)$$


Use Gaussian Quadrature to find the approximation of $\int_{-2}^{2}x^{3}e^{x} dx$

Note: $f(\frac{(b-a)t+(b+a)}{2})=f(\frac{(2-(-2))t+(2-2)}{2})=f(\frac{4t + 0}{2})=f(2t)$

$n=1,$

$$\begin{align}\int_{-2}^{2} x^{3}e^{x}dx &=\frac{2-(-2)}{2}\int_{-1}^{1} f(2t)dt \\ &=\frac{4}{2}\Biggl[2\cdot f(2\cdot 0)\Biggl]\\&=0  \end{align}$$

$n=2,$

$$\begin{align}\int_{-2}^{2} x^{3}e^{x} dx &= \frac{2-(-2)}{2}\int_{-1}^{1}f(2t)dt\\ &=\frac{4}{2}\Biggl[1\cdot f\Biggl(2\cdot (-\sqrt{\frac{1}{3}})\Biggl)+1\cdot f\Biggl(2\cdot \sqrt{\frac{1}{3}}\Biggl)\Biggl]\\&=8.800116\end{align}$$

$n=3,$

$$\begin{align}\int_{-2}^{2} x^{3}e^{x} dx &= \frac{2-(-2)}{2}\int_{-1}^{1}f(2t)dt\\ &=\frac{4}{2}\Biggl[\frac{5}{9}\Biggl(f(2\cdot \sqrt{\frac{3}{5}})+f(2\cdot \bigl(-\sqrt{\frac{3}{5}}\bigl))\Biggl)+\frac{8}{9}f(0)\Biggl]\\&=18.570706\end{align}$$

$n=4,$

$$\begin{align}\int_{-2}^{2} x^{3}e^x dx&=\frac{2-(-2)}{2}\int_{-1}^{1} f(2t)dt\\&=\frac{4}{2}\Biggl[\frac{18+\sqrt{30}}{36}\biggl(f(2\cdot \sqrt{\frac{3-2\sqrt{\frac{6}{5}}}{7}})+f(2\cdot (-\sqrt{\frac{3-2\sqrt{\frac{6}{5}}}{7}}))\biggl)\\&+\frac{18-\sqrt{30}}{36}\biggl(f(2\cdot \sqrt{\frac{3+2\sqrt{\frac{6}{5}}}{7}})+f(2\cdot (-\sqrt{\frac{3+2\sqrt{\frac{6}{5}}}{7}}))\biggl)\Biggl]\\&=19.859939\end{align}$$


$n=5,$

$$\begin{align}\int_{-2}^{2} x^3 e^x dx&= \frac{2-(-2)}{2}\int_{-1}^{1}f(2t)dt\\&=\frac{4}{2}\Biggl[\frac{128}{255}f(2\cdot 0)\\&+\frac{322+13\sqrt{70}}{900}\biggl(f(2\cdot \frac{1}{3}\sqrt{5-2\sqrt{\frac{10}{7}}})+f(2\cdot \bigl(-\frac{1}{3}\sqrt{5-2\sqrt{\frac{10}{7}}}\bigl))\biggl)\\&+\frac{322-13\sqrt{70}}{900}\biggl(f(2\cdot \frac{3}{3}\sqrt{5+2\sqrt{\frac{10}{7}}})+f(2\cdot \bigl(-\frac{1}{3}\sqrt{5+2\sqrt{\frac{10}{7}}}\bigl))\biggl)\Biggl]\\&=19.919469\end{align}$$

Comments

Popular Posts