# University of Florida/Egm6341/s10.Team2/HW5

### Problem 1: Determination of leading coefficients of polynomials

#### Statement

To show that the value of the constants ${\displaystyle \;c_{6}=0}$ and ${\displaystyle c_{5}={\frac {-7}{360}}}$ in the polynomials ${\displaystyle P_{4}\left(t\right)}$ and ${\displaystyle P_{5}\left(t\right)}$

#### Solution

From page 26-2, we know that:

${\displaystyle P_{5}\left(t\right)={\frac {-t^{5}}{120}}+{\frac {t^{3}}{36}}+C_{5}t+C_{6}}$

We select ${\displaystyle \;P_{5}\left(t\right)}$ such that it is a odd function and ${\displaystyle \;P_{5}\left(1\right)=P_{5}\left(-1\right)=P_{5}\left(0\right)=0}$

Therefore, using ${\displaystyle P_{5}\left(0\right)=0}$, we get:

${\displaystyle P_{5}\left(0\right)={\frac {-0^{5}}{120}}+{\frac {0^{3}}{36}}+C_{5}*0+C_{6}=0}$

 ${\displaystyle \displaystyle {\boldsymbol {\therefore }}\;C_{6}=0}$ (1)

Similarly, using ${\displaystyle \;P_{5}\left(1\right)=0}$, we get:

${\displaystyle P_{5}\left(1\right)={\frac {-1^{5}}{120}}+{\frac {1^{3}}{36}}+C_{5}*1+C_{6}={\frac {-1}{120}}+{\frac {1}{36}}+C_{5}=0}$

 ${\displaystyle \displaystyle {\boldsymbol {\therefore }}\;C_{5}={\frac {1}{120}}-{\frac {1}{36}}=-{\frac {7}{360}}}$ (2)

#### Author

Egm6341.s10.team2.lee 08:58, 24 March 2010 (UTC)

proofread --Egm6341.s10.team2.niki 14:53, 24 March 2010 (UTC)

### Problem 2: Continuation of proof of trapezoidal error

#### Statement

Continue the proof of Trapezoidal Rule Error to steps 4a and 4b and determine ${\displaystyle {\boldsymbol {P_{6}(t)}}}$ and ${\displaystyle {\boldsymbol {P_{7}(t)}}}$

#### Solution

From steps 3a and 3b( P.26-3) we get the expression

 ${\displaystyle \displaystyle {\boldsymbol {E=[P_{2}(t)g^{(1)}(t)+P_{4}(t)g^{(3)}(t)]_{-1}^{+1}-\underbrace {\int _{-1}^{+1}P_{5}(t)g^{(5)}(t)dt} _{D}}}}$ (P.26-3)
 ${\displaystyle \displaystyle P_{4}(t)={\frac {-t^{4}}{24}}+{\frac {t^{2}}{12}}-{\frac {7}{360}}=c_{1}({\frac {t^{4}}{4!}})+c_{3}({\frac {t^{2}}{2!}})+c_{5}}$ ${\displaystyle P_{5}(t)={\frac {-t^{5}}{120}}+{\frac {t^{3}}{36}}-{\frac {7t}{360}}=c_{1}({\frac {t^{5}}{5!}})+c_{3}({\frac {t^{3}}{3!}})+c_{5}(t)}$ (P.26-3)
