User:Egm6341.s11.team2/hwk4

=Problem 4.1 Verifying the Accuracy of the Simple Simpson‘s Rule For a Cubic Polynomial=

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

From the lecture slide Mtg18-2

Given: The Integrand in the Form of a Simple Third Degree Polynomial
The integrand is

Show: That the Simple Simpsons's Rule Integrates Exactly
Verify that Simple Simpson ‘ Rule can integrate cubic polynomials exactly by numerically integrating the given function using Simple Simpson ‘ s Rule and compare the result with the same result.

Solution: By Exact and Numeric Integration
The exact value of integration $$\displaystyle I$$ is,

The numerical result by simple Simpson ‘ s rule is,

Hence,

In this case we have verified Simple Simpson ‘ s rule can integrate cubic polynomial exactly.

=Problem 4.2 "One Step in the Proof of the Simple Simpson's Error Theorem"=

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

Given: The Error Resulting from Numeric Integration
In order to prove Simple Simpson's Error Theorem, we define

Find: The First Derivative of the Error
Find the first derivative of the first term of (4.2.1) since it is needed to compute the first derivative of (4.2.2).

Solution: Differentiation
Suppose there is a constant $$ k \in \left] { - t,t} \right[ $$ and then the first term can be written as

Then we can find out the first derivative of (4.2.3) is

Therefore the first derivative of the first term of (4.2.1) is

=Problem 4.3 Verification of the Goal Function at Particular Point=

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

From the lecture slide Mtg20-3

Given: The Goal Function
The Goal function in proof of error of SSET is,

where,

Solution: By Taking Derivatives and Using Definitions
In the lecture slide 19 we have already got,

where

Then we have,

Hence,

=Problem 4.4 "Another Step in The Proof of the Simple Simpson's Error Theorem"=

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

Given: The Error Associated with the Simple Simpson's Rule
In order to prove Simple Simpson's Error Theorem, we define

Find: The Third Derivative of the Error
The third derivative of (4.4.1)

Solution: By Differentiation
From Problem 4.2, we have the first derivative of (4.4.1):

Then we can compute the second derivative of (4.4.1) use the above equation (4.4.2)

At last we can get the third derivative of (4.4.1) use the above equation (4.4.3)

=Problem 4.5: Show Relationship in the Simple Simpson's Error Theorem=

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

From the lecture slide Mtg 21-1

Find: The Relation Between $$ \xi\ \ $$ and $$ \zeta_4\ \ $$
Try to establish a relation between $$ \xi\ \ $$ and $$ \zeta_4\ \ $$.

Solution: By Transformation of Variables
Let

Transforming coordinates $$\displaystyle \left( t=\zeta_4, x=\xi\right) $$ gives:

With Eqn 5.1-7, the proof is as follows:

The fourth derivative of $$\displaystyle F \left(\zeta_4\right) $$ is

Substituting $$\displaystyle \frac{dx}{h} $$ for $$\displaystyle  dt $$ and $$\displaystyle  f\left(\xi\right) $$ for $$\displaystyle  F\left(\zeta_4\right) $$ in Eqn 5.8 gives:

Substitute Eqn 5.11 into Eqn 5.1 gives:

By transforming $$\displaystyle t=\zeta_4 $$ and $$\displaystyle x=\xi $$, Eqn 5.4 becomes

=Problem 4.6: Numerical Integration Using Non-Uniform Discretization =

Lecture 21-1

The Matlab code for this problem was written with assistance of problem 3 in Egm6341.s10.team3.sa/HW2

Given: A Known Function
$$ f(x) = \frac{1} $$ and $$ x \in [ - 1,1] $$

A) Find and Plot The Roots of the Legendre Polynomial
Use the roots of the Legendre polynomial, $$ \displaystyle{p_n}({x_i}) = 0 $$ and increase n until $${E_n} = I - {I_n} \leqslant {10^{ - 6}}$$. Plot $$ \displaystyle f_n^l(x)$$ and $$ \displaystyle f(x)$$.

B) Find and Plot The Roots of the Chebyshev Polynomial
Use the roots of the Chebyshev polynomial and increase n until $${E_n} = I - {I_n} \leqslant {10^{ - 6}}$$. Plot $$ \displaystyle f_n^l(x)$$ and $$ \displaystyle f(x)$$.

C) Find and Plot The Gauss-Legendre Quadrature
Use Gauss-Legendre quadrature and increase n until $${E_n} = I - {I_n} \leqslant {10^{ - 6}}$$

A) Using the roots of the Legendre polynomial as the nodes
Figures 6-1 and 6-2 show the results of using the roots of the Legendre polynomial as the nodes. The error is less than the acceptable lever for n=16. The Matlab code is shown below the figures. More details are described in the Matlab code.


 * HW4 P6 A.png


 * HW4 P6 A error.png

B) Using the roots of the Chebyshev polynomial as the nodes
Figures 6-3 and 6-4 show the results of using the roots of the Chevyshev polynomial as the nodes. The error is less than the acceptable lever for n=16. The Matlab code is shown below the figures. More details are described in the Matlab code.


 * HW4 P6 B.png


 * HW4 P6 B error.png

C) Using Gauss-Legendre quadrature
Figures 6-5 shows the results of using the Gauss-Legendre quadrature. The error is less than the acceptable lever for n=17. The Matlab code is shown below the figures. More details are described in the Matlab code.


 * HW4 P6 C error.png

D) Comparison
Based on the results of the previous subsections, the associated error with all the three methods reaches the acceptable level at the same n. The Gauss-Legendre Polynomial takes n=17 iterations to drop below the acceptable level for this function. Overall the Legendre Polynomial does only slightly better than the other two.

=Problem 4.7: Determining the Upper Bound of the Error in the Composite Simpson's Rule =

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

Given: The Error as the Difference between Actual and Numeric
The error $$ \displaystyle E_n $$ in the Composite Simpson's rule


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

$$ \displaystyle \begin{align} {E_n} &= I-I_n \\ &= \int\limits_{a}^{b} f(x)dx - \dfrac{h}{3}[f(x_0)+4f(x_1)+2f(x_2)+...+2f(x_{n-2})+4f(x_{n-1})+f(x_n)]\\ \end{align}$$ (7.0)
 * style="width:98%" |
 * style="width:98%" |
 * 
 * }

Show: The Error for the the Composite Simpson's Rule is Bounded Above
That the error for the Composite Simpson's Rule is given by,
 * {| style="width:100%" border="0"

$$ \displaystyle \left| {E}_{n}^{2} \right| \leq \frac{(b-a)^{5}}{2880 n^{4}} M_{4} = \frac{(b-a)h^{4}}{2880} M_{4} \quad where \quad M_{4} := max \left| f^{4}(\xi) \right| \quad s.t. \quad \xi \in [a,b] $$     (7.1)
 * style="width:98%" |
 * style="width:98%" |
 * 
 * }

Solution: Relating the Error in the Simple Simpson's Rule to the Partitioning of Intervals in the Composite Simpson's Rule
Consider the error $$ \displaystyle E_n $$ which is defined as the difference between the actual value of the integral, $$ \displaystyle I $$ and the value obtained from numerically integrating using the Composite Simpson's Rule, $$ \displaystyle I_n $$ where $$ \displaystyle n \geq 2 $$ is an even integer,


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

$$ \displaystyle \begin{align} {E_n} &= I-I_n \\ &= \int\limits_{a}^{b} f(x)dx - \dfrac{h}{3}[f(x_0)+4f(x_1)+2f(x_2)+...+2f(x_{n-2})+4f(x_{n-1})+f(x_n)]\\ \end{align}$$ (7.2) Observe that the following pattern arises from the terms $$ \displaystyle I_n $$ in (7.2)
 * style="width:98%" |
 * style="width:98%" |
 * 
 * }


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

$$ \begin{align}\displaystyle & f(x_0)+4f(x_1)+{\color{red}2f(x_2)}+...+{\color{green}2f(x_{n-2})}+4f(x_{n-1})+f(x_n) = \\ & \left[ f(x_0)+4f(x_1) + {\color{red}f(x_2)} \right] + \left[ {\color{red} f(x_2)}+4f(x_3) + f(x_4) \right] + \cdots \\ & \left[ f(x_{n-4})+4f(x_{n-3}) + {\color{green}f(x_{n-2})} \right] + \left[ {\color{green}f(x_{n-2})}+4f(x_{n-1}) + f(x_{n}) \right] \end{align} $$ The above relation allows us to write the terms inside of the summation as what is shown in (7.3). We must also take precautions to ensure that the partitioning of not only the summation, but also the partitioning of the integral contain the same subintervals namely, $$ \displaystyle [x_{2i-2},x_{2i}] $$. Both are accounted for defining $$ \displaystyle h:=\frac{b-a}{n} $$ and letting $$ \displaystyle x_i = a + ih $$ where $$ \displaystyle i = 0,1,2,...,n $$.
 * style="width:98%" |
 * style="width:98%" |
 * 
 * }
 * {| style="width:100%" border="0"

$$ \displaystyle \begin{align} {E_n} &= \sum_{i=1}^{n/2}\left[ \int\limits_{x_{2i-2}}^{x_{2i}} f(x)dx \right] - \dfrac{h}{3}\sum_{i=1}^{n/2} \left[ f(x_{2i-2})+4f(x_{2i-1})+f(x_{2i}) \right]\\ &= \sum_{i=1}^{n/2} \left[ \int\limits_{x_{2i-2}}^{x_{2i}} f(x)dx-\dfrac{h}{3}[f(x_{2i-2})+4f(x_{2i-1})+f(x_{2i})]\right]\\ where \quad h&=\frac{b-a}{n} = \frac{x_i - x_{i-1}}{n} \end{align}$$ (7.3)
 * style="width:98%" |
 * style="width:98%" |
 * 
 * }

