User:Egm6341.s11.team2/hwk2

=Problem 2.1 Taylor's Series Proof (Solution 1)=

Problem Statement
2.1.1) Using integration by parts show that the first five terms of the Taylor's Series expansion for $$ f(x) $$ is

2.1.2) Using the IMVT shown below in (2.2) express the remainder in terms of $$ f^5(\xi) $$ such that $$ \xi\in [x_0,x] $$. Integral Mean Value Theorem: Let $$\displaystyle w(x)$$ be a nonnegative integrable function defined on $$\displaystyle [x_0,x] $$

If $$\displaystyle f(x) $$ is a continuous function defined on $$\displaystyle [x_0,x] $$, then

for some $$\displaystyle \xi $$ such that

2.1.3) Assume that (1.5) and (1.6) defining $$ p_{n}(x) $$ and $$ R_{n+1}(x) $$ hold. Perform integration by parts again to obtain the $$ (n+1)th $$ expansion containing $$ R_{n+2}(x) $$. where $$ R_{n+1}(x) $$ will be

2.1.4) Use the IMVT shown in (2.1.2) to show

For n=1
Since $$ f(x) $$ can be written as follows, where we will define $$ {\color{red} I_1(x)} $$ as

Recall the general form for Integration By Parts

Then using integration by parts as shown in (2.9) we can let

Which provides us with the following result

Plugging (2.11) into (2.8) reveals the first term of the Taylor's Series Expansion

For n=2,3,4
Similarly we can carry out the same procedure to elucidate the $$ 2^{nd},3^{rd} and ,4^{th} $$ terms.

Putting all of these terms together results in

Solution to 2.1.2
From the previous part we know the remainder for the Taylor's Series Expansion

Using the IMVT shown in (1.2), (1.3) and (1.4) let us define $$ w(x=t) $$ and $$ f(x=t) $$ as follows

Since we are integrating from our constants of integration x and $$ x_{0} $$ we can use the IMVT, substituting our equations, to obtain the following.

Solution to 2.1.3
Assume that (1.5) and (1.6) defining $$ p_{n}(x) $$ and $$ R_{n+1}(x) $$ hold. Perform integration by parts again to obtain the $$ (n+1)th $$ expansion containing $$ R_{n+2}(x) $$.

where $$ R_{n+1}(x) $$ will be

Performing the integration results in

Since we are integrating from our constants of integration x and $$ x_{0} $$ we can use the IMVT, substituting our equations, to obtain the following.

Solution to 2.1.4
Therefore by applying the IMVT for $$ R_{n+2}(x) $$ will be

where $$ R_{n+2}(x) $$ will be

= 2.1 Generate Higher Order Terms of Taylor Series (Solution 2) =

''' This problem was solved referring to Team 3, Hwk 1, S10 homework. '''

From the lecture slide Mtg 6-2

Given
Taylor Series equation below


 * {| style="width:100%" border="0" align="left"

$$ $$
 * $$\displaystyle f(x) = f(x_0) + \frac{(x-x_0)}{1!}\ f^{(1)}(x_0) + \int_{x_0}^{x} (x-t) f^{(2)}(t)\ dt.
 * $$\displaystyle f(x) = f(x_0) + \frac{(x-x_0)}{1!}\ f^{(1)}(x_0) + \int_{x_0}^{x} (x-t) f^{(2)}(t)\ dt.
 * $$\displaystyle (1.1)
 * }
 * }

Find
(1) Repeat integration by parts on the Taylor Series to reveal the following items with remainder.


 * {| style="width:100%" border="0" align="left"

$$ $$
 * $$\displaystyle \frac{(x-x_0)^2}{2!}\ f^{(2)}(x_0) + \frac{(x-x_0)^3}{3!}\ f^{(3)}(x_0)
 * $$\displaystyle \frac{(x-x_0)^2}{2!}\ f^{(2)}(x_0) + \frac{(x-x_0)^3}{3!}\ f^{(3)}(x_0)
 * $$\displaystyle
 * }
 * }

(2) Assume Eqn 3 and Eqn 4 in [[media:nm1.s11.mtg3.djvu|Mtg3-3]] are true, do integration by parts one more time.

1 Integration by Parts
Integrate $$\int_{x_0}^{x} (x-t){f^{(2)}(t)} dt $$ by parts in Eq 1.


 * {| style="width:100%" border="0" align="left"

\int_{x_0}^{x} \underbrace{(x-t)}_{U^\prime} \underbrace{f^{(2)}(t)}_{V}\, dt & = \left [ UV \right ]_{x_0}^x -  \int_{t=x} UV^\prime\, dt \\ & = \left [ -\frac{(x-t)^2}{2}\ f^{(2)}(t) \right ]_{t=x_0}^{t=x} + \underbrace{\int_{x_0}^{x} \frac{(x-t)^2}{2}f^{(3)}(t)\, dt}_{W1} \\ & = \cancelto{o}{-\frac{(x-x)^2}{2}\ f^{(2)}(x)} + \frac{(x-x_0)^2}{2}\ f^{(2)}(x_0) + W1\\ & = \frac{(x-x_0)^2}{2!}\ f^{(2)}(x_0) + W1\\ \end{align} $$ $$
 * $$ \displaystyle \begin{align}
 * $$ \displaystyle \begin{align}
 * $$\displaystyle (1.2)
 * }
 * }

Use Eq 1.1, Eq 1.2, we have
 * {| style="width:100%" border="0" align="left"

$$ $$
 * $$\Rightarrow \ f(x) = f(x_0) + \frac{(x-x_0)}{1!}\ f^{(1)}(x_0) + \frac{(x-x_0)^2}{2!}\ f^{(2)}(x_0) + \frac{1}{2!}\int_{x_0}^{x} {(x-t)^2}f^{(3)}(t)\ dt.
 * $$\Rightarrow \ f(x) = f(x_0) + \frac{(x-x_0)}{1!}\ f^{(1)}(x_0) + \frac{(x-x_0)^2}{2!}\ f^{(2)}(x_0) + \frac{1}{2!}\int_{x_0}^{x} {(x-t)^2}f^{(3)}(t)\ dt.
 * $$\displaystyle (1.3)
 * }
 * }

Integrate $$\int_{x_0}^{x} {(x-t)^2}f^{(3)}(t)\,dt $$ by part one more time in Eq 1.3.
 * {| style="width:100%" border="0" align="left"

\int_{x_0}^{x} \underbrace{(x-t)^2}_{U^\prime} \underbrace{f^{(3)}(t)}_{V}\, dt & = \left [ UV \right ]_{x_0}^x -  \int_{t=x} UV^\prime\, dt \\ & = \left [ -\frac{(x-t)^3}{3}\ f^{(3)}(t) \right ]_{t=x_0}^{t=x} + \underbrace{\int_{x_0}^{x} \frac{(x-t)^3}{3}f^{(4)}(t)\, dt}_{W2} \\ & = \cancelto{o}{-\frac{(x-x)^3}{3}\ f^{(3)}(x)} + \frac{(x-x_0)^3}{3}\ f^{(3)}(x_0) + W2\\ & = \frac{(x-x_0)^3}{3}\ f^{(3)}(x_0) + W2\\ \end{align} $$ $$
 * $$ \displaystyle \begin{align}
 * $$ \displaystyle \begin{align}
 * $$\displaystyle (1.4)
 * }
 * }

Use Eq 1.3 and Eq 1.4, we have

2 Integration by Parts, Again
Int. $$\int_{x_0}^{x} {(x-t)^n}f^{(n+1)}(t)\,dt $$ by part one more time:


 * {| style="width:100%" border="0" align="left"

\int_{x_0}^{x} \underbrace{(x-t)^n}_{U^\prime} \underbrace{f^{(n+1)}(t)}_{V}\, dt & = \left [ UV \right ]_{x_0}^x -  \int_{t=x} UV^\prime\, dt \\ & = \left [ -\frac{(x-t)^{n+1}}{n+1}\ f^{(n+1)}(t) \right ]_{t=x_0}^{t=x} + \underbrace{\int_{x_0}^{x} \frac{(x-t)^{n+1}}{n+1}f^{(n+2)}(t)\, dt}_{W} \\ & = \cancelto{o}{-\frac{(x-x)^{n+1}}{n+1}\ f^{(n+1)}(x)} + \frac{(x-x_0)^{n+1}}{n+1}\ f^{(n+1)}(x_0) + W\\ & = \frac{(x-x_0)^{n+1}}{n+1}\ f^{(n+1)}(x_0) + W\\ \end{align} $$ $$
 * $$ \displaystyle \begin{align}
 * $$ \displaystyle \begin{align}
 * $$\displaystyle (1.6)
 * }
 * }

Use Eqn 1.6, Eqn 3 and Eqn 4 in [[media:nm1.s11.mtg3.djvu|Mtg3-3]], we have

= Problem 2.2 Taylor series expansion of sin(x) =

From the lecture slide Mtg 6 [[media:nm1.s11.mtg6.djvu|Mtg6]]

Ref: Egm6341.s10.team3.sa/HW1

Given
$$ f(x)=sin x, x \in [0,\pi] $$

Find
A) Construct a Taylor series of $$f(x)$$ around $$x_0 = \frac{\pi}{4}$$ for $$\displaystyle n=0,1,2......,10.$$

B) Construct a Taylor series of $$f(x)$$ around $$x_0 = \frac{3\pi}{8}$$ for $$\displaystyle n=0,1,2......,10.$$

C) Estimate the maximum $$\displaystyle R(x)$$ at $$ x=\frac{3\pi}{4}$$

D) Plot the series for each $$\displaystyle n $$

Solution
A)Considering

$$ {p_n}(x) = f({x_0}) + \frac{f^{(1)}}({x_0}) + \frac{f^{(2)}}({x_0}) + ... + \frac{f^{(n)}}({x_0}) $$

for $$ \displaystyle f({x}) = \sin ({x}) $$ around the point $${x_0} = \frac{\pi }{4} $$ the follwoing equations can be calculated for $$ \displaystyle n= 0,1,2,...,10.$$ Note that $$f({x_0}) = \sin (\frac{\pi }{4}) = \frac{2} $$

$${p_0}(x) = \frac{2}$$

$${p_1}(x) = \frac{2} + \frac\cos (\frac{\pi }{4}) $$

$${p_2}(x) = \frac{2} + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) $$

$${p_3}(x) = \frac{2} + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) - \frac\cos (\frac{\pi }{4}) $$

$${p_4}(x) = \frac{2} + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) - \frac\cos (\frac{\pi }{4}) + \frac\sin (\frac{\pi }{4}) $$

$${p_5}(x) = \frac{2} + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) - \frac\cos (\frac{\pi }{4}) + \frac\sin (\frac{\pi }{4}) + \frac\cos (\frac{\pi }{4}) $$

$$ {p_6}(x) = \frac{2} + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) - \frac\cos (\frac{\pi }{4}) + \frac\sin (\frac{\pi }{4}) + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) $$

$${p_7}(x) = \frac{2} + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) - \frac\cos (\frac{\pi }{4}) + \frac\sin (\frac{\pi }{4}) + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) - \frac\cos (\frac{\pi }{4})$$

$$ {p_8}(x) = \frac{2} + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) - \frac\cos (\frac{\pi }{4}) + \frac\sin (\frac{\pi }{4}) + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) - \frac\cos (\frac{\pi }{4}) + \frac\sin (\frac{\pi }{4}) $$

$${p_9}(x) = \frac{2} + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) - \frac\cos (\frac{\pi }{4}) + \frac\sin (\frac{\pi }{4}) + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) - \frac\cos (\frac{\pi }{4}) + \frac\sin (\frac{\pi }{4}) + \frac\cos (\frac{\pi }{4}) $$

$${p_{10}}(x) = \frac{2} + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) - \frac\cos (\frac{\pi }{4}) + \frac\sin (\frac{\pi }{4}) + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) - \frac\cos (\frac{\pi }{4}) + \frac\sin (\frac{\pi }{4}) + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) $$

which can be simplified to the following equations:

B)Considering

$$ {p_n}(x) = f({x_0}) + \frac{f^{(1)}}({x_0}) + \frac{f^{(2)}}({x_0}) + ... + \frac{f^{(n)}}({x_0}) $$

for $$ \displaystyle f({x}) = \sin ({x}) $$ around the point $${x_0} = \frac{3\pi }{8} $$ the follwoing equations can be calculated for $$ \displaystyle n= 0,1,2,...,10.$$

$${p_0}(x) = \sin (\frac{8}) $$

$${p_1}(x) = \sin (\frac{8}) + \frac\cos (\frac{8})$$

$${p_2}(x) = \sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8}) $$

$${p_3}(x) = \sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8}) - \frac\cos (\frac{8}) $$

$${p_4}x) = \sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8}) - \frac\cos (\frac{8}) + \frac\sin (\frac{8}) $$

$${p_5}(x) = \sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8}) - \frac\cos (\frac{8}) + \frac\sin (\frac{8}) + \frac\cos (\frac{8}) $$

$${p_6}(x) = \sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8}) - \frac\cos (\frac{8}) + \frac\sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8})$$

$${p_7}(x) = \sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8}) - \frac\cos (\frac{8}) + \frac\sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8}) - \frac\cos (\frac{8}) $$

$${p_8}(x) = \sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8}) - \frac\cos (\frac{8}) + \frac\sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8}) - \frac\cos (\frac{8}) + \frac\sin (\frac{8}) $$

$${p_9}(x) = \sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8}) - \frac\cos (\frac{8}) + \frac\sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8}) - \frac\cos (\frac{8}) + \frac\sin (\frac{8}) + \frac\cos (\frac{8}) $$

$${p_{10}}(x) = \sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8}) - \frac\cos (\frac{8}) + \frac\sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8}) - \frac\cos (\frac{8}) + \frac\sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8})$$

which can be simplified to the following equations:

D)Matlab Code and Graphs
And here, the graphs show the results. Note that the Matlab code is the same for part A and B and in order to run the Matlab code for part B, the value for $$ x_0 $$ needs to be changed to $$ \frac{8} $$


 * HW2 P2 A.png
 * HW2 P2 B.png

=Problem 2.3: Finding Taylor series=

''' This problem was solved without referring to S10 homework. '''

From the lecture slide Mtg 7

Given
Function $$\displaystyle f(x)$$ is,

Find
A)Expand $$\displaystyle {{e}^{x}}$$ in Taylor series up to order $$\displaystyle n$$ with remainder $$\displaystyle {{R}_{n+1}}[{{e}^{x}};x]$$.

B)Find Taylor series of $$\displaystyle f(x)$$ up to order $$\displaystyle n$$ with remainder $$\displaystyle {{R}_{n+1}}[f;x]$$.

Solution
A)Expand $$\displaystyle {{e}^{x}}$$ in Taylor series up to order $$\displaystyle n$$ with remainder $$\displaystyle {{R}_{n+1}}[{{e}^{x}};x]$$.

According the Taylor series theorem ,

Function $$\displaystyle g(x)={{e}^{x}}$$ can be expanded at $$\displaystyle {{x}_{0}}=0$$ as,

where the remaider $$\displaystyle {{R}_{n+1}}[{{e}^{x}};x]$$ is

where $$\displaystyle \xi \in [0,x]$$.

B)Find Taylor series of $$\displaystyle f(x)$$ up to order $$\displaystyle n$$ with remainder $$\displaystyle {{R}_{n+1}}[f;x]$$.

From Eq(3.2) we have,

Substituting Eq(3.4) into Eq(3.1) yield,

where the the Taylor series expansion is,

and the remainder is

from which we can conclude,

which satisfy Eq(1) in Mtg7.

=Problem 2.4 - Comparision of Numerical Integration Techniques= Note: This problem was studied for $$ [a,b] = [0,1]$$ in s10.

''' This problem was solved without referring to S10 homework. '''

Given

 * $$ f(x) = \frac{x} $$ for $$ x \in [a,b] $$

where $$ [a,b] = [-1,1]$$

Find
Plot f(x), then approximate the integral of f(x) as
 * $$ I_{n}\approx I := \int_{a}^{b}f(x)dx$$

using the following techniques: 1) Taylor Series Expansion 2) Composite Trapezoidal Rule 3) Composite Simpson Rule 4) Gauss-Legendre Quadrature

The value of n should be selected as n = 2,4,8,... until $$I_{n}$$ has a maximum error on the order of $$10^{-6}$$.

Plot of f(x)

 * Egm6341.s11.hw2_4a.jpg]

2.4.1 Taylor Series
As shown in Problem 1.2, the Taylor series expansion of f(x) is Because this is a polynomial, each term in the summation can be integrated individually. Thus, the integral approximation can be found as The maximum error of the Tayor series integration is shown in (Atkinson, 250) as The following table shows the results for integration by Taylor series expansion.

2.4.2 Composite Trapezoidal Rule
The formula for integration by composite trapezoidal rule is given by (Atkinson, 253)

The error in the composite trapezoidal integration is given by (Atkinson, 253)

Since we know that the error will achieve its maximum when Thus, the maximum error for integration by the composite trapezoidal rule is

The following table shows the results for integration by composite trapezoidal rule.

2.4.3 Composite Simpson Rule
The formula for integration by composite Simpson rule is given by (Atkinson, 257)

The error in the composite Simpson integration is given by (Atkinson, 257)

Like with the composite trapezoidal rule, since we know that the error will achieve its maximum when

Thus, the maximum error for integration by the composite Simpson rule is

The following table shows the results for integration by composite Simpson rule.

2.4.4 Gauss-Legendre Quadrature
The formula for Gaussian quadrature on the interval [-1,1] is given by (Atkinson, 276) The quadrature weights wj are given by (Atkinson, 276) and the nodes xj are the roots of the nth degree Legendre polynomial Pn(x) on the interval [-1,1]. The numerical values of xj and wj are listed in and verified in Problem 2.5.

The error using Gauss-Legendre quadrature is found as As in the composite trapezoidal and Simpson rules, the maximum value of f(2n)(η) is e. Thus, the maximum error using Gauss-Legendre quadrature is

The following table lists the results for integration by Gauss-Legendre quadrature.

For n = 1
The root of the Legendre Polynomial $$ P_1(x)=0 $$ is found by solving

$$ \displaystyle P_1(x)=x=0 $$

And the weight, $$ w_{1} $$ is

$$ \displaystyle \begin{align} w_{1} & = \frac{-2}{(1+1)[P_{1}^{'}({{x}_{1}}){{P}_{2}}({{x}_{1}})]}  \\ & = \frac{-2}{(1+1)\left[ 1\cdot \frac{3{x_1}^{2}-1}{2}\right] }  \\ & = \frac{-2}{(1+1)\left[ 1\cdot \frac{3\cdot{0}^{2}-1}{2}\right] } \\ & = 2 \end{align} $$

For n = 2
The root of the Legendre Polynomial $$ P_2(x)=0 $$ are found by solving

$$ \displaystyle P_2(x)=(3x^2-1)=0 $$

Where the weights, $$ w_{1} $$ and $$ w_{2} $$ are

$$ \displaystyle \begin{align} w_{1} & = \frac{-2}{(2+1)[P_2^{'}(x_1)P_3(x_1)]}  \\ & = \frac{-2}{(2+1)\left[ 3x_1 \cdot \frac{5{x_1}^{3}-3x_1}{2}\right] }  \\ & = \frac{-2}{(2+1)\left[ 3\left( {\frac{1}{\sqrt 3 }}\right)^3 \cdot \frac{5\left( {\frac{1}{\sqrt 3 }}\right)^3 -3\left(\frac{1}{\sqrt 3 }\right) }{2}\right] } \\ & = 1 \end{align} $$

$$ \displaystyle \begin{align} w_{2} & = \frac{-2}{(2+1)[P_2^{'}(x_2)P_3(x_2)]}  \\ & = \frac{-2}{(2+1)\left[ 3x_2 \cdot \frac{5{x_2}^{3}-3x_2}{2}\right] }  \\ & = \frac{-2}{(2+1)\left[ 3\left( {-\frac{1}{\sqrt 3 }}\right)^3 \cdot \frac{5\left( {-\frac{1}{\sqrt 3 }}\right)^3 -3\left( -\frac{1}{\sqrt 3 }\right) }{2}\right] } \\ & = 1 \end{align} $$

For n = 3
The root of the Legendre Polynomial $$ P_3(x)=0 $$ are found by solving

$$ \displaystyle P_3(x)=(5x^3-3x)=0 $$

Where the weights, $$ w_{1}, w_{2}, $$ and $$ w_{3} $$ are

$${{W}_{1}}=\frac{-2}{(3+1)[P_{3}^{'}({{x}_{1}}){{P}_{4}}({{x}_{1}})]}=\frac{8}{9} $$

$${{W}_{2}}=\frac{-2}{(3+1)[P_{3}^{'}({{x}_{2}}){{P}_{4}}({{x}_{2}})]}=\frac{5}{9} $$

$${{W}_{3}}=\frac{-2}{(3+1)[P_{3}^{'}({{x}_{3}}){{P}_{4}}({{x}_{3}})]}=\frac{5}{9}$$

For n = 4
The root of the Legendre Polynomial $$ P_4(x)=0 $$ are found by solving

$$ \displaystyle P_4(x)=(35x^4-30x^2+3)=0 $$

Where the weights, $$ w_{1}, w_{2}, w_{3}$$ and $$ w_{4} $$ are

$${{W}_{1}}=\frac{-2}{(4+1)[P_{4}^{'}({{x}_{1}}){{P}_{5}}({{x}_{1}})]}=(18-\sqrt{30})/36 $$

$${{W}_{2}}=\frac{-2}{(4+1)[P_{4}^{'}({{x}_{2}}){{P}_{5}}({{x}_{2}})]}=(18-\sqrt{30})/36 $$

$${{W}_{3}}=\frac{-2}{(4+1)[P_{4}^{'}({{x}_{3}}){{P}_{5}}({{x}_{3}})]}=(18+\sqrt{30})/36 $$

$${{W}_{4}}=\frac{-2}{(4+1)[P_{4}^{'}({{x}_{4}}){{P}_{5}}({{x}_{4}})]}=(18+\sqrt{30})/36 $$

For n = 5
The root of the Legendre Polynomial $$ P_5(x)=0 $$ are found by solving

$$ \displaystyle P_5(x)=(63x^5-70x^3+15x)=0 $$

Where the weights, $$ w_{1}, w_{2}, w_{3}, w_{4} $$ and $$ w_{5} $$ are

$${{W}_{1}}=\frac{-2}{(5+1)[P_{5}^{'}({{x}_{1}}){{P}_{6}}({{x}_{1}})]}=\frac{128}{225}$$

$${{W}_{2}}=\frac{-2}{(5+1)[P_{5}^{'}({{x}_{2}}){{P}_{6}}({{x}_{2}})]}=\frac{322-13\sqrt{70}}{900}$$

$${{W}_{3}}=\frac{-2}{(5+1)[P_{5}^{'}({{x}_{3}}){{P}_{6}}({{x}_{3}})]}=\frac{322-13\sqrt{70}}{900}$$

$${{W}_{4}}=\frac{-2}{(5+1)[P_{5}^{'}({{x}_{4}}){{P}_{6}}({{x}_{4}})]}=\frac{322+13\sqrt{70}}{900}$$

$${{W}_{5}}=\frac{-2}{(5+1)[P_{5}^{'}({{x}_{5}}){{P}_{6}}({{x}_{5}})]}=\frac{322+13\sqrt{70}}{900}$$

As can be seen from the values computed here, the table present in lecture has been verified by myself and is in agreement with the NIST publication.

=Problem 2.6: Verifying Lagrange Polynomials=

''' This problem was solved without referring to S10 homework. '''

From the lecture slide Mtg 8-1

Given
The equation for the Lagrange Polynomial is,


 * {| style="width:100%" border="0"

{P}_{n}(x) = \sum_{i=0}^{\lfloor n/2 \rfloor} (-1)^{i} \cdot \frac {(2n-2i)! \cdot x^{n-2i}} {2^{n}\cdot i! \cdot (n-i)! \cdot (n-2i)!} $$ $$
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle
 * }
 * }

and the equations for $$\displaystyle P_0\left(x\right) $$ through $$\displaystyle P_4\left(x\right). $$


 * {| style="width:100%" border="0"

\begin{align} &{P}_{0}(x) = 1\\ &{P}_{1}(x) = x\\ &{P}_{2}(x) = \frac {1}{2}(3x^{2}-1)\\ &{P}_{3}(x) = \frac {1}{2}(5x^{3}-3x)\\ &{P}_{4}(x) = \frac {35}{8}x^{4} - \frac {15}{4}x^{2} + \frac {3}{8}\\ \end{align} $$ $$
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle
 * }
 * }

Find
Show that the equations for $$\displaystyle P_0\left(x\right) $$ through $$\displaystyle P_4\left(x\right) $$ can be written as $$\displaystyle P_n\left(x\right). $$

Solution
i) n=0
 * {| style="width:100%" border="0"

\begin{align} {P}_{0}(x) &= \sum_{i=0}^{\lfloor 0/2 \rfloor} (-1)^{i} \cdot \frac {(2n-2i)! \cdot x^{n-2i}} {2^{n}\cdot i! \cdot (n-i)! \cdot (n-2i)!}\\ {P}_{0}(x) &= 1 \cdot \frac {1 \cdot 1} {1\cdot 1 \cdot 1 \cdot 1}\\ \end{align} $$ $$
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle
 * }
 * }

ii) n=1
 * {| style="width:100%" border="0"

\begin{align} {P}_{1}(x) &= \sum_{i=0}^{\lfloor 1/2 \rfloor} (-1)^{i} \cdot \frac {(2n-2i)! \cdot x^{n-2i}} {2^{n}\cdot i! \cdot (n-i)! \cdot (n-2i)!}\\ &=(-1)^{0} \cdot \frac {2! \cdot x^{1}} {2^{1}\cdot 0! \cdot 1! \cdot 1!} \\ {P}_{1}(x) &= 1 \cdot \frac {\cancel {2} \cdot x} {\cancel {2} \cdot 1 \cdot 1 \cdot 1} \\ \end{align} $$ $$
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle
 * }
 * }

iii) n=2
 * {| style="width:100%" border="0"

\begin{align} {P}_{2}(x) &= \sum_{i=0}^{\lfloor 2/2 \rfloor} (-1)^{i} \cdot \frac {(2n-2i)! \cdot x^{n-2i}} {2^{n}\cdot i! \cdot (n-i)! \cdot (n-2i)!}\\ &=(-1)^{0} \cdot \frac {(4)! \cdot x^{2}} {2^{2}\cdot 0! \cdot (2)! \cdot (2)!} + (-1)^{1} \cdot \frac {(4-2)! \cdot x^{2-2}} {2^{2}\cdot 1! \cdot (2-1)! \cdot (2-2)!}\\ &= 1 \cdot \frac {4 \cdot 3 \cdot 3 \cdot x^{2}}{4 \cdot 1 \cdot 2 \cdot 2} + (-1) \cdot \frac {2 \cdot 1}{4 \cdot 1 \cdot 1 \cdot 1} \\ {P}_{2}(x) &= \frac {3}{2}x^{2}-\frac {1}{2}\\ \end{align} $$ $$
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle
 * }
 * }

iv) n=3
 * {| style="width:100%" border="0"

\begin{align} {P}_{3}(x) &= \sum_{[i=0]}^{\lfloor 3/2 \rfloor} (-1)^{i} \cdot \frac {(2n-2i)! \cdot x^{n-2i}} {2^{n}\cdot i! \cdot (n-i)! \cdot (n-2i)!} \\ &=(-1)^{0} \cdot \frac {6! \cdot x^{3}} {2^{3}\cdot 0! \cdot 3! \cdot 3!} + (-1)^{1} \cdot \frac {4! \cdot x^{1}} {2^{3}\cdot 1! \cdot 2! \cdot 1!} \\ &= 1 \cdot \frac {6 \cdot 5 \cdot 4 \cdot 3 \cdot 2 \cdot x^{3}} {8 \cdot 1 \cdot 3 \cdot 2 \cdot 3 \cdot 2} + (-1) \cdot \frac {4 \cdot 3 \cdot 2 \cdot x^{1}} {8\cdot 1 \cdot 2 \cdot 1} \\ {P}_{3}(x) &= \frac {5}{2}x^{3} - \frac {3}{2} x \\ \end{align} $$ $$
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle
 * }
 * }

v) n=4
 * {| style="width:100%" border="0"

\begin{align} {P}_{4}(x) &= \sum_{[i]=0}^{\lfloor 4/2 \rfloor} (-1)^{i} \cdot \frac {(2n-2i)! \cdot x^{n-2i}} {2^{n}\cdot i! \cdot (n-i)! \cdot (n-2i)!}\\ &= (-1)^{0} \cdot \frac {8! \cdot x^4} {2^{4}\cdot 0! \cdot 4! \cdot 4!} + (-1)^{1} \cdot \frac {6! \cdot x^2} {2^{4}\cdot 1! \cdot 3! \cdot 2!} + (-1)^{2} \cdot \frac {4! \cdot x^0} {2^{4}\cdot 2! \cdot 2! \cdot 0!} \\ {P}_{4}(x) &= 1 \cdot \frac {8 \cdot 7 \cdot 6 \cdot 5 \cdot 4 \cdot 3 \cdot 2 \cdot x^4} {16 \cdot 1 \cdot 4 \cdot 3 \cdot 2 \cdot 4 \cdot 3 \cdot 2} + (-1) \cdot \frac {6 \cdot 5 \cdot 4 \cdot 3 \cdot 2 \cdot x^2} {16 \cdot 1 \cdot 3 \cdot 2 \cdot 2} + 1 \cdot \frac {4 \cdot 3 \cdot 2 \cdot 1} {16 \cdot 2 \cdot 2 \cdot 1} \\ \end{align} $$ $$
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle
 * }
 * }

=Problem 2.7: Verification of Orthogonality of Legendre polynominals=

Refer to lecture slide from [[media:nm1.s11.mtg9.djvu|mtg-9]] for the problem statement and table shown below.

Background
Legendre polynominals are given by :

Note that they are all defined on the domain $$\displaystyle (-1,+1)$$.

The first 6 Legendre polynominals are :

While the Gramian matrix is defined as:

Find
A) Construct Gramian Matrix $$\displaystyle \Gamma $$ with respect to Legendre polynominals from order $$\displaystyle 0$$ to $$\displaystyle 5$$ and show that it‘s diagonal.

B) Compute the determinant of $$\displaystyle \Gamma$$.

C)Discuss the orthogonality of Legendre polynominals.

Solution
A) Construct Gramian Matrix $$\displaystyle \Gamma $$ with respect to Legendre polynominals from order $$\displaystyle 0$$ to $$\displaystyle 5$$.

When the order of Legendere polynominals is less than or equal 2, we have,

As the order goes higher we may use WolframAlpha to help us construct the Gramian matrix(click on the link to check the results):

which means the Gramian matrix $$\displaystyle \Gamma $$ is,

which is apparently a diagonal matrix

B) Compute the determinant of $$\displaystyle \Gamma $$.

Since $$\displaystyle \Gamma $$ is a diagonal matrix, the determinant of it is

C)Discuss the orthogonality of Legendre polynominals.

From Eq(7.2) we can conclude that within order of 5 the Legendre polynominals are orthogonal to each other.

In fact Legendre polynominals have such orthogonality property :

where $$\displaystyle {{\delta }_{mn}}$$ is the Kronecker delta.

The proof of the above statement is given by A.K.Lal et al.

=Problem 2.8 - Newton-Cotes Simplification to Trapezoidal Rule=

Find
Show that the Newton-Cotes method for numerical integration with n=1 simplifies to the simple trapezoidal rule.

Given
The Newton-Cotes method using Lagrange interpolating polynomials is given as The simple trapezoidal rule is expressed as

Solution
For n=1, the Newton-Cotes method becomes Let a = x0 and b = x1, and substitute in the Lagrange interpolating polynomials as

The Newton-Cotes equation becomes Manipulation proceeds as follows to yield the simple trapezoidal rule: The last line of 2.8.6 is identical to the simple trapezoidal rule, thus the proof is complete.

=Problem 2.9: "Gauss-Legendre Quadrature and Runge's phenomenon"=

Given
Legendre polynomial

Find
A) Use (9.1) to generate $$ {P_5}(x) $$ and Matlab command "roots" to compute the roots of $$ {P_5}(x) $$ to check values in table on p7-5. Plot the roots on $$ [-1,+1] $$ using Matlab "plot" command.

B) Repeat the above for $$ {P_{10}}(x) $$ and observe the location of roots near end points -1 and +1.

Solution
A) Substitute n=5 in (9.1) and then can get $$ {P_5}(x) $$:

Use the following codes in Matlab :

p=[63 0 -70 0 15 0]/8 roots(p)

we can get the roots for $$ {P_5}(x) $$: ans = 0  -0.9062   -0.5385    0.9062    0.5385

The above answers are exactly the same as the data in table on p7-5.

Use the "plot" command we can get the distribution of roots on $$ [-1,+1] $$ as following:



B) Substitute n=10 in (9.1) and then can get $$ {P_{10}}(x) $$:

Use the following codes in Matlab :

p=[46189 0 -109395 0 90090 0 -30030 0 3465 0 -63]/256 roots(p)

we can get the roots for $$ {P_{10}}(x) $$: ans = -0.9739  -0.8651   -0.6794    0.9739    0.8651    0.6794   -0.4334    0.4334   -0.1489    0.1489

The above answers are exactly the same as the data in table on p7-5.

Use the "plot" command we can get the distribution of roots on $$ [-1,+1] $$ as following:



From the above image, we can observe that quadrature nodes become more dense near the end points. That means the interpolation with high order polynomial may has more oscillation near the edge of interval region because the interpolation only exactly accurate at the quadrature nodes and this phenomenon is so called Runge's phenomenon.

=Problem 2.10: "Proof of Simpson's Rule(simple)"=

Given
In the interval $$ \left[ {a,b} \right] $$ there are three nodes $$ {x_0} = a, {x_1} = \frac{2},  x{_2} = b $$ satisfy that

Find
Use (10.1) to find expression for $$ \left\{ \right\} $$ in terms $$ \left( {{x_i},f({x_i})} \right) $$.

Proof
From (10.1) we can have three equations for 3 unknown $$ \left\{ \right\} $$

$$ {c_2}{x_0}^2 + {c_1}{x_0} + {c_0} = f\left( \right) $$

$$ {c_2}{x_1}^2 + {c_1}{x_1} + {c_0} = f\left( \right) $$

$$ {c_2}{x_2}^2 + {c_1}{x_2} + {c_0} = f\left( \right) $$

And then we write them in matrix form:

where

$$ \left[ K \right] = \left[ {\begin{array}{ccccccccccccccc} 1&&{x_0^2} \\ 1&&{x_1^2} \\ 1&&{x_2^2} \end{array}} \right] $$

Because the determine of the matrix K is

$$ \det \left[ K \right] = - \left( {{x_0} - {x_1}} \right)\left( {{x_0} - {x_2}} \right)\left( {{x_1} - {x_2}} \right) $$

we then compute the inverse of matrix K is

$${\left[ K \right]^{ - 1}} = \left[ {\begin{array}{ccccccccccccccc} {\frac}&{ - \frac}&{\frac} \\ { - \frac}&{\frac}&{ - \frac} \\ {\frac{1}}&{ - \frac{1}}&{\frac{1}} \end{array}} \right]\; $$

Then we can get $$ \left\{ \right\} $$ by multiple $$  {\left[ K \right]^{ - 1}} $$ on both sides of (10.2):

Consider that $$ {x_0} = a, {x_1} = \frac{2},  x{_2} = b $$ we can rewrite $$ \left\{ \right\} $$:

If integrate (10,1) on $$ \left[ {a,b} \right] $$, then

(10.9) is exactly Simpson's Rule for numerical integration.

=Problem 2.11: Proof of the Simple Simpson's Rule =

''' This problem was solved without referring to S10 homework. '''

From the lecture slide Mtg 10-4

Given
The Lagrange Interpretation Equation,


 * {| style="width:100%" border="0"

P_2(x_j)=\sum_{k=0}^2 l_{i,2}(x_j)f(x_i). $$ $$
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle
 * }
 * }

Find
Derive the Simple Simpson's rule from the above Lagrange Interpolation Equation of degree 2. The Simple Simpson's rule is as follows,


 * {| style="width:100%" border="0"

I_2=\dfrac{h}{3}[f(x_0)+4f(x_1)+f(x_2)] , $$ $$
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle
 * }
 * }

where


 * {| style="width:100%" border="0"

h=\dfrac{b-a}{2}. $$ $$
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle
 * }
 * }

Solution
By definition,
 * {| style="width:100%" border="0"

I_2 = \int_{a}^{b} P_2(x)\ dx $$
 * $$ \displaystyle
 * $$ \displaystyle
 * <p style="text-align:right;">
 * }
 * }

Evaluating the above integral gives


 * {| style="width:100%" border="0"

I_2 & = \int_{a}^{b} P_2(x)\ dx \\ & = \int_{a}^{b} \sum_{i=0}^{2}l_i(x)f(x_i)\ dx \\ & = \int_{a}^{b} l_0(x)f(x_0) + l_1(x)f(x_1) + l_2(x)f(x_2)\ dx \\ & = f(x_0)\int_{a}^{b} l_0(x)\ dx + f(x_1)\int_{a}^{b} l_1(x)\ dx + f(x_2)\int_{a}^{b} l_2(x)\ dx , \end{align} $$
 * $$ \displaystyle \begin{align}
 * $$ \displaystyle \begin{align}
 * <p style="text-align:right;">(11.1-4)
 * }
 * }

where $$ \displaystyle x_0 = a, x_1 = \frac{a+b}{2}, $$ and $$\displaystyle x_2 = b .$$

Next, integrate $$\displaystyle l_0(x), l_1(x),$$ and $$\displaystyle l_2(x). $$

1)$$\displaystyle I_0 $$


 * {| style="width:100%" border="0"

\int_{a}^{b} l_0(x)\ dx & = \int_{a}^{b}\frac{(x-x_1)(x-x_2)}{(x_0-x_1)(x_0-x_2)}\ dx \\ & = \int_{a}^{b}\frac{(x-\frac{a+b}{2})(x-b)}{(a-\frac{a+b}{2})(a-b)}\ dx \\ & = \frac{2}{(b-a)^2}\left [ \frac{x^3}{3} - \frac{a+3b}{4}x^2 + \frac{b(a+b)}{2}x \right ]_{a}^b \\ & = \frac{2}{(b-a)^2} \left [ \frac{(b-a)(b^2 + ab + a^2)}{3} - \frac{a+3b}{4}(b-a)(b+a) + \frac{b(a+b)}{2}(b-a) \right ] \\ & = \frac{2}{(b-a)} \left [ \frac{(b^2 + ab + a^2)}{3} - \frac{a+3b}{4}(b+a) + \frac{b(a+b)}{2} \right ] \\ & = \frac{(b-a)^2}{6(b-a)} \\ & = \frac{b-a}{6}\\ \end{align} $$
 * $$ \displaystyle \begin{align}
 * $$ \displaystyle \begin{align}
 * <p style="text-align:right;">(11.4-11)
 * }
 * }

2)$$\displaystyle I_1 $$


 * {| style="width:100%" border="0"

\int_{a}^{b} l_1(x)\ dx & = \int_{a}^{b}\frac{(x-x_0)(x-x_2)}{(x_1-x_0)(x_1-x_2)}\ dx \\ & = \int_{a}^{b}\frac{(x-a)(x-b)}{(\frac{a+b}{2}-a)(\frac{a+b}{2}-b)}\ dx \\ & = \frac{4}{(b-a)(a-b)}\left [ \frac{x^3}{3} - \frac{a+b}{2}x^2 + abx \right ]_{a}^b \\ & = \frac{4}{(b-a)(a-b)}\left [ \frac{(b-a)(b^2+ab+a^2)}{3} - \frac{(a+b)(a+b)(a-b)}{2} + ab(b-a) \right ]_{a}^b \\ & = \frac{4}{(a-b)}\left [ \frac{(b^2+ab+a^2)}{3} - \frac{(a+b)(a+b)}{2} + ab \right ]_{a}^b \\ & = \frac{2(b-a)^2}{3(b-a)} \\ & = \frac{2(b-a)}{3}\\ \end{align} $$
 * $$ \displaystyle \begin{align}
 * $$ \displaystyle \begin{align}
 * <p style="text-align:right;">(11.11-18)
 * }
 * }

3)$$\displaystyle I_2 $$


 * {| style="width:100%" border="0"

\int_{a}^{b} l_2(x) \ dx & = \int_{a}^{b}\frac{(x-x_0)(x-x_1)}{(x_2-x_0)(x_2-x_1)}\ dx \\ & = \int_{a}^{b}\frac{(x-a)(x-\frac{a+b}{2})}{(b-a)(b-\frac{a+b}{2})}\ dx \\ & = \frac{2}{(b-a)^2}\left [ \frac{x^3}{3} - \frac{3a+b}{4}x^2 + \frac{a(a+b)}{2}x \right ]_{a}^b \\ & = \frac{2}{(b-a)^2} \left [ \frac{(b-a)(b^2 + ab + a^2)}{3} - \frac{3a+b}{4}(b-a)(b+a) + \frac{b(a+b)}{2}(b-a) \right ] \\ & = \frac{2}{(b-a)} \left [ \frac{(b^2 + ab + a^2)}{3} - \frac{3a+b}{4}(b+a) + \frac{b(a+b)}{2} \right ] \\ & = \frac{(b-a)^2}{6(b-a)} \\ & = \frac{b-a}{6}\\ \end{align} $$
 * $$ \displaystyle \begin{align}
 * $$ \displaystyle \begin{align}
 * <p style="text-align:right;">(11.18-26)
 * }
 * }

Substituting the values for the integrals of $$\displaystyle l_0(x), l_1(x),$$ and $$\displaystyle l_2(x) $$ into equation 11.4 gives


 * {| style="width:100%" border="0"

\begin{align} I_2 & = f(x_0)\frac{b-a}{6}+f(x_1)\frac{2(b-a)}{3}+f(x_2)\frac{b-a}{6} \\ I_2 & = \frac{b-a}{6}[f(x_0)+4f(x_1)+f(x_2)]\\ \end{align} $$
 * $$ \displaystyle
 * $$ \displaystyle
 * }

where


 * {| style="width:100%" border="0"

h = \frac{b-a}{2}. $$
 * $$\displaystyle
 * $$\displaystyle
 * <p style="text-align:right;">(11.28)
 * }
 * }

= Problem 2.12 Numerically calculating integral of a function using Lagrange method =

From the lecture slide Mtg 10 [[media:nm1.s11.mtg10.djvu|Mtg10]]

Ref: Egm6341.s10.team3.sa/HW2

Given
$$ f(x)=\frac{e^{x}-1}{x} $$ on $$ x\in[0,1] (a) $$ and $$ x\in[0,1] (b) $$

Find
A) Construct $$ f_{n}(x)= \sum_{i=0}^{n}l_{i,n}(x)f(x_{i}) $$ for $$\displaystyle n = 1, 2, 4, 8, 16 $$ for both intervals.

B) Plot $$\displaystyle f(x) $$ and $$\displaystyle f_{n}(x) $$ for n = 1, 2, 4, 8, 16.

C) Compute $$ I_{n}=\int_{b}^{b}f_{n}(x)dx $$ for n = 1, 2, 4, 8 and compare to $$\displaystyle I $$.

D) For n = 5, plot $$\displaystyle l_{0}, l_{1}, l_{2} $$.

Solution
A) Considering the following equations:

$$  \displaystyle l_{i,n}(x) = \prod_{j=0,i\neq j}^{n}\frac{x-x_{j}}{x_{i}-x_{j}} $$ and $$  \displaystyle

f_{n}=\sum_{i=0}^{n}l_{i,n}(x)f(x_{i}) $$

for different n values and $$ x\in[0,1] $$, the followings can be calculated:

When n = 1

$$ \displaystyle x_{0} = 0, x_{1} = 1 $$.

$$\displaystyle l_{0,1}=\prod_{j=0,j\neq 0}^{1}\frac{x-x_{j}}{x_{0}-x_{j}}=\frac{x-1}{0-1}, \quad f(x_{0})=f(0)=1, $$

$$\displaystyle l_{1,1}=\prod_{j=0,j\neq 1}^{1}\frac{x-x_{j}}{x_{1}-x_{j}}=\frac{x-0}{1-0}, \quad f(x_{1})=f(1)=e-1. $$

When n = 2

$$ x_{0} = 0, x_{1} = \frac{1}{2}, x_{2} = 1 $$.

$$\displaystyle l_{0,2}=\prod_{j=0,j\neq 0}^{2}\frac{x-x_{j}}{x_{0}-x_{j}}=\frac{(x-\frac{1}{2})(x-1)}{(0-\frac{1}{2}(0-1)}, \quad f(x_{0})=f(0)=1, $$

$$\displaystyle l_{1,2}=\prod_{j=0,j\neq 1}^{2}\frac{x-x_{j}}{x_{1}-x_{j}}=\frac{(x-0)(x-1)}{(\frac{1}{2}-0)(\frac{1}{2}-1)}, \quad f(x_{1})=f(\frac{1}{2})=2\left(e^{\frac{1}{2}}-1\right), $$

$$\displaystyle l_{2,2}=\prod_{j=0,j\neq 2}^{2}\frac{x-x_{j}}{x_{2}-x_{j}}=\frac{(x-0)(x-\frac{1}{2})}{(1-0)(1-\frac{1}{2})}, \quad f(x_{2})=f(1)=e-1. $$

When n = 4

$$ x_{0} = 0, x_{1} = \frac{1}{4}, x_{2} = \frac{2}{4}, x_{3} = \frac{3}{4}, x_{4} = 1 $$.

$$\displaystyle l_{0,4}=\prod_{j=0,j\neq 0}^{4}\frac{x-x_{j}}{x_{0}-x_{j}}=\frac{(x-\frac{1}{4})(x-\frac{2}{4})(x-\frac{3}{4})(x-1)}{(0-\frac{1}{4})(0-\frac{2}{4})(0-\frac{3}{4})(0-1)}, \quad f(x_{0})=f(0)=1, $$

$$\displaystyle l_{1,4}=\prod_{j=0,j\neq 1}^{4}\frac{x-x_{j}}{x_{1}-x_{j}}=\frac{(x-0)(x-\frac{2}{4})(x-\frac{3}{4})(x-1)}{(\frac{1}{4}-0)(\frac{1}{4}-\frac{2}{4})(\frac{1}{4}-\frac{3}{4})(\frac{1}{4}-1)}, \quad f(x_{1})=f(\frac{1}{4})=4\left(e^{\frac{1}{4}}-1\right), $$

$$\displaystyle l_{2,4}=\prod_{j=0,j\neq 2}^{4}\frac{x-x_{j}}{x_{2}-x_{j}}=\frac{(x-0)(x-\frac{1}{4})(x-\frac{3}{4})(x-1)}{(\frac{2}{4}-0)(\frac{2}{4}-\frac{1}{4})(\frac{2}{4}-\frac{3}{4})(\frac{2}{4}-1)}, \quad f(x_{2})=f(\frac{2}{4})=2\left(e^{\frac{2}{4}}-1\right), $$

$$\displaystyle l_{3,4}=\prod_{j=0,j\neq 3}^{4}\frac{x-x_{j}}{x_{3}-x_{j}}=\frac{(x-0)(x-\frac{1}{4})(x-\frac{2}{4})(x-1)}{(\frac{3}{4}-0)(\frac{3}{4}-\frac{1}{4})(\frac{3}{4}-\frac{2}{4})(\frac{3}{4}-1)}, \quad f(x_{3})=f(\frac{3}{4})=\frac{4}{3}\left(e^{\frac{3}{4}}-1\right), $$

$$\displaystyle l_{4,4}=\prod_{j=0,j\neq 4}^{4}\frac{x-x_{j}}{x_{4}-x_{j}}=\frac{(x-0)(x-\frac{1}{4})(x-\frac{2}{4})(x-\frac{3}{4})}{(1-0)(1-\frac{1}{4})(1-\frac{2}{4})(1-\frac{3}{4})}, \quad f(x_{4})=f(1)=e-1, $$

When n = 8

$$ x_{0} = 0, x_{1} = \frac{1}{8}, x_{2} = \frac{2}{8}, x_{3} = \frac{3}{8}, x_{4} = \frac{4}{8}, x_{5} = \frac{5}{8}, x_{6} = \frac{6}{8}, x_{7} = \frac{7}{8}, x_{8} = 1 $$.

$$\displaystyle l_{0,8}=\prod_{j=0,j\neq 0}^{8}\frac{x-x_{j}}{x_{0}-x_{j}}=\frac{(x-\frac{1}{8})(x-\frac{2}{8})(x-\frac{3}{8})(x-\frac{4}{8})(x-\frac{5}{8})(x-\frac{6}{8})(x-\frac{7}{8})(x-1)}{(0-\frac{1}{8})(0-\frac{2}{8})(0-\frac{3}{8})(0-\frac{4}{8})(0-\frac{5}{8})(0-\frac{6}{8})(0-\frac{7}{8})(0-1)}, \quad f(x_{0})=f(0)=1, $$

$$\displaystyle l_{1,8}=\prod_{j=0,j\neq 1}^{8}\frac{x-x_{j}}{x_{1}-x_{j}}=\frac{(x-0)(x-\frac{2}{8})(x-\frac{3}{8})(x-\frac{4}{8})(x-\frac{5}{8})(x-\frac{6}{8})(x-\frac{7}{8})(x-1)}{(\frac{1}{8}-0)(\frac{1}{8}-\frac{2}{8})(\frac{1}{8}-\frac{3}{8})(\frac{1}{8}-\frac{4}{8})(\frac{1}{8}-\frac{5}{8})(\frac{1}{8}-\frac{6}{8})(\frac{1}{8}-\frac{7}{8})(\frac{1}{8}-1)}, \quad f(x_{1})=f(\frac{1}{8})=8\left(e^{\frac{1}{8}}-1\right), $$

$$\displaystyle l_{2,8}=\prod_{j=0,j\neq 2}^{8}\frac{x-x_{j}}{x_{2}-x_{j}}=\frac{(x-0)(x-\frac{1}{8})(x-\frac{3}{8})(x-\frac{4}{8})(x-\frac{5}{8})(x-\frac{6}{8})(x-\frac{7}{8})(x-1)}{(\frac{2}{8}-0)(\frac{2}{8}-\frac{1}{8})(\frac{2}{8}-\frac{3}{8})(\frac{2}{8}-\frac{4}{8})(\frac{2}{8}-\frac{5}{8})(\frac{2}{8}-\frac{6}{8})(\frac{2}{8}-\frac{7}{8})(\frac{2}{8}-1)}, \quad f(x_{2})=f(\frac{2}{8})=\frac{8}{2}\left(e^{\frac{2}{8}}-1\right), $$

$$\displaystyle l_{3,8}=\prod_{j=0,j\neq 3}^{8}\frac{x-x_{j}}{x_{3}-x_{j}}=\frac{(x-0)(x-\frac{1}{8})(x-\frac{2}{8})(x-\frac{4}{8})(x-\frac{5}{8})(x-\frac{6}{8})(x-\frac{7}{8})(x-1)}{(\frac{3}{8}-0)(\frac{3}{8}-\frac{1}{8})(\frac{3}{8}-\frac{2}{8})(\frac{3}{8}-\frac{4}{8})(\frac{3}{8}-\frac{5}{8})(\frac{3}{8}-\frac{6}{8})(\frac{3}{8}-\frac{7}{8})(\frac{3}{8}-1)}, \quad f(x_{3})=f(\frac{3}{8})=\frac{8}{3}\left(e^{\frac{3}{8}}-1\right), $$

$$\displaystyle l_{4,8}=\prod_{j=0,j\neq 4}^{8}\frac{x-x_{j}}{x_{4}-x_{j}}=\frac{(x-0)(x-\frac{1}{8})(x-\frac{2}{8})(x-\frac{3}{8})(x-\frac{5}{8})(x-\frac{6}{8})(x-\frac{7}{8})(x-1)}{(\frac{4}{8}-0)(\frac{4}{8}-\frac{1}{8})(\frac{4}{8}-\frac{2}{8})(\frac{4}{8}-\frac{3}{8})(\frac{4}{8}-\frac{5}{8})(\frac{4}{8}-\frac{6}{8})(\frac{4}{8}-\frac{7}{8})(\frac{4}{8}-1)}, \quad f(x_{4})=f(\frac{4}{8})=\frac{8}{4}\left(e^{\frac{4}{8}}-1\right), $$

$$\displaystyle l_{5,8}=\prod_{j=0,j\neq 5}^{8}\frac{x-x_{j}}{x_{5}-x_{j}}=\frac{(x-0)(x-\frac{1}{8})(x-\frac{2}{8})(x-\frac{3}{8})(x-\frac{4}{8})(x-\frac{6}{8})(x-\frac{7}{8})(x-1)}{(\frac{5}{8}-0)(\frac{5}{8}-\frac{1}{8})(\frac{5}{8}-\frac{2}{8})(\frac{5}{8}-\frac{3}{8})(\frac{5}{8}-\frac{4}{8})(\frac{5}{8}-\frac{6}{8})(\frac{5}{8}-\frac{7}{8})(\frac{5}{8}-1)}, \quad f(x_{5})=f(\frac{5}{8})=\frac{8}{5}\left(e^{\frac{5}{8}}-1\right), $$

$$\displaystyle l_{6,8}=\prod_{j=0,j\neq 6}^{8}\frac{x-x_{j}}{x_{6}-x_{j}}=\frac{(x-0)(x-\frac{1}{8})(x-\frac{2}{8})(x-\frac{3}{8})(x-\frac{4}{8})(x-\frac{5}{8})(x-\frac{7}{8})(x-1)}{(\frac{6}{8}-0)(\frac{6}{8}-\frac{1}{8})(\frac{6}{8}-\frac{2}{8})(\frac{6}{8}-\frac{3}{8})(\frac{6}{8}-\frac{4}{8})(\frac{6}{8}-\frac{5}{8})(\frac{6}{8}-\frac{7}{8})(\frac{6}{8}-1)}, \quad f(x_{6})=f(\frac{6}{8})=\frac{8}{6}\left(e^{\frac{6}{8}}-1\right), $$

$$\displaystyle l_{7,8}=\prod_{j=0,j\neq 7}^{8}\frac{x-x_{j}}{x_{7}-x_{j}}=\frac{(x-0)(x-\frac{1}{8})(x-\frac{2}{8})(x-\frac{3}{8})(x-\frac{4}{8})(x-\frac{5}{8})(x-\frac{6}{8})(x-1)}{(\frac{7}{8}-0)(\frac{7}{8}-\frac{1}{8})(\frac{7}{8}-\frac{2}{8})(\frac{7}{8}-\frac{3}{8})(\frac{7}{8}-\frac{4}{8})(\frac{7}{8}-\frac{5}{8})(\frac{7}{8}-\frac{6}{8})(\frac{7}{8}-1)}, \quad f(x_{7})=f(\frac{7}{8})=\frac{8}{7}\left(e^{\frac{7}{8}}-1\right), $$

$$\displaystyle l_{8,8}=\prod_{j=0,j\neq 8}^{8}\frac{x-x_{j}}{x_{8}-x_{j}}=\frac{(x-0)(x-\frac{1}{8})(x-\frac{2}{8})(x-\frac{3}{8})(x-\frac{4}{8})(x-\frac{5}{8})(x-\frac{6}{8})(x-\frac{7}{8})}{(1-0)(1-\frac{1}{8})(1-\frac{2}{8})(1-\frac{3}{8})(1-\frac{4}{8})(1-\frac{5}{8})(1-\frac{6}{8})(1-\frac{7}{8})}, \quad f(x_{8})=f(1)=e-1. $$

When n = 16 $$ x_{0} = 0, x_{1} = \frac{1}{16}, x_{2} = \frac{2}{16}, x_{3} = \frac{3}{16}, x_{4} = \frac{4}{16}, x_{5} = \frac{5}{16}, x_{6} = \frac{6}{16}, x_{7} = \frac{7}{16}, x_{8} = \frac{8}{16}, x_{9} = \frac{9}{16}, x_{10} = \frac{10}{16}, x_{11} = \frac{11}{16}, x_{12} = \frac{12}{16}, x_{13} = \frac{13}{16}, x_{14} = \frac{14}{16}, x_{15} = \frac{15}{16}, x_{16} = 1 $$.

$$\displaystyle l_{0,16}=\prod_{j=0,j\neq 0}^{16}\frac{x-x_{j}}{x_{0}-x_{j}}=\frac{(x-\frac{1}{16})(x-\frac{2}{16})(x-\frac{3}{16})(x-\frac{4}{16})(x-\frac{5}{16})(x-\frac{6}{16})(x-\frac{7}{16})(x-\frac{8}{16})(x-\frac{9}{16})(x-\frac{10}{16})(x-\frac{11}{16})(x-\frac{12}{16})(x-\frac{13}{16})(x-\frac{14}{16})(x-\frac{15}{16})(x-1)}{(0-\frac{1}{16})(0-\frac{2}{16})(0-\frac{3}{16})(0-\frac{4}{16})(0-\frac{5}{16})(0-\frac{6}{16})(0-\frac{7}{16})(0-\frac{8}{16})(0-\frac{9}{16})(0-\frac{10}{16})(0-\frac{11}{16})(0-\frac{12}{16})(0-\frac{13}{16})(0-\frac{14}{16})(0-\frac{15}{16})(0-1)}, \quad f(x_{0})=f(0)=1, $$

$$\displaystyle l_{1,16}=\prod_{j=0,j\neq 1}^{16}\frac{x-x_{j}}{x_{1}-x_{j}}=\frac{(x-0)(x-\frac{2}{16})(x-\frac{3}{16})(x-\frac{4}{16})(x-\frac{5}{16})(x-\frac{6}{16})(x-\frac{7}{16})(x-\frac{8}{16})(x-\frac{9}{16})(x-\frac{10}{16})(x-\frac{11}{16})(x-\frac{12}{16})(x-\frac{13}{16})(x-\frac{14}{16})(x-\frac{15}{16})(x-1)}{(\frac{1}{16}-0)(\frac{1}{16}-\frac{2}{16})(\frac{1}{16}-\frac{3}{16})(\frac{1}{16}-\frac{4}{16})(\frac{1}{16}-\frac{5}{16})(\frac{1}{16}-\frac{6}{16})(\frac{1}{16}-\frac{7}{16})(\frac{1}{16}-\frac{8}{16})(\frac{1}{16}-\frac{9}{16})(\frac{1}{16}-\frac{10}{16})(\frac{1}{16}-\frac{11}{16})(\frac{1}{16}-\frac{12}{16})(\frac{1}{16}-\frac{13}{16})(\frac{1}{16}-\frac{14}{16})(\frac{1}{16}-\frac{15}{16})(\frac{1}{16}-1)}, \quad f(x_{1})=f(\frac{1}{16})=16\left(e^{\frac{1}{16}}-1\right), $$

and it can be calculate up to $$ l_{16,16} $$ in the same manner.

$$\displaystyle l_{16,16}=\prod_{j=0,j\neq 16}^{16}\frac{x-x_{j}}{x_{16}-x_{j}}=\frac{(x-0)(x-\frac{1}{16})(x-\frac{2}{16})(x-\frac{3}{16})(x-\frac{4}{16})(x-\frac{5}{16})(x-\frac{6}{16})(x-\frac{7}{16})(x-\frac{8}{16})(x-\frac{9}{16})(x-\frac{10}{16})(x-\frac{11}{16})(x-\frac{12}{16})(x-\frac{13}{16})(x-\frac{14}{16})(x-\frac{15}{16})}{(1-0)(1-\frac{1}{16})(1-\frac{2}{16})(1-\frac{3}{16})(1-\frac{4}{16})(1-\frac{5}{16})(1-\frac{6}{16})(1-\frac{7}{16})(1-\frac{8}{16})(1-\frac{9}{16})(1-\frac{10}{16})(1-\frac{11}{16})(1-\frac{12}{16})(1-\frac{13}{16})(1-\frac{14}{16})(1-\frac{15}{16})}, \quad f(x_{16})=f(1)=e-1, $$

And for different n values and $$ x\in[-1,1] $$, the followings can be calculated:

When n = 1

$$ \displaystyle x_{0} = -1, x_{1} = 1 $$.

$$\displaystyle l_{0,1} = \prod\limits_{j = 0,j \ne 0}^1 {\frac} = \frac,\quad f({x_0}) = f( - 1) =  - ({e^{ - 1}} - 1) $$

$$ {l_{1,1}} = \prod\limits_{j = 0,j \ne 1}^1 {\frac} = \frac,\quad f({x_1}) = f(1) = e - 1. $$

When n = 2

$$ \displaystyle x_{0} = -1, x_{1} = 0, x_{2} = 1 $$.

$${l_{0,2}} = \prod\limits_{j = 0,j \ne 0}^2 {\frac} = \frac,\quad f({x_0}) = f( - 1) =  - ({e^{ - 1}} - 1), $$

$${l_{1,2}} = \prod\limits_{j = 0,j \ne 1}^2 {\frac} = \frac,\quad f({x_1}) = f(0) = 1 $$

$${l_{2,2}} = \prod\limits_{j = 0,j \ne 2}^2 {\frac} = \frac,\quad f({x_2}) = f(1) = e - 1. $$

When n = 4

$$ \displaystyle x_{0} = -1, x_{1} = -\frac{1}{2}, x_{2} = 0, x_{3} = \frac{1}{2}, x_{4} = 1 $$.

$$ {l_{0,4}} = \prod\limits_{j = 0,j \ne 0}^4 {\frac} = \frac,\quad f({x_0}) = f( - 1) =  - ({e^{ - 1}} - 1)$$

$${l_{1,4}} = \prod\limits_{j = 0,j \ne 1}^4 {\frac} = \frac,\quad f({x_1}) = f( - \frac{1}{2}) =  - 2\left( {{e^{ - \frac{1}{2}}} - 1} \right), $$

$${l_{2,4}} = \prod\limits_{j = 0,j \ne 2}^4 {\frac} = \frac,\quad f({x_2}) = f(0) = 1, $$

$${l_{3,4}} = \prod\limits_{j = 0,j \ne 3}^4 {\frac} = \frac,\quad f({x_3}) = f(\frac{1}{2}) = 2\left( {{e^{\frac{1}{2}}} - 1} \right), $$

$$ {l_{4,4}} = \prod\limits_{j = 0,j \ne 4}^4 {\frac} = \frac,\quad f({x_4}) = f(1) = e - 1, $$

When n = 8

$$ \displaystyle x_{0} = -1, x_{1} = -\frac{3}{4}, x_{2} =- \frac{2}{4}, x_{3} = -\frac{1}{4}, x_{4} = 0, x_{5} = \frac{1}{4}, x_{6} = \frac{2}{4}, x_{7} = \frac{3}{4}, x_{8} = 1 $$.

$$ l_{0,8} = \prod\limits_{j = 0,j \ne 0}^8 {\frac} = \frac,\quad f({x_0}) = f( - 1) =  - ({e^{ - 1}} - 1), $$

$${l_{1,8}} = \prod\limits_{j = 0,j \ne 1}^8 {\frac} = \frac,\quad f({x_1}) = f( - \frac{3}{4}) =  - \frac{4}{3}\left( {{e^{ - \frac{3}{4}}} - 1} \right), $$

$$ {l_{2,8}} = \prod\limits_{j = 0,j \ne 2}^8 {\frac}  = \frac,\quad f({x_2}) = f( - \frac{2}{4}) =  - 2\left( {{e^{ - \frac{2}{4}}} - 1} \right), $$

$$ {l_{3,8}} = \prod\limits_{j = 0,j \ne 3}^8 {\frac}  = \frac,\quad f({x_3}) = f( - \frac{1}{4}) =  - 4\left( {{e^{ - \frac{1}{4}}} - 1} \right)$$

$$ {l_{4,8}} = \prod\limits_{j = 0,j \ne 4}^8 {\frac}  = \frac,\quad f({x_4}) = f(0) = 1, $$

$$ {l_{5,8}} = \prod\limits_{j = 0,j \ne 5}^8 {\frac} = \frac,\quad f({x_5}) = f(\frac{1}{4}) = 4\left( {{e^{\frac{1}{4}}} - 1} \right),$$

$$ {l_{6,8}} = \prod\limits_{j = 0,j \ne 6}^8 {\frac}  = \frac,\quad f({x_6}) = f(\frac{2}{4}) = 2\left( {{e^{\frac{2}{4}}} - 1} \right), $$

$$ {l_{7,8}} = \prod\limits_{j = 0,j \ne 7}^8 {\frac} = \frac,\quad f({x_7}) = f(\frac{3}{4}) = \frac{4}{3}\left( {{e^{\frac{3}{4}}} - 1} \right),$$

$${l_{8,8}} = \prod\limits_{j = 0,j \ne 8}^8 {\frac} = \frac,\quad f({x_8}) = f(1) = e - 1. $$

When n = 16 $$ \displaystyle x_{0} = -1, x_{1} = -\frac{7}{8}, x_{2} = -\frac{6}{8}, x_{3} = -\frac{5}{8}, x_{4} = -\frac{4}{8}, x_{5} = -\frac{3}{8}, x_{6} = -\frac{2}{8}, x_{7} = \frac{1}{8}, x_{8} = 0, x_{9} = \frac{1}{8}, x_{10} = \frac{2}{8}, x_{11} = \frac{3}{8}, x_{12} = \frac{4}{8}, x_{13} = \frac{5}{8}, x_{14} = \frac{6}{8}, x_{15} = \frac{7}{8}, x_{16} = 1 $$.

$$ l_{0,16} = \prod\limits_{j = 0,j \ne 0}^{16} {\frac} = \frac,\quad f({x_0}) = f( - 1) =  - ({e^{ - 1}} - 1), $$

$${l_{1,16}} = \prod\limits_{j = 0,j \ne 1}^{16} {\frac} = \frac,\quad f({x_1}) = f( - \frac{7}{8}) =  - \frac{8}{7}\left( {{e^{ - \frac{7}{8}}} - 1} \right),$$

and it can be calculate up to $$ l_{16,16} $$ in the same manner.

$$ {l_{16,16}} = \prod\limits_{j = 0,j \ne 16}^{16} {\frac}  = \frac,\quad f({x_{16}}) = f(1) = e - 1, $$

B) Considering the following equation, the approximated integral can be calculated:

$$ {I_n} = \int\limits_a^b {\sum\limits_{i = 0}^n {{l_{i,n}}({x_i}).f({x_i})dx} } $$

note that $$ {E_n} = \left| {I - {I_n}} \right| $$ is the difference between the exact integral $$\displaystyle I $$ and approximated integral $$\displaystyle  I_n $$ The exact integral was calculated using wolframalpha

C) Figure 12.1 shows the $$\displaystyle f(x), f_1(x), f_2(x), f_4(x), f_8(x) for x\in[0,1] $$. As it can be seen, other than $$\displaystyle f_1(x)$$ the rest of the higher order approximations lie on the exact function.


 * [[File:HW2 P12 A.png|1000px|center|thumb|Figure 12.1: $$\displaystyle f(x), f_1(x), f_2(x), f_4(x), f_8(x) for x\in[0,1] $$]]

Figure 12.2 shows the $$\displaystyle f(x), f_1(x), f_2(x), f_4(x), f_8(x) for x\in[-1,1] $$. As it can be seen, other than $$\displaystyle f_1(x)$$ the rest of the higher order approximations lie on the exact function.


 * [[File:HW2 P12 B.png|1000px|center|thumb|Figure 12.2: $$\displaystyle f(x), f_1(x), f_2(x), f_4(x), f_8(x) for x\in[-1,1] $$]]

D) Figure 12.3 shows $$\displaystyle l_{0,5},l_{1,5},l_{2,5} for x\in[0,1] $$]].


 * [[File:HW2 P12 C.png|1000px|center|thumb|Figure 12.3: $$\displaystyle f(x), l_{0,5},l_{1,5},l_{2,5} for x\in[0,1] $$]]

= Problem 2.13: Simple to Composite Trapezoidal and Simpson's Rules =

''' This problem was solved without referring to S10 homework. '''

From the lecture slide Mtg 10-5

Given
The simple Trapezoidal rule is


 * {| style="width:100%" border="0"

I_1=\dfrac{b-a}{2}[f(a)+f(b)]. $$
 * $$\displaystyle
 * $$\displaystyle
 * <p style="text-align:right;">(13.1)
 * }
 * }

The simple Simpson's rule is


 * {| style="width:100%" border="0"

I_2=\dfrac{h}{3}[f(x_0)+4f(x_1)+f(x_2)]. $$
 * $$\displaystyle
 * $$\displaystyle
 * <p style="text-align:right;">(13.2)
 * }
 * }

