University of Florida/Egm6341/s10.team2.niki/HW3

Problem Statement
Pg. 17-2

See also HW1-problem 8[] Using the error estimates of estimate $$\boldsymbol{n}$$ such that $$\boldsymbol{E_n=I-I_n=O(10^{-6})}$$
 * Taylor Series
 * Composite Trapezoidal rule
 * Composite Simpson's rule

Solution: Taylor series
Error is defined as
 * {| style="width:100%" border="0"

$$  \displaystyle E_n=I-I_n =\int_{a}^{b}[f(x)-f_n(x)]dx $$
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }

For the Taylor series, from the discussion on p6-4, we know that the error is nothing but the remainder of the Taylor series integrated over the given interval i.e
 * {| style="width:100%" border="0"

$$  \displaystyle \int_{a}^{b}R_{n+1}(x)=\int_{a}^{b}[\frac{(x-x_0)^{n+1}}{(n+1)!}f^{(n+1)}(\xi )]$$ where $$\xi \varepsilon [a,b] $$    (1 p2-3)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }

For the given function the error is
 * {| style="width:100%" border="0"

$$  \displaystyle E_n=\int_{0}^{1}\underbrace{\frac{x^n}{(n+1)!}}_{w(x)}\underbrace{e^{\xi (x)}}_{g(x)}dx $$    (2)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }

Using the Integral Mean Value Theorem, we have
 * {| style="width:100%" border="0"

$$  \displaystyle E_n=e^{\xi (x=\alpha)} \int_{0}^{1}\frac{x^n}{(n+1)!}dx $$    (3)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }

integrating we get,
 * {| style="width:100%" border="0"

$$  \displaystyle E_n=e^{\xi (x=\alpha)} \frac{1}{(n+1)!(n+1)} $$    (4)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }

This function has a minimum when $$\alpha=0$$ and maximum when $$\alpha=1$$ thus we have
 * {| style="width:100%" border="0"

$$  \displaystyle \frac{1}{(n+1)!(n+1)}\leq E_n\leq \frac{e}{(n+1)!(n+1)} $$    (5) Setting the upper bound of the error to $$10^{-6}$$ we have
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }
 * {| style="width:100%" border="0"

$$  \displaystyle \ E_n\leq \frac{e}{(n+1)!(n+1)}=10^{-6} $$    (6) Solving this equation for n we get
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }


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

$$  \displaystyle (n+1)!(n+1)=e*10^6 \Rightarrow n\approx 7.92 = 7 $$     (A)
 * style="width:92%; padding:10px; border:2px solid #8888aa" |
 * style="width:92%; padding:10px; border:2px solid #8888aa" |
 * 
 * }

Solution:Composite Trapezoidal rule
From the discussion on page 16-3 we have


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

$$  \displaystyle \left | E_n^1 \right |\leq \frac{(b-a)}{12n^2}M_2 $$    (1)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }

where $$M_2 = max \left | f^{(2)} (\zeta )\right |$$ for $$\zeta \varepsilon [a,b]$$

For the given function $$f(x)= \frac{e^x - 1}{x}$$, we have


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

$$  \displaystyle f^{(2)}(x)= \frac{e^x [x^2-2x+2]-2}{x^3} $$     (2)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }

Evaluating over the given interval it is seen that the function $$f^{(2)}(x)$$ has maximum value at $$x=1$$


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

$$  \displaystyle M_2= f^{(2)}(x=1)=\frac{e[1+2-2]-2}{1}=0.718282 $$    (3)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }

Setting the error to the $$10^{-6}$$ and solving for $$n$$ we get


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

$$  \displaystyle \frac{(1-0)^3}{12n^2}(0.718282)=10^{-6}\Rightarrow n\approx 244.657= 245 $$     (B)
 * style="width:92%; padding:10px; border:2px solid #8888aa" |
 * style="width:92%; padding:10px; border:2px solid #8888aa" |
 * 
 * }

Solution :Composite Simpson's Rule
We have from p 17-2, the error estimate of the Composite Simpson's rule as
 * {| style="width:100%" border="0"

$$  \displaystyle \left | E_n^2 \right |\leq \frac{(b-a)^5}{2880n^4}M_4 $$    (1)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }

where $$M_4 = max \left | f^{(4)} (\zeta )\right |$$ for $$\zeta \varepsilon [a,b]$$

For the given function $$f(x)= \frac{e^x - 1}{x}$$, we have


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

$$  \displaystyle f^{(4)}(x)= \frac{e^x [x^4-4x^3+12x^2-24x]-24}{x^5} $$     (2)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }

Evaluating over the given interval it is seen that the function $$f^{(2)}(x)$$ has maximum value at $$x=1$$
 * {| style="width:100%" border="0"

$$  \displaystyle M_4= f^{(4)}(x=1)=\frac{e[1-4+12-24+24]-24}{1}=9(e)-24=0.464536
 * style="width:95%" |
 * style="width:95%" |

$$    (3)
 * 
 * }

Setting the error to the $$10^{-6}$$ and solving for $$n$$ we get


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

$$  \displaystyle \frac{(1-0)^5}{2880n^4}(0.464536)=10^{-6}\Rightarrow n\approx 3.35735= 3 $$     (c)
 * style="width:92%; padding:10px; border:2px solid #8888aa" |
 * style="width:92%; padding:10px; border:2px solid #8888aa" |
 * 
 * }

Part 2:Numerical determination of power of h
In order to verify the power of $$\boldsymbol {h}$$ in the error, data from Problem 8 of HW1 is used.

In the case of a Semilog plot (log(y) vs x), an equation of the form

$$\boldsymbol{log(Y)=a X+b}$$

such that

$$\boldsymbol{Y= e^{(aX+b)}=e^b (e^{aX})=ke^{aX}}$$

From the above equation it is seen that if the plot on a semilog graph is a straight line then the relationship between the two variables is exponential.

A log-log plot(log(y) vs log(x)) is a similar plot, for which the equation is of the form

$$\boldsymbol{log(Y)=a [log(X)]+b}$$

such that, $$\boldsymbol{Y= kx^a;k=e^b}$$

This discussion is used in the interpretation of the graphs given below.

It is readily seen that the slope of the line in the log-log graph is the power of the x variable.

Composite trapezoidal Rule
Given below is the data from the numerical evaluation of the given function using Composite Trapezoidal Rule. First we plot a semilog graph for the data. The graph is shown below:



The graph is not a straight line which implies that the relationship between $$\boldsymbol{h}$$ and $$\boldsymbol{log(error)}$$ is not exponential. Hence we plot a log-log graph as below:



This is seen to be linear. A straight line if fitted to the data the equation of which is given above. From the discussion above, we see that the slope of line is 2.1447 which is very close to the analytical value of 2.

Composite Simpson's Rule
Given below is the data obtained from HW1 for the COmposite Simpsons Rule.

Plotting a semilog graph of $$\boldsymbol{log(error)}$$ against $$\boldsymbol{h}$$ we see that it is non-linear as in the case of the Composite Trapezoidal Rule.



Thus, plotting the log-log graph as below,



we see that the slope of the line is 4.0881 which is very close to the analytically determined value of 4.

Taylor Series
Given below is the data for the Taylor series method. Eventhough $$\boldsymbol{h}$$ is not used in the Taylor series method,defining $$\boldsymbol{h}$$ based on the number of terms of the series, it is seen that the error and h are not related exponentially or by a power relation i.e. both semilog and log log plots are not linear.



--Egm6341.s10.team2.niki 08:10, 17 February 2010 (UTC)