We know that for the Simple Simson's Rule the error associated with the Lagrange Interpolation in, $$ \displaystyle E_2 $$ is,
 * {| style="width:100%" border="0"

$$ \displaystyle {E_2} = \frac{x_{i+1}-x_{i-1}}{2}f^{(4)}(\xi) \quad s.t. \quad \xi \in [x_{i-1},x_{i+1}] $$     (7.4)
 * style="width:98%" |
 * style="width:98%" |
 * 
 * }

Which implies for the Composite Simpson's Rule
 * {| style="width:100%" border="0"

$$ \displaystyle \begin{align} \left| {E_n} \right| &\leq  \sum_{i=1}^{n/2} max \left| \frac{(x_{i+1}-x_{i-1})^5}{90\cdot 2^5}f^{(4)}(\xi) \right| \quad s.t. \quad \xi \in [x_{i-1},x_{i+1}]\\ &= \frac{(x_{i+1}-x_{i-1})^5}{90} \cdot \sum_{i=1}^{n/2} {\color{red}\underbrace{max \left| f^{(4)}(\xi)\right|}_{M_4}} \quad s.t. \quad \xi \in [x_{i-1},x_{i+1}] \end{align} $$ (7.5)
 * style="width:98%" |
 * style="width:98%" |
 * 
 * }

Where $$ M_{4} $$ is defined on $$ \displaystyle [a,b] $$ as
 * {| style="width:100%" border="0"

$$ \displaystyle M_{4} := max \left| f^{(4)}(\xi)\right| \quad s.t. \quad \xi \in [a,b] $$     (7.6) Next we will consider $$ \displaystyle \bar{M}_{4} \leq n \cdot M_{4} $$ allowing us to write $$ \displaystyle E_n $$ as,
 * style="width:98%" |
 * style="width:98%" |
 * 
 * }
 * {| style="width:100%" border="0"

$$ \begin{align} \displaystyle \left| {E_n} \right| & \leq \left| \frac{(b-a)^{5}}{2880n^{5}}nM_{4} \right| \\ &= \left| \left(\frac{(b-a)}{2880}\right) {\color{red} \left( \frac{(b-a)^4} {n^4}\right)} M_{4}\right| \\ &= \left| \frac{(b-a){\color{red}h^{4}}}{2880}M_{4} \right| \end{align} $$ (7.7)
 * style="width:98%" |
 * style="width:98%" |
 * 
 * }

Therefore showing that the error associated with the Composite Simpson's Rule is

=Problem 4.8 Comparison of error bound in different estimation method with numerical result=

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

From the lecture slide Mtg22-2

Background
The maximum error of composite trapezoidal rule is ,

where $$\displaystyle {{M}_{2}}$$ is the maximum of $$\displaystyle \left| {{f}^{(2)}}(.) \right|$$

The maximum error of composite Simpson ‘ s rule is ,

where $$\displaystyle {{M}_{4}}$$ is the maximum of $$\displaystyle \left| {{f}^{(4)}}(.) \right|$$

Given
In the Problem 2.4, we have numerically calculate the order $$\displaystyle n$$ such that the following integration, with Taylor series expansion, composite trapezoidal rule and composite Simpson ‘ s rule, is with error less than $$\displaystyle Q={{10}^{-6}}$$.

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

And in Problem 2.3 we have the remainder of Taylor expansion of $$\displaystyle f(x)=\frac{{{e}^{x}}-1}{x}$$ is,

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

Find
(1)Use different error bound of Taylor series, composite trapezoidal rule and composite Simpson ‘ s rule to calculate the smallest order n needed such that the error of numerical integration of that in Problem 2.4 is less than $$\displaystyle Q={{10}^{-6}}$$. And then compare them with the actual numerical calculation.