Find
Show that the simple Trapezoidal and Simpson's rules can be transformed into their respective composite forms.

The composite Trapezoidal rule is as follows


 * {| style="width:100%" border="0"

I_n=h[\dfrac{1}{2}f_0+f_1+...+\dfrac{1}{2}f_{n-1}]. $$
 * $$\displaystyle
 * $$\displaystyle
 * <p style="text-align:right;">(13.3)
 * }
 * }

The composite Simpson's rule is as follows


 * {| style="width:100%" border="0"

I_n=\dfrac{h}{3}[f_0+4f_1+2f_2+4f_3+2f_4+...+2f_{n-2}+4f_{n-1}+f_n]. $$
 * $$\displaystyle
 * $$\displaystyle
 * <p style="text-align:right;">(13.4)
 * }
 * }

Trapezoidal Rule
The Trapezoidal rule, $$\displaystyle n=1 $$, $$\displaystyle h $$ is equal to width of the interval $$\displaystyle [a,b] $$ is


 * {| style="width:100%" border="0"

I_1=\dfrac{x_1-x_0}{2}[f(x_0)+f(x_1)]. $$
 * $$\displaystyle
 * $$\displaystyle
 * <p style="text-align:right;">(13.5)
 * }
 * }

Next, the Trapezoidal rule, $$\displaystyle n=2 $$ is


 * {| style="width:100%" border="0"

I_2=\dfrac{x_1-x_0}{2}(f(x_0)+f(x_1))+\dfrac{x_2-x_1}{2}(f(x_1)+f(x_2)). $$
 * $$\displaystyle
 * $$\displaystyle
 * <p style="text-align:right;">(13.6)
 * }
 * }

