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

Using the following equations find the expressions for ${\boldsymbol {c_{i}}}$ in terms of ${\boldsymbol {x_{i}}}$ and ${\boldsymbol {f(x_{i})}}$ where i=0,1,2
    $\displaystyle {\boldsymbol {f_{2}(x)=p_{2}(x)=c_{2}x^{2}+c_{1}x+c_{0}}}$ (1 p8-3)
    $\displaystyle {\boldsymbol {p_{2}(x)=\sum _{i=0}^{2}(l_{i}(x)f(x_{i}))}}$ (3 p8-3)

### Solution

We have the general formula for the Lagrange basis function ${\boldsymbol {l_{i}(x)}}$ as
    $\displaystyle {\boldsymbol {l_{i}(x)=\prod _{j=0;j\neq i}^{n}\left({\frac {x-x_{j}}{x_{i}-x_{j}}}\right)}}$ (2 p7-3)
for the case of Simple Simpson's Rule, n =2 i.e i=0,1,2. For the given interval $[a,b]$
${\boldsymbol {x_{0}=a}}$
${\boldsymbol {x_{2}=b}}$
${\boldsymbol {x_{1}={\frac {a+b}{2}}}}$
Expanding equation 3 p8-3 we get:
${\boldsymbol {p_{2}(x)=l_{0}(x)f(x_{0})+l_{1}(x)f(x_{1})+l_{2}(x)f(x_{2})}}$ where,
${\boldsymbol {l_{0}(x)=\left({\frac {x-x_{1}}{x_{0}-x_{1}}}\right)\left({\frac {x-x_{2}}{x_{0}-x_{2}}}\right)}}$;
${\boldsymbol {l_{1}(x)=\left({\frac {x-x_{0}}{x_{1}-x_{0}}}\right)\left({\frac {x-x_{2}}{x_{1}-x_{2}}}\right)}}$;
${\boldsymbol {l_{2}(x)=\left({\frac {x-x_{0}}{x_{2}-x_{0}}}\right)\left({\frac {x-x_{1}}{x_{2}-x_{1}}}\right)}}$
Thus we have the polynomial as ${\boldsymbol {p_{2}(x)=\left({\frac {x^{2}-(x_{2}+x_{1})x+(x_{1}x_{2})}{(x_{0}-x_{1})(x_{0}-x_{2}))}}\right)f(x_{0})+\left({\frac {x^{2}-(x_{2}+x_{0})x+(x_{0}x_{2})}{(x_{1}-x_{0})(x_{1}-x_{2}))}}\right)f(x_{1})+\left({\frac {x^{2}-(x_{0}+x_{1})x+(x_{1}x_{0})}{(x_{2}-x_{0})(x_{2}-x_{1}))}}\right)f(x_{2})}}$
Grouping coefficients of ${\boldsymbol {x^{2},x^{1},x^{0}}}$, ${\boldsymbol {p_{2}(x)=\left\{{\frac {f(x_{0})}{(x_{0}-x_{1})(x_{0}-x_{2})}}+{\frac {f(x_{1})}{(x_{1}-x_{0})(x_{1}-x_{2})}}+{\frac {f(x_{2})}{(x_{2}-x_{0})(x_{2}-x_{1})}}\right\}x^{2}-\left\{{\frac {f(x_{0})[x_{2}+x_{1}]}{(x_{0}-x_{1})(x_{0}-x_{2})}}+{\frac {f(x_{1})[x_{2}+x_{0}]}{(x_{1}-x_{0})(x_{1}-x_{2})}}+{\frac {f(x_{2})[x_{1}+x_{0}]}{(x_{2}-x_{0})(x_{2}-x_{1})}}\right\}x+\left\{{\frac {f(x_{0})[x_{1}x_{2}]}{(x_{0}-x_{1})(x_{0}-x_{2})}}+{\frac {f(x_{1})[x_{0}x_{2}]}{(x_{1}-x_{0})(x_{1}-x_{2})}}+{\frac {f(x_{2})[x_{0}x_{1}]}{(x_{2}-x_{0})(x_{2}-x_{1})}}\right\}}}$
Comparing this equation with eqn 1p8-3 we see that
    $\displaystyle {\boldsymbol {c_{2}=\left\{{\frac {f(x_{0})}{(x_{0}-x_{1})(x_{0}-x_{2})}}+{\frac {f(x_{1})}{(x_{1}-x_{0})(x_{1}-x_{2})}}+{\frac {f(x_{2})}{(x_{2}-x_{0})(x_{2}-x_{1})}}\right\}}}$ (1)
    $\displaystyle {\boldsymbol {c_{1}=-\left\{{\frac {f(x_{0})[x_{2}+x_{1}]}{(x_{0}-x_{1})(x_{0}-x_{2})}}+{\frac {f(x_{1})[x_{2}+x_{0}]}{(x_{1}-x_{0})(x_{1}-x_{2})}}+{\frac {f(x_{2})[x_{1}+x_{0}]}{(x_{2}-x_{0})(x_{2}-x_{1})}}\right\}}}$ (2)
    $\displaystyle {\boldsymbol {c_{0}=\left\{{\frac {f(x_{0})[x_{1}x_{2}]}{(x_{0}-x_{1})(x_{0}-x_{2})}}+{\frac {f(x_{1})[x_{0}x_{2}]}{(x_{1}-x_{0})(x_{1}-x_{2})}}+{\frac {f(x_{2})[x_{0}x_{1}]}{(x_{2}-x_{0})(x_{2}-x_{1})}}\right\}}}$ (3)