(2)Numerically find the power of h in error by plotting the logarithm of error versus the logarithm of h. The slope of the linear regression fit line is equal to the power of h.

Taylor series comparison
Using the same method in Mtg7 we can find the error bound of Taylor series,

Since we have set n to be even,

The error should be within $$\displaystyle Q$$

By WolframAlpha we have,

which coincide with the result in Problem 2.4.

Composite trapezoidal rule comparison
By 4.8.1 we have,

where $$\displaystyle {{M}_{2}}$$ can be calculated by WolframAlpha ,

Then we have,

Calculated by WolframAlpha we have,

While in Problem 2.4 we have $$\displaystyle n=512$$, the order produced by the error bound is larger than the numerical result.

Composite Simpson's rule comparison
By 8.2 we have,

where $$\displaystyle {{M}_{4}}$$ can be calculated by WolframAlpha ,

Then we have,

Calculated by WolframAlpha we have,

In Problem 2.4 we calculated the case $$\displaystyle n=8$$ and $$\displaystyle n=16$$, the former case failed to satisfy the condition that $$\displaystyle \left| {{E}_{n}} \right|\le Q={{10}^{-6}}$$ while the latter succeed. This is a verification of the result above.

Conclusion
From the case of Taylor series and composite trapezoidal rule we can see the order of estimation given by the error bound is larger than or equal to that given by numerical calculation. This can be explained as: the error bound is stricter because it denotes the maximal error hence it is reasonably larger than or equal to the real error and thus requires higher order.

While in case of composite Simpson ‘ s rule we didn ‘ t calculate the case $$\displaystyle n=9$$, but the case $$\displaystyle n=8$$ and $$\displaystyle n=16$$ have demonstrate that if the error bound is satisfied with error limit then the numerical result must be satisfied.

Solution to part (2)
Figure 4.8-1 shows a plot of the logarithm of the Taylor series approximation for values of n = 2,4,8,16. This data was then fitted with a least square linear regression. The slope of this line is 16, however, this value increases as n is increased (and h is consequently decreased). Thus, the power of h is not a constant and the error using Taylor series shrinks at a faster rate than composite trapezoidal or Simpson's rule.


 * Egm6341.s11.team2.hw4_8_1.jpg

Figure 4.8-2 shows the logarithm of the composite trapezoidal rule error for varying values of log(h). The linear regression line has a slope of 2, Thus h appears as a quadratic term in finding the error.


 * Egm6341.s11.team2.hw4_8_2.jpg

Figure 4.8-3 shows the logarithm of the composite Simpson's rule error for varying values of log(h). The linear regression line has a slope of 4. Consequently, h appears as a 4th-order term in finding the integration error using the composite Simpson's rule.


 * Egm6341.s11.team2.hw4_8_3.jpg

=Problem 4.9: Determining the Conditions For Which an Upper Bound of the Error in the Simple Simpson's Rule Exists=

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

Given: The Error in the Simple Simpson's Rule, the IMVT and Rolle's Theorem
It was previously show in | Problem 3.8 that the error in the Simple Simpson's Rule is given by

Introduced in | Lecture 16-1 was the Derivative Mean Value Theorem(DMVT). It is shown below and is required for this proof.

Derivative Mean Value Theorem:

Given a continuously differentiable function $$\displaystyle f(x) \ s.t. \ f: \mathbb{R} \rightarrow \mathbb{R} $$, then there exists at least one point $$\displaystyle \xi \in [a,b] $$ such that

Another important theorem introduced in | Lecture 16-1 is Rolle's Theorem.

Rolle's Theorem:

If $$\displaystyle f(a)=f(b)=constant$$, then there exists at least one $$\displaystyle \xi [a,b] $$ such that $$\displaystyle f'(\xi)=0 $$.

Part A: For the case with $$ t^4 $$
That the following holds for the case when $$\displaystyle t^4 $$

Part B: For the Case With $$ t^6 $$
That the following holds for the case when $$\displaystyle t^6 $$

Show: What Happens For the Case With $$ t^5 $$
Find $$ \displaystyle G^{(3)}(0) $$ and follow same steps in the proof to see what happens.

Solution: For $$t^4 $$ and $$ t^6 $$
For the purpose of this proof let us define

Next let $$ \displaystyle e(t) $$ shown in (9.6) be defined as

Part A: For the case with $$ t^4 $$
Let us first differentiate $$ \displaystyle G(t) $$ defined in (9.4) three times.

Using (9.7) we know that,

