# University of Florida/Egm6341/s10.team3.aks/HW3

(4)Use Error estimate for Taylor series, composite trapezoidal and composite Simpsons rule

## Problem Statement

Use Error estimate for Taylor series, composite trapezoidal and composite Simpson's rule to find n such that
and compare to numerical results.

## Solution

    $I=\int _{0}^{1}{\frac {e^{x}-1}{x}}dx$
Taylor Series
    $e^{x}=\sum _{j=0}^{\infty }{\frac {x^{j}}{j!}}\Rightarrow {\frac {e^{x}-1}{x}}=\sum _{j=1}^{\infty }{\frac {x^{j-1}}{j!}}$
    $I_{n}=\int _{0}^{1}f_{n}(x)dx=\int _{0}^{1}\sum _{j=1}^{\infty }{\frac {x^{j-1}}{j!}}dx=\sum _{j=1}^{n}{\frac {x^{j}}{j!j}}|_{0}^{1}=\sum _{j=1}^{n}{\frac {1}{j!j}}$
    $f(x)-f_{n}(x)=R_{n}(x)={\frac {(x-x_{0})^{n}}{(n+1)!}}f^{(n+1)}(\xi )$ with $\xi \in [0,x]\,$ and $x_{0}=0\,$
    $\Rightarrow f(x)-f_{n}(x)={\frac {x^{n}}{(n+1)!}}f^{(n+1)}(\xi )$
    $E_{n}=I-I_{n}=\int _{0}^{1}\left[f(x)-f_{n}(x)\right]dx=\int _{0}^{1}\underbrace {\frac {x^{n}}{(n+1)!}} _{w(x)}\underbrace {f^{(n+1)}\left(\xi (x)\right)} _{g(x)}dx$
    $\Rightarrow g(\alpha )\int _{0}^{1}w(x)dx$ for $\alpha \in [0,1]$
    $E_{n}=\,$
    $\Rightarrow max={\frac {g(\alpha )}{(n+1)!(n+1)}}$, $\alpha ={\frac {e}{(n+1)!(n+1)}}\,$
    $\Rightarrow min={\frac {g(\alpha )}{(n+1)!(n+1)}}$, $\alpha ={\frac {1}{(n+1)!(n+1)}}\,$
    $n=2,E_{2}\leq .151016\,$
    $n=4,E_{5}\leq .00453\,$
    $n=6,E_{6}\leq 6.2792X10^{-4}\,$
    $n=8,E_{8}\leq 8.42X10^{-6}\,$
Below are the values from Numerical Analysis of Taylor series from HW_1
    $n=2,E_{2}\leq .151016\,$
    $n=4,E_{5}\leq .00453\,$
    $n=6,E_{6}\leq 6.2792X10^{-4}\,$
    $n=8,E_{8}\leq 8.42X10^{-6}\,$
We are getting same values from both analysis for Taylor series
Trapazoidal Rule
Error for Composite Trapazoidal rule is given by
$\displaystyle \left|E_{n}^{1}\right|\leq {\frac {(b-a)^{3}}{12n^{2}}}M_{2}$
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}}}$
For the given interval [0,1] the maximum value of function $f^{(2)}(x)$ is achieved at $x=1$
$\displaystyle M_{2}=f^{(2)}(x=1)={\frac {e[1+2-2]-2}{1}}=0.71828182$
$E_{n}^{1}\leq {\frac {(1-0)^{3}}{12n^{2}}}X0.71828182$
$E_{2}^{1}\leq .014964204$
$E_{4}^{1}\leq 3.74105X10^{-3}$
$E_{6}^{1}\leq 1.662689X10^{-3}$
$E_{8}^{1}\leq 9.3526278X10^{-4}$
$E_{16}^{1}\leq 2.3381569X10^{-4}$
$E_{32}^{1}\leq 5.845392X10^{-5}$
$E_{64}^{1}\leq 1.4613481X10^{-5}$
$E_{128}^{1}\leq 3.65337026X10^{-6}$
$E_{256}^{1}\leq 9.1334256X10^{-7}$
Below are the results from Numerical analysis from HW 1
$E_{2}^{1}\leq 0.010389576$
$E_{4}^{1}\leq 0.002602468$
$E_{8}^{1}\leq 0.650935X10^{-3}$
$E_{16}^{1}\leq 162753X10^{-4}$
$E_{32}^{1}\leq 4.06892X10^{-5}$
$E_{64}^{1}\leq 1.0172X10^{-5}$
$E_{128}^{1}\leq 2.54263X10^{-6}$
$E_{256}^{1}\leq 6.3528X10^{-7}$
We can see that we are getting order $10^{-6}$ at n=128 from both the analysis.
Composite Simpsons Rule
The error estimate of the Composite Simpson's rule is given as
$E_{n}^{2}\leq {\frac {(b-a)^{5}}{2880n^{4}}}M_{4}$
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}}}$
The function $f^{4}(x)$ has maximum value at $x=1$
$\displaystyle M_{4}={\frac {e[1-4+12-24+24]-24}{1}}=0.46453645$
$E_{n}^{1}\leq {\frac {(1-0)^{5}}{2880n^{4}}}X0.46453645$
$E_{2}^{2}\leq 1.00810X10^{-5}$
$E_{4}^{2}\leq 6.300678X10^{-7}$
Below are the results from Numerical analysis from HW 1
$E_{2}^{2}\leq 1.06514X10^{-4}$
$E_{4}^{2}\leq 6.76473X10^{-6}$
We can see that we are getting order $10^{-6}$ at n=4 from both the analysis.