User:EGM4313.f14.Team1.Linehan/Report 4

=Report 4=

Problem Statement
For the following L2-ODE-CC


 * {| style="width:100%" border="0"

$$ y'' + \frac23 y' + \frac{37}{9} y = r(x) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

with excitation close to the damped circular frequency:


 * {| style="width:100%" border="0"

$$ r(x) = \cos 2.1 x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

and initial conditions


 * {| style="width:100%" border="0"

$$ y(0) = 1, \ y'(0) = 0 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

1. Identify the damped circular frequency.

2. Find the solution; show clearly the trial solution used in each part of the solution. plot separately (1) the homogeneous solution,

(2) the particular solution and the excitation, (3) the total / complete solution, and (4) a combined plot of complete solution,

homogeneous solution, and particular solution. discuss the long-term behavior of the homogeneous (transient) solution versus the

particular (steady-state) solution. pay particular attention to the amplitude of vibration as the excitation frequency is close to the system natural frequency.

3. Provide a quantitative and a qualitative (graphic) verification of the above results: solution satisfies the initial conditions, and solution satisfies the L2-ODE-CC.

Part 1

 * {| style="width:100%" border="0"

$$ y'' + \frac23 y' + \frac{37}{9} y = cos 2.1x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Can break solution into homogeneous and particular solutions.


 * {| style="width:100%" border="0"

$$ y = y_h + y_p $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

To find homogeneous solution we must assume a trial solution that takes the form


 * {| style="width:100%" border="0"

$$ y_h= e^{\lambda t} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

with derivatives


 * {| style="width:100%" border="0"

$$ y_h'= \lambda e^{\lambda t} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ y_h''= \lambda^2 e^{\lambda t} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

plugging in


 * {| style="width:100%" border="0"

$$ (\lambda^2 + \frac{2}{3} \lambda + \frac{37}{9}) e^{\lambda t} = 0 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

since $$ e^{\lambda t} $$ cannot be zero we retrieve following relation.


 * {| style="width:100%" border="0"

$$ \lambda^2 + \frac23 \lambda + \frac{37}{9}= 0 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Seeing that


 * {| style="width:100%" border="0"

$$ \Delta=\frac23^2-4(\frac{37}{9})=-\frac{80}{30} < 0 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

therefore there must be two complex conjugate roots


 * {| style="width:100%" border="0"

$$ \lambda_{1} = -\frac13 - i 2 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \lambda_{2} = -\frac13 + i 2 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

and the damped circular frequency $$ \tilde \omega = 2 $$.

Part 2
Continuing on from part 1 the homogeneous solution will then take the form


 * {| style="width:100%" border="0"

$$ y_h= e^{-0.5}(Acos(2t)+Bsin(2t)) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

where A and B are undetermined coefficients to be found by solving

the full solution IVP.

Now we must find the particular solution. We begin by noting that the excitation r(x)

is trigonometric. There for we must select a particular solution that takes the form


 * {| style="width:100%" border="0"

$$ y_p= Mcos2.1x + Nsin2.1x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

noting that this choice of particular solution must satisfy the initial ODE


 * {| style="width:100%" border="0"

$$ y_p'' + \frac23 y_p' + \frac{37}{9} y_p = cos2.1x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

therefore finding the necessary derivatives of the choice of particular solution


 * {| style="width:100%" border="0"

$$ y_p'= -M(2.1)sin2.1x + N(2.1)cos2.1x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ y_p''= -M(4.41)cos2.1x - N(4.41)sin2.1x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

therefore


 * {| style="width:100%" border="0"

$$ -M(4.41)cos2.1x - N(4.41)sin2.1x + \frac23(-M(2.1)sin2.1x + N(2.1)cos2.1x) + \frac{37}{9}(Mcos2.1x + Nsin2.1x)= cos2.1x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

rearranging equation to be more digestible


 * {| style="width:100%" border="0"

$$ (-0.30M + 1.4N)cos2.1x + (-1.4M + -0.30N)sin2.1x = cos2.1x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

in order for the above solution to be satisfied the coefficients of the each of the

trig functions must matchup with coefficients of the trig functions of the excitation.

This yields two equations which allows us to solve for the two unknowns M and N.

The first equation


 * {| style="width:100%" border="0"

$$ -0.30M + 1.4N= 1 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

and the second equation


 * {| style="width:100%" border="0"

$$ -1.4M + -0.30N=0 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

placing these equations into matrix form allows the system of equations to be solved easily


 * {| style="width:100%" border="0"

$$ \begin{bmatrix}-0.30 & 1.4 \\ 1.4 & -0.30\end{bmatrix} \begin{Bmatrix} M \\ N \end{Bmatrix} = \begin{Bmatrix} 1 \\ 0 \end{Bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

therefore coefficients M and N


 * {| style="width:100%" border="0"

$$ M= 0.1604 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ N= 0.7487 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

and the particular solution becomes


 * {| style="width:100%" border="0"

$$ y_p= 0.1604cos2.1x + 0.7487sin2.1x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

the full solution which is a sum of the two linearly independent homogeneous and particular solutions

takes the form


 * {| style="width:100%" border="0"

$$ y= e^{-0.5}(Acos(2t)+Bsin(2t)) + 0.1604cos2.1x + 0.7487sin2.1x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

to recover undetermined coefficients A and B we must utilize our given initial conditions.

taking the derivative of our solution


 * {| style="width:100%" border="0"

$$ y= e^{-0.5x}(Acos(2x)+Bsin(2x)) + 0.1604cos2.1x + 0.7487sin2.1x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ y'= 2 e^{-0.5 x} (B cos2x-A sin2x)-0.5 e^{-0.5 x} (A cos2x+B sin2x)-0.33684 sin2.1x+1.57227 cos2.1x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

therefore with initial conditions


 * {| style="width:100%" border="0"

$$ y(0)= A + 0.1604 = 1 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ y'(0)= 2(B)-0.5(A)+1.57227 = 0 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

therefore


 * {| style="width:100%" border="0"

$$ A = 0.8396 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ B = -0.5762 $$ Therefore the final solution becomes
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ y= e^{-0.5x}(0.8396cos(2x)-0.5762sin(2x)) + 0.1604cos2.1x + 0.7487sin2.1x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Plot of the homogeneous solution can be seen below:



The homogeneous solution represents the transient solution in that at time equal to zero it starts at a high amplitude and attenuates at a rate of $$ e^{-0.5x} $$ to zero as time goes to infinity.

Plot of the particular solution:



The particular solution takes on a sinusoidal form which is indicative of the given sinusoidal

excitation. As time goes to infinity the particular solution does not attenuate and

Plot of the full solution:



Plot of the homogeneous, particular, and full solution:



From the principle of superposition of the particular and homogeneous solutions which combine to

generate the total solution, the total solution should inherent properties of both the homogeneous and

particular solutions. It can be seen that the total solution attenuates at a much slower rate then

the homogeneous solution which is attributed to the fact that it is added to by the purely sinusoidal

particular solution. As time goes to infinity the total solution still approaches zero but again at a

rate slower then the homogeneous solution.

Part 3
Checking if the retrieved solution indeed satisfies the L2-ODE-CC we plug the solution back into the ODE.


 * {| style="width:100%" border="0"

$$ y'= 2 e^{-0.5 x} (-0.5762 cos2x-0.8396sin2x)-0.5 e^{-0.5 x} (0.8396cos2x-0.5762  sin2x)-0.33684 sin2.1x+1.57227 cos2.1x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ y''= -3.30177 sin(2.1 x)-1.9961 e^{-0.5 x} cos(2 x)-0.707364 cos(2.1 x)+7.6799 e^{-0.5 x} sin(x) cos(x) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

plugging solution into ODE and using Wolfram Alpha to find and check if indeed the answer to the left hand of the

ODE is equal to given excitation


 * {| style="width:100%" border="0"

$$ y'' + \frac23 y' + \frac{37}{9} y= cos2.1x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

which indeed it is.

Now plotting solution to check that initial conditions are met.



it can be seen that at a x location of 0 the function holds a value of one. Also it can be seen at

an x location of 0 the derivative of the function is 0.

Problem Statement
1. Find the expression for the normal stress $$ \sigma_{y'} $$ in y’ direction by replacing the angle $$ \theta $$ in Eq.(7.5) above with the angle $$ \theta +\frac{\pi}{2} $$.

2. Let the basis vectors for the (x,y) coordinates be $$ \mathbf e_{x}, \mathbf e_{y} $$, and the basis vectors in the (x’,y’) coordinates be $$ \mathbf e_{x'} , \mathbf e_{y'} $$. then we have


 * {| style="width:100%" border="0"

$$ \mathbf e_{x'} = \cos \theta \, \mathbf e_x + \sin \theta \, \mathbf e_y $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \mathbf e_{y'} = -\sin \theta \, \mathbf e_x + \cos \theta \, \mathbf e_y $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \begin{Bmatrix} \mathbf e_{x'} \\ \mathbf e_{y'} \end{Bmatrix} = \begin{bmatrix} \cos \theta & \sin \theta \\ -\sin \theta & \cos \theta \end{bmatrix} \begin{Bmatrix} \mathbf e_{x} \\ \mathbf e_{y} \end{Bmatrix} = \mathbf Q \begin{Bmatrix} \mathbf e_{x} \\ \mathbf e_{y} \end{Bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

arrange the stresses $$ (\sigma_{x'}, \ \sigma_{y'}, \ \tau_{x'y'} ) e_{x}, \mathbf e_{y} $$  and the stresses $$ (\sigma_{x}, \ \sigma_{y}, \ \tau_{xy} )$$  in symmetric matrix form, and verify the following relation by comparing with the above expressions for $$ (\sigma_{x'}, \ \sigma_{y'}, \ \tau_{x'y'} )$$  in terms of  $$ (\sigma_{x}, \ \sigma_{y}, \ \tau_{xy} )$$.


 * {| style="width:100%" border="0"

$$ \begin{bmatrix} \sigma_{x'} & \tau_{x'y'} \\ \tau_{x'y'} & \sigma_{y'} \end{bmatrix} = \mathbf Q \, \begin{bmatrix} \sigma_{x} & \tau_{xy} \\ \tau_{xy} & \sigma_{y} \end{bmatrix} \, \mathbf Q^T $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

compare the above transformation of coordinates for stresses to the transformation of coordinates for the stiffness matrix in mtg.13, p.7, and sec.53e, Eq.(1) p.53-40.

3. The principal stresses are the max and min stresses as given by eq. (7.14) and principle directions are given by (7.12). solve the standard eigenvalue problem of the symmetric stress matrix.


 * {| style="width:100%" border="0"

$$ \begin{bmatrix} \sigma_{x} & \tau_{xy} \\ \tau_{xy} & \sigma_{y} \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

to show that the eigenvalues are the max and min stresses in Eq.(7.14) above, and the eigendirections are given by Eq.(7.12) above.

Part 1
Eq. (7.5) states


 * {| style="width:100%" border="0"

$$ \sigma_{x'}=\frac{\sigma_x+\sigma_y}{2}+\frac{\sigma_x-\sigma_y}{2}\cos{2\theta}+\tau_{xy}\sin{2\theta} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Substituting $$\theta=\theta+\frac{\pi}{2}$$ into (7.5) gives us $$\sigma_{y'}$$


 * {| style="width:100%" border="0"

$$ \sigma_{y'}=\frac{\sigma_x+\sigma_y}{2}+\frac{\sigma_x-\sigma_y}{2}\cos{2(\theta+\frac{\pi}{2})}+\tau_{xy}\sin{2(\theta+\frac{\pi}{2})} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Simplifying


 * {| style="width:100%" border="0"

$$ \sigma_{y'}=\frac{\sigma_x+\sigma_y}{2}+\frac{\sigma_x-\sigma_y}{2}\cos{(2\theta+\pi)}+\tau_{xy}\sin{(2\theta+\pi)} $$     (1)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }

From trigonometry, we know that $$sin{x+\pi}=-sin{x}$$ and $$cos{x+\pi}=-cos{x}$$. Substituting both into (1) gives


 * {| style="width:100%" border="0"

$$ \sigma_{y'}=\frac{\sigma_x+\sigma_y}{2}-\frac{\sigma_x-\sigma_y}{2}\cos{2\theta}-\tau_{xy}\sin{2\theta} $$     (2)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }

Part 2
From Eq. (7.5), Eq. (7.6), and (2), we know the formulas for $$\sigma_{x'}$$, $$\sigma_{y'}$$, and $$\tau_{x'y'}$$:


 * {| style="width:100%" border="0"

$$ \sigma_{x'}=\frac{\sigma_x+\sigma_y}{2}+\frac{\sigma_x-\sigma_y}{2}\cos{2\theta}+\tau_{xy}\sin{2\theta} $$     (7.5)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }


 * {| style="width:100%" border="0"

$$ \sigma_{y'}=\frac{\sigma_x+\sigma_y}{2}-\frac{\sigma_x-\sigma_y}{2}\cos{2\theta}-\tau_{xy}\sin{2\theta} $$     (2)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }


 * {| style="width:100%" border="0"

$$ \tau_{x'y'}=-\frac{\sigma_x-\sigma_y}{2}\sin{2\theta}+\tau_{xy}\cos{2\theta} $$     (7.6)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }

From trigonometry, we know the following:


 * {| style="width:100%" border="0"

$$ \frac{1+cos{2\theta}}{2}=cos^2{\theta} $$     (3)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }


 * {| style="width:100%" border="0"

$$ \frac{1-cos{2\theta}}{2}=sin^2{\theta} $$     (4)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }


 * {| style="width:100%" border="0"

$$ sin{2\theta}=2sin{\theta}cos{\theta} $$     (5)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }


 * {| style="width:100%" border="0"

$$ cos{2\theta}=cos^2{\theta}-sin^2{\theta} $$     (6)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }

(7.5) can be rewritten as shown below:


 * {| style="width:100%" border="0"

$$ \sigma_{x'}=\frac{\sigma_x}{2}+\frac{\sigma_y}{2}+\frac{\sigma_x}{2}\cos{2\theta}-\frac{\sigma_y}{2}\cos{2\theta}+\tau_{xy}sin{2\theta} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \sigma_{x'}=\sigma_x(\frac{1+cos{2\theta}}{2})+\sigma_y(\frac{1-cos{2\theta}}{2})+\tau_{xy}sin{2\theta} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Substituting in (3), (4), and (5) gives the new form of (7.5):


 * {| style="width:100%" border="0"

$$ \sigma_{x'}=\sigma_xcos^2{\theta}+\sigma_ysin^2{\theta}+2\tau_{xy}sin{\theta}cos{\theta} $$     (7.5)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }

Similarly, with (2):


 * {| style="width:100%" border="0"

$$ \sigma_{y'}=\sigma_xsin^2{\theta}+\sigma_ycos^2{\theta}-2\tau_{xy}sin{\theta}cos{\theta} $$     (2)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }

(7.6) can also be rewritten:


 * {| style="width:100%" border="0"

$$ \tau_{x'y'}=-\frac{\sigma_x}{2}sin{2\theta}+\frac{\sigma_y}{2}sin{2\theta}+\tau_{xy}cos{2\theta} $$ Substituting in (5) and (6) gives the new form of (7.6):
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \tau_{x'y'}=-\sigma_xsin{\theta}cos{\theta}+\sigma_ysin{\theta}cos{\theta}+\tau_{xy}(cos^2{\theta}-sin^2{\theta}) $$     (7.6)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }

(7.5), (2), and (7.6) can be written in matrix from as below:


 * {| style="width:100%" border="0"

$$ \begin{bmatrix} \sigma_{x'} & \tau_{x'y'} \\ \tau_{x'y'} & \sigma_{y'} \end{bmatrix} = \mathbf Q \, \begin{bmatrix} \sigma_{x} & \tau_{xy} \\ \tau_{xy} & \sigma_{y} \end{bmatrix} \, \mathbf Q^T $$     (7)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }

Where $$\mathbf Q=\begin{bmatrix}Q_{11} & Q_{12} \\ Q_{21} & Q_{22}\end{bmatrix}$$ and $$\mathbf Q^T=\begin{bmatrix}Q_{11} & Q_{21} \\ Q_{12} & Q_{22}\end{bmatrix}$$

Multiplying out (7) to find the values in $$\mathbf Q$$


 * {| style="width:100%" border="0"

$$ \begin{bmatrix} \sigma_{x'} & \tau_{x'y'} \\ \tau_{x'y'} & \sigma_{y'} \end{bmatrix} = \begin{bmatrix}Q_{11} & Q_{12} \\ Q_{21} & Q_{22}\end{bmatrix} \begin{bmatrix} Q_{11}\sigma_{x}+Q_{12}\tau_{xy} & Q_{21}\sigma_{x}+Q_{22}\tau_{xy} \\ Q_{11}\tau_{xy}+Q_{12}\sigma_{y} & Q_{21}\tau_{xy}+Q_{22}\sigma_{y} \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \begin{bmatrix} \sigma_{x'} & \tau_{x'y'} \\ \tau_{x'y'} & \sigma_{y'} \end{bmatrix} = \begin{bmatrix} Q_{11}^2\sigma_{x}+2Q_{11}Q_{12}\tau_{xy}+Q_{12}^2\sigma_{y} & Q_{11}Q_{12}\sigma_{x}+(Q_{11}Q_{22}+Q_{12}Q_{21})\tau_{xy}+Q_{12}Q_{22}\sigma_{y} \\ Q_{11}Q_{12}\sigma_{x}+(Q_{11}Q_{22}+Q_{12}Q_{21})\tau_{xy}+Q_{12}Q_{22}\sigma_{y} & Q_{21}^2\sigma_{x}+2Q_{21}Q_{22}\tau_{xy}+Q_{22}^2\sigma_{y} \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Equating the values in the right matrix with the new forms of (7.5), (2), and (7.6) gives


 * {| style="width:100%" border="0"

$$ \sigma_xcos^2{\theta}+\sigma_ysin^2{\theta}+2\tau_{xy}sin{\theta}cos{\theta}=Q_{11}^2\sigma_{x}+2Q_{11}Q_{12}\tau_{xy}+Q_{12}^2\sigma_{y} $$     (8)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }


 * {| style="width:100%" border="0"

$$ \sigma_xsin^2{\theta}+\sigma_ycos^2{\theta}-2\tau_{xy}sin{\theta}cos{\theta}=Q_{21}^2\sigma_{x}+2Q_{21}Q_{22}\tau_{xy}+Q_{22}^2\sigma_{y} $$     (9)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }


 * {| style="width:100%" border="0"

$$ -\sigma_xsin{\theta}cos{\theta}+\sigma_ysin{\theta}cos{\theta}+\tau_{xy}(cos^2{\theta}-sin^2{\theta})=Q_{11}Q_{12}\sigma_{x}+(Q_{11}Q_{22}+Q_{12}Q_{21})\tau_{xy}+Q_{12}Q_{22}\sigma_{y} $$     (10)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }

From (10), we can deduce that $$Q_{11}=Q_{22}=cos{\theta}$$ and that $$Q_{12}$$ and $$Q_{21}$$ are both sin{\theta}, with one of them being negative.

We can then deduce from (9) that $$Q_{21}$$ has to be negative to account for the negative sign in front of the third coefficient on the left side of the equation. Therefore, $$Q_{12}=sin{\theta}$$

We can now form the matrix $$\mathbf Q$$:


 * {| style="width:100%" border="0"

$$ \mathbf Q=\begin{bmatrix}cos{\theta} & sin{\theta} \\ -sin{\theta} & cos{\theta}\end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Rewriting (7) gives the matrix form of the stresses:


 * {| style="width:100%" border="0"

$$ \begin{bmatrix} \sigma_{x'} & \tau_{x'y'} \\ \tau_{x'y'} & \sigma_{y'} \end{bmatrix} = \begin{bmatrix}cos{\theta} & sin{\theta} \\ -sin{\theta} & cos{\theta}\end{bmatrix} \begin{bmatrix} \sigma_{x} & \tau_{xy} \\ \tau_{xy} & \sigma_{y} \end{bmatrix} \begin{bmatrix}cos{\theta} & -sin{\theta} \\ sin{\theta} & cos{\theta}\end{bmatrix} $$     (7)
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

We know from the GEP that transforming the stiffness matrix $$\mathbf K$$ from the old coordinate system to the new coordinate system is done by
 * {| style="width:100%" border="0"

$$ \overline{\mathbf K}=\begin{bmatrix}\bar{\boldsymbol \phi}_1 \ \bar{\boldsymbol \phi}_2 \end{bmatrix}^T \mathbf K \begin{bmatrix}\bar{\boldsymbol \phi}_1 \ \bar{\boldsymbol \phi}_2\end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

This method is essentially the same to (7), where $$\mathbf Q^T$$ is the matrix of eigenvectors and the stiffness matrix is the stress matrix.

Part 3
From (7.14),


 * {| style="width:100%" border="0"

$$ \sigma_{max, min}=\frac{\sigma_x+\sigma_y}{2} \pm \sqrt{\left( \frac{\sigma_x-\sigma_y}{2}\right)^2 + \tau_{xy}^2} $$     (7.14)
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

From (7.12),


 * {| style="width:100%" border="0"

$$ \tan{2\theta_p}=\frac{2\tau_{xy}}{\sigma_x-\sigma_y} $$     (7.12)
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

Part 3a
The Standard Eigenvalue Problem (SEP) is


 * {| style="width:100%" border="0"

$$ \mathbf K \boldsymbol \phi = \beta \mathbf I \boldsymbol \phi $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

where $$\mathbf K$$ is the matrix being transformed by the eigenvector (in this case, the stress matrix),

$$\boldsymbol \phi$$ is the eigenvector (in this case, the first or second column of $$\mathbf Q^T$$), and $$\beta$$

is the eigenvalue corresponding to the eigenvector. $$\mathbf I$$ is the identity matrix, standing in for the mass matrix for the SEP.

To solve the SEP, we first need to find the two eigenvalues. This is done by solving the equation


 * {| style="width:100%" border="0"

$$ \begin{vmatrix} \mathbf K - \beta \mathbf I \end{vmatrix}=0 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

As a reminder from Part 2,


 * {| style="width:100%" border="0"

$$ \mathbf K = \begin{bmatrix} \sigma_{x} & \tau_{xy} \\ \tau_{xy} & \sigma_{y} \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \mathbf Q^T=\boldsymbol \Phi=\begin{bmatrix}cos{\theta} & -sin{\theta} \\ sin{\theta} & cos{\theta}\end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Now we solve for the eigenvalues.


 * {| style="width:100%" border="0"

$$ \begin{vmatrix} \sigma_x-\beta & \tau_{xy} \\ \tau_{xy} & \sigma_y-\beta \end{vmatrix}=0 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \left( \sigma_x-\beta \right) \left( \sigma_y-\beta \right) - \tau_{xy}^2=0 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \sigma_x \sigma_y - \left( \sigma_x + \sigma_y \right) \beta + \beta^2 - \tau_{xy}^2=0 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \beta^2 - \left( \sigma_x + \sigma_y \right) \beta + \left( \sigma_x \sigma_y - \tau_{xy}^2 \right)=0 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \beta=\frac{\left( \sigma_x + \sigma_y \right) \pm \sqrt{\left( \sigma_x + \sigma_y \right)^2 - 4\left( \sigma_x \sigma_y - \tau_{xy}^2 \right)}}{2} $$     (8)
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

(8) can be simplified as follows:


 * {| style="width:100%" border="0"

$$ \beta=\frac{\sigma_x+\sigma_y}{2} \pm \sqrt{\left( \frac{\sigma_x + \sigma_y}{2} \right)^2 - \sigma_x \sigma_y + \tau_{xy}^2} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \beta=\frac{\sigma_x+\sigma_y}{2} \pm \sqrt{\frac{\sigma_x^2}{4} + \frac{\sigma_x \sigma_y}{2} + \frac{\sigma_y^2}{4} - \sigma_x \sigma_y + \tau_{xy}^2} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \beta=\frac{\sigma_x+\sigma_y}{2} \pm \sqrt{\frac{\sigma_x^2}{4} - \frac{\sigma_x \sigma_y}{2} + \frac{\sigma_y^2}{4} + \tau_{xy}^2} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \beta=\frac{\sigma_x+\sigma_y}{2} \pm \sqrt{\left( \frac{\sigma_x - \sigma_y}{2} \right)^2 + \tau_{xy}^2} $$     (9)
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

It can be seen that (9) is the same as (7.14). So, the maximum and minimum stresses are the eigenvalues of the stress matrix.

Part 3b
Now that we know the eigenvalues, we can solve for the eigenvectors in terms of $$\sigma_x$$, $$\sigma_y$$, and $$\tau_{xy}$$.

We are solving for the first eigenvector using the first eigenvalue. While either coefficient in the eigenvectors can be set to any value, the first coefficient is being set to 1 because it will make proving (7.12) easier.

We know from Part 2 that the first eigenvector is $$\begin{bmatrix}\cos{\theta} \\ \sin{\theta} \end{bmatrix}$$

If we solve for $$\phi_{12}$$ when $$\phi_{11}=1$$, then we are solving for $$\tan{\theta}$$, because we divide the first eigenvector by $$\cos{\theta}$$. This is beneficial to us because we want to find $$\tan{2\theta}$$, as (7.12) has. From trigonometry, we know that


 * {| style="width:100%" border="0"

$$ \tan{2\theta}=\frac{2\sin{\theta}\cos{\theta}}{\cos^2{\theta}-\sin^2{\theta}} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Which, knowing the definition of the tangent function, can be rewritten as


 * {| style="width:100%" border="0"

$$ \tan{2\theta}=\frac{2\cos^2{\theta}\tan{\theta}}{\cos^2{\theta}\left(1-\tan^2{\theta}\right)} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \tan{2\theta}=\frac{2\tan{\theta}}{1-\tan^2{\theta}} $$     (10)
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

So, if we know what $$\tan{\theta}$$ is, we can calculate what $$\tan{2\theta}$$ is.


 * {| style="width:100%" border="0"

$$ \begin{bmatrix} \sigma_{x} & \tau_{xy} \\ \tau_{xy} & \sigma_{y} \end{bmatrix} \begin{bmatrix} 1 \\ \tan{\theta} \end{bmatrix} = \left(\frac{\sigma_x+\sigma_y}{2} - \sqrt{\left( \frac{\sigma_x - \sigma_y}{2} \right)^2 + \tau_{xy}^2}\right) \begin{bmatrix} 1 \\ \tan{\theta} \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \sigma_{x}+\tau_{xy}\tan{\theta}=\frac{\sigma_x+\sigma_y}{2} - \sqrt{\left( \frac{\sigma_x - \sigma_y}{2} \right)^2 + \tau_{xy}^2} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \tau_{xy}\tan{\theta}=\frac{\sigma_y-\sigma_x}{2} - \sqrt{\left( \frac{\sigma_x - \sigma_y}{2} \right)^2 + \tau_{xy}^2} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \tan{\theta}=\frac{\sigma_y-\sigma_x}{2\tau_{xy}} - \sqrt{\left( \frac{\sigma_x - \sigma_y}{2\tau_{xy}} \right)^2 + 1} $$     (11)
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

Now that we know $$\tan{\theta}$$ from (11), we can calculate $$\tan{2\theta}$$ from (10). We used Wolfram Alpha to simplify this process. Here is a link to the page. On the page, x represents $$\sigma_x$$, y represents $$\sigma_y$$, and z represents $$\tau_{xy}$$.

The first "alternate form" shown by Wolfram Alpha is


 * {| style="width:100%" border="0"

$$ \tan{2\theta}=\frac{2\tau_{xy}}{\sigma_x-\sigma_y} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Which is the same as (7.12). What this tells us is that the principal stresses, the values in the transformed stress matrix, act along the angle $$\theta$$ given by (7.12), the eigendirection.

Problem Statement
For the following L2-ODE-CC


 * {| style="width:100%" border="0"

$$ y'' + \frac23 y' + \frac{37}{9} y = r(x) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

with excitation close to the damped circular frequency:


 * {| style="width:100%" border="0"

$$ r(x) = e^{-x/4} \cos 2.1 x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

and initial conditions


 * {| style="width:100%" border="0"

$$ y(0) = 1, \ y'(0) = 0 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

1. Identify the damped circular frequency.

2. Plot separately (1) the homogeneous solution, (2) the particular solution and the excitation, (3) the total / complete solution, and

(4) a combined plot of complete solution, homogeneous solution, and particular solution. discuss the long-term behavior of the

homogeneous (transient) solution versus the particular (steady-state) solution. pay particular attention to the amplitude

of vibration as the excitation frequency is close to the system natural frequency. compare the results to those in R4.1.

3. Provide a quantitative and a qualitative (graphic) verification of the above results: solution satisfies the initial conditions, and solution satisfies the L2-ODE-CC.

Part 1

 * {| style="width:100%" border="0"

$$ y'' + \frac23 y' + \frac{37}{9} y = 1.5 + e^cos2.1x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Can break solution into homogeneous and particular solutions.


 * {| style="width:100%" border="0"

$$ y = y_h + y_p $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

To find homogeneous solution we must assume a trial solution that takes the form


 * {| style="width:100%" border="0"

$$ y_h= e^{\lambda t} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

with derivatives


 * {| style="width:100%" border="0"

$$ y_h'= \lambda e^{\lambda t} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ y_h''= \lambda^2 e^{\lambda t} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

plugging in


 * {| style="width:100%" border="0"

$$ (\lambda^2 + \frac{2}{3} \lambda + \frac{37}{9})e^{\lambda t} = 0 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

since $$ e^{\lambda t} $$ cannot be zero we retrieve following relation.


 * {| style="width:100%" border="0"

$$ \lambda^2 + \frac23 \lambda + \frac{37}{9}= 0 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Seeing that


 * {| style="width:100%" border="0"

$$ \Delta=\frac23^2-4(\frac{37}{9})=-\frac{80}{30} < 0 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

therefore there must be two complex conjugate roots


 * {| style="width:100%" border="0"

$$ \lambda_{1} = -\frac13 - i 2 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \lambda_{2} = -\frac13 + i 2 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

and the damped circular frequency $$ \tilde \omega = 2 $$.

Part 2
Continuing on from part 1 the homogeneous solution will then take the form


 * {| style="width:100%" border="0"

$$ y_h= e^(Acos(2t)+Bsin(2t)) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

where A and B are undetermined coefficients to be found by solving

the full solution IVP.

Now we must find the particular solution. We begin by noting that the excitation r(x) can be resolved as the

linear combination of two independent excitations. Therefore we can find two particular solutions $$ y_{p_1}, y_{p_2} $$

and using the sum rule for particular solutions add together the two determined particular solutions to get the actual

particular solution.


 * {| style="width:100%" border="0"

$$ y_p= y_{p_1} + y_{p_2} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

To determine the first particular solution $$ y_{p_1} $$ we look at the following L2-ODE-CC:


 * {| style="width:100%" border="0"

$$ y'' + \frac23 y' + \frac{37}{9} y = 1.5 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

we know that the choice of particular solution must satisfy this ODE therefore


 * {| style="width:100%" border="0"

$$ y_{p_1}'' + \frac23 y_{p_1}' + \frac{37}{9} y_{p_1} = 1.5 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

guessing a particular solution of the form


 * {| style="width:100%" border="0"

$$ y_{p_1} = A $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

therefore


 * {| style="width:100%" border="0"

$$ y_{p_1}' = y_{p_1}''=0 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

thus plugging back in to the ODE we get the relation


 * {| style="width:100%" border="0"

$$ \frac{37}{9} A = 1.5 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

thus


 * {| style="width:100%" border="0"

$$ y_{p_1}= A = 0.364865 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

To determine the first particular solution $$ y_{p_2} $$ we look at the following L2-ODE-CC:


 * {| style="width:100%" border="0"

$$ y'' + \frac23 y' + \frac{37}{9} y = e^{-x/4}cos 2.1 x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

we know that the choice of particular solution must satisfy this ODE therefore


 * {| style="width:100%" border="0"

$$ y_{p_2}'' + \frac23 y_{p_2}' + \frac{37}{9} y_{p_2} = e^{-x/4}cos 2.1 x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

guessing a particular solution in the form of


 * {| style="width:100%" border="0"

$$ y_{p_2}=e^{-x/4}(Mcos2.1x + Nsin2.1x) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Take the first derivative of the particular solution


 * {| style="width:100%" border="0"

$$ y_{p_2}'= e^((-2.1M - \frac{1}{4}N)sin2.1x + (2.1N - \frac{1}{4}M)cos2.1x) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Take the Second Derivative of the particular solution
 * {| style="width:100%" border="0"

$$ y_{p_2}'' = e^{-x/4} ((1.05 M-4.3475 N) sin(2.1 x)+(-4.3475 M-1.05 N) cos(2.1 x)) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Therefore,


 * {| style="width:100%" border="0"

$$ e^{-x/4} ((1.05 M-4.3475 N) sin(2.1 x)+(-4.3475 M-1.05 N) cos(2.1 x)) + (\frac{2}{3})(e^((-2.1M - \frac{1}{4}N)sin2.1x + (2.1N - \frac{1}{4}M)cos2.1x)) + (\frac{37}{9})(e^{-x/4}(Mcos2.1x + Nsin2.1x))=e^{-x/4}cos 2.1 x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Rearrange Equation
 * {| style="width:100%" border="0"

$$ (e^{-\frac{x}{4}}((-0.35M-0.402556N)sin2.1x + (1.16361M + 0.35N)cos2.1x)=e^{-x/4}cos 2.1 x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

equating coefficients for two trigonometric functions we retrieve 2 equations which allow us to solve

for the two unknowns M and N.


 * {| style="width:100%" border="0"

$$ -0.35M-0.402556N=0 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ 1.16361M+0.35N=0 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

solving the system of equations we find that


 * {| style="width:100%" border="0"

$$ N= -1.0118 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ M= 1.16373 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ y_{p_2}=e^{-x/4}(1.16373cos2.1x -1.0118sin2.1x) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

combining the two particular solutions to get the total particular solution.


 * {| style="width:100%" border="0"

$$ y_{p}= y_{p_1}+y_{p_2}=e^{-x/4}(1.16373cos2.1x -1.0118sin2.1x) + 0.364865 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

the full solution which is a sum of the two linearly independent homogeneous and particular solutions

takes the form


 * {| style="width:100%" border="0"

$$ y= e^(Acos(2x)+Bsin(2x)) + e^{-x/4}(1.16373cos2.1x -1.0118sin2.1x) + 0.364865 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

to recover undetermined coefficients A and B we must utilize our given initial conditions.

taking the derivative of our solution


 * {| style="width:100%" border="0"

$$ y= e^(Acos(2x)+Bsin(2x)) + e^{-x/4}(1.16373cos2.1x -1.0118sin2.1x) + 0.364865 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ y'= e^{-x/3} ((2 B-0.3333 A) cos(2 x)-4 A sin(x) cos(x)-0.6667 B sin(x) cos(x)-2.19088 e^{x/12} sin(2.1 x)-2.41571 e^{x/12} cos(2.1 x)) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

therefore with initial conditions


 * {| style="width:100%" border="0"

$$ y(0)=1=A+1.16373+0.364865 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ y'(0)=0=2B-0.3333A-2.41571 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

therefore


 * {| style="width:100%" border="0"

$$ A = -0.528595 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ B = 1.11976 $$ Therefore the final solution becomes
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ y= e^(-0.528595cos(2x)+1.11976sin(2x)) + e^{-x/4}(1.16373cos2.1x + -1.0118sin2.1x) + 0.364865 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Plot of the homogeneous solution can be seen below:



The homogeneous solution represents the transient solution in that at time equal to zero it starts at a high amplitude and attenuates at a

rate of $$ e^{-0.3333x} $$ to zero as time goes to infinity.

Plot of the particular solution:



The particular solution takes similar form as the homogeneous solution but it attenuates $$ e^{-0.25x} $$ and as time goes to infinity

the particular solution settles to a value of 0.364865

Plot of the full solution:



Plot of the homogeneous, particular, and full solution:



From the principle of superposition of the particular and homogeneous solutions which combine to

generate the total solution, the total solution should inherent properties of both the homogeneous and

particular solutions. It can be seen that the total solution attenuates at a faster rate then

both the homogeneous solution and particular solution. As time goes to infinity the total solution

approaches the value of 0.364865. The total solution for this problem attenuates at a much faster

rate as compared to Report problem 1. This can be attributed to the form taken by the particular solution.

Further this solution has a non-zero steady state value unlike in problem 1.

Part 3
Checking if the retrieved solution indeed satisfies the L2-ODE-CC we plug the solution back into the ODE.


 * {| style="width:100%" border="0"

$$ y'= e^{-x/3} (-2.19088 e^{x/12} sin(2.1 x)+2.41572 cos(2 x)-2.41571 e^{x/12} cos(2.1 x)+1.36787 sin(x) cos(x)) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

y''= e^{-x/3} ((0.56263-4.85723x10^-17 i) cos(2 x)+5.62071 e^{x/12} sin(2.1 x)-3.99692 e^{x/12} cos(2.1 x)-10.1188 sin(x) cos(x))

$$
 * }
 * }

plugging solution into ODE and using Wolfram Alpha to find and check if indeed the answer to the left hand of the

ODE is equal to given excitation


 * {| style="width:100%" border="0"

$$ y'' + \frac23 y' + \frac{37}{9} y= 1.5 + e^cos2.1x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

which it is.

plotting the full solution to check that the initial conditions are fulfilled.



it can be seen that at a x location of 0 the function holds a value of one. Also it can be seen at

an x location of 0 the derivative of the function is 0.

Problem Statement
Find the projections (approximations) of each the functions below, defined on the interval [0,1], onto the polynomial basis


 * {| style="width:100%" border="0"

$$ \{ 1, x, x^2, ...., x^n \} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

for different values of n; here n = 2, 4, 6.

for each of the functions below, plot the exact function and its approximations.

1. Exponential function: $$ e^x = \exp(x) $$ use integration by parts, and verify your results with Wolfram integrator; provide links to your Wolfram integrator results.

2. Same as in Question 1, but with the sine function: sin x

3. Same as in Question 1, but the logarithm function : log(1+x). try to integrate with integration by parts first, and and point out the difficulty in your report.

when you come to a deadend with integration by parts, use numerical integration with with both GNU Octave / matlab commands trapz

and quad to verify, and verify again with Wolfram integrator, as mentioned above.

Solution
General approximation projected on the polynomial basis:
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

f(x) \approx \sum_{j=1}^n c_j b_j(x) = c_o + c_1x + c_2x^2 +...+c_nx^n $$ find c_j using Gram matrix as with vectors
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\{ b_i(x), \, i=1,...n \} $$ to obtain
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\sum_{j=1}^n c_j \langle b_i, b_j \rangle = \langle b_i , f \rangle , \ i=1,...,n $$ Gram matrix:
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\Gamma (\{ b_i \}) = \begin{bmatrix} \langle b_1, b_1 \rangle & ... & \langle b_1, b_n \rangle \\

\vdots & \vdots & \vdots \\ \langle b_n, b_1 \rangle & ... & \langle b_n, b_n \rangle \end{bmatrix} $$
 * }
 * }

Unknown coefficients that need to be solve:
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\mathbf c = \lfloor c_1, ... , c_n \rfloor^T $$ Known components
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\mathbf d = \lfloor \langle b_1, f \rangle , ... , \langle b_n, f \rangle \rfloor^T = \lfloor d_1 , ..., d_n \rfloor^T $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\boldsymbol \Gamma \mathbf c = \mathbf d $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\Gamma \ne 0 \Rightarrow \boldsymbol \Gamma^{-1} \text{ exists} \Rightarrow \mathbf c = \boldsymbol \Gamma^{-1} \mathbf d $$ (1)
 * <p style="text-align:right">
 * }

Question 1

 * {| style="width:100%" border="0"

$$ f(x)=e^x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

n=2
The basis is


 * {| style="width:100%" border="0"

$$ \{ 1, x, x^2 \} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

so the function f(x) can be approximated as


 * {| style="width:100%" border="0"

$$ f(x) \approx c_0b_0+c_1b_1+c_2b_2=c_0+c_1x+c_2x^2 $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

Now, determine the known computable right hand side:
 * {| style="width:100%" border="0"

$$ \mathbf d = \begin{bmatrix} \langle x^0,e^x \rangle \\ \langle x^1,e^x \rangle\\ \langle x^2,e^x \rangle \end{bmatrix} = \begin{bmatrix} \int_{0}^{1} e^x dx \\ \int_{0}^{1} xe^x dx \\ \int_{0}^{1} x^2e^x dx  \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

We will need to employ the method of integration by parts to determine the matrix, d.


 * {| style="width:100%" border="0"

$$ d_0 =\langle x^0,e^x \rangle= \int_{0}^{1} e^x dx = e^x|_{0}^{1} = e-1 = 1.718 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

http://integrals.wolfram.com/index.jsp?expr=e%5Ex&random=false


 * {| style="width:100%" border="0"

$$ d_1 = \langle x^1,e^x \rangle=\int_{0}^{1} xe^x dx = xe^x-1\int_{0}^{1} e^x dx= xe^x-e^x|_{0}^{1} = (e-e)-(-1) = 1 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

http://integrals.wolfram.com/index.jsp?expr=x*e%5Ex&random=false


 * {| style="width:100%" border="0"

$$ d_2 =\langle x^2,e^x \rangle= \int_{0}^{1} x^2e^x dx = x^2e^x-2\int_{0}^{1} xe^x dx = x^2e^x-2xe^x+2e^x|_{0}^{1} = (e-2e+2e)-(0-0+2) = e-2= 0.718 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

http://integrals.wolfram.com/index.jsp?expr=x%5E2*e%5Ex&random=false


 * {| style="width:100%" border="0"

$$ \mathbf d=\begin{bmatrix} 1.718 \\ 1 \\ 0.718 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Now, we must compute the Gram matrix (as Hilbert matrix) of the order 3.

Understanding that...


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\Gamma (\{ b_i \}) = \begin{bmatrix} \langle b_1, b_1 \rangle & ... & \langle b_1, b_n \rangle \\

\vdots & \vdots & \vdots \\ \langle b_n, b_1 \rangle & ... & \langle b_n, b_n \rangle \end{bmatrix} =

\begin{bmatrix} \int_{0}^{1} 1 dx & ... & \int_{0}^{1} x^2 dx \rangle \\

\vdots & \vdots & \vdots \\ \int_{0}^{1} x^2 dx \rangle & ... & \int_{0}^{1} x^4 dx \rangle \end{bmatrix} $$
 * }
 * }

We can use the Matlab function: hilb(3) to determine the Hilbert matrix of order 3.


 * {| style="width:100%" border="0"

$$ \boldsymbol \Gamma = \begin{bmatrix}1 & \frac{1}{2} & \frac{1}{3} \\ \frac{1}{2} & \frac{1}{3} & \frac{1}{4} \\ \frac{1}{3} & \frac{1}{4} & \frac{1}{5}\end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Then, using Matlab again, we solve for the inverse of the Hilbert matrix


 * {| style="width:100%" border="0"

$$ \boldsymbol \Gamma^{-1} = \begin{bmatrix}9 & -36 & 30 \\ -36 & 192 & -180 \\ 30 & -180 & 180\end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Now that we have all our knowns solved for, we can solve for c.


 * {| style="width:100%" border="0"

$$ \boldsymbol c = \begin{bmatrix} c_0\\c_1\\c_2 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Using the relationship (1)
 * {| style="width:100%" border="0"

$$ \mathbf c= \boldsymbol \Gamma^{-1} \mathbf d $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Performing matrix multiplication in Matlab...
 * {| style="width:100%" border="0"

$$ \mathbf c= \begin{bmatrix}9 & -36 & 30 \\ -36 & 192 & -180 \\ 30 & -180 & 180\end{bmatrix} \begin{bmatrix} 1.718 \\ 1 \\ 0.718 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \mathbf c \approx \begin{bmatrix} 1.0130 \\ 0.8511 \\ 0.8392 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Therefore, the function can be approximated by:


 * {| style="width:100%" border="0"

$$ e^x \approx 1.0130+0.8511x+0.8392x^2 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Plotting:



n=4
The basis is


 * {| style="width:100%" border="0"

$$ \{ 1, x, x^2,x^3, x^4 \} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

so the function f(x) can be approximated as


 * {| style="width:100%" border="0"

$$ f(x) \approx c_0b_0+c_1b_1+c_2b_2+c_3b_3+c_4b_4=c_0+c_1x+c_2x^2+c_3x^3+c_4x^4 $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

Now, determine the known computable right hand side:
 * {| style="width:100%" border="0"

$$ \mathbf d = \begin{bmatrix} \langle x^0,e^x \rangle \\ \langle x^1,e^x \rangle\\ \langle x^2,e^x \rangle \\ \langle x^3,e^x \rangle \\ \langle x^4,e^x \rangle \end{bmatrix} = \begin{bmatrix} \int_{0}^{1} e^x dx \\ \int_{0}^{1} xe^x dx \\ \int_{0}^{1} x^2e^x dx  \\ \int_{0}^{1} x^3e^x dx \\ \int_{0}^{1} x^4e^x dx  \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

We will need to employ the method of integration by parts to determine the matrix, d. We already solved for the first 3 terms, the next two are solved for below:


 * {| style="width:100%" border="0"

$$ d_3 = \int_{0}^{1} x^3e^x dx = x^3e^x-3 \int_{0}^{1} x^2e^x dx= x^3e^x-3x^2e^x+6xe^x-6e^x|_{0}^{1} = (e-3e+6e-6e)-(0-0+0-6) = 6-2e = 0.563 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

http://integrals.wolfram.com/index.jsp?expr=x%5E3*e%5Ex&random=false


 * {| style="width:100%" border="0"

$$ d_4 = \int_{0}^{1} x^4e^x dx = x^4e^x -4\int_{0}^{1} x^3e^x dx= x^4e^x -4x^3e^x+12x^2e^x-24xe^x+24e^x = (e-4e+12e-24e+24e)-(0-0+0-0+24) = 9e-24= 0.465 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

http://integrals.wolfram.com/index.jsp?expr=x%5E4*e%5Ex&random=false


 * {| style="width:100%" border="0"

$$ \mathbf d=\begin{bmatrix} 1.718 \\ 1 \\ 0.718 \\ 0.563 \\ 0.465 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Now, we must compute the Gram matrix (as Hilbert matrix) of the order 5.

Understanding that...


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\Gamma (\{ b_i \}) = \begin{bmatrix} \langle b_1, b_1 \rangle & ... & \langle b_1, b_n \rangle \\

\vdots & \vdots & \vdots \\ \langle b_n, b_1 \rangle & ... & \langle b_n, b_n \rangle \end{bmatrix} =

\begin{bmatrix} \int_{0}^{1} 1 dx & ... & \int_{0}^{1} x^4 dx \rangle \\

\vdots & \vdots & \vdots \\ \int_{0}^{1} x^4 dx \rangle & ... & \int_{0}^{1} x^8 dx \rangle \end{bmatrix} $$
 * }
 * }

We can use the Matlab function: hilb(5) to determine the Hilbert matrix of order 5.


 * {| style="width:100%" border="0"

$$ \boldsymbol \Gamma = \begin{bmatrix}1 & \frac{1}{2} & \frac{1}{3} & \frac{1}{4} & \frac{1}{5} \\ \frac{1}{2} & \frac{1}{3} & \frac{1}{4} & \frac{1}{5} & \frac{1}{6}\\ \frac{1}{3} & \frac{1}{4} & \frac{1}{5} & \frac{1}{6} & \frac{1}{7} \\ \frac{1}{3} & \frac{1}{4} & \frac{1}{5} & \frac{1}{6} & \frac{1}{7} \\ \frac{1}{4} & \frac{1}{5} & \frac{1}{5} & \frac{1}{7} & \frac{1}{8} \\ \frac{1}{5} & \frac{1}{6} & \frac{1}{7} & \frac{1}{8} & \frac{1}{9}\end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Then, using Matlab again, we solve for the inverse of the Hilbert matrix


 * {| style="width:100%" border="0"

$$ \boldsymbol \Gamma^{-1} = 10^5 \begin{bmatrix} 0.0002 & -0.0030 &   0.0105  & -0.0140 &   0.0063\\ -0.0030 &  0.0480  & -0.1890 &   0.2688  & -0.1260\\    0.0105  & -0.1890  &  0.7938  & -1.1760  &  0.5670\\   -0.0140 &   0.2688  & -1.1760  &  1.7920 &  -0.8820\\    0.0063  & -0.1260  &  0.5670  & -0.8820  &  0.4410 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Now that we have all our knowns solved for, we can solve for c.


 * {| style="width:100%" border="0"

$$ \boldsymbol c = \begin{bmatrix} c_0\\c_1\\c_2 \\c_3\\c_4\end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Using the relationship (1)
 * {| style="width:100%" border="0"

$$ \mathbf c= \boldsymbol \Gamma^{-1} \mathbf d $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Performing matrix multiplication in Matlab...
 * {| style="width:100%" border="0"

$$ \mathbf c= 10^5 \begin{bmatrix} 0.0002 & -0.0030 &   0.0105  & -0.0140 &   0.0063\\ -0.0030 &  0.0480  & -0.1890 &   0.2688  & -0.1260\\    0.0105  & -0.1890  &  0.7938  & -1.1760  &  0.5670\\   -0.0140 &   0.2688  & -1.1760  &  1.7920 &  -0.8820\\    0.0063  & -0.1260  &  0.5670  & -0.8820  &  0.4410 \end{bmatrix} \begin{bmatrix} 1.718 \\ 1 \\ 0.718 \\ 0.563 \\ 0.465 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \mathbf c \approx \begin{bmatrix} 1.0001\\   0.9984\\    0.5106\\    0.1397\\    0.0695 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Therefore, the function can be approximated by:


 * {| style="width:100%" border="0"

$$ e^x \approx 1.0001+0.9984x+0.5106x^2+0.1397x^3+0.0695x^4 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Plotting:

n=6
The basis is


 * {| style="width:100%" border="0"

$$ \{ 1, x, x^2,x^3, x^4, x^5, x^6 \} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

so the function f(x) can be approximated as


 * {| style="width:100%" border="0"

$$ f(x) \approx c_0b_0+c_1b_1+c_2b_2+c_3b_3+c_4b_4+c_5b_5+c_6b_6=c_0+c_1x+c_2x^2+c_3x^3+c_4x^4+c_5x^5+c_6x^6 $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

Now, determine the known computable right hand side:
 * {| style="width:100%" border="0"

$$ \mathbf d = \begin{bmatrix} \langle x^0,e^x \rangle \\ \langle x^1,e^x \rangle\\ \langle x^2,e^x \rangle \\ \langle x^3,e^x \rangle \\ \langle x^4,e^x \rangle \\ \langle x^5,e^x \rangle \\ \langle x^6,e^x \rangle\end{bmatrix}=\begin{bmatrix} \int_{0}^{1} e^x dx \\ \int_{0}^{1} xe^x dx \\ \int_{0}^{1} x^2e^x dx  \\ \int_{0}^{1} x^3e^x dx \\ \int_{0}^{1} x^4e^x dx \\ \int_{0}^{1} x^5e^x dx \\ \int_{0}^{1} x^6e^x dx \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

We will need to employ the method of successive integration by parts to determine the matrix, d. We already solved for the first 5 terms, the next two are solved for below:


 * {| style="width:100%" border="0"

$$ d_5 = \int_{0}^{1} x^5e^x dx = x^5e^x - 5x^4e^4 +20x^3e^x-60x^2e^x+120xe^x-120e^x= 120-44e=0.396 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

http://integrals.wolfram.com/index.jsp?expr=x%5E5*e%5Ex&random=false


 * {| style="width:100%" border="0"

$$ d_6 = \int_{0}^{1} x^6e^x dx = x^6e^6 -6x^5e^x +30x^4e^4 - 120x^3e^x + 360x^2e^x - 720xe^x +720e^x = 265e-720=0.345 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

http://integrals.wolfram.com/index.jsp?expr=x%5E6*e%5Ex&random=false


 * {| style="width:100%" border="0"

$$ \mathbf d=\begin{bmatrix} 1.718 \\ 1 \\ 0.718 \\ 0.563 \\ 0.465 \\ 0.396 \\0.345 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Now, we must compute the Gram matrix (as Hilbert matrix) of the order 7.

Understanding that...


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\Gamma (\{ b_i \}) = \begin{bmatrix} \langle b_1, b_1 \rangle & ... & \langle b_1, b_n \rangle \\

\vdots & \vdots & \vdots \\ \langle b_n, b_1 \rangle & ... & \langle b_n, b_n \rangle \end{bmatrix} =

\begin{bmatrix} \int_{0}^{1} 1 dx & ... & \int_{0}^{1} x^6 dx \rangle \\

\vdots & \vdots & \vdots \\ \int_{0}^{1} x^6 dx \rangle & ... & \int_{0}^{1} x^{12} dx \rangle \end{bmatrix} $$
 * }
 * }

We can use the Matlab function: hilb(7) to determine the Hilbert matrix of order 7.


 * {| style="width:100%" border="0"

$$ \boldsymbol \Gamma = \begin{bmatrix}1 & \frac{1}{2} & \frac{1}{3} & \frac{1}{4} & \frac{1}{5} &\frac{1}{6} &\frac{1}{7}\\ \frac{1}{2} & \frac{1}{3} & \frac{1}{4} & \frac{1}{5} & \frac{1}{6} &\frac{1}{7} &\frac{1}{8}\\ \frac{1}{3} & \frac{1}{4} & \frac{1}{5} & \frac{1}{6} & \frac{1}{7} &\frac{1}{8} &\frac{1}{9} \\ \frac{1}{4} & \frac{1}{5} & \frac{1}{6} & \frac{1}{7} & \frac{1}{8} &\frac{1}{9} &\frac{1}{10}\\ \frac{1}{5} & \frac{1}{6} & \frac{1}{7} & \frac{1}{8} & \frac{1}{9} &\frac{1}{10} &\frac{1}{11} \\ \frac{1}{6} & \frac{1}{7} & \frac{1}{8} & \frac{1}{9} & \frac{1}{10} &\frac{1}{11} &\frac{1}{12} \\ \frac{1}{7} & \frac{1}{8} & \frac{1}{9} & \frac{1}{10} & \frac{1}{11} &\frac{1}{12} &\frac{1}{13}\end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Then, using Matlab again, we solve for the inverse of the Hilbert matrix


 * {| style="width:100%" border="0"

$$ \boldsymbol \Gamma^{-1} = 10^8 \begin{bmatrix} 0.0000 & -0.0000 &   0.0001 &  -0.0003 &   0.0005 &  -0.0004  &  0.0001\\   -0.0000   & 0.0004  & -0.0032   & 0.0113  & -0.0194   & 0.0160  & -0.0050\\    0.0001  & -0.0032    &0.0286  & -0.1058   & 0.1871  & -0.1572   & 0.0505\\   -0.0003  &  0.0113  & -0.1058   & 0.4032  & -0.7277   & 0.6209  & -0.2018\\    0.0005   &-0.0194   & 0.1871   &-0.7277   & 1.3340   &-1.1526    &0.3784\\   -0.0004   & 0.0160   &-0.1572  &  0.6209  & -1.1526  &  1.0059  & -0.3330\\    0.0001   &-0.0050    &0.0505 &  -0.2018   & 0.3784 &  -0.3330   & 0.1110\\ \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Now that we have all our knowns solved for, we can solve for c.


 * {| style="width:100%" border="0"

$$ \boldsymbol c = \begin{bmatrix} c_0\\c_1\\c_2 \\c_3\\c_4\\c_5\\c_6\end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Using the relationship (1)
 * {| style="width:100%" border="0"

$$ \mathbf c= \boldsymbol \Gamma^{-1} \mathbf d $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Performing matrix multiplication in Matlab...
 * {| style="width:100%" border="0"

$$ \mathbf c= 10^8 \begin{bmatrix} 0.0000 & -0.0000 &   0.0001 &  -0.0003 &   0.0005 &  -0.0004  &  0.0001\\   -0.0000   & 0.0004  & -0.0032   & 0.0113  & -0.0194   & 0.0160  & -0.0050\\    0.0001  & -0.0032    &0.0286  & -0.1058   & 0.1871  & -0.1572   & 0.0505\\   -0.0003  &  0.0113  & -0.1058   & 0.4032  & -0.7277   & 0.6209  & -0.2018\\    0.0005   &-0.0194   & 0.1871   &-0.7277   & 1.3340   &-1.1526    &0.3784\\   -0.0004   & 0.0160   &-0.1572  &  0.6209  & -1.1526  &  1.0059  & -0.3330\\    0.0001   &-0.0050    &0.0505 &  -0.2018   & 0.3784 &  -0.3330   & 0.1110\\ \end{bmatrix}\begin{bmatrix} 1.718 \\ 1 \\ 0.718 \\ 0.563 \\ 0.465 \\ 0.396 \\0.345 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \mathbf c \approx 10^4\begin{bmatrix} 1.0000\\   1.0000\\    0.5001\\    0.1663\\    0.0427\\    0.0069\\    0.0023 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Therefore, the function can be approximated by:


 * {| style="width:100%" border="0"

$$ e^x \approx 1.0000+1.0000x+0.5001x^2+0.1663x^3+0.0427x^4+0.0068x^5 + 0.0023x^6 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Plotting:



Summary
Examining the results of the above approximations, we can see that e^x is best approximated using the polynomial basis on the order of n=4. The comparison the the exact function and its approximations is plotted below:



Question 2

 * {| style="width:100%" border="0"

$$ f(x)=sin(x) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

In order to get the scalar product between $$\sin{x}$$ and the basis functions, we need to use integration by parts. Because the basis functions are in the form $$x^n$$, where $$n \ge 1$$, we can use a general form of the scalar product to make the process simpler.

First, we need to define how to integrate by parts.


 * {| style="width:100%" border="0"

$$ \int u dv=uv-\int v du $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \int_0^1 x^n \sin{x} dx $$ (1)
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

In (1), $$u=x^n$$ and $$dv=\sin{x} dx$$, so $$du=nx^{n-1}dx$$ and $$v=\cos{x}$$. So, (1) can be rewritten as


 * {| style="width:100%" border="0"

$$ \int_0^1 x^n e^x dx= \left( -1^x\cos{1}+0^n\cos{0} \right)-n\int_0^1x^{n-1}\cos{x} dx $$ (1)
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }


 * {| style="width:100%" border="0"

$$ \int_0^1 x^n e^x dx= -\cos{1}-n\int_0^1x^{n-1}\cos{x} dx $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

In order to do the same method as with $$e^x$$, we need to do integration by parts again. $$u=x^{n-1}$$ and $$dv=\cos{x} dx$$, so $$du=(n-1)x^{n-2} dx$$ and $$v=sin{x}$$.


 * {| style="width:100%" border="0"

$$ \int_0^1 x^n e^x dx= -\cos{1}-n \left( 1^{n-1}\sin{1}-0^{n-1}\sin{0} - (n-1)\int_0^1 x^{n-2}\sin{x} dx \right) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \int_0^1 x^n e^x dx= n\sin{1}-\cos{1}-n(n-1)\int_0^1 x^{n-2}\sin{x} dx $$ (2)
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

When $$n \ge 1$$, we can use (2) to quickly get the value of the integral, so we don't have to do integration by parts every time. If $$n=0$$, then we just have to integrate the sine function.


 * {| style="width:100%" border="0"

$$ \langle x^0,\sin{x} \rangle = \langle 1,\sin{x} \rangle = \int_0^1 \sin{x} dx = [-\cos{x}]_0^1=1-\cos{1} $$     (3)
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

http://integrals.wolfram.com/index.jsp?expr=sin%28x%29&random=false


 * {| style="width:100%" border="0"

$$ \langle x,\sin{x} \rangle=\int_0^1 x^1 \sin{x} dx= 1\sin{1}-\cos{1}-1(1-1)\int_0^1 x^{1-2}\sin{x} dx = \sin{1}-\cos{1} $$     (4)
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

http://integrals.wolfram.com/index.jsp?expr=x*sin%28x%29&random=false


 * {| style="width:100%" border="0"

$$ \langle x^2,\sin{x} \rangle=\int_0^1 x^2 \sin{x} dx=2\sin{1}-\cos{1}-2\int_0^1\sin{x} dx= 2\sin{1}-\cos{1}-2+2\cos{1}=2\sin{1}+\cos{1}-2 $$     (5)
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

http://integrals.wolfram.com/index.jsp?expr=x%5E2*sin%28x%29&random=false


 * {| style="width:100%" border="0"

$$ \langle x^3,\sin{x} \rangle=\int_0^1 x^3 \sin{x} dx=3\sin{1}-\cos{1}-6\int_0^1x\sin{x} dx= 3\sin{1}-\cos{1}-6\sin{1}+6\cos{1}=5\cos{1}-3\sin{1} $$     (6)
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

http://integrals.wolfram.com/index.jsp?expr=x%5E3*sin%28x%29&random=false


 * {| style="width:100%" border="0"

$$ \langle x^4,\sin{x} \rangle=\int_0^1 x^4 \sin{x} dx=4\sin{1}-\cos{1}-12\int_0^1x^2\sin{x} dx= 4\sin{1}-\cos{1}-24\sin{1}-12\cos{1}+24=24-13\cos{1}-20\sin{1} $$     (7)
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

http://integrals.wolfram.com/index.jsp?expr=x%5E4*sin%28x%29&random=false


 * {| style="width:100%" border="0"

$$ \langle x^5,\sin{x} \rangle=\int_0^1 x^5 \sin{x} dx=5\sin{1}-\cos{1}-20\int_0^1x^3\sin{x} dx= 5\sin{1}-\cos{1} - 100\cos{1} + 60\sin{1} = 65\sin{1} - 101\cos{1} $$     (8)
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

http://integrals.wolfram.com/index.jsp?expr=x%5E5*sin%28x%29&random=false


 * {| style="width:100%" border="0"

$$ \langle x^6,\sin{x} \rangle=\int_0^1 x^6 \sin{x} dx= 6\sin{1}-\cos{1}-30\int_0^1x^4\sin{x} dx= 6\sin{1}-\cos{1}-720+390\cos{1}+600\sin{1}=389\cos{1}+606\sin{1}-720 $$     (9)
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

http://integrals.wolfram.com/index.jsp?expr=x%5E6*sin%28x%29&random=false

n=2
The basis is


 * {| style="width:100%" border="0"

$$ \{ 1, x, x^2 \} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

so the function f(x) can be approximated as


 * {| style="width:100%" border="0"

$$ f(x) \approx c_0b_0+c_1b_1+c_2b_2=c_0+c_1x+c_2x^2 $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

Using the values solved for above, we can determine the known computable right hand side:
 * {| style="width:100%" border="0"

$$ \mathbf d = \begin{bmatrix} \langle x^0,sinx \rangle \\ \langle x^1,sinx \rangle\\ \langle x^2,sinx \rangle \end{bmatrix} = \begin{bmatrix} 1-cos1\\sin1-cos1\\2sin1+cos1-2 \end{bmatrix} =\begin{bmatrix} 0.4597\\0.30117\\0.22324 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Because we are using the same basis on the same interval, we can use the Hilbert matrix solved for in Question 1 for n=2:


 * {| style="width:100%" border="0"

$$ \boldsymbol \Gamma = \begin{bmatrix}1 & \frac{1}{2} & \frac{1}{3} \\ \frac{1}{2} & \frac{1}{3} & \frac{1}{4} \\ \frac{1}{3} & \frac{1}{4} & \frac{1}{5}\end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \boldsymbol \Gamma^{-1} = \begin{bmatrix}9 & -36 & 30 \\ -36 & 192 & -180 \\ 30 & -180 & 180\end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

We can now solve for the coefficients, c:


 * {| style="width:100%" border="0"

$$ \mathbf c= \boldsymbol \Gamma^{-1} \mathbf d $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \mathbf c= \begin{bmatrix}9 & -36 & 30 \\ -36 & 192 & -180 \\ 30 & -180 & 180\end{bmatrix} \begin{bmatrix} 1-\cos{1} \\ \sin{1}-\cos{1} \\ \cos{1}+2\sin{1}-2 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \mathbf c= \begin{bmatrix} 9-9\cos{1}-36\sin{1}+36\cos{1}+30\cos{1}+60\sin{1}-60 \\ -36+36\cos{1}+192\sin{1}-192\cos{1}-180\cos{1}-360\sin{1}+360 \\ 30-30\cos{1}-180\sin{1}+180\cos{1}+180\cos{1}+360\sin{1}-360 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \mathbf c= \begin{bmatrix} 57\cos{1}+24\sin{1}-51 \\ 324-336\cos{1}-168\sin{1} \\ 330\cos{1}+180\sin{1}-330 \end{bmatrix} \approx \begin{bmatrix} -0.007465 \\ 1.0913 \\ -0.2355 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Therefore, the function can be approximated by:


 * {| style="width:100%" border="0"

$$ \sin{x} \approx -0.007465+1.0913x-0.2355x^2 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }



n=4
The basis is


 * {| style="width:100%" border="0"

$$ \{ 1, x, x^2,x^3, x^4 \} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

so the function f(x) can be approximated as


 * {| style="width:100%" border="0"

$$ f(x) \approx c_0b_0+c_1b_1+c_2b_2+c_3b_3+c_4b_4=c_0+c_1x+c_2x^2+c_3x^3+c_4x^4 $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

Now, determine the known computable right hand side:
 * {| style="width:100%" border="0"

$$ \mathbf d = \begin{bmatrix} \langle x^0,sinx \rangle \\ \langle x^1,sinx \rangle\\ \langle x^2,sinx \rangle \\ \langle x^3,sinx \rangle \\ \langle x^4,sinx \rangle \end{bmatrix} = \begin{bmatrix} 1-cos1\\sin1-cos1\\2sin1+cos1-2\\5cos1-3sin1\\24-13cos1-20sin1 \end{bmatrix} = \begin{bmatrix} 0.4597\\0.30117\\0.22324\\0.17710\\0.14665 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Because we are using the same basis on the same interval, we can use the Hilbert matrix solved for in Question 1 for n=4:


 * {| style="width:100%" border="0"

$$ \boldsymbol \Gamma = \begin{bmatrix}1 & \frac{1}{2} & \frac{1}{3} & \frac{1}{4} & \frac{1}{5} \\ \frac{1}{2} & \frac{1}{3} & \frac{1}{4} & \frac{1}{5} & \frac{1}{6}\\ \frac{1}{3} & \frac{1}{4} & \frac{1}{5} & \frac{1}{6} & \frac{1}{7} \\ \frac{1}{3} & \frac{1}{4} & \frac{1}{5} & \frac{1}{6} & \frac{1}{7} \\ \frac{1}{4} & \frac{1}{5} & \frac{1}{5} & \frac{1}{7} & \frac{1}{8} \\ \frac{1}{5} & \frac{1}{6} & \frac{1}{7} & \frac{1}{8} & \frac{1}{9}\end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \boldsymbol \Gamma^{-1} = 10^5 \begin{bmatrix} 0.0002 & -0.0030 &   0.0105  & -0.0140 &   0.0063\\ -0.0030 &  0.0480  & -0.1890 &   0.2688  & -0.1260\\    0.0105  & -0.1890  &  0.7938  & -1.1760  &  0.5670\\   -0.0140 &   0.2688  & -1.1760  &  1.7920 &  -0.8820\\    0.0063  & -0.1260  &  0.5670  & -0.8820  &  0.4410 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

We can now solve for the coefficients, c:


 * {| style="width:100%" border="0"

$$ \mathbf c= \boldsymbol \Gamma^{-1} \mathbf d $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \mathbf c= 10^5 \begin{bmatrix} 0.0002 & -0.0030 &   0.0105  & -0.0140 &   0.0063\\ -0.0030 &  0.0480  & -0.1890 &   0.2688  & -0.1260\\    0.0105  & -0.1890  &  0.7938  & -1.1760  &  0.5670\\   -0.0140 &   0.2688  & -1.1760  &  1.7920 &  -0.8820\\    0.0063  & -0.1260  &  0.5670  & -0.8820  &  0.4410 \end{bmatrix} \begin{bmatrix} 0.4597\\0.30117\\0.22324\\0.17710\\0.14665 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \boldsymbol c= \begin{bmatrix} 0.0000\\   0.9991\\    0.0063\\   -0.1837\\    0.0198 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Therefore, the function can be approximated as:


 * {| style="width:100%" border="0"

$$ sin(x) \approx 0.9991x +0.0063x^2 - 0.1837x^3 +0.0198x^4 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }



n=6
The basis is


 * {| style="width:100%" border="0"

$$ \{ 1, x, x^2,x^3, x^4, x^5, x^6 \} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

so the function f(x) can be approximated as


 * {| style="width:100%" border="0"

$$ f(x) \approx c_0b_0+c_1b_1+c_2b_2+c_3b_3+c_4b_4+c_5b_5+c_6b_6=c_0+c_1x+c_2x^2+c_3x^3+c_4x^4+c_5x^5+c_6x^6 $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

Now, determine the known computable right hand side:
 * {| style="width:100%" border="0"

$$ \mathbf d = \begin{bmatrix} \langle x^0,sinx \rangle \\ \langle x^1,sinx \rangle\\ \langle x^2,sinx \rangle \\ \langle x^3,sinx \rangle \\ \langle x^4,sinx \rangle \\ \langle x^5,sinx \rangle \\ \langle x^6,sinx \rangle \end{bmatrix} = \begin{bmatrix} 1-cos1\\sin1-cos1\\2sin1+cos1-2\\5cos1-3sin1\\24-13cos1-20sin1\\65sin1-101cos1\\389cos1-606sin1-720 \end{bmatrix} = \begin{bmatrix} 0.4597\\0.30117\\0.22324\\0.17710\\0.14665\\0.12508\\0.10901 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Because we are using the same basis on the same interval, we can use the Hilbert matrix solved for in Question 1 for n=6:


 * {| style="width:100%" border="0"

$$ \boldsymbol \Gamma = \begin{bmatrix}1 & \frac{1}{2} & \frac{1}{3} & \frac{1}{4} & \frac{1}{5} &\frac{1}{6} &\frac{1}{7}\\ \frac{1}{2} & \frac{1}{3} & \frac{1}{4} & \frac{1}{5} & \frac{1}{6} &\frac{1}{7} &\frac{1}{8}\\ \frac{1}{3} & \frac{1}{4} & \frac{1}{5} & \frac{1}{6} & \frac{1}{7} &\frac{1}{8} &\frac{1}{9} \\ \frac{1}{4} & \frac{1}{5} & \frac{1}{6} & \frac{1}{7} & \frac{1}{8} &\frac{1}{9} &\frac{1}{10}\\ \frac{1}{5} & \frac{1}{6} & \frac{1}{7} & \frac{1}{8} & \frac{1}{9} &\frac{1}{10} &\frac{1}{11} \\ \frac{1}{6} & \frac{1}{7} & \frac{1}{8} & \frac{1}{9} & \frac{1}{10} &\frac{1}{11} &\frac{1}{12} \\ \frac{1}{7} & \frac{1}{8} & \frac{1}{9} & \frac{1}{10} & \frac{1}{11} &\frac{1}{12} &\frac{1}{13}\end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \boldsymbol \Gamma^{-1} = 10^8 \begin{bmatrix} 0.0000 & -0.0000 &   0.0001 &  -0.0003 &   0.0005 &  -0.0004  &  0.0001\\   -0.0000   & 0.0004  & -0.0032   & 0.0113  & -0.0194   & 0.0160  & -0.0050\\    0.0001  & -0.0032    &0.0286  & -0.1058   & 0.1871  & -0.1572   & 0.0505\\   -0.0003  &  0.0113  & -0.1058   & 0.4032  & -0.7277   & 0.6209  & -0.2018\\    0.0005   &-0.0194   & 0.1871   &-0.7277   & 1.3340   &-1.1526    &0.3784\\   -0.0004   & 0.0160   &-0.1572  &  0.6209  & -1.1526  &  1.0059  & -0.3330\\    0.0001   &-0.0050    &0.0505 &  -0.2018   & 0.3784 &  -0.3330   & 0.1110\\ \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Using the relationship (1)
 * {| style="width:100%" border="0"

$$ \mathbf c= \boldsymbol \Gamma^{-1} \mathbf d $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \mathbf c= 10^8 \begin{bmatrix} 0.0000 & -0.0000 &   0.0001 &  -0.0003 &   0.0005 &  -0.0004  &  0.0001\\   -0.0000   & 0.0004  & -0.0032   & 0.0113  & -0.0194   & 0.0160  & -0.0050\\    0.0001  & -0.0032    &0.0286  & -0.1058   & 0.1871  & -0.1572   & 0.0505\\   -0.0003  &  0.0113  & -0.1058   & 0.4032  & -0.7277   & 0.6209  & -0.2018\\    0.0005   &-0.0194   & 0.1871   &-0.7277   & 1.3340   &-1.1526    &0.3784\\   -0.0004   & 0.0160   &-0.1572  &  0.6209  & -1.1526  &  1.0059  & -0.3330\\    0.0001   &-0.0050    &0.0505 &  -0.2018   & 0.3784 &  -0.3330   & 0.1110\\ \end{bmatrix} \begin{bmatrix} 0.4597\\0.30117\\0.22324\\0.17710\\0.14665\\0.12508\\0.10901 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \mathbf c= \begin{bmatrix} -0.0000\\   1.0000\\   -0.0000\\   -0.1664\\   -0.0006\\    0.0092\\   -0.0007 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Therefore, the function can be approximated as:
 * {| style="width:100%" border="0"

$$ sin(x) \approx x-0.1664x^3-0.0006x^4+0.0092x^5-0.0007x^6 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }



Summary
Again, we can see that the n=4 and n=6 approximations follow the exact function most closely. The approximations are plotted below:



Question 3

 * {| style="width:100%" border="0"

$$ f(x)=log(1+x) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Following the same steps as the preceding problems, we know that it is necessary to develop the vector, d. We will start by applying the same method of integration by parts.


 * {| style="width:100%" border="0"

$$ \int u dv=uv-\int v du $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

For the first integral, we will use u= log(1+x) and dv=1
 * {| style="width:100%" border="0"

$$ \langle x^0,\log(1+x) \rangle = \langle 1,\log(1+x) \rangle = \int_0^1 \log(1+x) dx = x\log(x)-\int_0^1 \frac{x}{1+x} dx $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

In order to solve the integral, we need to make a "U-substitution". We will use u=(1+x) and du=dx:
 * {| style="width:100%" border="0"

$$ x\log(x)-\int_0^1 \frac{x}{1+x} dx= x\log(x)-\int_0^1 \frac{u-1}{u} dx = x\log(x)-\int_0^1 1-\frac{1}{u} dx=x\log(x)-u+\log(u) $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

Substituting back in and simplifying:
 * {| style="width:100%" border="0"

$$ x\log(x)-u+\log(u) = x\log(x)-(1+x)+\log(1+x)= (1+x)(\log(x)-1)|_0^1= 2\log(2) \approx 0.38629 $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

http://integrals.wolfram.com/index.jsp?expr=log%281%2Bx%29&random=false

We apply the same integration process for the d_1 except that it quickly gets very complicated:
 * {| style="width:100%" border="0"

$$ \langle x,\log(1+x) \rangle=\int_0^1 x^1 \log(1+x) dx= \frac{x^2\log(1+x)}{2}-\frac{1}{2}\int\frac{x^2}{1+x}dx $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

Instead of performing the unnecessary algebra to solve the remaining integrals, we will use the Matlab functions trapz and quad as well as Wolfram:


 * {| style="width:100%" border="0"

$$ \langle x,\log(1+x) \rangle=\int_0^1 x^1 \log(1+x) dx= \frac{1}{4}(2(x^2-1)\log(1 + x)-x(x-2)) = \frac{1}{4} \approx 0.25 $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

http://integrals.wolfram.com/index.jsp?expr=x*log%281%2Bx%29&random=false


 * {| style="width:100%" border="0"

$$ \langle x^2,\log(1+x) \rangle=\int_0^1 x^2 \log(1+x) dx= \frac{1}{18}(x(-6 + (3 - 2x)x) + 6(1 + x^3)\log(1 + x))= \frac{2}{3}log(2)-\frac{5}{18}\approx 0.18432 $$     (5)
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

http://integrals.wolfram.com/index.jsp?expr=x%5E2*log%281%2Bx%29&random=false


 * {| style="width:100%" border="0"

$$ \langle x^3,\log(1+x) \rangle=\int_0^1 x^3 \log(1+x) dx= \frac{x}{4} - \frac{x^2}{8} + \frac{x^3}{12} -\frac{x^4}{16} - \frac{\log(1 + x)}{4} + \frac{x^4\log(1 + x)}{4}=\frac{7}{48}\approx 0.14583 $$     (6)
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

http://integrals.wolfram.com/index.jsp?expr=x%5E3*log%281%2Bx%29&random=false


 * {| style="width:100%" border="0"

$$ \langle x^4,\log(1+x) \rangle=\int_0^1 x^4 \log(1+x) dx= \frac{-x}{5} + \frac{x^2}{10} - \frac{x^3}{15} + \frac{x^4}{20} - \frac{x^5}{25} + \frac{\log(1 + x)}{5} + \frac{1}{5}x^5\log(1 + x) \approx 0.12059 $$     (7)
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

http://integrals.wolfram.com/index.jsp?expr=x%5E4*log%281%2Bx%29&random=false


 * {| style="width:100%" border="0"

$$ \langle x^5,\log(1+x) \rangle=\int_0^1 x^5 \log(1+x) dx= \frac{x}{6} - \frac{x^2}{12} + \frac{x^3}{18} - \frac{x^4}{24} + \frac{x^5}{30} - \frac{x^6}{36} - \frac{1}{6}\log(1 + x) + \frac{1}{6}x^6\log(1 + x) \approx 0.10278 $$     (8)
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

http://integrals.wolfram.com/index.jsp?expr=x%5E5*log%281%2Bx%29&random=false


 * {| style="width:100%" border="0"

$$ \langle x^6,\log(1+x) \rangle=\int_0^1 x^6 \log(1+x) dx= \frac{-x}{7} + \frac{x^2}{14} - \frac{x^3}{21} +\frac{x^4}{28} - \frac{x^5}{35} + \frac{x^6}{42} - \frac{x^7}{49} + \frac{1}{7}\log(1 + x) + \frac{1}{7}x^7\log(1 + x) \approx 0.089539 $$     (9)
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

http://integrals.wolfram.com/index.jsp?expr=x%5E6*log%281%2Bx%29&random=false

n=2
The basis is


 * {| style="width:100%" border="0"

$$ \{ 1, x, x^2 \} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

so the function f(x) can be approximated as


 * {| style="width:100%" border="0"

$$ f(x) \approx c_0b_0+c_1b_1+c_2b_2=c_0+c_1x+c_2x^2 $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

Now, determine the known computable right hand side (using the values determined from the quad function in Matlab):
 * {| style="width:100%" border="0"

$$ \mathbf d = \begin{bmatrix} \langle x^0,\log(1+x) \rangle \\ \langle x^1,\log(1+x)\rangle\\ \langle x^2,\log(1+x) \rangle \end{bmatrix} = \begin{bmatrix} 0.3863\\0.2500\\0.1843\end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Using the Hilbert matrix of order 3 calculated prior, we can plug into the equation (1) and solve for c:


 * {| style="width:100%" border="0"

$$ \boldsymbol \Gamma \mathbf c = \mathbf d $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \mathbf c =  \begin{bmatrix} 0.0057\\   0.9192\\   -0.2370\end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Therefore, the function can be approximated by:
 * {| style="width:100%" border="0"

$$ \log(1+x) \approx 0.0057 + 0.9192x - 0.2370x^2 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }



n=4
The basis is


 * {| style="width:100%" border="0"

$$ \{ 1, x, x^2,x^3, x^4 \} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

so the function f(x) can be approximated as


 * {| style="width:100%" border="0"

$$ f(x) \approx c_0b_0+c_1b_1+c_2b_2+c_3b_3+c_4b_4=c_0+c_1x+c_2x^2+c_3x^3+c_4x^4 $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

Now, determine the known computable right hand side (using the values determined from the quad function in Matlab):
 * {| style="width:100%" border="0"

$$ \mathbf d = \begin{bmatrix} \langle x^0,\log(1+x) \rangle \\ \langle x^1,\log(1+x)\rangle\\ \langle x^2,\log(1+x) \rangle \\ \langle x^3,\log(1+x)\rangle \\ \langle x^4,\log(1+x)\rangle \end{bmatrix} = \begin{bmatrix} 0.3863\\ 0.2500\\   0.1843\\    0.1458\\    0.1206 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Using the Hilbert matrix of order 5 calculated prior, we can plug into the equation (1) and solve for c:


 * {| style="width:100%" border="0"

$$ \boldsymbol \Gamma \mathbf c = \mathbf d $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \mathbf c = \begin{bmatrix} -0.0179\\1.3181\\1.8119\\2.2059\\-1.011\end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Therefore, the function can be approximated as:
 * {| style="width:100%" border="0"

$$ \log(1+x) \approx -0.0179+1.3181x-1.8119x^2+2.2059x^3-1.011x^4 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }



n=6
The basis is


 * {| style="width:100%" border="0"

$$ \{ 1, x, x^2,x^3, x^4, x^5, x^6 \} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

so the function f(x) can be approximated as


 * {| style="width:100%" border="0"

$$ f(x) \approx c_0b_0+c_1b_1+c_2b_2+c_3b_3+c_4b_4+c_5b_5+c_6b_6=c_0+c_1x+c_2x^2+c_3x^3+c_4x^4+c_5x^5+c_6x^6 $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

Now, determine the known computable right hand side (using the values determined from the quad function in Matlab):
 * {| style="width:100%" border="0"

$$ \mathbf d = \begin{bmatrix} \langle x^0,\log(1+x) \rangle \\ \langle x^1,\log(1+x)\rangle\\ \langle x^2,\log(1+x) \rangle \\ \langle x^3,\log(1+x)\rangle \\ \langle x^4,\log(1+x)\rangle \\ \langle x^5,\log(1+x)\rangle \\ \langle x^6,\log(1+x)\rangle\end{bmatrix} = \begin{bmatrix} 0.3863\\ 0.2500\\   0.1843\\    0.1458\\    0.1206\\ 0.1028\\ 0.0895 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Using the Hilbert matrix of order 7 calculated prior, we can plug into the equation (1) and solve for c:


 * {| style="width:100%" border="0"

$$ \boldsymbol \Gamma \mathbf c = \mathbf d $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \mathbf c = \begin{bmatrix}    -0.1477\\ 9.6768\\ -104.2020\\ 464.1000\\ -939.0150\\  873.7344\\ -303.9036 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Therefore, the function can be approximated as:
 * {| style="width:100%" border="0"

$$ \log(1+x) \approx -0.1477+9.6768x-104.202x^2+464.1x^3-939.015x^4+873.7344x^5-303.9036x^6 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }



As you can see, this graph shows that the function is not a good approximation. This could be attributed to rounding error when using the quad function to determine the d matrix in Matlab.

Problem Statement
Find the projection (approximation) of each the functions below, defined on the interval [0,1], onto the Fourier cosine basis (Fourier cosine series)


 * {| style="width:100%" border="0"

$$ \{ 1, \cos \omega x , \cos 2 \omega x , ..., \cos n \omega x \} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

1. use L = 1, which half the period p, find the circular frequency and verify the orthogonality of the Fourier basis for n = 4.

for each of the functions below, plot the exact function and its approximations.

for integration by parts, you may want to consult sec.9d, and then use Wolfram Alpha or Wolfram integrator to verify your results. for example, here is the exact integration of x^2 log(1+x).

for numerical integration, you may want to use both GNU Octave / matlab commands trapz and quad to verify your results. you can also use Wolfram integrator to verify your results when possible.

2. Exponential function: $$ e^x = \exp(x) $$ use integration by parts, and verify your results with Wolfram integrator; provide links to your Wolfram integrator results.

3. Same as in Question 1, but with the sine function: sin x

4. Same as in Question 1, but the logarithm function : log(1+x). try to integrate with integration by parts first, and and point out the difficulty in your report.

when you come to a deadend with integration by parts, use numerical integration with with both GNU Octave / matlab commands trapz

and quad to verify, and verify again with Wolfram integrator, as mentioned above.

for different values of n; here n = 2,3,4.

Solution
Circular frequency
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\omega := \frac{\pi}{L} = \frac{\pi}{1} = {\pi} $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\omega = \frac{2\pi}{p} \rightarrow {\pi} = \frac{2\pi}{p} \rightarrow p = 2 $$ family of basis functions
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\{ b_1(x), b_2(x) , b_3(x), ... , b_n(x) \} \rightarrow  \{ 1, \cos \omega x , \cos 2 \omega x , ..., \cos n \omega x \} $$ (here n = 2,3,4).
 * }
 * }

General approximation projected on the above basis:
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

f(x) \approx \sum_{j=1}^n c_j b_j(x) $$ find $$c_j$$ using Gram matrix as with vectors
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\{ b_i(x), \, i=1,...n \} $$ to obtain
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\sum_{j=1}^n c_j \langle b_i, b_j \rangle = \langle b_i , f \rangle , \ i=1,...,n $$ Gram matrix:
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\Gamma (\{ b_i \}) = \begin{bmatrix} \langle b_1, b_1 \rangle & ... & \langle b_1, b_n \rangle \\

\vdots & \vdots & \vdots \\ \langle b_n, b_1 \rangle & ... & \langle b_n, b_n \rangle \end{bmatrix} $$
 * }
 * }

Unknown coefficients that need to be solve:
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\mathbf c = \lfloor c_1, ... , c_n \rfloor^T $$ Known components
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\mathbf d = \lfloor \langle b_1, f \rangle , ... , \langle b_n, f \rangle \rfloor^T = \lfloor d_1 , ..., d_n \rfloor^T $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\boldsymbol \Gamma \mathbf c = \mathbf d $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\Gamma \ne 0 \Rightarrow \boldsymbol \Gamma^{-1} \text{ exists} \Rightarrow \mathbf c = \boldsymbol \Gamma^{-1} \mathbf d $$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\langle b_i, b_j \rangle = \int_{a}^{b} b_i b_j dx $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\langle b_i, b_j \rangle =\langle b_j , b_i \rangle $$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\langle b_1, b_1 \rangle = \int_{0}^{1} 1 dx = 1 $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\langle b_1, b_2 \rangle = \int_{0}^{1}  \cos( \pi x) dx = 0 $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\langle b_1, b_3 \rangle = \int_{0}^{1}  \cos( 2\pi x) dx = 0 $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\langle b_1, b_4 \rangle = \int_{0}^{1}  \cos( 3\pi x) dx = 0 $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\langle b_1, b_5 \rangle = \int_{0}^{1}  \cos( 4\pi x) dx = 0 $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\langle b_2, b_1 \rangle = \int_{0}^{1}  \cos( \pi x) ( 1 ) dx = 0 $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\langle b_2, b_2 \rangle = \int_{0}^{1}  \cos( \pi x) \cos( \pi x) dx = .5 $$
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+%28cos%28pi*x%29%29%28cos%28pi*x%29%29+dx+from+0+to+1
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\langle b_2, b_3 \rangle = \int_{0}^{1}  \cos( \pi x) \cos( 2\pi x) dx = 0 $$
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+%28cos%28pi*x%29%29%28cos%282pi*x%29%29+dx+from+0+to+1
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\langle b_2, b_4 \rangle = \int_{0}^{1}  \cos( \pi x) \cos( 3\pi x) dx = 0 $$
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+%28cos%28pi*x%29%29%28cos%283pi*x%29%29+dx+from+0+to+1
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\langle b_2, b_5 \rangle = \int_{0}^{1}  \cos( \pi x) \cos( 4\pi x) dx = 0 $$
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+%28cos%28pi*x%29%29%28cos%284pi*x%29%29+dx+from+0+to+1
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\langle b_3, b_1 \rangle = \langle b_0 , b_2 \rangle = 0 $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\langle b_3, b_2 \rangle = \langle b_1 , b_2 \rangle = 0 $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\langle b_3, b_3 \rangle = \int_{0}^{1}  \cos( 2\pi x) \cos( 2\pi x) dx = .5 $$
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+%28cos%282pi*x%29%29%28cos%282pi*x%29%29+dx+from+0+to+1
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\langle b_3, b_4 \rangle = \int_{0}^{1}  \cos( 2\pi x) \cos( 3\pi x) dx = 0 $$
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+%28cos%282pi*x%29%29%28cos%283pi*x%29%29+dx+from+0+to+1
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\langle b_3, b_5 \rangle = \int_{0}^{1}  \cos( 2\pi x) \cos( 4\pi x) dx = 0 $$
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+%28cos%282pi*x%29%29%28cos%284pi*x%29%29+dx+from+0+to+1
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\langle b_4, b_1 \rangle = \langle b_0 , b_3 \rangle = 0 $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\langle b_4, b_2 \rangle = \langle b_1 , b_3 \rangle = 0 $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\langle b_4, b_3 \rangle = \langle b_2 , b_3 \rangle = 0 $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\langle b_4, b_4 \rangle = \int_{0}^{1}  \cos( 3\pi x) \cos( 3\pi x) dx = .5 $$
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+%28cos%283pi*x%29%29%28cos%283pi*x%29%29+dx+from+0+to+1
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\langle b_4, b_5 \rangle = \int_{0}^{1}  \cos( 3\pi x) \cos( 4\pi x) dx = 0 $$
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+%28cos%283pi*x%29%29%28cos%284pi*x%29%29+dx+from+0+to+1
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\langle b_5, b_1 \rangle = \langle b_0 , b_4 \rangle = 0 $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\langle b_5, b_2 \rangle = \langle b_1 , b_4 \rangle = 0 $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\langle b_5, b_3 \rangle = \langle b_2 , b_4 \rangle = 0 $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\langle b_5, b_4 \rangle = \langle b_3 , b_4 \rangle = 0 $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\langle b_5, b_5 \rangle = \int_{0}^{1}  \cos( 4\pi x) \cos( 4\pi x) dx = .5 $$
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+%28cos%284pi*x%29%29%28cos%284pi*x%29%29+dx+from+0+to+1
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+%28cos%284pi*x%29%29%28cos%284pi*x%29%29+dx+from+0+to+1

Question 2

 * {| Italic textstyle="width:100%" border="0"

$$ e^x = \exp(x) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

n = 2

 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\Gamma (\{ b_i \}) = \begin{bmatrix} 1 & 0 & 0 \\ 0 & .5 & 0  \\ 0 & 0 & .5 \end{bmatrix} $$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\Gamma^{-1} (\{ b_i \}) = \begin{bmatrix} 1 & 0 & 0 \\ 0 & .5 & 0  \\ 0 & 0 & .5 \end{bmatrix} $$ Compute known components on rhs
 * }
 * }
 * {| style="width:100%" border="0"

$$ \mathbf d = \begin{bmatrix} d_1 \\ d_2  \\ d_3  \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_i = \langle b_i, f \rangle = \int_{a}^{b} b_i f dx $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_1 = \langle b_1, f \rangle = \int_{0}^{1} 1 e^x dx = e - 1 = 1.71828 $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$ d_2 = \langle b_2, f \rangle = \int_{0}^{1} \cos(\pi x) e^x dx $$ Must use integration by parts to solve for d_2
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} \cos(\pi x) e^x dx = u v - \int_{0}^{1} v du

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

u = \cos(\pi x) \rightarrow du = -\pi \sin(\pi x) dx

$$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

dv = e^x dx \rightarrow v = e^x

$$ Substituting in
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} \cos(\pi x) e^x dx = \cos(\pi x) e^x +  \int_{0}^{1} \pi e^x \cos(\pi x) dx

$$ Must use integration by parts again for the remaining integral
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

u = \pi\sin(\pi x) \rightarrow du = \pi^2 \cos(\pi x) dx

$$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

dv = e^x dx \rightarrow v = e^x

$$ Which gives us
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} \cos(\pi x) e^x dx = \cos(\pi x) e^x +  \pi e^x \sin(\pi x)  - \pi^2 \int_{0}^{1} e^x \cos(\pi x) dx

$$ Using some algebra to rearrange:
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

(1 + \pi^2)\int_{0}^{1} e^x \cos(\pi x) dx = \cos(\pi x) e^x  +  \pi e^x \sin(\pi x)

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} e^x \cos(\pi x) dx = \frac {1}{(1 + \pi^2)} [\cos(\pi x) e^x  +  \pi e^x \sin(\pi x)] |_{0}^{1}

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

= \frac {1}{(1 + \pi^2)} [\cos(\pi) e^1 +  \pi e^1 \pi\sin(\pi) - \cos(0)   +  \pi\sin(0)]

$$ Therefore
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_2 = -.34208

$$
 * } Verified at http://www.wolframalpha.com/input/?i=integrate+cos%28pi*x%29*e^xdx+from+0to+1
 * } Verified at http://www.wolframalpha.com/input/?i=integrate+cos%28pi*x%29*e^xdx+from+0to+1


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_3 = \langle b_3, f \rangle = \int_{0}^{1} \cos(2\pi x) e^x dx

$$ Must use integration by parts to solve for d_3
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} \cos(2\pi x) e^x dx = u v - \int_{0}^{1} v du

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

u = \cos(2\pi x) \rightarrow du = -2\pi \sin(2\pi x) dx

$$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

dv = e^x dx \rightarrow v = e^x

$$ Substituting in
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} \cos(2\pi x) e^x dx = \cos(2\pi x) e^x +  2\pi\int_{0}^{1}  e^x \cos(2\pi x) dx

$$ Must use integration by parts again for the remaining integral
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

u = 2\pi\sin(2\pi x) \rightarrow du = 4\pi^2 \cos(2\pi x) dx

$$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

dv = e^x dx \rightarrow v = e^x

$$ Which gives us
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} \cos(2\pi x) e^x dx = \cos(2\pi x) e^x +  2\pi e^x \sin(2\pi x)  - 4\pi^2 \int_{0}^{1} e^x \cos(2\pi x) dx

$$ Using some algebra to rearrange:
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

(1 + 4\pi^2)\int_{0}^{1} e^x \cos(2\pi x) dx = \cos(2\pi x) e^x  +  2\pi e^x \sin(2\pi x)

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} e^x \cos(2\pi x) dx = \frac {1}{(1 + 4\pi^2)} [\cos(2\pi x) e^x  +  2\pi e^x \sin(2\pi x)] |_{0}^{1}

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

= \frac {1}{(1 + 4\pi^2)} [\cos(2\pi) e^1 +  \pi e^1 \pi\sin(2\pi) - \cos(0)   +  2\pi\sin(0)]

$$ Therefore
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_3 = .04245

$$
 * } Verified at http://www.wolframalpha.com/input/?i=integrate+cos%282pi*x%29*e^xdx+from+0to+1
 * } Verified at http://www.wolframalpha.com/input/?i=integrate+cos%282pi*x%29*e^xdx+from+0to+1


 * {| style="width:100%" border="0"

$$ \mathbf d = \begin{bmatrix} 1.71828 \\ -.34208  \\ .04245  \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Recall that
 * {| style="width:100%" border="0"

$$ \mathbf c = \boldsymbol \Gamma^{-1} \mathbf d $$ Substituting in to solve for the unknowns:
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }
 * {| style="width:100%" border="0"

$$ \begin{bmatrix} c_1 \\ c_2 \\ c_3  \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0  \\ 0 & .5 & 0  \\ 0 & 0 & .5  \end{bmatrix} \begin{bmatrix} 1.71828 \\ -.34208  \\ .04245  \end{bmatrix} $$ And so
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }
 * {| style="width:100%" border="0"

$$ \begin{bmatrix} c_1 \\ c_2 \\ c_3  \end{bmatrix} = \begin{bmatrix} 1.17828 \\ -.17104  \\ .021225  \end{bmatrix} $$ The approximation on the Fourier basis is:
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }
 * {| style="width:100%" border="0"

$$ f(x) = e^x \approx c_1 b_1(x) + c_2 b_2(x) + c_3 b_3(x) = (1.17828)(1) + (-.17104)(\cos(\pi x)) + (.021225)(\cos(2\pi x)) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Red = Approximation

Blue = Exact



n = 3

 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\Gamma (\{ b_i \}) = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & .5 & 0 & 0 \\ 0 & 0 & .5 & 0 \\ 0 & 0 & 0 & .5 \end{bmatrix} $$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\Gamma^{-1} (\{ b_i \}) = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & .5 & 0 & 0 \\ 0 & 0 & .5 & 0 \\ 0 & 0 & 0 & .5 \end{bmatrix} $$
 * }
 * }

Compute known components on rhs
 * {| style="width:100%" border="0"

$$ \mathbf d = \begin{bmatrix} d_1 \\ d_2  \\ d_3 \\d_4 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_i = \langle b_i, f \rangle = \int_{a}^{b} b_i f dx $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_1 = \langle b_1, f \rangle = \int_{0}^{1} 1 e^x dx = e - 1 = 1.71828 $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$ d_2 = \langle b_2, f \rangle = \int_{0}^{1} \cos(\pi x) e^x dx $$ Must use integration by parts to solve for $$d_2$$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} \cos(\pi x) e^x dx = u v - \int_{0}^{1} v du

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

u = \cos(\pi x) \rightarrow du = -\pi \sin(\pi x) dx

$$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

dv = e^x dx \rightarrow v = e^x

$$ Substituting in
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} \cos(\pi x) e^x dx = \cos(\pi x) e^x +  \int_{0}^{1} \pi e^x \cos(\pi x) dx

$$ Must use integration by parts again for the remaining integral
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

u = \pi\sin(\pi x) \rightarrow du = \pi^2 \cos(\pi x) dx

$$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

dv = e^x dx \rightarrow v = e^x

$$ Which gives us
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} \cos(\pi x) e^x dx = \cos(\pi x) e^x +  \pi e^x \sin(\pi x)  - \pi^2 \int_{0}^{1} e^x \cos(\pi x) dx

$$ Using some algebra to rearrange:
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

(1 + \pi^2)\int_{0}^{1} e^x \cos(\pi x) dx = \cos(\pi x) e^x  +  \pi e^x \sin(\pi x)

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} e^x \cos(\pi x) dx = \frac {1}{(1 + \pi^2)} [\cos(\pi x) e^x  +  \pi e^x \sin(\pi x)] |_{0}^{1}

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

= \frac {1}{(1 + \pi^2)} [\cos(\pi) e^1 +  \pi e^1 \pi\sin(\pi) - \cos(0)   +  \pi\sin(0)]

$$ Therefore
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_2 = -.34208

$$
 * } Verified at http://www.wolframalpha.com/input/?i=integrate+cos%28pi*x%29*e^xdx+from+0to+1
 * } Verified at http://www.wolframalpha.com/input/?i=integrate+cos%28pi*x%29*e^xdx+from+0to+1


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_3 = \langle b_3, f \rangle = \int_{0}^{1} \cos(2\pi x) e^x dx

$$ Must use integration by parts to solve for $$d_3$$
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} \cos(2\pi x) e^x dx = u v - \int_{0}^{1} v du

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

u = \cos(2\pi x) \rightarrow du = -2\pi \sin(2\pi x) dx

$$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

dv = e^x dx \rightarrow v = e^x

$$ Substituting in
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} \cos(2\pi x) e^x dx = \cos(2\pi x) e^x +  2\pi\int_{0}^{1}  e^x \cos(2\pi x) dx

$$ Must use integration by parts again for the remaining integral
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

u = 2\pi\sin(2\pi x) \rightarrow du = 4\pi^2 \cos(2\pi x) dx

$$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

dv = e^x dx \rightarrow v = e^x

$$ Which gives us
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} \cos(2\pi x) e^x dx = \cos(2\pi x) e^x +  2\pi e^x \sin(2\pi x)  - 4\pi^2 \int_{0}^{1} e^x \cos(2\pi x) dx

$$ Using some algebra to rearrange:
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

(1 + 4\pi^2)\int_{0}^{1} e^x \cos(2\pi x) dx = \cos(2\pi x) e^x  +  2\pi e^x \sin(2\pi x)

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} e^x \cos(2\pi x) dx = \frac {1}{(1 + 4\pi^2)} [\cos(2\pi x) e^x  +  2\pi e^x \sin(2\pi x)] |_{0}^{1}

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

= \frac {1}{(1 + 4\pi^2)} [\cos(2\pi) e^1 +  \pi e^1 \pi\sin(2\pi) - \cos(0)   +  2\pi\sin(0)]

$$ Therefore
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_3 = .04245

$$
 * } Verified at http://www.wolframalpha.com/input/?i=integrate+cos%282pi*x%29*e^xdx+from+0to+1
 * } Verified at http://www.wolframalpha.com/input/?i=integrate+cos%282pi*x%29*e^xdx+from+0to+1


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_4 = \langle b_4, f \rangle = \int_{0}^{1} \cos(3\pi x) e^x dx

$$ Must use integration by parts to solve for
 * }
 * }
 * {| style="width:100%" border="0"

$$ d_4 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} \cos(3\pi x) e^x dx = u v - \int_{0}^{1} v du

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

u = \cos(3\pi x) \rightarrow du = -3\pi \sin(3\pi x) dx

$$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

dv = e^x dx \rightarrow v = e^x

$$ Substituting in
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} \cos(3\pi x) e^x dx = \cos(3\pi x) e^x +  3\pi\int_{0}^{1}  e^x \cos(3\pi x) dx

$$ Must use integration by parts again for the remaining integral
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

u = 3\pi\sin(3\pi x) \rightarrow du = 9\pi^2 \cos(3\pi x) dx

$$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

dv = e^x dx \rightarrow v = e^x

$$ Which gives us
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} \cos(3\pi x) e^x dx = \cos(3\pi x) e^x +  3\pi e^x \sin(3\pi x)  - 9\pi^2 \int_{0}^{1} e^x \cos(3\pi x) dx

$$ Using some algebra to rearrange:
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

(1 + 9\pi^2)\int_{0}^{1} e^x \cos(3\pi x) dx = \cos(3\pi x) e^x  +  3\pi e^x \sin(3\pi x)

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} e^x \cos(3\pi x) dx = \frac {1}{(1 + 9\pi^2)} [\cos(3\pi x) e^x  +  3\pi e^x \sin(3\pi x)] |_{0}^{1}

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

= \frac {1}{(1 + 9\pi^2)} [\cos(3\pi) e^1 +  \pi e^1 \sin(3\pi) - \cos(0)   +  3\pi\sin(0)]

$$ Therefore
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_4 = -.04139

$$
 * } Verified at http://www.wolframalpha.com/input/?i=integrate+cos%283pi*x%29*e^xdx+from+0+to+1
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$ \mathbf d = \begin{bmatrix} 1.71828 \\ -.34208  \\ .04245 \\-.04139 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Recall that
 * {| style="width:100%" border="0"

$$ \mathbf c = \boldsymbol \Gamma^{-1} \mathbf d $$ Substituting in to solve for the unknowns:
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }
 * {| style="width:100%" border="0"

$$ \begin{bmatrix} c_1 \\ c_2 \\ c_3 \\c_4 \end{bmatrix} = \begin{bmatrix}  1 & 0 & 0 & 0  \\ 0 & .5 & 0 & 0 \\ 0 & 0 & .5 & 0 \\ 0 & 0 & 0 & .5 \end{bmatrix} \begin{bmatrix} 1.71828 \\ -.34208  \\ .04245 \\-.04139 \end{bmatrix} $$ And so
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }
 * {| style="width:100%" border="0"

$$ \begin{bmatrix} c_1 \\ c_2 \\ c_3 \\c_4 \end{bmatrix} = \begin{bmatrix} 1.17828 \\ -.17104  \\ .021225 \\-.020695 \end{bmatrix} $$ The approximation on the Fourier basis is:
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }
 * {| style="width:100%" border="0"

$$ f(x) = e^x \approx c_1 b_1(x) + c_2 b_2(x) + c_3 b_3(x) + c_4 b_4(x) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$ \approx (1.17828)(1) + (-.17104)(\cos(\pi x)) + (.021225)(\cos(2\pi x)) + (-.020695)(\cos(3\pi x)) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Red = Approximation

Blue = Exact



n = 4

 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\Gamma (\{ b_i \}) = \begin{bmatrix} 1 & 0 & 0 & 0 & 0 \\ 0 & .5 & 0 & 0 & 0 \\ 0 & 0 & .5 & 0 & 0 \\ 0 & 0 & 0 & .5 & 0 \\ 0 & 0 & 0 & 0 & .5 \end{bmatrix} $$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\Gamma^{-1} (\{ b_i \}) = \begin{bmatrix} 1 & 0 & 0 & 0 & 0 \\ 0 & .5 & 0 & 0 & 0 \\ 0 & 0 & .5 & 0 & 0 \\ 0 & 0 & 0 & .5 & 0 \\ 0 & 0 & 0 & 0 & .5 \end{bmatrix} $$
 * }
 * }

Compute known components on rhs
 * {| style="width:100%" border="0"

$$ \mathbf d = \begin{bmatrix} d_1 \\ d_2  \\ d_3 \\d_4 \\d_5 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_i = \langle b_i, f \rangle = \int_{a}^{b} b_i f dx $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_1 = \langle b_1, f \rangle = \int_{0}^{1} 1 e^x dx = e - 1 = 1.71828 $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$ d_2 = \langle b_2, f \rangle = \int_{0}^{1} \cos(\pi x) e^x dx $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Must use integration by parts to solve for $$d_2$$
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} \cos(\pi x) e^x dx = u v - \int_{0}^{1} v du

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

u = \cos(\pi x) \rightarrow du = -\pi \sin(\pi x) dx

$$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

dv = e^x dx \rightarrow v = e^x

$$ Substituting in
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} \cos(\pi x) e^x dx = \cos(\pi x) e^x +  \int_{0}^{1} \pi e^x \cos(\pi x) dx

$$ Must use integration by parts again for the remaining integral
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

u = \pi\sin(\pi x) \rightarrow du = \pi^2 \cos(\pi x) dx

$$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

dv = e^x dx \rightarrow v = e^x

$$ Which gives us
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} \cos(\pi x) e^x dx = \cos(\pi x) e^x +  \pi e^x \sin(\pi x)  - \pi^2 \int_{0}^{1} e^x \cos(\pi x) dx

$$ Using some algebra to rearrange:
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

(1 + \pi^2)\int_{0}^{1} e^x \cos(\pi x) dx = \cos(\pi x) e^x  +  \pi e^x \sin(\pi x)

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} e^x \cos(\pi x) dx = \frac {1}{(1 + \pi^2)} [\cos(\pi x) e^x  +  \pi e^x \sin(\pi x)] |_{0}^{1}

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

= \frac {1}{(1 + \pi^2)} [\cos(\pi) e^1 +  \pi e^1 \pi\sin(\pi) - \cos(0)   +  \pi\sin(0)]

$$ Therefore
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_2 = -.34208

$$
 * } Verified at http://www.wolframalpha.com/input/?i=integrate+cos%28pi*x%29*e^xdx+from+0to+1
 * } Verified at http://www.wolframalpha.com/input/?i=integrate+cos%28pi*x%29*e^xdx+from+0to+1


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_3 = \langle b_3, f \rangle = \int_{0}^{1} \cos(2\pi x) e^x dx

$$ Must use integration by parts to solve for $$ d_3$$
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} \cos(2\pi x) e^x dx = u v - \int_{0}^{1} v du

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

u = \cos(2\pi x) \rightarrow du = -2\pi \sin(2\pi x) dx

$$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

dv = e^x dx \rightarrow v = e^x

$$ Substituting in
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} \cos(2\pi x) e^x dx = \cos(2\pi x) e^x +  2\pi\int_{0}^{1}  e^x \cos(2\pi x) dx

$$ Must use integration by parts again for the remaining integral
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

u = 2\pi\sin(2\pi x) \rightarrow du = 4\pi^2 \cos(2\pi x) dx

$$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

dv = e^x dx \rightarrow v = e^x

$$ Which gives us
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} \cos(2\pi x) e^x dx = \cos(2\pi x) e^x +  2\pi e^x \sin(2\pi x)  - 4\pi^2 \int_{0}^{1} e^x \cos(2\pi x) dx

$$ Using some algebra to rearrange:
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

(1 + 4\pi^2)\int_{0}^{1} e^x \cos(2\pi x) dx = \cos(2\pi x) e^x  +  2\pi e^x \sin(2\pi x)

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} e^x \cos(2\pi x) dx = \frac {1}{(1 + 4\pi^2)} [\cos(2\pi x) e^x  +  2\pi e^x \sin(2\pi x)] |_{0}^{1}

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

= \frac {1}{(1 + 4\pi^2)} [\cos(2\pi) e^1 +  \pi e^1 \pi\sin(2\pi) - \cos(0)   +  2\pi\sin(0)]

$$ Therefore
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_3 = .04245

$$
 * } Verified at http://www.wolframalpha.com/input/?i=integrate+cos%282pi*x%29*e^xdx+from+0to+1
 * } Verified at http://www.wolframalpha.com/input/?i=integrate+cos%282pi*x%29*e^xdx+from+0to+1


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_4 = \langle b_4, f \rangle = \int_{0}^{1} \cos(3\pi x) e^x dx

$$ Must use integration by parts to solve for $$d_4$$
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} \cos(3\pi x) e^x dx = u v - \int_{0}^{1} v du

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

u = \cos(3\pi x) \rightarrow du = -3\pi \sin(3\pi x) dx

$$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

dv = e^x dx \rightarrow v = e^x

$$ Substituting in
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} \cos(3\pi x) e^x dx = \cos(3\pi x) e^x +  3\pi\int_{0}^{1}  e^x \cos(3\pi x) dx

$$ Must use integration by parts again for the remaining integral
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

u = 3\pi\sin(3\pi x) \rightarrow du = 9\pi^2 \cos(3\pi x) dx

$$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

dv = e^x dx \rightarrow v = e^x

$$ Which gives us
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} \cos(3\pi x) e^x dx = \cos(3\pi x) e^x +  3\pi e^x \sin(3\pi x)  - 9\pi^2 \int_{0}^{1} e^x \cos(3\pi x) dx

$$ Using some algebra to rearrange:
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

(1 + 9\pi^2)\int_{0}^{1} e^x \cos(3\pi x) dx = \cos(3\pi x) e^x  +  3\pi e^x \sin(3\pi x)

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} e^x \cos(3\pi x) dx = \frac {1}{(1 + 9\pi^2)} [\cos(3\pi x) e^x  +  3\pi e^x \sin(3\pi x)] |_{0}^{1}

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

= \frac {1}{(1 + 9\pi^2)} [\cos(3\pi) e^1 +  \pi e^1 \sin(3\pi) - \cos(0)   +  3\pi\sin(0)]

$$ Therefore
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_4 = -.04139

$$
 * } Verified at http://www.wolframalpha.com/input/?i=integrate+cos%283pi*x%29*e^xdx+from+0+to+1
 * } Verified at http://www.wolframalpha.com/input/?i=integrate+cos%283pi*x%29*e^xdx+from+0+to+1


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_5 = \langle b_5, f \rangle = \int_{0}^{1} \cos(4\pi x) e^x dx

$$ Must use integration by parts to solve for $$d_4$$
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%284pi*x%29*e^xdx+from+0+to+1
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%284pi*x%29*e^xdx+from+0+to+1
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} \cos(4\pi x) e^x dx = u v - \int_{0}^{1} v du

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

u = \cos(4\pi x) \rightarrow du = -4\pi \sin(4\pi x) dx

$$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

dv = e^x dx \rightarrow v = e^x

$$ Substituting in
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} \cos(4\pi x) e^x dx = \cos(4\pi x) e^x +  4\pi\int_{0}^{1}  e^x \cos(4\pi x) dx

$$ Must use integration by parts again for the remaining integral
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

u = 4\pi\sin(4\pi x) \rightarrow du = 16\pi^2 \cos(4\pi x) dx

$$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

dv = e^x dx \rightarrow v = e^x

$$ Which gives us
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} \cos(4\pi x) e^x dx = \cos(4\pi x) e^x +  4\pi e^x \sin(4\pi x)  - 16\pi^2 \int_{0}^{1} e^x \cos(4\pi x) dx

$$ Using some algebra to rearrange:
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

(1 + 16\pi^2)\int_{0}^{1} e^x \cos(4\pi x) dx = \cos(4\pi x) e^x  +  4\pi e^x \sin(4\pi x)

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\int_{0}^{1} e^x \cos(4\pi x) dx = \frac {1}{(1 + 16\pi^2)} [\cos(4\pi x) e^x  +  4\pi e^x \sin(4\pi x)] |_{0}^{1}

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

= \frac {1}{(1 + 16\pi^2)} [\cos(4\pi) e^1 +  \pi e^1 \sin(4\pi) - \cos(0)   +  4\pi\sin(0)]

$$ Therefore
 * }
 * }
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_5 = .010813

$$
 * } Verified at http://www.wolframalpha.com/input/?i=integrate+cos%284pi*x%29*e^xdx+from+0+to+1
 * } Verified at http://www.wolframalpha.com/input/?i=integrate+cos%284pi*x%29*e^xdx+from+0+to+1


 * {| style="width:100%" border="0"

$$ \mathbf d = \begin{bmatrix} 1.71828 \\ -.34208  \\ .04245 \\-.04139 \\.010813 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Recall that
 * {| style="width:100%" border="0"

$$ \mathbf c = \boldsymbol \Gamma^{-1} \mathbf d $$ Substituting in to solve for the unknowns:
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }
 * {| style="width:100%" border="0"

$$ \begin{bmatrix} c_1 \\ c_2 \\ c_3 \\c_4 \end{bmatrix} = \begin{bmatrix}  1 & 0 & 0 & 0 & 0  \\ 0 & .5 & 0 & 0 & 0 \\ 0 & 0 & .5 & 0 & 0 \\ 0 & 0 & 0 & .5 & 0 \\ 0 & 0 & 0 & 0 & .5 \end{bmatrix} \begin{bmatrix} 1.71828 \\ -.34208  \\ .04245 \\-.04139 \\.010813  \end{bmatrix} $$ And so
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }
 * {| style="width:100%" border="0"

$$ \begin{bmatrix} c_1 \\ c_2 \\ c_3 \\c_4 \\c_5 \end{bmatrix} = \begin{bmatrix} 1.17828 \\ -.17104  \\ .021225 \\-.020695 \\.0054065  \end{bmatrix} $$ The approximation on the Fourier basis is:
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }
 * {| style="width:100%" border="0"

$$ f(x) = e^x \approx c_1 b_1(x) + c_2 b_2(x) + c_3 b_3(x) + c_4 b_4(x)+ c_5 b_5(x) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$ \approx (1.17828)(1) + (-.17104)(\cos(\pi x)) + (.021225)(\cos(2\pi x)) + (-.020695)(\cos(3\pi x)) + (.0054065)(\cos(4\pi x)) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Red = Approximation

Blue = Exact



Question 3

 * {| style="width:100%" border="0"

$$ \sin(x) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

n = 2

 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\Gamma (\{ b_i \}) = \begin{bmatrix} 1 & 0 & 0 \\ 0 & .5 & 0  \\ 0 & 0 & .5 \end{bmatrix} $$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\Gamma^{-1} (\{ b_i \}) = \begin{bmatrix} 1 & 0 & 0 \\ 0 & .5 & 0  \\ 0 & 0 & .5 \end{bmatrix} $$ Compute known components on rhs using exact integration
 * }
 * }
 * {| style="width:100%" border="0"

$$ \mathbf d = \begin{bmatrix} d_1 \\ d_2  \\ d_3  \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_i = \langle b_i, f \rangle = \int_{a}^{b} b_i f dx $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_1 = \langle b_1, f \rangle = \int_{0}^{1} 1 \sin(x) dx = .45970 $$
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+sin%28x%29dx+from+0+to+1
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$ d_2 = \langle b_2, f \rangle = \int_{0}^{1} \cos(\pi x) \sin(x) dx = -.17366 $$
 * style="width:95%" |
 * style="width:95%" |
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%28pi*x%29*sin%28x%29dx+from+0+to+1
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%28pi*x%29*sin%28x%29dx+from+0+to+1


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_3 = \langle b_3, f \rangle = \int_{0}^{1} \cos(2\pi x) \sin(x) dx =  -.0011947

$$
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%282pi*x%29*sin%28x%29dx+from+0+to+1
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%282pi*x%29*sin%28x%29dx+from+0+to+1


 * {| style="width:100%" border="0"

$$ \mathbf d = \begin{bmatrix} .45970 \\  -.17366  \\  -.0011947  \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Recall that
 * {| style="width:100%" border="0"

$$ \mathbf c = \boldsymbol \Gamma^{-1} \mathbf d $$ Substituting in to solve for the unknowns:
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }
 * {| style="width:100%" border="0"

$$ \begin{bmatrix} c_1 \\ c_2 \\ c_3  \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0  \\ 0 & .5 & 0  \\ 0 & 0 & .5  \end{bmatrix} \begin{bmatrix} .45970 \\  -.17366  \\ -.0011947 \end{bmatrix} $$ And so
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }
 * {| style="width:100%" border="0"

$$ \begin{bmatrix} c_1 \\ c_2 \\ c_3  \end{bmatrix} = \begin{bmatrix} .45970 \\ -0.08683  \\  -0.00059  \end{bmatrix} $$ The approximation on the Fourier basis is:
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ f(x) = e^x \approx c_1 b_1(x) + c_2 b_2(x) + c_3 b_3(x) = (.45970)(1) + (-0.08683)(\cos(\pi x)) + (-0.00059)(\cos(2\pi x)) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Red = Approximation

Blue = Exact



n = 3

 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\Gamma (\{ b_i \}) = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & .5 & 0 & 0 \\ 0 & 0 & .5 & 0 \\ 0 & 0 & 0 & .5 \end{bmatrix} $$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\Gamma^{-1} (\{ b_i \}) = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & .5 & 0 & 0 \\ 0 & 0 & .5 & 0 \\ 0 & 0 & 0 & .5 \end{bmatrix} $$
 * }
 * }

Compute known components on rhs using exact integration
 * {| style="width:100%" border="0"

$$ \mathbf d = \begin{bmatrix} d_1 \\ d_2  \\ d_3 \\ d_4 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_i = \langle b_i, f \rangle = \int_{a}^{b} b_i f dx $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_1 = \langle b_1, f \rangle = \int_{0}^{1} 1 \sin(x) dx = .45970 $$
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+sin%28x%29dx+from+0+to+1
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$ d_2 = \langle b_2, f \rangle = \int_{0}^{1} \cos(\pi x) \sin(x) dx = -.17366 $$
 * style="width:95%" |
 * style="width:95%" |
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%28pi*x%29*sin%28x%29dx+from+0+to+1
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%28pi*x%29*sin%28x%29dx+from+0+to+1


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_3 = \langle b_3, f \rangle = \int_{0}^{1} \cos(2\pi x) \sin(x) dx =  -.0011947

$$
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%282pi*x%29*sin%28x%29dx+from+0+to+1
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%282pi*x%29*sin%28x%29dx+from+0+to+1


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_4 = \langle b_4, f \rangle = \int_{0}^{1} \cos(3\pi x) \sin(x) dx = -0.017538

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$ \mathbf d = \begin{bmatrix} .45970 \\  -.17366  \\  -.0011947 \\ -0.017538 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Recall that
 * {| style="width:100%" border="0"

$$ \mathbf c = \boldsymbol \Gamma^{-1} \mathbf d $$ Substituting in to solve for the unknowns:
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }
 * {| style="width:100%" border="0"

$$ \begin{bmatrix} c_1 \\ c_2 \\ c_3 \\ c_4 \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0 & 0  \\ 0 & .5 & 0 & 0 \\ 0 & 0 & .5 & 0 \\ 0 & 0 & 0 & .5 \end{bmatrix} \begin{bmatrix} .45970 \\  -.17366  \\ -.0011947 \\ -0.017538\end{bmatrix} $$ And so
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }
 * {| style="width:100%" border="0"

$$ \begin{bmatrix} c_1 \\ c_2 \\ c_3 \\ c_4 \end{bmatrix} = \begin{bmatrix} .45970 \\ -0.08683  \\  -0.00059 \\ -.008769 \end{bmatrix} $$ The approximation on the Fourier basis is:
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ f(x) = e^x \approx c_1 b_1(x) + c_2 b_2(x) + c_3 b_3(x) + c_4 b_4(x) = (.45970)(1) + (-0.08683)(\cos(\pi x)) + (-0.00059)(\cos(2\pi x)) + (-.008769)(\cos(3\pi x)) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Red = Approximation

Blue = Exact



n = 4

 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\Gamma (\{ b_i \}) = \begin{bmatrix} 1 & 0 & 0 & 0 & 0 \\ 0 & .5 & 0 & 0 & 0 \\ 0 & 0 & .5 & 0 & 0 \\ 0 & 0 & 0 & .5 & 0 \\ 0 & 0 & 0 & 0 & .5 \end{bmatrix} $$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\Gamma^{-1} (\{ b_i \}) = \begin{bmatrix} 1 & 0 & 0 & 0 & 0 \\ 0 & .5 & 0 & 0 & 0 \\ 0 & 0 & .5 & 0 & 0 \\ 0 & 0 & 0 & .5 & 0 \\ 0 & 0 & 0 & 0 & .5 \end{bmatrix} $$
 * }
 * }

Compute known components on rhs using exact integration
 * {| style="width:100%" border="0"

$$ \mathbf d = \begin{bmatrix} d_1 \\ d_2  \\ d_3 \\ d_4 \\ d_5 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_i = \langle b_i, f \rangle = \int_{a}^{b} b_i f dx $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_1 = \langle b_1, f \rangle = \int_{0}^{1} 1 \sin(x) dx = .45970 $$
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+sin%28x%29dx+from+0+to+1
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$ d_2 = \langle b_2, f \rangle = \int_{0}^{1} \cos(\pi x) \sin(x) dx = -.17366 $$
 * style="width:95%" |
 * style="width:95%" |
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%28pi*x%29*sin%28x%29dx+from+0+to+1
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%28pi*x%29*sin%28x%29dx+from+0+to+1


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_3 = \langle b_3, f \rangle = \int_{0}^{1} \cos(2\pi x) \sin(x) dx =  -.0011947

$$
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%282pi*x%29*sin%28x%29dx+from+0+to+1
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%282pi*x%29*sin%28x%29dx+from+0+to+1


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_4 = \langle b_4, f \rangle = \int_{0}^{1} \cos(3\pi x) \sin(x) dx = -0.017538

$$
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%283pi*x%29*sin%28x%29dx+from+0+to+1
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%283pi*x%29*sin%28x%29dx+from+0+to+1


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_5 = \langle b_5, f \rangle = \int_{0}^{1} \cos(4\pi x) \sin(x) dx = -0.0029296

$$
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%284pi*x%29*sin%28x%29dx+from+0+to+1
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$ \mathbf d = \begin{bmatrix} .45970 \\  -.17366  \\  -.0011947 \\ -0.017538 \\-0.0029296 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Recall that
 * {| style="width:100%" border="0"

$$ \mathbf c = \boldsymbol \Gamma^{-1} \mathbf d $$ Substituting in to solve for the unknowns:
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }
 * {| style="width:100%" border="0"

$$ \begin{bmatrix} c_1 \\ c_2 \\ c_3 \\ c_4 \\ c_5 \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0 & 0 & 0  \\ 0 & .5 & 0 & 0 & 0 \\ 0 & 0 & .5 & 0 & 0 \\ 0 & 0 & 0 & .5 & 0 \\ 0 & 0 & 0 & 0 & .5 \end{bmatrix} \begin{bmatrix} .45970 \\ -.17366  \\ -.0011947 \\ -0.017538 \\ -0.0029296\end{bmatrix} $$ And so
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }
 * {| style="width:100%" border="0"

$$ \begin{bmatrix} c_1 \\ c_2 \\ c_3 \\ c_4 \\ c_5 \end{bmatrix} = \begin{bmatrix} .45970 \\ -0.08683  \\  -0.00059 \\ -.008769 \\ -.0014648 \end{bmatrix} $$ The approximation on the Fourier basis is:
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ f(x) = e^x \approx c_1 b_1(x) + c_2 b_2(x) + c_3 b_3(x) + c_4 b_4(x) + c_5 b_5(x)
 * style="width:95%" |
 * style="width:95%" |

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

= (.45970)(1) + (-0.08683)(\cos(\pi x)) + (-0.00059)(\cos(2\pi x)) + (-.008769)(\cos(3\pi x)) + (-.0014648)(\cos(4\pi x)) $$
 * }
 * }

Red = Approximation

Blue = Exact



Question 4

 * {| style="width:100%" border="0"

$$ \log(1 + x) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

n = 2

 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\Gamma (\{ b_i \}) = \begin{bmatrix} 1 & 0 & 0 \\ 0 & .5 & 0  \\ 0 & 0 & .5 \end{bmatrix} $$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\Gamma^{-1} (\{ b_i \}) = \begin{bmatrix} 1 & 0 & 0 \\ 0 & .5 & 0  \\ 0 & 0 & .5 \end{bmatrix} $$
 * }
 * }

Compute known components on rhs
 * {| style="width:100%" border="0"

$$ \mathbf d = \begin{bmatrix} d_1 \\ d_2  \\ d_3  \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_i = \langle b_i, f \rangle = \int_{a}^{b} b_i f dx $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_1 = \langle b_1, f \rangle = \int_{0}^{1} 1 \log(1+x) dx = 0.38629 $$
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+log%281%2Bx%29dx+from+0+to+1
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$ d_2 = \langle b_2, f \rangle = \int_{0}^{1} \cos(\pi x) \log(1+x) dx = -0.138078 $$
 * style="width:95%" |
 * style="width:95%" |
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%28pi*x%29log%281%2Bx%29dx+from+0+to+1
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%28pi*x%29log%281%2Bx%29dx+from+0+to+1


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_3 = \langle b_3, f \rangle = \int_{0}^{1} \cos(2\pi x) \log(1+x) dx =  -0.011779

$$
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%282pi*x%29log%281%2Bx%29dx+from+0+to+1
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%282pi*x%29log%281%2Bx%29dx+from+0+to+1


 * {| style="width:100%" border="0"

$$ \mathbf d = \begin{bmatrix}  0.38629 \\  -0.138078  \\ -0.011779 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Recall that
 * {| style="width:100%" border="0"

$$ \mathbf c = \boldsymbol \Gamma^{-1} \mathbf d $$ Substituting in to solve for the unknowns:
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }
 * {| style="width:100%" border="0"

$$ \begin{bmatrix} c_1 \\ c_2 \\ c_3  \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0  \\ 0 & .5 & 0  \\ 0 & 0 & .5 \end{bmatrix} \begin{bmatrix} 0.38629 \\  -0.138078  \\ -0.011779  \end{bmatrix} $$ And so
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }
 * {| style="width:100%" border="0"

$$ \begin{bmatrix} c_1 \\ c_2 \\ c_3   \end{bmatrix} = \begin{bmatrix}  0.38629 \\  -.069039  \\ -.0058895  \end{bmatrix} $$ The approximation on the Fourier basis is:
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ f(x) = e^x \approx c_1 b_1(x) + c_2 b_2(x) + c_3 b_3(x)
 * style="width:95%" |
 * style="width:95%" |

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

= (0.38629)(1) + (-.069039)(\cos(\pi x)) + (-.0058895)(\cos(2\pi x)) $$
 * }
 * }

Red = Approximation

Blue = Exact



n = 3

 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\Gamma (\{ b_i \}) = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & .5 & 0 & 0 \\ 0 & 0 & .5 & 0 \\ 0 & 0 & 0 & .5 \end{bmatrix} $$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\Gamma^{-1} (\{ b_i \}) = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & .5 & 0 & 0 \\ 0 & 0 & .5 & 0 \\ 0 & 0 & 0 & .5 \end{bmatrix} $$
 * }
 * }

Compute known components on rhs
 * {| style="width:100%" border="0"

$$ \mathbf d = \begin{bmatrix} d_1 \\ d_2  \\ d_3 \\ d_4  \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_i = \langle b_i, f \rangle = \int_{a}^{b} b_i f dx $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_1 = \langle b_1, f \rangle = \int_{0}^{1} 1 \log(1+x) dx = 0.38629 $$
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+log%281%2Bx%29dx+from+0+to+1
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$ d_2 = \langle b_2, f \rangle = \int_{0}^{1} \cos(\pi x) \log(1+x) dx = -0.138078 $$
 * style="width:95%" |
 * style="width:95%" |
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%28pi*x%29log%281%2Bx%29dx+from+0+to+1
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%28pi*x%29log%281%2Bx%29dx+from+0+to+1


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_3 = \langle b_3, f \rangle = \int_{0}^{1} \cos(2\pi x) \log(1+x) dx =  -0.011779

$$
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%282pi*x%29log%281%2Bx%29dx+from+0+to+1
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_4 = \langle b_4, f \rangle = \int_{0}^{1} \cos(3\pi x) \log(1+x) dx = -0.0166293

$$
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%283pi*x%29log%281%2Bx%29dx+from+0+to+1
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$ \mathbf d = \begin{bmatrix}  0.38629 \\  -0.138078  \\ -0.011779 \\ -0.0166293 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Recall that
 * {| style="width:100%" border="0"

$$ \mathbf c = \boldsymbol \Gamma^{-1} \mathbf d $$ Substituting in to solve for the unknowns:
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }
 * {| style="width:100%" border="0"

$$ \begin{bmatrix} c_1 \\ c_2 \\ c_3 \\ c_4 \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0 & 0   \\ 0 & .5 & 0 & 0  \\ 0 & 0 & .5 & 0 \\ 0 & 0 & 0 & .5  \end{bmatrix} \begin{bmatrix} 0.38629 \\  -0.138078  \\ -0.011779 \\ -0.0166293 \end{bmatrix} $$ And so
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }
 * {| style="width:100%" border="0"

$$ \begin{bmatrix} c_1 \\ c_2 \\ c_3 \\ c_4  \end{bmatrix} = \begin{bmatrix}  0.38629 \\  -.069039  \\ -.0058895 \\ -.00831465 \end{bmatrix} $$ The approximation on the Fourier basis is:
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ f(x) = e^x \approx c_1 b_1(x) + c_2 b_2(x) + c_3 b_3(x) + c_4 b_4(x)
 * style="width:95%" |
 * style="width:95%" |

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

= (0.38629)(1) + (-.069039)(\cos(\pi x)) + (-.0058895)(\cos(2\pi x)) + ( -.00831465)(\cos(3\pi x)) $$
 * }
 * }

Red = Approximation

Blue = Exact



n = 4

 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\Gamma (\{ b_i \}) = \begin{bmatrix} 1 & 0 & 0 & 0 & 0 \\ 0 & .5 & 0 & 0 & 0 \\ 0 & 0 & .5 & 0 & 0 \\ 0 & 0 & 0 & .5 & 0 \\ 0 & 0 & 0 & 0 & .5 \end{bmatrix} $$
 * }
 * }


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

\Gamma^{-1} (\{ b_i \}) = \begin{bmatrix} 1 & 0 & 0 & 0 & 0 \\ 0 & .5 & 0 & 0 & 0 \\ 0 & 0 & .5 & 0 & 0 \\ 0 & 0 & 0 & .5 & 0 \\ 0 & 0 & 0 & 0 & .5 \end{bmatrix} $$
 * }
 * }

Compute known components on rhs
 * {| style="width:100%" border="0"

$$ \mathbf d = \begin{bmatrix} d_1 \\ d_2  \\ d_3 \\ d_4 \\ d_5 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_i = \langle b_i, f \rangle = \int_{a}^{b} b_i f dx $$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_1 = \langle b_1, f \rangle = \int_{0}^{1} 1 \log(1+x) dx = 0.38629 $$
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+log%281%2Bx%29dx+from+0+to+1
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$ d_2 = \langle b_2, f \rangle = \int_{0}^{1} \cos(\pi x) \log(1+x) dx = -0.138078 $$
 * style="width:95%" |
 * style="width:95%" |
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%28pi*x%29log%281%2Bx%29dx+from+0+to+1
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%28pi*x%29log%281%2Bx%29dx+from+0+to+1


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_3 = \langle b_3, f \rangle = \int_{0}^{1} \cos(2\pi x) \log(1+x) dx =  -0.011779

$$
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%282pi*x%29log%281%2Bx%29dx+from+0+to+1
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_4 = \langle b_4, f \rangle = \int_{0}^{1} \cos(3\pi x) \log(1+x) dx = -0.0166293

$$
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%283pi*x%29log%281%2Bx%29dx+from+0+to+1
 * }Verified at http://www.wolframalpha.com/input/?i=integrate+cos%283pi*x%29log%281%2Bx%29dx+from+0+to+1


 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

d_5 = \langle b_5, f \rangle = \int_{0}^{1} \cos(4\pi x) \log(1+x) dx = -0.00310114

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$ \mathbf d = \begin{bmatrix}  0.38629 \\  -0.138078  \\ -0.011779 \\ -0.0166293 \\-0.00310114 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Recall that
 * {| style="width:100%" border="0"

$$ \mathbf c = \boldsymbol \Gamma^{-1} \mathbf d $$ Substituting in to solve for the unknowns:
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }
 * {| style="width:100%" border="0"

$$ \begin{bmatrix} c_1 \\ c_2 \\ c_3 \\ c_4 \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0 & 0 & 0  \\ 0 & .5 & 0 & 0 & 0 \\ 0 & 0 & .5 & 0 & 0 \\ 0 & 0 & 0 & .5 & 0 \\ 0 & 0 & 0 & 0 & .5 \end{bmatrix} \begin{bmatrix} 0.38629 \\  -0.138078  \\ -0.011779 \\ -0.0166293 \\-0.00310114 \end{bmatrix} $$ And so
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }
 * {| style="width:100%" border="0"

$$ \begin{bmatrix} c_1 \\ c_2 \\ c_3 \\ c_4  \\ c_5 \end{bmatrix} = \begin{bmatrix}  0.38629 \\  -.069039  \\ -.0058895 \\ -.00831465 \\ -.00155057 \end{bmatrix} $$ The approximation on the Fourier basis is:
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ f(x) = e^x \approx c_1 b_1(x) + c_2 b_2(x) + c_3 b_3(x) + c_4 b_4(x)
 * style="width:95%" |
 * style="width:95%" |

$$
 * }
 * {| style="width:100%" border="0"
 * {| style="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

= (0.38629)(1) + (-.069039)(\cos(\pi x)) + (-.0058895)(\cos(2\pi x)) + ( -.00831465)(\cos(3\pi x)) + (-.00155057)(\cos(4\pi x)) $$
 * }
 * }

Red = Approximation

Blue = Exact



Problem Statement

 * {| style="width:100%" border="0"

$$ f(x) = a_0 + \sum_{n=1}^\infty [a_n \cos n \omega x + b_n \sin n \omega x] $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| style="width:100%" border="0"

$$ \omega = \frac{2\pi}{p} = \frac{2\pi}{2L} = \frac{\pi}{L} \Rightarrow p = \frac{2 \pi}{\omega} = 2L $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

1. plot the constant function $$ a_0 $$. What is the period of the constant function $$ a_0 $$? Deduce that the constant function $$ a_0 $$ is periodic p=2L.

2. plot the functions $$ cos3\omega x $$ and $$ sin3\omega x $$ with L = 2. what is the smallest period of the periodic functions $$ cos3\omega x $$ and $$ sin3\omega x $$ ? deduce that these periodic functions have period p = 2L. hint: find the period $$ \bar{p} $$ of the function $$ cos\bar{\omega}x $$ with $$ \bar{\omega}=3\omega $$, and relate $$ \bar{p} $$ to p.

3. now the general case, what is the smallest period of the periodic functions $$ cosn\omega x $$ and $$ sinn\omega x $$, where n can be any positive integer? deduce that these periodic functions have period p = 2L. similar hint as above.

4. do the Fourier series expansion of some simple functions.


 * {| style="width:100%" border="0"

$$ f(x) = x^2 (-1<x<1), p=2 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

and


 * {| style="width:100%" border="0"

$$ f(x) = 1-\frac{x^2}{4} (-2<x<2), p=4 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Verification
"Verifying: Part 1"

The following is a property of all periodic functions (not necessarily continuous)


 * {| Italic textstyle="width:100%" border="0"

$$ f(\hat x + n p) = f(\hat x), \text{ for any } \hat x
 * style="width:95%" |
 * style="width:95%" |

\text{ andfor all } n = ..., -2, -1, 0, 1, 2,... $$
 * }
 * }

where


 * {| Italic textstyle="width:100%" border="0"

$$ \hat x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

is a fixed, selected point (to distinguish from the variable x) and p is the period.

From now on, the hat over x will be omitted for simplicity in later calculations.

This property describes a period by showing how the value at any point x in period is

equivalent to that point x plus or minus p for any other period of the function.

Using this property we will describe that one period of a periodic function will start

at x=a and end at x=b. First we want to find the center of a and b.


 * {| Italic textstyle="width:100%" border="0"

$$ \frac{a + b}{2} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Now, we can find the distance from this center to either end of the period.


 * {| Italic textstyle="width:100%" border="0"

$$ \text{ from a } \Rightarrow \bar x = a - \frac{a + b}{2} = \frac{a + b}{2} = -\frac{b - a}{2} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$ \text{ from b } \Rightarrow \bar x = b - \frac{a + b}{2} = \frac{-a + b}{2} = \frac{b - a}{2} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Substituting 2L in for (b - a), since 2L is equal to one period yields:


 * {| Italic textstyle="width:100%" border="0"

$$ \text{ from a } \Rightarrow \bar x = \frac{-2L}{2} = -L $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$ \text{ from b } \Rightarrow \bar x = \frac{2L}{2} = L $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

With the period extending a magnitude of L on either side of the center point, it can be

deduced by adding these two magnitudes together that from a to b is 2L. Therefore, we

can now say that:


 * {| Italic textstyle="width:100%" border="0"

$$ p = 2L $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Since
 * {| Italic textstyle="width:100%" border="0"

$$ a_0 $$ is the first term of the Fourier Series and represents the average of the function, it
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

is a constant function (a straight line) like y = 0 shown below.



Constant functions can have any period because the value of the function at all points

is the same. Therefore, it too has a period of 2L.

"Verifying: Part 2"

We are given the following functions (each with L = 2):


 * {| Italic textstyle="width:100%" border="0"

$$ \cos 3 \omega x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$ \sin 3 \omega x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Using the following property of periodic functions


 * {| Italic textstyle="width:100%" border="0"

$$ f(x + n p) = f(x), \text{ for any } \hat x
 * style="width:95%" |
 * style="width:95%" |

\text{ andfor all } n = ..., -2, -1, 0, 1, 2,... $$
 * }
 * }

we can find the period of these two functions by finding the two the distance between

two consecutive points where the functions have equivalent values.

Both functions have the same distance between consecutive points:




 * {| Italic textstyle="width:100%" border="0"

$$ \text{distance} = \frac{4}{3} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

This value can be compared to the distance between equivalent

values of the function when looking at the function


 * {| Italic textstyle="width:100%" border="0"

$$ \cos \omega x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$ \text{distance} = 4 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

It can be seen that there is a difference between these two distances of a factor

of 3. This factor of 3 affects the value of L.




 * {| Italic textstyle="width:100%" border="0"

$$
 * style="width:95%" |
 * style="width:95%" |

$$ Using the following equality
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$ \omega = \frac{\pi}{L} = \frac{2 \pi}{p} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

we can conclude that


 * {| Italic textstyle="width:100%" border="0"

$$ p = 2L = \frac{2 \pi}{\omega} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

So for the original functions given L is one third of the L for


 * {| Italic textstyle="width:100%" border="0"

$$ \cos \omega x $$ , but, while L may be defined differently, it still holds that the period of each
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

function is two times what L is.

This can be seen is how substituting L in the original equations for 3L yields an graph

equivalent to that of the equation using omega instead of 3 times omega.

"Verifying: Part 3"

With the general case


 * {| Italic textstyle="width:100%" border="0"

$$ \cos n \omega x \text{ and } \sin n \omega x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

for any positive integer n the period can also be deduced to be equal to 2L through a

the same process as deducing the period for


 * {| Italic textstyle="width:100%" border="0"

$$ \cos 3 \omega x \text{ and } \sin 3 \omega x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

For this general case, though, the value of L is affected by a factor of n so that

the L of this function is equal to 1/n of the L for the simplest case of


 * {| Italic textstyle="width:100%" border="0"

$$ \cos \omega x \text{ and } \sin \omega x $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

So, as explained earlier, although the value of L changes, the period p of the function

can be still be defined as


 * {| Italic textstyle="width:100%" border="0"

$$ p = 2L $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Fourier Series Expansion Problems
"Problem #11"

The following is the function given with period, p, equal to 2.


 * {| Italic textstyle="width:100%" border="0"

$$ f(x) = x^2 $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

on the interval (-1 < x < 1).

The Fourier Series is defined, in general, as


 * {| Italic textstyle="width:100%" border="0"

$$ f(x) = a_0 + \sum_{n=1}^\infty [a_n \cos n \omega x + b_n \sin n \omega x] $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

The three coefficients are defined, in general as


 * {| Italic textstyle="width:100%" border="0"

$$ a_0 = \frac{1}{p} \int_{0}^{p} f(x) dx $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$ a_n = \frac{2}{p} \int_{0}^{p} f(x) \cos(n \omega x) dx $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$ b_n = \frac{2}{p} \int_{0}^{p} f(x) \sin(n \omega x) dx $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Plugging in the values and function given yields the following results


 * {| Italic textstyle="width:100%" border="0"

$$ a_0 = \frac{1}{2} \int_{0}^{2} x^{2} dx $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$   = \frac{1}{2} [\frac{1}{3} x^{3}]_{0}^{2} = \frac{4}{3} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$ a_n = \frac{2}{2} \int_{0}^{2} x^{2} \cos(n \pi x) dx $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$   = [\frac{1}{3} x^{3} \cos(n \pi x) + \frac{1}{n \pi} x^{2} \sin(n \pi x)]_{0}^{2} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$   = \frac{8}{3} \cos(2 n \pi) + \frac{4}{n \pi} \sin(2 n \pi) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$ \text{Since sine of any integer times } 2 \pi \text{ equals zero this term can be omitted.} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$   = \frac{8}{3} \cos(2 n \pi) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$ b_n = \frac{2}{2} \int_{0}^{2} x^{2} \sin(n \omega x) dx $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$   = [\frac{1}{3} x^{3} \sin(n \pi x) - \frac{1}{n \pi} x^{2} \cos(n \pi x)]_{0}^{2} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$   = \frac{1}{3} 2^{3} \sin(2 n \pi) - \frac{1}{n \pi} 2^{2} \cos(2 n \pi) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$ \text{Since sine of any integer times } 2 \pi \text{ equals zero this term can be omitted.} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$   = \frac{-4}{n \pi} \cos(2 n \pi) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Putting these values into the Fourier Series equation and cancelling out terms that come out

to zero yields:


 * {| Italic textstyle="width:100%" border="0"

$$ f(x) = \frac{4}{3} + \sum_{n=1}^{\infty}[\frac{8}{3} \cos(2 n \pi) \cos(n \pi x)] $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

"Problem #12"

The following is the function given with period, p, equal to 4.


 * {| Italic textstyle="width:100%" border="0"

$$ f(x) = 1 - \frac{x^2}{4} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

on the interval (-2 < x <2).

The Fourier Series is defined, in general, as


 * {| Italic textstyle="width:100%" border="0"

$$ f(x) = a_0 + \sum_{n=1}^\infty [a_n \cos n \omega x + b_n \sin n \omega x] $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

The three coefficients are defined, in general as


 * {| Italic textstyle="width:100%" border="0"

$$ a_0 = \frac{1}{p} \int_{0}^{p} f(x) dx $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$ a_n = \frac{2}{p} \int_{0}^{p} f(x) \cos(n \omega x) dx $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$ b_n = \frac{2}{p} \int_{0}^{p} f(x) \sin(n \omega x) dx $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Plugging in the values and function given yields the following results


 * {| Italic textstyle="width:100%" border="0"

$$ a_0 = \frac{1}{4} \int_{0}^{4} 1 - \frac{x^{2}}{4} dx $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$   = \frac{1}{4} [x - \frac{x^{3}}{12}]_{0}^{4} = \frac{-1}{3} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$ a_n = \frac{2}{4} \int_{0}^{4} 1 - \frac{x^{2}}{4} \cos(n \frac{\pi}{2} x) dx $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$   = \frac{1}{2} [\frac{2}{n \pi} \sin(n \frac{\pi}{2} x) - \frac{x^{3}}{12} \cos(n \frac{\pi}{2} x) + \frac{x^{2}}{2 n \pi} \sin(n \frac{\pi}{2} x)]_{0}^{4} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$   = \frac{1}{2} [\frac{2}{n \pi} \sin(2 n \pi) - \frac{16}{3} \cos(2 n \pi) + \frac{8}{n \pi} \sin(2 n \pi)] $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$ \text{Since sine of any integer times } 2 \pi \text{ equals zero these terms can be omitted.} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$   = \frac{-8}{3} \cos(2 n \pi) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$ b_n = \frac{2}{4} \int_{0}^{4} 1 - \frac{x^{2}}{4} \sin(n \frac{\pi}{2} x) dx $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$   = \frac{1}{2} [\frac{-2}{n \pi} \cos(n \frac{\pi}{2} x) - \frac{x^{3}}{12} \sin(n \frac{\pi}{2} x) + \frac{x^{2}}{2 n \pi} \cos(n \frac{\pi}{2} x)]_{0}^{4} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$   = \frac{1}{2} [\frac{-2}{n \pi} \cos(2 n \pi) - \frac{16}{3} \sin(2 n \pi) + \frac{8}{n \pi} \cos(2 n \pi)] $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$ \text{Since sine of any integer times } 2 \pi \text{ equals zero this term can be omitted.} $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$   = \frac{-1}{n \pi} \cos(2 n \pi) + \frac{4}{n \pi}cos(2 n \pi) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }


 * {| Italic textstyle="width:100%" border="0"

$$   = \frac{3}{n \pi} \cos(2 n \pi) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Putting these values into the Fourier Series equation yields:


 * {| Italic textstyle="width:100%" border="0"

$$ f(x) = \frac{-1}{3} + \sum_{n=1}^{\infty}[\frac{-8}{3} \cos(2 n \pi) \cos(n \pi x) + \frac{3}{n \pi} \cos(2 n \pi)sin(\frac{\pi}{2} n x)] $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

Problem Statement
Create a spreadsheet with the 88 piano keys, their corresponding frequencies (pitches), and deduce for each

pitch the music note (in scientific notation) for that piano key, using the spreadsheet formulas provided in

this section. also, check your results with portions of this spreadsheet, as given in this section.

Solution
The table below shows the frequencies of all 88 piano keys along with pitch for each corresponding piano key. All other information was

a supplement to the calculations performed. The following formula was provided and used to find the frequency of each piano key.


 * {| Italic textstyle="width:100%" border="0"

$$ f_n = f_1 * (\sqrt[12]{2} \,)^{(n-1)}, \ \text{with } f_1 = 27.5 \text{ Hz } $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

$$ f_1 $$ is given and remains constant through all frequency calculations performed for the table.

$$ (\sqrt[12]{2} \,)^{(n-1)} $$ represents the frequency factor where $$ n $$ represents the key number.

The part of the frequency formula that is used to find frequency factor is derived from the premise that an octave is divided into 12 semitones. The ratio of the 2 frequencies to the 2 successive semitones equals $$ (\sqrt[12]{2} \,) $$.

The number of keys from A0 is approximated by $$ n-1 $$.

When the calculated frequency is not an exact key away from A0 ($$ n-1 $$ is not a round integer number) the following equation is used to find the key number away from A0 that is closest to the calculated frequency.


 * {| Italic textstyle="width:100%" border="0"

$$ n-1 = 12 * \ln ( f_n / f_1 ) / \ln(2) $$
 * style="width:95%" |
 * style="width:95%" |
 * }
 * }

The key number within an octave was found using the excel formula MOD(ROUND(n-1,0),12)+1 where ROUND(n-1,0) equals rounding (n-1) with a zero decimal digit and MOD(m, 12) equals the remainder of m divided by 12.

Finally the octave number was determined by using the excel test

if ("key no. in an octave"<4) then

QUOTIENT (ROUND(n-1, 0), 12)

else

QUOTIENT (ROUND(n-1, 0), 12) + 1

endif

The actual code used in excel to determine frequency was Ci = Bi * 27.5 where Ci is any given piano key frequency and Bi is its corresponding frequency factor.

The actual code used in excel to determine frequency factor was Bi = (2^(1/12))^(Ai-1) where Bi is any given piano key frequency factor and Ai is its corresponding piano key number.