We must next apply Rolle's Theorem three times to see that

Substituting (9.11) and (9.12) into (9.10)

Applying the DMVT shown in (9.2) to the third derivative of F

Substituting the LHS of (9.14) into (9.13) gives

We also know that the error associated with the Simple Simpson's Rule, $$ E_2 $$ is

From (9.15) and (9.16) we get

The relationship between $$ \displaystyle \xi $$ and $$ \displaystyle \zeta_4 $$ was established in Problem 4.5.

Substituting (9.18) into (9.17) gives

Comment: Regarding the Result Obtained
This result is interesting because it contains a $$\displaystyle \zeta_{3} $$ term which one would not expect. This is a direct consequence of $$\displaystyle \zeta_{3} $$ having order one and order two in the resulting equation of (9.15). As a result we do not the anticipated cancellation of $$\displaystyle \zeta_{3} $$ as is seen for the $$ \displaystyle t^5 $$ case.

Part B: For the Case With $$ t^6 $$
For this part we will consider the case with $$ \displaystyle t^6 $$ shown below,

Let us first differentiate $$ \displaystyle G(t) $$ defined in (9.5) three times.

Applying Rolle's Theorem, the DMVT and making the same substitutions as what was done in (9.11) to (9.14) gives

Using the error associated with the Simple Simpson's Rule given in (9.16) results in

The relationship between $$ \displaystyle \xi $$ and $$ \displaystyle \zeta_4 $$ was established in Problem 4.5.

Substituting (9.18) into (9.24) gives

Comment: Regarding the Result Obtained
This result is interesting because it contains a $$\displaystyle \zeta_{3} $$ term which one would not expect. This is a direct consequence of $$\displaystyle \zeta_{3} $$ having order one and order two in the resulting equation of (9.23). As a result we do not the anticipated cancellation of $$\displaystyle \zeta_{3} $$ as is seen for the $$ \displaystyle t^5 $$ case.

Solution: For $$ t^5 $$
It follow from (9.11) that the three derivatives of interest are

Now lets focus our attention to what happens when $$\displaystyle G^{(3)}(t = 0)$$ in (9.28)

This means that the only way $$ \displaystyle G^{(3)}(t=0)=0 $$ is if $$ \displaystyle t=\zeta_3 $$ which a consequence of Rolle's Theorem (9.3).

Differentiating (9.28) one more time to obtain $$ \displaystyle G^{(4)} $$ is

Letting $$ \displaystyle t=\zeta_4 $$ results in

Next we will solve for $$\displaystyle e(1)$$ to get

Using the previously established relationship between $$\displaystyle \xi$$ and $$\displaystyle \zeta_4$$ gives

Where

Comment: Regarding the Result Obtained
In summary this means that as long as we have $$\displaystyle f(x) \in \mathcal{P}_{3}$$ we get that $$\displaystyle f^{(4)}(x) = 0 $$.

And therefore the Simple Simpson's rule is exact for polynomials of degree less than 3,   $$\displaystyle \quad i.e \quad e(1) = 0 \Rightarrow E_{2} = 0 $$.

=Problem 4.10: Comparisons Between Composite Trapezoidal and Composite Simpson's Rules=

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

From the lecture slide Mtg 22-3

Find: The Numerical Integration Using the Composite Trapezoid and Composite Simpson's Rule
a) Produce a table similar to table 5.1, page 255, Atkinson text book using the composite Trapezoidal rule (Atkinson is cos(x) instead of sin(x)).

b) Produce a table similar to table 5.3, page 258, Atkinson text book using the composite Simpson's rule (Atkinson is cos(x) instead of sin(x)).

Part (a): Composite Trapezoid Rule For Computing Numerical Integrals
The given integral is: $$I=\int_{0}^{\pi} e^{x} \sin \left ( x \right )\cdot dx$$ where $$f\left ( x \right )=e^{x} \sin \left ( x \right )$$ is the integrand and $$\;x\in \left [ 0,\pi \right ]$$. We will use the composite trapezoidal rule to obtain the following tabulated results:

Part (b): Composite Simpson's Rule for Computing Numerical Integrals
The given integral is: $$I=\int_{0}^{\pi} e^{x} \sin \left ( x \right )\cdot dx$$ where $$f\left ( x \right )=e^{x} \sin \left ( x \right )$$ is the integrand and $$\;x\in \left [ 0,\pi \right ]$$. We will use composite simpson's rule to generate the following tabulated results:

Concluding Remarks: Composite Trapezoid Versus Composite Simpson's
=References=

=Contributing Members & Referenced Lecture=