# University of Florida/Egm6341/s10.Team2/HW6
## Problem 1: Arc Length Computation and Comparisons
### Statement

P.32-1 1. Compute the arc length to O(1e-10), using error analysis of composite trapezoidal rule, and verify the results by Romberg quadrature rule, Clenshaw-Curtis rule and chebfun/sum command.
2. Compute it again by means of the elliptical quadrature formula.

### Solution

Results Discussion
1) For error analysis, the n required for O(1e-10) is 16756.
2) For actual performace of trapezoidal rule, n is 16384.
3) For the first method, I = 1.263690485847868, I_romb = 1.263690485847868, I_cc = 1.263690485847865, II = 1.263690485847865.
4) For the second method, I = 1.036826643842352. This is because theta is defined differently in both cases.

### Author

Egm6341.s10.team2.lee 20:58, 7 April 2010 (UTC)

## Problem 2: Derivation of the Linear Momentum Term in the Y' Direction
### Statement

P.33-2
At an instant t+dt, consider v+dv to show that
$dP_{y'}=mVd\gamma \quad$
after neglecting the higher order terms.

### Solution

The Above figure represents the original axes and the new axes. It also shows the vector representations of the velocities at time=t and time=t+dt.
Our goal is to identify the following:
$dPy'=mV_{y'}$
The velocity at time t+dt is represented by V+dV. This means an infinitesimally small amount of time has elapsed. With this small change in time the angle $d\gamma$ is considered to be small.
Using trigonometry to express the component of V+dV that is in the direction of Y', we write the following
$V_{y'}=\sin(d\gamma )[V+dV]$
Using Taylor Series expansion to approximate the sine of the small angle (as described in Small-Angle Approximation), we can identify that for small values of the angle:
$\sin(d\gamma )=d\gamma$
Using this approximation the following can be written:
$V_{y'}=d\gamma [V+dV]=d\gamma V+d\gamma dV$
By ignoring the higher order term of the previous result we are able to show:
$dPy'=mV_{y'}=m(Vd\gamma )$

### Author

Solved by--Guillermo Varela (GV)

## Problem 3: Computation of the co-efficient matrix to express $C_{i}$ interms of the degrees of freedom
### Statement

P.35-3
From the discussion in the above mentioned slides it we have the following equation:
${\begin{bmatrix}A_{1,1}&A_{1,2}&A_{1,3}&A_{1,4}\\A_{2,1}&A_{2,2}&A_{2,3}&A_{2,4}\\A_{3,1}&A_{3,2}&A_{3,3}&A_{3,4}\\A_{4,1}&A_{4,2}&A_{4,3}&A_{4,4}\end{bmatrix}}{\begin{Bmatrix}c_{0}\\c_{1}\\c_{2}\\c_{3}\end{Bmatrix}}={\begin{Bmatrix}Z_{i}\\Z_{i}'\\Z_{i+1}\\Z_{i+1}'\end{Bmatrix}}$
The first two rows of matrix A, is given. Calculate the rows 3 and 4.So that the co-efficients can be expressed as below:
${\begin{Bmatrix}c_{0}\\c_{1}\\c_{2}\\c_{3}\end{Bmatrix}}={\begin{bmatrix}A_{1,1}&A_{2,1}&A_{3,1}&A_{4,1}\\A_{1,2}&A_{2,2}&A_{3,2}&A_{4,2}\\A_{1,3}&A_{2,3}&A_{3,3}&A_{4,3}\\A_{1,4}&A_{2,4}&A_{3,4}&A_{4,4}\end{bmatrix}}{\begin{Bmatrix}Z_{i}\\Z_{i}'\\Z_{i+1}\\Z_{i+1}'\end{Bmatrix}}$

### Solution

From the discussion in P.35-2 and P.35-3 we have the following equations:
    $\displaystyle Z(s)=\sum _{i=0}^{3}c_{i}s^{i}=\sum _{i=1}^{3}N_{i}(s)d_{i}$ (2 p35-2)
    $\displaystyle d_{1}=Z_{i}$ $\displaystyle d_{3}=Z_{i+1}$ $\displaystyle d_{2}={\dot {Z_{i}}}$ $\displaystyle d_{4}={{\dot {Z}}_{i+1}}$ (3 p35-2)
    $\displaystyle {\dot {Z}}={\frac {dZ}{dt}}=\underbrace {\frac {dZ}{ds}} _{Z'}.{\frac {ds}{dt}}$ (4 p35-2)
Using ${\frac {ds}{dt}}={\frac {1}{h}}$ and the above equations we have shown the first two rows of the matrix A to be ${\begin{bmatrix}1&0&0&0\\0&1&0&0\end{bmatrix}}$
Using the equations above we have
    $\displaystyle d_{3}=Z_{i+1}=Z(s=1)=c_{0}+c_{1}+c_{2}+c_{3}$ (1)
    $\displaystyle d_{4}={\dot {Z}}_{i+1}={\frac {1}{h}}Z'(s=1)=c_{1}+2c_{2}+3c_{3}$ (2)
Putting the results in matrix form we have eqn 7 P.35-3.
${\begin{bmatrix}1&0&0&0\\0&1&0&0\\1&1&1&1\\0&1&2&3\end{bmatrix}}{\begin{Bmatrix}c_{0}\\c_{1}\\c_{2}\\c_{3}\end{Bmatrix}}={\begin{Bmatrix}Z_{i}\\Z'_{i}\\Z_{i+1}\\Z'_{i+1}\end{Bmatrix}}$

### Author

--Egm6341.s10.team2.niki 21:45, 5 April 2010 (UTC)
--Proofread by Egm6341.s10.team2.lee 00:38, 6 April 2010 (UTC)

## Problem 4: Inverse of Matrix
### Statement

P. 35-4

### Solution

The Inverse of the Matrix $A={\begin{bmatrix}1&0&0&0\\0&1&0&0\\1&1&1&1\\0&1&2&3\end{bmatrix}}\;\;$ can be found out by doing row operations as follows:
The augmented matrix of A and I is represented by
$X={\begin{bmatrix}1&0&0&0&|\;1&0&0&0\\0&1&0&0&|\;0&1&0&0\\1&1&1&1&|\;0&0&1&0\\0&1&2&3&|\;0&0&0&1\end{bmatrix}}$
By carrying out row transformation: $R_{3}\rightarrow 3R_{3}-R_{4}$ on the augmented matrix 'X', it becomes:
$X={\begin{bmatrix}1&0&0&0&|\;1&0&0&0\\0&1&0&0&|\;0&1&0&0\\3&2&1&0&|\;0&0&3&-1\\0&1&2&3&|\;0&0&0&1\end{bmatrix}}$
By carrying out row transformation: $R_{3}\rightarrow R_{3}-3R_{1}-2R_{2}$ on the augmented matrix 'X', it becomes:
$X={\begin{bmatrix}1&0&0&0&|\;+1&0&0&0\\0&1&0&0&|\;+0&1&0&0\\0&0&1&0&|\;-3&-2&3&-1\\0&1&2&3&|\;+0&0&0&1\end{bmatrix}}$
By carrying out row transformation: $R_{4}\rightarrow R_{4}-R_{2}-2R_{3}$ on the augmented matrix 'X', it becomes:
$X={\begin{bmatrix}1&0&0&0&|\;+1&0&0&0\\0&1&0&0&|\;+0&1&0&0\\0&0&1&0&|\;-3&-2&3&-1\\0&0&0&3&|\;+6&3&-6&3\end{bmatrix}}$
Finally, by carrying out row transformation: $R_{4}\rightarrow R_{4}/3$ on the augmented matrix 'X', it becomes:
$X={\begin{bmatrix}1&0&0&0&|\;+1&0&0&0\\0&1&0&0&|\;+0&1&0&0\\0&0&1&0&|\;-3&-2&3&-1\\0&0&0&1&|\;+2&1&-2&1\end{bmatrix}}$
Here the Left part of the augmented matrix is reduced to a unit matrix $\;I_{(4X4)}$ by carrying out the row operations and as a result we obtained a transformed matrix on the right part of the augmented matrix which is $\;A^{-1}$. Therefore,
$A^{-1}={\begin{bmatrix}+1&0&0&0\\+0&1&0&0\\-3&-2&3&-1\\+2&1&-2&1\end{bmatrix}}$
The same result can be verified by using the Matlab code below and 'B' is the value of $\;A^{-1}$ in the code.
Matlab code to verify the inverse of matrix- 'A':

### Author

Solved by--Srikanth Madala (SM)

## Problem 5:Identify basis functions
### Statement

P. 35-4
To identify the set of basis functions: $\;N_{1}(s),N_{2}(s),N_{3}(s)\;and\;N_{4}(s)$ and plot them as a function of 's' varying between $\;s=0\;and\;s=1$

### Solution

Using the $\;A^{-1}$ calculated in the above problem, we can find out the values of the coefficients- $\;C_{0},C_{1},C_{2}\;and\;C_{3}$ in terms of $Z_{i},Z'_{i},Z_{i+1}\;and\;Z'_{i+1}$ by using the following equation:
${\begin{bmatrix}C_{0}\\C_{1}\\C_{2}\\C_{3}\end{bmatrix}}={\begin{bmatrix}1&0&0&0\\0&1&0&0\\-3&-2&3&-1\\2&1&-2&1\end{bmatrix}}{\begin{bmatrix}Z_{i}\\Z'_{i}\\Z_{i+1}\\Z'_{i+1}\end{bmatrix}}$
Therefore, ${\begin{Bmatrix}C_{0}=Z_{i}\\C_{1}=Z'_{i}\\C_{2}=-3Z_{i}-2Z'_{i}+3Z_{i+1}-1Z'_{i+1}\\C_{3}=2Z_{i}+1Z'_{i}-2Z_{i+1}+1Z'_{i+1}\end{Bmatrix}}$
But, we know that:
$Z\left(s\right)=\sum _{i=1}^{4}N_{i}\left(s\right)d_{i}=\sum _{i=0}^{3}C_{i}s^{i}$
$N_{1}\left(s\right)d_{1}+N_{2}\left(s\right)d_{2}+N_{3}\left(s\right)d_{3}+N_{4}\left(s\right)d_{4}=C_{0}s^{0}+C_{1}s^{1}+C_{2}s^{2}+C_{3}s^{3}$
By definition: $d_{1}:=Z_{i},\;d_{2}:=Z'_{i},\;d_{3}:=Z_{i+1}\;and\;d_{4}:=Z'_{i+1}$ and also we already know the values of the coefficients- $\;C_{0},C_{1},C_{2}\;and\;C_{3}$ in terms of $Z_{i},Z'_{i},Z_{i+1}\;and\;Z'_{i+1}.$ Therefore, plugging these values in the above equation, gives us:
$N_{1}\left(s\right)Z_{i}+N_{2}\left(s\right)Z'_{i}+N_{3}\left(s\right)Z_{i+1}+N_{4}\left(s\right)Z'_{i+1}=Z_{i}+Z'_{i}s+\left[-3Z_{i}-2Z'_{i}+3Z_{i+1}-Z'_{i+1}\right]s^{2}+\left[2Z_{i}+Z'_{i}-2Z_{i+1}+Z'_{i+1}\right]s^{3}$
$N_{1}\left(s\right)Z_{i}+N_{2}\left(s\right)Z'_{i}+N_{3}\left(s\right)Z_{i+1}+N_{4}\left(s\right)Z'_{i+1}=Z_{i}\left(1-3s^{2}+2s^{3}\right)+Z'_{i}\left(s-2s^{2}+s^{3}\right)+Z_{i+1}\left(3s^{2}-2s^{3}\right)+Z'_{i+1}\left(-s^{2}+s^{3}\right)$
By comparing LHS and RHS, we can deduce the following:
    $N_{1}\left(s\right)=\left(1-3s^{2}+2s^{3}\right)$ $N_{2}\left(s\right)=\left(s-2s^{2}+s^{3}\right)$ $N_{3}\left(s\right)=\left(3s^{2}-2s^{3}\right)$ $N_{4}\left(s\right)=\left(-s^{2}+s^{3}\right)$
Matlab code to generate the following plots:

### Author

Solved by--Srikanth Madala (SM) Proofread by--Egm6341.s10.team2.lee 02:13, 8 April 2010 (UTC)

## Problem 6: Transformation of Variables
### Statement

P.36-1 Express s in terms of t

### Solution

Since
$t(s)=t_{i}+{\frac {t_{i+1}-t_{i}}{1-0}}S=t_{i}+hS$
Solving for S,
$s(t)={\frac {t-t_{i}}{h}}$
Verify:
$s(t_{i})=0\quad and\quad s(t_{i+1})=1$

### Author

Egm6341.s10.team2.lee 00:10, 5 April 2010 (UTC)

## Problem 7:Enforcing compliance with the DE at the point (s=1/2)
### Statement

P. 36-2 By enforcing compliance with the DE at the point $Z_{i+1}=Z(s=1/2)$ show that
    $\displaystyle Z_{i+1/2}=Z(s=1/2)={\frac {1}{2}}[Z_{i}+Z_{i+1}]+{\frac {h}{8}}[f_{i}-f_{i+1}]$

### Solution

We have from eqn 1 P. 35-4 and Prob 4 of HW6 the following
    $\displaystyle {\begin{bmatrix}c_{0}\\c_{1}\\c_{2}\\c_{3}\end{bmatrix}}={\begin{bmatrix}1&0&0&0\\0&1&0&0\\-3&-2&3&-1\\2&1&-2&1\end{bmatrix}}{\begin{Bmatrix}Z_{i}\\Z_{i}'\\Z_{i+1}\\Z_{i+1}'\end{Bmatrix}}$ (1 p 35-4)
In eqn 2 P. 35-2 at the point $s={\frac {1}{2}}$ we get
    $\displaystyle Z(s={\frac {1}{2}})=Z_{i}+Z'_{i}({\frac {1}{2}})+[-3Z_{i}-2Z'_{i}+3Z_{i+1}-Z_{i+1}]({\frac {1}{4}})+[2Z_{i}+Z'_{i}-2Z_{i+1}+Z'_{i+1}]({\frac {1}{8}})$ (1)
    $\displaystyle Z(s={\frac {1}{2}})=Z_{i}[1-{\frac {3}{4}}+{\frac {1}{4}}]+Z'_{i}[{\frac {1}{2}}-{\frac {1}{2}}+{\frac {1}{8}}]+Z_{i+1}[{\frac {3}{4}}-{\frac {1}{4}}]+Z'_{i+1}[{\frac {-1}{4}}+{\frac {1}{8}}]$ (2)
    $\displaystyle Z(s={\frac {1}{2}})=Z_{i}[{\frac {1}{2}}]+Z'_{i}[{\frac {1}{8}}]+Z_{i+1}[{\frac {1}{2}}]+Z'_{i+1}[-{\frac {1}{8}}]$ (3)
    $\displaystyle Z(s={\frac {1}{2}})={\frac {1}{2}}[Z_{i}+Z_{i+1}]+{\frac {1}{8}}[Z'_{i}-Z'_{i+1}]$ (4)
But we know from eqn 1P. 36-1 that $Z'=h{\dot {Z}}$. By imposing collocation we have $Z_{i}=f_{i}$ and $Z_{i+1}=f_{i+1}$. Using these results in the above equation we get
    $\displaystyle Z_{i+1/2}=Z(s=1/2)={\frac {1}{2}}[Z_{i}+Z_{i+1}]+{\frac {h}{8}}[f_{i}-f_{i+1}]$

### Author

--Egm6341.s10.team2.niki 23:03, 5 April 2010 (UTC)
--Proofread by Egm6341.s10.team2.lee 00:37, 6 April 2010 (UTC)

## Problem 8:Enforcing compliance with the DE at (s=1/2):Part B
### Statement

P.36-2 By enforcing compliance with the DE at the point $Z_{i+1}=Z(s=1/2)$ show that
    $\displaystyle Z'_{i+1/2}=Z'(s=1/2)=-{\frac {3}{2}}[Z_{i}-Z_{i+1}]-{\frac {1}{2}}[Z'_{i}+Z'_{i+1}]$

### Solution

We have from eqn 1 P.35-4 and Prob 4 of HW6 the following
    $\displaystyle {\begin{bmatrix}c_{0}\\c_{1}\\c_{2}\\c_{3}\end{bmatrix}}={\begin{bmatrix}1&0&0&0\\0&1&0&0\\-3&-2&3&-1\\2&1&-2&1\end{bmatrix}}{\begin{Bmatrix}Z_{i}\\Z_{i}'\\Z_{i+1}\\Z_{i+1}'\end{Bmatrix}}$ (1 p 35-4)
We know from eqn 3 P.35-3
    $\displaystyle Z'(s)=\sum _{i=1}^{3}ic_{i}s^{i-1}$
Expanding and substituting for the constants we get:
    $\displaystyle Z'(s=1/2)=c_{1}+2c_{2}({\frac {1}{2}})+3c_{3}({\frac {1}{4}})$ (1)
    $\displaystyle Z'(s=1/2)=Z_{i}+2[-3Z_{i}-2Z'_{i}+3Z_{i+1}-Z'_{i+1}]({\frac {1}{2}})+3[2Z_{i}+Z'_{i}-2Z_{i+1}+Z'_{1+1}]({\frac {1}{4}})$ (2)
Rearranging terms we get
    $\displaystyle Z'(s=1/2)=Z_{i}[-3+{\frac {3}{2}}]+Z'_{i}[1-2+{\frac {3}{4}}]+Z_{i+1}[3-{\frac {3}{2}}]+Z'_{i+1}[-1+{\frac {3}{4}}]$ (3)
    $\displaystyle Z'_{i+1/2}=Z'(s=1/2)=-{\frac {3}{2}}[Z_{i}-Z_{i+1}]-{\frac {1}{2}}[Z'_{i}+Z'_{i+1}]$
which is the required result.

### Author

--Egm6341.s10.team2.niki 23:29, 5 April 2010 (UTC)
--Proofread by Egm6341.s10.team2.lee 00:37, 6 April 2010 (UTC)

## Problem 9: Condition for collocation at $t_{i+1/2}$
### Statement

P. 36-3 To prove that the condition for collocation at $\;t_{i+1/2}$ is:
$Z_{i+1}=Z_{i}+{\frac {\frac {h}{2}}{3}}\left[f_{i}+4f_{i+{\frac {1}{2}}}+f_{i+1}\right]$

### Solution

From P.36-2 we know that:
$Z'_{i+{\frac {1}{2}}}={\frac {-3}{2}}\left(Z_{i}-Z_{i+1}\right)-{\frac {1}{4}}\left(Z'_{i}+Z'_{i+1}\right)$
using ${\dot {Z}}={\frac {1}{h}}Z'\;$, we get:
${\dot {Z}}_{i+{\frac {1}{2}}}={\frac {-3}{2h}}\left(Z_{i}-Z_{i+1}\right)-{\frac {1}{4}}\left({\dot {Z}}_{i}+{\dot {Z}}_{i+1}\right)$
${\dot {Z}}_{i+{\frac {1}{2}}}={\frac {-3}{2h}}\left(Z_{i}-Z_{i+1}\right)-{\frac {1}{4}}\left(f_{i}+f_{i+1}\right)$
Subtracting $\;f_{i+{\frac {1}{2}}}$ from both sides:
${\dot {Z}}_{i+{\frac {1}{2}}}-f_{i+{\frac {1}{2}}}={\frac {-3}{2h}}\left(Z_{i}-Z_{i+1}\right)-{\frac {1}{4}}\left(f_{i}+f_{i+1}\right)-f_{i+{\frac {1}{2}}}$
We know that in order for the collocation to be satisfied at point $t_{i+1/2}$, $\;{\dot {Z}}_{i+{\frac {1}{2}}}-f_{i+{\frac {1}{2}}}=0$
$\therefore {\frac {-3}{2h}}\left(Z_{i}-Z_{i+1}\right)-{\frac {1}{4}}\left(f_{i}+f_{i+1}+4f_{i+{\frac {1}{2}}}\right)=0$
$\left(Z_{i+1}-Z_{i}\right)={\frac {2h}{3*4}}\left[f_{i}+f_{i+1}+4f_{i+{\frac {1}{2}}}\right]$
    $\therefore \;Z_{i+1}=Z_{i}+{\frac {\frac {h}{2}}{3}}\left[f_{i}+4f_{i+{\frac {1}{2}}}+f_{i+1}\right]$

### Author

Solved by-Srikanth Madala (SM)

## Problem 10: Commentary on the matlab code available on Kessler's paper for the evaluation of polynomials and their coefficients in the trapezoidal rule error
### Statement

P. 37-1
Run Kessler's code to reproduce his table, and complete the HW of P.30-2, i.e., follow Kessler's code line by line to produce the pairs $\;[P_{2}(x),P_{3}(x)],\;[P_{4}(x),P_{5}(x)],\;[P_{6}(x),P_{7}(x)]$ and write comments on his code.

### Solution

Matlab code

### Author

Solved by-Srikanth Madala (SM)

## Problem 11: Verify the results of Problem 10, HW #5 by using Team 4's code to debug
### Statement

P. 37-1
An Ellipse was given:
$r(\theta )={\frac {a(1-e^{2})}{1-e\cos(\theta )}}$
where:
$eccentricity=e=\sin({\frac {\pi }{12}})$
$a=1$
Calculate the Circumference of the elipse as follows:
Method 1:
$C=\int _{0}^{2\pi }\left[r^{2}+({\frac {dr}{d\theta }})^{2}\right]^{\frac {1}{2}}$
Method 2:
$C=4aE(e^{2})$
$E(e^{2})=\int _{0}^{\frac {\pi }{2}}\left[1-e^{2}\sin(\theta )\right]^{\frac {1}{2}}d\theta$
Use Team 4's Solution to debug own code and compare results.

### Solution
#### Composite Trapezoidal Rule

After looking at Team 4's codes I was able to gain knowledge into checking for the error of the numerical integration. Like our team, they also used the 'Quad' command as the theoretical answer to compare their results to. In addition they used an extra argument to the 'Quad' command which provides for more accurate results by providing the order of the error.
In addition the way the derivative of the radius relative to the angle is calculated differently. We used Matlab's Symbolic toolbox to find the integration results while team 4 used the theoretical results then plugged in values for their respective variables.
Regarding Method 2, the same applies.
Below are our results
Method 1
Method 2

##### Matlab Code Used

Modified Matlab code for composite Trapezoidal calculation

#### Clencurt Command

Comparing the two codes used for using the 'clencurt' command were different. Our approach took a simple way to just use the weights to calculate our results with no error bounding, as it was done by Team 4.
Method 1
Method 2

##### Modified Matlab Code For Clencurt

Matlab code

#### Romberg Table

The solution approaches to creating the Romberg Table were different from both teams. Team 4's approach uses the simple trapezoidal rule formula as compared to Our team's approach of using the matlab 'trapz' command. In addition the method used to calculate row by row of the Romberg Table were different.
When running Team 4's code I'm not able to get all of the Romberg Table to be completed. At the moment Team 2 is continiously working on figuring out the cause for the difference of the solutions as shown below:
Method 1
Method 2

### Author

Solved by--Guillermo Varela (GV)

## Signatures

Solved problems 3,7,8 and proofread --Niki Nachappa (NN) 23:31, 5 April 2010 (UTC)
Solved problems 4,5,9,10 --Srikanth Madala (SM)
Solved problems 2, 11 and Proofread 4, 8 --Guillermo Varela (GV) 20:50, 7 April 2010 (UTC)
Solved problems 1,6 and Proofread 3,7,8 --Egm6341.s10.team2.lee 02:12, 8 April 2010 (UTC)
Proofread problems 4,9,5,10 --Patrick O'Donoughue(PO)