Combine terms.


 * {| style="width:100%" border="0"

I_2=\dfrac{h}{2}[f(x_0)+2f(x_1)+f(x_2)] $$
 * $$\displaystyle
 * $$\displaystyle
 * <p style="text-align:right;">(13.7)
 * }
 * }

Next, the Trapezoidal rule, $$\displaystyle n=4 $$ is


 * {| style="width:100%" border="0"

I_4=\dfrac{x_1-x_0}{2}[f(x_0)+f(x_1)]+\dfrac{x_2-x_1}{2}[f(x_1)+f(x_2)]+\dfrac{x_3-x_2}{2}[f(x_2)+f(x_3)]+\dfrac{x_4-x_3}{2}[f(x_3)+f(x_4)]. $$
 * $$\displaystyle
 * $$\displaystyle
 * <p style="text-align:right;">(13.8)
 * }
 * }

Combine terms.


 * {| style="width:100%" border="0"

I_4=\dfrac{h}{2}[f(x_0)+2f(x_1)+2f(x_2)+2f(x_3)+f(x_4)] $$
 * $$\displaystyle
 * $$\displaystyle
 * <p style="text-align:right;">(13.9)
 * }
 * }

Finally, the composite Trapezoidal rule is

Simpson's Rule
Similarly, Simpson's rule, $$\displaystyle n=2 $$, $$\displaystyle h $$ is equal to width of the interval $$\displaystyle [a,b] $$ is


 * {| style="width:100%" border="0"

I_2=\dfrac{h}{3}[f(x_0)+4f(x_1)+f(x_2)] $$
 * $$\displaystyle
 * $$\displaystyle
 * <p style="text-align:right;">(13.11)
 * }
 * }

Next, Simpson's rule, $$\displaystyle n=4 $$ is


 * {| style="width:100%" border="0"

I_4=\dfrac{h}{3}[f(x_0)+4f(x_1)+f(x_2)]+\dfrac{h}{3}[f(x_2)+4f(x_3)+f(x_4)] $$
 * $$\displaystyle
 * $$\displaystyle
 * <p style="text-align:right;">(13.12)
 * }
 * }

Combine terms.


 * {| style="width:100%" border="0"

I_4=\dfrac{h}{3}[f(x_0)+4f(x_1)+2f(x_2)+4f(x_3)+f(x_4)] $$
 * $$\displaystyle
 * $$\displaystyle
 * <p style="text-align:right;">(13.13)
 * }
 * }

Next, Simpson's rule, $$\displaystyle n=6 $$ is


 * {| style="width:100%" border="0"

I_6=\dfrac{h}{3}[f(x_0)+4f(x_1)+f(x_2)]+\dfrac{h}{3}[f(x_2)+4f(x_3)+f(x_4)]+\dfrac{h}{3}[f(x_4)+4f(x_5)+f(x_6)] $$
 * $$\displaystyle
 * $$\displaystyle
 * <p style="text-align:right;">(13.14)
 * }
 * }

Combine terms.


 * {| style="width:100%" border="0"

I_6=\dfrac{h}{3}[f(x_0)+4f(x_1)+2f(x_2)+4f(x_3)+2f(x_4)+4f(x_5)+f(x_6)] $$
 * $$\displaystyle
 * $$\displaystyle
 * <p style="text-align:right;">(13.15)
 * }
 * }