## Problem 6
### Statement

For the Lagrange Interpolation Error verify the following:
    $\displaystyle {\boldsymbol {E^{(n+1)}(x)=f^{(n+1)}(x)-0}}$ (1)

### Solution

We can write the Lagrange Interpolation error as
${\boldsymbol {E(x)=f(x)-f_{n}(x)}}$
differentiating the above expression once we get
${\boldsymbol {E^{1}(x)=f^{1}(x)-f_{n}^{1}(x)}}$
differentiating the expression (n+1) times we get
${\boldsymbol {E^{n+1}(x)=f^{n+1}(x)-f_{n}^{n+1}(x)}}$
But since ${\boldsymbol {f_{n}(x)}}$ is a polynomial of degree n the (n+1)th derivative is zero
    $\displaystyle {\boldsymbol {E^{n+1}(x)=f^{n+1}(x)-0}}$ (1)

## Problem 11:To show that Simpson's rule can be used to integrate a cubic polynomial exactly
### Statement

Given the polynomial ${\boldsymbol {f_{3}(x)=P_{3}(x)=3+8x^{1}-2x^{2}+6x^{3}}}$ where ${\boldsymbol {x\epsilon \left[0,1\right]}}$ determine the exact integral ${\boldsymbol {I}}$ and the integral using Simpson's Rule ${\boldsymbol {I_{n}}}$

### Solution
#### Case A: Determination of Exact Integral

${\boldsymbol {I=\int _{0}^{1}(3+8x-2x^{2}+6x^{3})dx}}$
${\boldsymbol {I=[3x+4x^{2}-{\frac {2}{3}}x^{3}+{\frac {3}{2}}x^{4}]_{0}^{1}}}$
${\boldsymbol {I=3+4-{\frac {2}{3}}+1.5}}$
    $\displaystyle {\boldsymbol {I=7.833}}$ (1)

#### Case B: Using Simple Simpson's rule

We have the Simple Simpson's rule as
    $\displaystyle {\boldsymbol {I_{2}={\frac {h}{3}}\left\{f(x_{0})+4f(x_{1})+f(x_{2})\right\}}}$ (2 p7-2)
where ${\boldsymbol {h={\frac {a+b}{2}}={\frac {0+1}{2}}=0.5}}$
${\boldsymbol {I_{2}={\frac {0.5}{3}}\left\{f(0)+4f(0.5)+f(1)\right\}}}$ we know ${\boldsymbol {f(0)=3;f(0.5)=7.25;f(1)=15}}$ substituting we get
${\boldsymbol {I_{2}={\frac {0.5}{3}}\left\{3+4(7.25)+15\right\}={\frac {0.5}{3}}\left\{47\right\}}}$
    $\displaystyle {\boldsymbol {I_{2}=7.833}}$ (2)