# University of Florida/Egm6341/s10.team2.niki/HW3
#### Problem Statement

Pg. 17-2
See also HW1-problem 8 Using the error estimates of
* Taylor Series
* Composite Trapezoidal rule
* Composite Simpson's rule
estimate ${\boldsymbol {n}}$ such that ${\boldsymbol {E_{n}=I-I_{n}=O(10^{-6})}}$

#### Problem Solution
##### Solution: Taylor series

Error is defined as
    $\displaystyle E_{n}=I-I_{n}=\int _{a}^{b}[f(x)-f_{n}(x)]dx$
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
    $\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)
For the given function the error is
    $\displaystyle E_{n}=\int _{0}^{1}\underbrace {\frac {x^{n}}{(n+1)!}} _{w(x)}\underbrace {e^{\xi (x)}} _{g(x)}dx$ (2)
Using the Integral Mean Value Theorem, we have
    $\displaystyle E_{n}=e^{\xi (x=\alpha )}\int _{0}^{1}{\frac {x^{n}}{(n+1)!}}dx$ (3)
integrating we get,
    $\displaystyle E_{n}=e^{\xi (x=\alpha )}{\frac {1}{(n+1)!(n+1)}}$ (4)
This function has a minimum when $\alpha =0$ and maximum when $\alpha =1$ thus we have
    $\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
    $\displaystyle \ E_{n}\leq {\frac {e}{(n+1)!(n+1)}}=10^{-6}$ (6)
Solving this equation for n we get
    $\displaystyle (n+1)!(n+1)=e*10^{6}\Rightarrow n\approx 7.92=7$ (A)

##### Solution:Composite Trapezoidal rule

From the discussion on page 16-3 we have
    $\displaystyle \left|E_{n}^{1}\right|\leq {\frac {(b-a)}{12n^{2}}}M_{2}$ (1)
For the given function $f(x)={\frac {e^{x}-1}{x}}$, we have
    $\displaystyle f^{(2)}(x)={\frac {e^{x}[x^{2}-2x+2]-2}{x^{3}}}$ (2)
Evaluating over the given interval it is seen that the function $f^{(2)}(x)$ has maximum value at $x=1$
    $\displaystyle M_{2}=f^{(2)}(x=1)={\frac {e[1+2-2]-2}{1}}=0.718282$ (3)
Setting the error to the $10^{-6}$ and solving for $n$ we get
    $\displaystyle {\frac {(1-0)^{3}}{12n^{2}}}(0.718282)=10^{-6}\Rightarrow n\approx 244.657=245$ (B)

##### Solution :Composite Simpson's Rule

We have from p 17-2, the error estimate of the Composite Simpson's rule as
    $\displaystyle \left|E_{n}^{2}\right|\leq {\frac {(b-a)^{5}}{2880n^{4}}}M_{4}$ (1)
For the given function $f(x)={\frac {e^{x}-1}{x}}$, we have
    $\displaystyle f^{(4)}(x)={\frac {e^{x}[x^{4}-4x^{3}+12x^{2}-24x]-24}{x^{5}}}$ (2)
Evaluating over the given interval it is seen that the function $f^{(2)}(x)$ has maximum value at $x=1$
    $\displaystyle M_{4}=f^{(4)}(x=1)={\frac {e[1-4+12-24+24]-24}{1}}=9(e)-24=0.464536$ (3)
Setting the error to the $10^{-6}$ and solving for $n$ we get
    $\displaystyle {\frac {(1-0)^{5}}{2880n^{4}}}(0.464536)=10^{-6}\Rightarrow n\approx 3.35735=3$ (c)

### 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
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
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)