Finally, the composite Simpson's rule is

=Problem 2.14: Expand the specific interpolation interval to arbitrary domains=

Refer to lecture slide from [[media:nm1.s11.mtg11.djvu|mtg-11]] for the problem statement and table shown below.

Given
Tables have been established for Lagrangian Interpolation method to acquire weights on different points for integrations like:

Find
Expand the applicable domain from $$\displaystyle [-1,+1]$$ to an arbitrary one, i.e. make the tables established applicable to integrations like:

Solution
Integration such as Eq $$\displaystyle \int_{a}^{b}{f(x)dx}$$ can be transformed to $$\displaystyle \int_{-1}^{1}{f(x)dx}$$ by transformation of variables $$\displaystyle x=x(t)$$such that:

where $$\displaystyle \bar{f}(t)=f\left( x(t) \right){x}'(t)$$.

Note that this transformation requires that $$\displaystyle x=x(t)$$ is a continuously differentiable function and that:

For simplicity, let‘s assume $$\displaystyle x(t)$$ to be a linear function such that:

Combine Eqs(14.1) and Eq(14.2) we have,

And,

Then we can transform the integration $$\displaystyle I(f)=\int_{a}^{b}{f(x)dx}$$ into,

which meets the prerequisite of tables for Lagrangian Interpolation in Mtg11.

=References=

=Contributing Members=