##### Step 4a
 ${\displaystyle \displaystyle \int _{-1}^{+1}\underbrace {P_{5}(t)} _{v'}\underbrace {g^{(5)}(t)} _{u}dt=[g^{(5)}(t)P_{6}(t)]_{-1}^{+1}-\underbrace {\int _{-1}^{+1}[{P_{6}(t)g^{(6)}(t)}} _{E}]dt}$

where, ${\displaystyle P_{6}(t)=\int P_{5}(t)=c_{1}({\frac {t^{6}}{6!}})+c_{3}({\frac {t^{4}}{4!}})+c_{5}({\frac {t^{2}}{2!}})+c_{7}}$

${\displaystyle P_{6}(t)={\frac {-t^{6}}{720}}+{\frac {t^{4}}{144}}-{\frac {7t^{2}}{720}}+\alpha }$
##### Step 4b
 ${\displaystyle \displaystyle \int _{-1}^{+1}[{\underbrace {P_{6}(t)} _{v'}\underbrace {g^{(6)}(t)} _{u}}]dt=E=[g^{(6)}(t)P_{7}(t)]_{-1}^{+1}-\int _{-1}^{+1}P_{7}(t)g^{(7)}(t)dt}$

where, ${\displaystyle P_{7}(t)=\int P_{6}(t)==c_{1}({\frac {t^{7}}{7!}})+c_{3}({\frac {t^{5}}{5!}})+c_{5}({\frac {t^{3}}{3!}})+c_{7}(t)+c_{8}}$

${\displaystyle P_{7}(t)={\frac {-t^{7}}{5040}}+{\frac {t^{5}}{720}}-{\frac {7t^{3}}{2160}}+\alpha t+\beta }$

Selecting ${\displaystyle \displaystyle {P_{7}(t)}}$ such that

${\displaystyle \displaystyle {P_{7}(+1)=P_{7}(-1)=P_{7}(0)=0}}$ ,we get

${\displaystyle \displaystyle {P_{7}(t=0)=0\Rightarrow \beta =c_{8}=0}}$

${\displaystyle P(-1)=0=-{\frac {(-1)^{7}}{7!}}+{\frac {1}{6}}({\frac {(-1)^{5}}{5!}})-{\frac {7}{360}}({\frac {(-1)^{3}}{3!}})-\alpha \Rightarrow \alpha =c_{7}={\frac {31}{15120}}}$

##### Summary
 ${\displaystyle \displaystyle P_{6}(t)={\frac {-t^{6}}{720}}+{\frac {t^{4}}{144}}-{\frac {7t^{2}}{720}}+{\frac {31}{15120}}}$ ${\displaystyle P_{7}(t)=\int P_{6}(t)={\frac {-t^{7}}{5040}}+{\frac {t^{5}}{720}}-{\frac {7t^{3}}{2160}}+{\frac {31}{15120}}t}$

#### Author

--Egm6341.s10.team2.niki 22:04, 23 March 2010 (UTC)

--Proofread by Egm6341.s10.team2.lee 10:14, 26 March 2010 (UTC)

### Problem 3: Expression of ${\displaystyle \;t_{k}}$ as function of ${\displaystyle \;x}$

#### Statement

find ${\displaystyle \;t_{k}(x)}$ on P. 27-1

#### Solution

From Page 27-1, we know:

${\displaystyle x\left(t_{k}\right)={\frac {1}{2}}\left(x_{k}+x_{k+1}\right)+t_{k}{\frac {h}{2}}}$

Now rearranging the terms on both sides to write ${\displaystyle \;t_{k}}$ in terms of ${\displaystyle \;x}$, we get:

${\displaystyle t_{k}\left(x\right)={\frac {2x-\left(x_{k}+x_{k+1}\right)}{h}}}$ ${\displaystyle \;\;}$ where the size of the interval, ${\displaystyle \;h=x_{k+1}-x_{k}}$

It can also be easily verified by substituting ${\displaystyle \;x=x_{k}}$ which yields ${\displaystyle t_{k}\left(x=x_{k}\right)={\frac {x_{k}-x_{k+1}}{x_{k+1}-x_{k}}}=-1}$

Also when ${\displaystyle \;x=x_{k+1}}$ yields ${\displaystyle t_{k}\left(x=x_{k+1}\right)={\frac {x_{k+1}-x_{k}}{x_{k+1}-x_{k}}}=1}$

### Problem 4: Evaluation of ${\displaystyle d_{1},d_{2}\;and\;d_{3}}$ which can be used to calculate the coefficients of the even power euler-maclaurin error series for trapezoidal rule

#### Statement

Find the values of ${\displaystyle d_{1}={\bar {d_{2}}},d_{2}={\bar {d_{4}}}}$ and ${\displaystyle d_{3}={\bar {d_{6}}}}$

Clue: Use the formula: ${\displaystyle d_{i}={\bar {d_{2i}}}={\frac {P_{2i}\left(1\right)}{2^{2i}}}}$

#### Solution

We know from the formula:

${\displaystyle d_{i}={\bar {d_{2i}}}={\frac {P_{2i}\left(1\right)}{2^{2i}}}}$

From Mtg 26,slide 26-1, we know the formula:

${\displaystyle P_{2}\left(t\right)={\frac {-t^{2}}{2!}}+{\frac {1}{6}}}$

${\displaystyle P_{2}\left(1\right)={\frac {-1^{2}}{2!}}+{\frac {1}{6}}}$

 ${\displaystyle d_{1}={\bar {d_{2}}}={\frac {P_{2}\left(1\right)}{2^{2}}}={\frac {\frac {-1}{3}}{4}}={\frac {-1}{12}}}$ (1)

From Mtg 26,slide 26-3, we know the formula:

${\displaystyle P_{4}\left(t\right)={\frac {-t^{4}}{24}}+{\frac {t^{2}}{12}}-{\frac {7}{360}}}$

${\displaystyle P_{4}\left(1\right)={\frac {-1^{4}}{24}}+{\frac {1^{2}}{12}}-{\frac {7}{360}}={\frac {1}{45}}}$

 ${\displaystyle d_{2}={\bar {d_{4}}}={\frac {P_{4}\left(1\right)}{2^{4}}}={\frac {\frac {1}{45}}{16}}={\frac {1}{720}}}$ (2)

From problem 2 on this HW , where we deduced that:

${\displaystyle P_{6}(t)={\frac {-t^{6}}{720}}+{\frac {t^{4}}{144}}-{\frac {7t^{2}}{720}}+{\frac {31}{15120}}}$

${\displaystyle P_{6}(1)={\frac {-1^{6}}{720}}+{\frac {1^{4}}{144}}-{\frac {7*1^{2}}{720}}+{\frac {31}{15120}}={\frac {-2}{945}}}$

 ${\displaystyle d_{3}={\bar {d_{6}}}={\frac {P_{6}\left(1\right)}{2^{6}}}={\frac {\frac {-2}{945}}{64}}={\frac {-1}{30240}}}$ (3)

### Problem 5: Derivation of the Error of the Trapezoidal Rule

#### Statement

P. 28-2 derive

Derive the Following Equation for the error of the trapezoidal rule:

${\displaystyle E_{n}^{1}=I-T_{0}(n)=\sum _{r=1}^{l}h^{2r}{\tilde {d}}_{2r}\left[f^{2r-1}(b)-f^{2r-1}(a)\right]-{\frac {h^{2l}}{2^{2l}}}\sum _{k=0}^{n-1}\int _{x_{k}}^{x_{k+1}}P_{2}l(t_{k}(x))f^{2l}(x)dx}$

#### Solution

The Following Equation is to be derived:

${\displaystyle E_{n}^{1}=I-T_{0}(n)=\sum _{r=1}^{l}h^{2r}{\tilde {d}}_{2r}\left[f^{2r-1}(b)-f^{2r-1}(a)\right]-{\frac {h^{2l}}{2^{2l}}}\sum _{k=0}^{n-1}\int _{x_{k}}^{x_{k+1}}P_{2}l(t_{k}(x))f^{2l}(x)dx}$

${\displaystyle E=\int _{-1}^{+1}P_{1}(t)g^{1}(t)dt=\underbrace {{\frac {h}{2}}\left[P_{2}g^{1}+P_{4}g^{3}+...+P_{2l}g^{2l-1}\right]_{-1}^{+1}} _{A}-\underbrace {\int _{-1}^{+1}P_{2l}(t)g^{2l}(t)dt} _{B}}$

Since ${\displaystyle P_{2}}$ is an even function then:

${\displaystyle \left[P_{2}(t)g^{1}(t)\right]_{-1}^{+1}=P_{2}(+1)\left[g^{1}(+1)-g^{1}(-1)\right]}$

With this property then A can be rewritten as follows:

${\displaystyle \sum _{i}^{l}P_{2r}(+1)\left[g^{2r-1}(+1)-g^{2r-1}(-1)\right]}$

A transformation of variable is needed from 't' to 'x' and is as follows:

${\displaystyle g_{k}^{i}(t)=({\frac {h}{2}})^{i}f^{i}(x(t))\quad \quad x\epsilon [x_{k},x_{k+1}]}$

With this transformation A can be rewritten as follows:

${\displaystyle {\frac {h}{2}}\sum _{i=1}^{l}P_{2r}(+1)({\frac {h}{2}})^{2r-1}\left[f^{2r-1}(b)-f^{2r-1}(a)\right]}$

The Following is then defined:

${\displaystyle {\tilde {d}}_{2r}={\frac {P_{2r}(+1)}{2^{2r}}}}$ as discussed in [28-2] of the lectures.

A is then rewritten as follows:

${\displaystyle {\frac {h}{2}}\sum _{i=1}^{l}{\tilde {d}}_{2r}2^{2r}\left({\frac {h}{2}}\right)^{2r-1}\left[f^{2r-1}(b)-f^{2r-1}(a)\right]}$

${\displaystyle {\frac {h}{2}}\sum _{i=1}^{l}{\tilde {d}}_{2r}2h^{2r-1}\left[f^{2r-1}(b)-f^{2r-1}(a)\right]}$

${\displaystyle \sum _{i=1}^{l}{\tilde {d}}_{2r}h^{2r}\left[f^{2r-1}(b)-f^{2r-1}(a)\right]}$

The Next Step is to simplify the term 'B'

${\displaystyle B=\int {-1}^{+1}P_{2l}(t)g^{2l}(t)dt}$

Using the previously mentioned transformation of variable the following can be stated:

${\displaystyle \int _{-1}^{+1}P_{2l}(t)\left({\frac {h}{2}}\right)^{2l}f^{2l}(x(t))dt}$

With the previously performed simplifications the following is written:

${\displaystyle E_{n}^{1}=A-B=\sum _{i=1}^{l}{\tilde {d}}_{2r}h^{2r}\left[f^{2r-1}(b)-f^{2r-1}(a)\right]-{\frac {h^{2l}}{2^{2l}}}\int _{-1}^{+1}P_{2l}(t)\left({\frac {h}{2}}\right)^{2l}f^{2l}(x(t))dt}$

This is recognized as the Error for the trapezoidal rule.

#### Author

--Egm6341.s10.Team2.GV 22:09, 25 March 2010 (UTC)

--Proofread by Egm6341.s10.team2.lee 10:13, 26 March 2010 (UTC)

### Problem 6: Derivation of ${\displaystyle {\bar {d}}}$ terms using Taylor expansion of the hyperbolic function

#### Statement

P. 28-2 bernoulli nos

#### Author

Egm6341.s10.team2.lee 10:12, 26 March 2010 (UTC)

### Problem 7: Understanding the derivation of the proof of Trapezoidal Error

#### Statement

Redo steps in the proof of the Trapezoidal Rule error by trying to cancel terms with odd order derivatives of "g"

#### Solution

We begin with equation (5) on P. 21-1 which is the result of transformation of variables on equation (1) P. 21-1

(Prob 4 HW4) (P. 21-1)

 ${\displaystyle \displaystyle E_{n}^{1}={\frac {h}{2}}\sum _{k=0}^{n-1}[\int _{-1}^{1}g_{k}(t)dt-[g_{k}(-1)+g_{k}({+1})]]}$

From Prob 5 HW4, we can express the above equation as:

 ${\displaystyle \displaystyle E_{n}^{1}={\frac {h}{2}}\sum _{k=0}^{n-1}[\int _{-1}^{+1}(-t)g^{(1)}(t)dt]}$ (1)

Integrating the term withing the square brackets by "Integration by parts" Prob 7 HW4 we can rewrite (1) as follows

 ${\displaystyle \displaystyle E_{n}^{1}={\frac {h}{2}}\sum _{k=0}^{n-1}[[P_{2}(t)g^{(1)}(t)]_{-1}^{+1}-\int _{-1}^{+1}P_{2}(t)g^{(2)}(t)dt]}$ (2)

In order to eliminate terms with even powers of ${\displaystyle \displaystyle {h}}$ we need to remove terms with odd derivatives of ${\displaystyle \displaystyle {g(t)}}$.Therefore, the boundary term in eqn (2) above must be set to zero by selection of ${\displaystyle \displaystyle {P_{2}(t)}}$.

We have ${\displaystyle \displaystyle {P_{2}(t)}}$ from eqns (1 and 2)P. 21-3

 ${\displaystyle \displaystyle P_{2}(t)=c_{1}({\frac {t^{2}}{2!}})+c_{3}}$ (1)p21-3
 ${\displaystyle \displaystyle c_{2}=0}$ (2)p21-3

Setting ${\displaystyle \displaystyle {P_{2}(-1)=0}}$ gives ${\displaystyle \displaystyle {c_{3}=1/2}}$ and hence we get

 ${\displaystyle \displaystyle P_{2}(t)=c_{1}({\frac {t^{2}}{2!}})+c_{3}}$ (3)

So following this method, the next term to be eliminated will have P4(t)

 ${\displaystyle \displaystyle P_{4}(t)=c_{1}({\frac {t^{4}}{4!}})+c_{3}({\frac {t^{2}}{2!}})+c_{4}(t)+c_{5}}$ (4)

Setting ${\displaystyle \displaystyle {P_{4}(-1)=0andP_{4}(1)=0}}$ and solving we get ${\displaystyle \displaystyle {c_{4}=0andc_{4}=-5/24}}$.Continuing on these lines we get the eqn (2) in the form

 ${\displaystyle \displaystyle E_{n}^{1}={\frac {h}{2}}\sum _{k=0}^{n-1}{[P_{2}g^{(1)}]_{-1}^{+1}-[P_{3}g^{(2)}]_{-1}^{+1}}+[P_{4}g^{(3)}]_{-1}^{+1}-[P_{5}g^{(4)}]_{-1}^{+1}+[P_{6}g^{(5)}]_{-1}^{+1}-[P_{7}g^{(6)}]_{-1}^{+1}-\int _{-1}^{+1}P_{7}g^{(7)}dt}$ (5)

Dropping all the terms with odd order derivatives of ${\displaystyle g(t)}$ we get

 ${\displaystyle \displaystyle E_{n}^{1}={\frac {h}{2}}\sum _{k=0}^{n-1}{-[P_{3}g^{(2)}]_{-1}^{+1}}+-[P_{5}g^{(4)}]_{-1}^{+1}+-[P_{7}g^{(6)}]_{-1}^{+1}-\int _{-1}^{+1}P_{7}g^{(7)}dt}$ (6)

In general on integrating "m" times we get:

 ${\displaystyle \displaystyle E_{n}^{1}={\frac {h}{2}}\sum _{k=0}^{n-1}(\sum _{i=1}^{m}-[P_{(2i+1)}g^{(2i)}]_{-1}^{+1})-\int _{-1}^{+1}P_{(2m+1)}g^{(2m+1)}dt}$ (7)

manipulating the terms yields,

 ${\displaystyle \displaystyle E_{n}^{1}={\frac {h}{2}}\sum _{k=0}^{n-1}[\sum _{i=1}^{m}-[(P_{(2i+1)}(+1)g^{(2i)}(+1))-(P_{(2i+1)}(-1)g^{(2i)}(-1))]-\int _{-1}^{+1}P_{(2m+1)}g^{(2m+1)}dt}$ (8)

Transforming g(t) back to f(x) we get [see [prob 6 HW4]

 ${\displaystyle \displaystyle E_{n}^{1}=\sum _{i=1}^{m}({\frac {h}{2}})^{2i+1}\sum _{k=0}^{n-1}[(P_{(2i+1)}(-1)(f^{(2i)}(x_{k}))-(P_{(2i+1)}(+1)f^{(2i)}(x_{k+1}))]-({\frac {h}{2}})^{2m+1}\sum _{k=0}^{n-1}(\int _{x_{k}}^{x_{k+1}}P_{(2m+1)}(x)f^{(2m+1)}(x))dx)}$ (9)

Since the polynomial is odd, it can be extracted out to give the eqn in the form

 ${\displaystyle \displaystyle E_{n}^{1}=\sum _{i=1}^{m}({\frac {h}{2}})^{2i+1}P_{(2i+1)}(-1)\left[\sum _{k=0}^{n-1}[(f^{(2i)}(x_{k})+f^{(2i)}(x_{k+1})]\right]-({\frac {h}{2}})^{2m+2}\sum _{k=0}^{n-1}(\int _{x_{k}}^{x_{k+1}}P_{(2m+1)}(x)f^{(2m+1)}(x))dx)}$ (9)

The problem with this formula is evident at first sight, from this expression.The HO derivatives add up in the first term of the expression and since they will not cancel out (9) cannot be reduced to a simpler form. To see the difference in the two approaches more clearly we compare the equations from the two methods. From (1) P. 27-1 we have

 ${\displaystyle \displaystyle E_{n}^{1}=\sum _{r=1}^{l}h^{2r}d_{2r}[f^{(2r-1)}(b)-f^{(2r-1)}(a)]-{\frac {h^{(2l)}}{2^{(2l)}}}\sum _{k=0}^{n-1}\int _{x_{k}}^{x_{k+1}}P_{2l}(t_{k}(x))f^{(2l)}(x)dx}$ (10)
 ${\displaystyle \displaystyle E_{n}^{1}=\sum _{i=1}^{m}({\frac {h}{2}})^{2i+1}P_{(2i+1)}(-1)\left[\sum _{k=0}^{n-1}[(f^{(2i)}(x_{k})+f^{(2i)}(x_{k+1})]\right]-({\frac {h}{2}})^{2m+2}\sum _{k=0}^{n-1}(\int _{x_{k}}^{x_{k+1}}P_{(2m+1)}(x)f^{(2m+1)}(x))dx)}$ (9)

Comparing the eqns 9 and 10 we see that the first term on 9 has a summation of HO derivatives at different points in the square brackets as opposed to 10 which has the difference of the higher order derivative at only the end points. In this lies the difference of the two methods. 10 is general and easier to apply as we need to evaluate the differential of F(x) at only the end points while 9 is computationally cumbersome since it needs the derivative evaluated at all points.

#### Author

--Egm6341.s10.team2.niki 14:52, 24 March 2010 (UTC)

### Problem 8: Calculating the coefficients ${\displaystyle C_{3},C_{5}\;and\;C_{7}}$ and the pairs of polynomials ${\displaystyle \left(P_{2},P_{3}\right),\;\left(P_{4},P_{5}\right),\;\left(P_{6},P_{7}\right)}$ using the Recurrence formula

#### Statement

Use the recurrence formula on P.29-2 to obtain the coefficients and expressions of the pairs of polynomials ${\displaystyle \left(P_{2},P_{3}\right),\;\left(P_{4},P_{5}\right),\;\left(P_{6},P_{7}\right)}$

#### Solution

We know the recurrence formulae:

${\displaystyle P_{2i}(t)=\sum _{j=0}^{i}C_{2j+1}\;{\frac {t^{2(i-j)}}{[2(i-j)]!}}}$

${\displaystyle P_{2i+1}(t)=\int P_{2i}(t)}$

${\displaystyle P_{2i+1}(t)=\sum _{j=0}^{i}C_{2j+1}\;{\frac {t^{2(i-j)+1}}{[2(i-j)+1]!}}+C_{2i+2}}$

Since all the ${\displaystyle \;P_{2i+1}(t)}$ polynomials are odd functions and are set to zero at +1 and -1, we have:

${\displaystyle P_{2i+1}(1)=\sum _{j=0}^{i}C_{2j+1}\;{\frac {1}{[2(i-j)+1]!}}=0}$

${\displaystyle \sum _{j=0}^{1}C_{2j+1}\;{\frac {1}{[2(1-j)+1]!}}=0\Rightarrow {\frac {C_{1}}{3!}}+{\frac {C_{3}}{1!}}=0\;\Rightarrow {\frac {C_{3}}{1!}}=-{\frac {C_{1}}{3!}}=-{\frac {(-1)}{3!}}={\frac {1}{6}}}$

similarly,

${\displaystyle \sum _{j=0}^{2}C_{2j+1}\;{\frac {1}{[2(2-j)+1]!}}=0\Rightarrow {\frac {C_{1}}{5!}}+{\frac {C_{3}}{3!}}+{\frac {C_{5}}{1!}}=0\;\Rightarrow {\frac {C_{5}}{1!}}=-{\frac {C_{1}}{5!}}-{\frac {C_{3}}{3!}}=-{\frac {(-1)}{5!}}-{\frac {\frac {1}{6}}{3!}}={\frac {-7}{360}}}$

${\displaystyle \sum _{j=0}^{3}C_{2j+1}\;{\frac {1}{[2(3-j)+1]!}}=0\Rightarrow {\frac {C_{1}}{7!}}+{\frac {C_{3}}{5!}}+{\frac {C_{5}}{3!}}+{\frac {C_{7}}{1!}}=0\;\Rightarrow {\frac {C_{7}}{1!}}=-{\frac {C_{1}}{7!}}-{\frac {C_{3}}{5!}}-{\frac {C_{5}}{3!}}=-{\frac {(-1)}{7!}}-{\frac {\frac {1}{6}}{5!}}-{\frac {\frac {-7}{360}}{3!}}={\frac {31}{15120}}}$

Now evaluating the polynomials using the coefficients:

${\displaystyle P_{2}(t)=\sum _{j=0}^{1}C_{2j+1}\;{\frac {t^{2(1-j)}}{[2(1-j)]!}}=C_{1}{\frac {t^{2}}{2!}}+C_{3}=-{\frac {t^{2}}{2}}+{\frac {1}{6}}}$

${\displaystyle P_{3}(t)=\sum _{j=0}^{1}C_{2j+1}\;{\frac {t^{[2(1-j)+1]}}{[2(1-j)+1]!}}=C_{1}{\frac {t^{3}}{3!}}+C_{3}{\frac {t^{1}}{1!}}=-{\frac {t^{3}}{6}}+{\frac {t}{6}}}$

Similarly,

${\displaystyle P_{4}(t)=\sum _{j=0}^{2}C_{2j+1}\;{\frac {t^{2(2-j)}}{[2(2-j)]!}}=C_{1}{\frac {t^{4}}{4!}}+C_{3}{\frac {t^{2}}{2!}}+C_{5}{\frac {t^{0}}{0!}}=-{\frac {t^{4}}{24}}+{\frac {t^{2}}{12}}-{\frac {7}{360}}}$

${\displaystyle P_{5}(t)=\sum _{j=0}^{2}C_{2j+1}\;{\frac {t^{[2(2-j)+1]}}{[2(2-j)+1]!}}=C_{1}{\frac {t^{5}}{5!}}+C_{3}{\frac {t^{3}}{3!}}+C_{5}{\frac {t^{1}}{1!}}=-{\frac {t^{5}}{120}}+{\frac {t^{3}}{36}}-{\frac {7t}{360}}}$

${\displaystyle P_{6}(t)=\sum _{j=0}^{3}C_{2j+1}\;{\frac {t^{2(3-j)}}{[2(3-j)]!}}=C_{1}{\frac {t^{6}}{6!}}+C_{3}{\frac {t^{4}}{4!}}+C_{5}{\frac {t^{2}}{2!}}+C_{7}=-{\frac {t^{6}}{720}}+{\frac {t^{4}}{144}}-{\frac {7t^{2}}{720}}+{\frac {31}{15120}}}$

${\displaystyle P_{7}(t)=\sum _{j=0}^{3}C_{2j+1}\;{\frac {t^{[2(3-j)+1]}}{[2(3-j)+1]!}}=C_{1}{\frac {t^{7}}{7!}}+C_{3}{\frac {t^{5}}{5!}}+C_{5}{\frac {t^{3}}{3!}}+C_{7}{\frac {t^{1}}{1!}}=-{\frac {t^{7}}{5040}}+{\frac {t^{5}}{720}}-{\frac {7t^{3}}{2160}}+{\frac {31t}{15120}}}$

### Problem 9: Understanding the Matlab code on Kessler paper

#### Statement

To write a explanatory commentary on kessler's Matlab code for the evaluation of polynomials and their coefficients in the Trapezoidal error P. 30-2

#### Solution

Matlab code

function [c,p]= traperror(n)
%compute the coefficients p_2, p_4, ... , p_{2n} associated with the
%trapezoidal rule error expansion. Also compute c_1, c_3, ...

f=1; g=2; %defining variables 'f,g,cn and cd'
cn=-1; cd=1;

for k=1:n %beginning of 'for' loop with 'n' as the input value of 'traperror' function

f=f.*g.*(g+1); %reassigning the value of f by using element-wise multiplication of matrix f,g

[newcn,newcd]=fracsum(-1*cn,cd.*f); %calling the function 'fracsum' and passing the arguments n=-1*cn and d=cd.*f to the function fracsum(n,d).
%The function fracsum returns the values [nsum,dsum] which are stored in [newcn,newcd]

cn=[cn;newcn]; cd=[cd;newcd]; % the 'cn' (numerator of the coefficient)  and 'cd' (denominator of the coefficient) values are reassigned in
%the execution of the For loop. In each iteration of the for loop, the new values of 'cn' and 'cd' matrices are incremented by one additional
%column element 'newcn' and 'newcd' respectively

f=[f;1]; %the 'f' matrix is incremented by an additional column element=1, in each iteration of the for loop

g=[2+g(1);g]; % the 'g' matrix is incremented by an additional column element=even number, in each iteration of the for loop

[newpn,newpd]=fracsum((g-1).*cn,f.*cd);%calling the function 'fracsum' and passing the arguments n=(g-1).*cn and d=f.*cd to the function fracsum(n,d).
%The function fracsum returns the values [nsum,dsum] which are stored in [newpn,newpd]

pn(k,1)=newpn; % each numerator element of the polynomial function is stored in a column matrix with 'k' rows

pd(k,1)=newpd;  % each denominator element of the polynomial function is stored in a column matrix with 'k' rows

end % end of for loop to check and see if k=n?

c=int64([cn cd]); % converts the numerator and denominator of the coefficient to signed 64-bit integers

p=int64([pn pd]); % converts the numerator and denominator of the polynomial function to signed 64-bit integers

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function [nsum,dsum]= fracsum(n,d) %the arguments 'n' and 'd' are passed to this function and the output of this function are 'nsum' and 'dsum'

div=gcd(round(n),round(d)); %'round' is a matlab function to rounding off the fraction to the nearest integer and 'gcd' is a matlab function that
%returns the greatest common divisor of round(n) and round(d). This value of gcd is stored in a variable 'div'

n=round(n./div); % 'n' matrix is reassigned by carrying out element wise division with 'div' and then rounding off

d=round(d./div); % 'd' matrix is reassigned by carrying out element wise division with 'div' and then rounding off

dsum=1; % a new variable 'dsum' is initially assigned a value of 1

for k=1:length(d) % a new 'for' loop is started

dsum=lcm(dsum,d(k)); %'lcm' is a matlab function that returns the lowest common multiple of the values in the parentheses and in this case dsum and d(k)

end % end of for loop to check and see if k=length(d)?

nsum=dsum*sum(n./d); %'nsum' variable is defined by carrying out the arithemetic operation between 'dsum' and sum(n./d)

div=gcd(round(nsum),round(dsum)); %'div' is reassigned a different value which is the GCD of rounded values of 'nsum' and 'dsum'

nsum=nsum/div; %'nsum' is redefined

### Problem 10: Calculating the Circumference of an ellipse

#### Statement

An Ellipse as given:

${\displaystyle r(\theta )={\frac {a(1-e^{2})}{1-e\cos(\theta )}}}$

where:

${\displaystyle eccentricity=e=\sin({\frac {\pi }{12}})}$

${\displaystyle a=1}$

Calculate the Circumference of the elipse as follows:

Method 1:

${\displaystyle C=\int _{0}^{2\pi }\left[r^{2}+({\frac {dr}{d\theta }})^{2}\right]^{\frac {1}{2}}}$

Method 2:

${\displaystyle C=4aE(e^{2})}$

${\displaystyle E(e^{2})=\int _{0}^{\frac {\pi }{2}}\left[1-e^{2}\sin(\theta )\right]^{\frac {1}{2}}d\theta }$

##### Method 1

The Circumference will be calculated by using the following:

${\displaystyle C=\int _{0}^{2\pi }\left[r^{2}+({\frac {dr}{d\theta }})^{2}\right]^{\frac {1}{2}}}$

And then integrated numerically using 3 methods:

- Composite Trapezoidal
- Clencurt
- Romberg Table

The approximation for the exact integral was calculated using the "quad" Matlab command. It was approximated to be 6.176517851674653

###### Composite Trapezoidal
 Composite Trapezoidal Rule n Value Error 2 6.283099768855828 0.106581917181175 4 6.169238034994176 0.007279816680477 8 6.176493841410109 2.401026454457167e-005 16 6.176517900218237 4.854358426342742e-008

Matlab code for composite Trapezoidal calculation

%Calculates the Integral using the Composite Trapezoidal Rule
function [I,E]=circompos(a,b,n)

h=(b-a)/n;
pi2=2*pi();
i=0;
Itot=0;
It=0;
It2=0;
%Function elarc calculates the value of the function of the integral as seen in the code below
while i<=n
if i==0
Itot1=(1/2)*elarc(a);
else if i<n
u=h*i;
It(i)= elarc(u);
else
It2=(1/2)*elarc(b);
end
end
Itot=Itot1+sum(It)+It2;
i=i+1;
end

I=Itot*(h);

%Error Calculation compared to built in 'quad' matlab command
E=Ir-I;

Matlab code for calculation of the integrand

function arc = elarc(t)

%Finding the Circumference of an ellipse

%C=integral(dl) from 0 to 2PI

e=sin(pi()/12);
e2=e^2;
r=(1-.0670)./(1-e.*cos(t));
dr2=(118270190867084615574681258512889*sin(t).^2)./(2028240960365167042394725128601600*((291404338770025.*cos(t))./1125899906842624 - 1).^4);

%Integrand:

arc=(r.^2 + (dr2) ).^(.5);
###### Clencurt
 Clencurt Function Value Error 6.176517900218237 4.854358426342742e-008

Matlab code

[xx,ww] = clencurt(n);                               %Calls the clencurt function
xx=pi+xx.*pi;
ww=ww.*pi;
F=elarc(xx);  %Evaluation of the function
I_cl=ww*F
I=6.176517851674653;
E=abs(I_cl-I)

function arc = elarc(t)

%Finding the Circumference of an ellipse

%C=integral(dl) from 0 to 2PI

e=sin(pi()/12);
e2=e^2;
r=(1-.0670)./(1-e.*cos(t));
dr2=(118270190867084615574681258512889*sin(t).^2)./(2028240960365167042394725128601600*((291404338770025.*cos(t))./1125899906842624 - 1).^4);

%Integrand:

arc=(r.^2 + (dr2) ).^(.5);
###### Romberg Table

Romberg Table for n=16

6.176517900218236   6.176517900385847   6.176517900341150   6.176517900343991   6.176517900343945   6.176517900343941
6.176517900343945   6.176517900343943   6.176517900343947   6.176517900343945   6.176517900343941                   0
6.176517900343944   6.176517900343946   6.176517900343945   6.176517900343941                   0                   0
6.176517900343946   6.176517900343946   6.176517900343941                   0                   0                   0
6.176517900343946   6.176517900343942                   0                   0                   0                   0
6.176517900343943                   0                   0                   0                   0                   0

Error of Romberg Table

• 1.0e-007 *
-0.485435833752490  -0.487111941893659  -0.486664966103945
-0.486692917078813  -0.486692899315244  -0.486692934842381
-0.486692908197028  -0.486692925960597  -0.486692917078813
-0.486692925960597  -0.486692925960597  -0.486692881551676
-0.486692925960597  -0.486692890433460                   0
-0.486692899315244                   0                   0
Columns 4 through 6
-0.486693378931591  -0.486692917078813  -0.486692881551676
-0.486692917078813  -0.486692881551676                   0
-0.486692881551676                   0                   0
0                   0                   0
0                   0                   0
0                   0                   0
 Romberg Table Results Value Error 6.176517900343941 4.86692881551676e-008

Matlab code

%The Function outputs the romberg table and a table with the error,  the
%inputs are a=low boundary b=high boundary n=initial number of integration
%points for the romberg table
function [table,etable] = elarcromb(a,b,n)
tic
table=zeros(6,6);

%Generate 1st column of Romberg Table using built in composite trapezoidal
%function.  Notice it calls the function 'Valus' which obtains the values
%for the function.  The function is also corrected at initial point 0
for j=1:6
r=n;
x=linspace(a,b,r+1);
FX=elarc(x);
%FX(1)=1;  %because of 0 start point
table(j,1)=trapz(x,FX);
n=2*r;
end

%Generate 2nd column of Romberg Table
for j=1:5
table(j,2)= ([(2^2)*table(j+1,1)] - [table(j,1)])/(2^2 - 1);
end

%Generate 3rd column of Romberg Table
for j=1:4
table(j,3) = ([(2^(2*2))*table(j+1,2)] - table(j,2))/(2^(2*2)-1);
end

%Generate 4th column of Romberg Table
for j=1:3
table(j,4) = ([(2^(2*3))*table(j+1,3)] - table(j,3))/(2^(2*3)-1);
end

%Generate 5th Column of Romberg Table
for j=1:2
table(j,5) = ([(2^(2*4))*table(j+1,4)] - table(j,4))/(2^(2*4)-1);
end

%Generate 6th column of Romberg Table
table(1,6) = ([(2^(2*5))*table(2,5)] - table(1,5))/(2^(2*5)-1);

%Table of errors for the Romberg Table
etable=zeros(6,6);
pi2=2*pi();

%1st column
for i=1:6
etable(i,1)= I - (table(i,1));
end

%2nd column
for i=1:5
etable(i,2)= I - (table(i,2));
end

%3rd column
for i=1:4
etable(i,3)= I - (table(i,3));
end

%4th Column
for i=1:3
etable(i,4)= I - (table(i,4));
end

%5th column
for i=1:2
etable(i,5)= I - (table(i,5));
end

%6th Column
etable(1,6) = I - (table(1,6));

toc
##### Method 2

${\displaystyle \mathbb {C} =4aE(e^{2})}$

${\displaystyle E(e^{2})=\int _{0}^{\frac {\pi }{2}}\left[1-e^{2}\sin(\theta )\right]^{\frac {1}{2}}d\theta }$

The integral is calculated using 3 methods:

- Composite Trapezoidal
- "Clencurt" Matlab Command
- Romberg Table

It will then by used to find the circumference as previously stated.

###### Composite Trapezoidal
 Composite Trapezoidal Rule n Value Error 2 1.538588738571503 0.001739607794329 4 1.537280664642864 4.315338656908363e-004 8 1.536956805756325 1.076749791522058e-004 16 1.536855855380622 6.724603448970967e-006

${\displaystyle \mathbb {C} =4\times I=6.147423421522488}$

###### Romberg Table
1.536876035753892   1.536849128589532   1.536849129666574   1.536849129666558   1.536849129666558   1.536849129666558
1.536855855380622   1.536849129599258   1.536849129666558   1.536849129666558   1.536849129666558                   0
1.536850811044599   1.536849129662352   1.536849129666558   1.536849129666558                   0                   0
1.536849550007914   1.536849129666295   1.536849129666558                   0                   0                   0
1.536849234751700   1.536849129666542                   0                   0                   0                   0
1.536849155937831                   0                   0                   0                   0                   0

${\displaystyle I=1.536849129666558}$

${\displaystyle \mathbb {C} =4\times I=4\times 1.536849129666558=6.147396518666232}$

Both Methods yield similar but not equal results. Also it is noted that the error associated with method 1 is less than that of method 2

#### Author

--Egm6341.s10.Team2.GV 22:07, 25 March 2010 (UTC)

### Problem 11: Derivation of infinitesimal arc length using the Law of cosine

#### Statement

Derive the infinitesimal arc length using the Law of cosine

#### Author

Egm6341.s10.team2.lee 08:57, 24 March 2010 (UTC)