User:Egm6341.s11.team2.DT

Homework sandbox =Problem 1.1=

Find
Plot f(x) and find:


 * $$ \lim_{x \to 0}f(x) $$

Given

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

Solution
Using l'Hôpital's rule,


 * $$ \lim_{x \to 0}\frac{x} = \lim_{x \to 0}\frac{1} = 1$$


 * Hw1aplot.jpg]

=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.

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.

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 trapezoidal rule comparison
By 4.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 5.5: - Richardson Extrapolation and Romberg Integration applied to HW* 2.4=

Statement:
1) Modify the Matlab code from HW*2.4 (links) to make it more efficient, i.e. use Richardson extrapolation to compute higher order integral estimates starting from the trapezoidal rule.

2) Construct a Romberg table for results in 1). Compare to results from HW* 2.4.

Solution:
1) From problem 2.4, the composite trapezoidal rule was implemented for 2,4,8,16,32, and 64 node points. Equation 5.5.1 was then implemented to find the higher order integral estimates. The code is easily modified to include greater numbers of nodes or even higher order integral estimates.

The order of the error on each integral estimate can be found using Equation 5.5.2:

2) The following table presents the results of using Romberg integration on problem 2.4. The subscript on T corresponds to the iteration. Since the method starts with the composite trapezoidal rule, T0 corresponds to integration by the trapezoidal rule for various numbers of nodes.

Using Equation 5.5.2, the error of T3(4) is on the order of ~O(-7). Thus, using this method the third order estimate using only 4 nodes has O(-7) accuracy. However, this requires knowing the integral estimate using the composite trapezoidal rule for 2,4,8,16 and 32 nodes. For comparison, the composite trapezoidal rule alone only reaches O(-6) accuracy using 512 nodes, and the composite Simpson rule reaches O(-6) accuracy with 16 nodes. Legendre-Gauss quadrature reaches O(-7) accuracy with only 4 nodes. If the quadrature weights are readily available, Legendre-Gauss quadrature converges to an accurate solution with many fewer nodes required than the other methods. The Romberg integration scheme provides another useful method for numerically calculating the value of an integral, especially because it uses previous results to improve the integral estimate.

=Problem 6.6 - Understanding Kessler's Code=

Given
Kessler's code, given in his paper :

Find
In order to better understand Kessler's code and the HOTRE, improve upon the work of s10 and explain the code line by line. Then, run Kessler's code for $$i=1,2,3$$ to reproduce his results. The collective work of s10 is referenced here under HW5, Problem 10.

Solution
The following box presents Kessler's code commented line-by-line to describe the algorithm for using the HOTRE.

Running Kessler's code with n = 3 results in the following output:

These with the additional last line written into the code, the output matches the tables presented in Kessler's paper: