User:Egm6322.s12.team2.shields

Matt Shields' HW problems

Report 8
R8.1: 

'''Construct the Gram matrix for the Fourier basis functions (3)p.40-1 using the scalar product (2)p.42-8. What is the property of the Gram matrix?'''

Solution (Note: solved independently):

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

$$  \displaystyle \textbf{B} = \left\{1,cos(n\omega\theta),sin(n\omega\theta)\right\}, n = 1,2,.... $$     (8.1.1)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }

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

$$  \displaystyle \mathbf{\Gamma} = [\mathbf{\Gamma_{ij}}] = [(\mathbf b_i \cdot \mathbf b_j)] \in \mathbb{R} $$     (8.1.2)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }

Definition of inner product for functions:
 * {| style="width:100%" border="0"

$$  \displaystyle \langle g,h \rangle = \int_a^b g(x)h(x)dx $$     (8.1.3)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }

To form the Gram matrix for the Fourier basis functions given in Eq. 8.1.1, it is necessary to compute the inner product for all combinations of basis functions; ie, $$g(\theta)=1,h(\theta)=cos(n\omega\theta); g(\theta)=1,h(\theta)=sin(n\omega\theta); g(\theta)=cos(n\omega\theta),h(\theta)=cos(n\omega\theta);$$ etc. Using Eq. 3 for all permutations, the components of the Gram matrix are computed below. The diagonal terms are given by:


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

$$  \displaystyle \begin{align} \langle 1,1 \rangle &= 1 \\ &=\Gamma_{11} \end{align} $$     (8.1.4)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }


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

$$  \displaystyle \begin{align} \langle \text{cos}(n\omega\theta),\text{cos}(n\omega\theta) \rangle& = \int_0^T \text{cos}^2(n\omega\theta)d\theta \\ &= \int_0^T \frac{1}{2} + \frac{1}{2}\text{cos}(2n\omega\theta) d\theta \\ &=\left[\frac{\theta}{2} + \frac{\text{sin}(2n\omega\theta)}{4n\omega}\right]_0^T \\ &= \frac{T}{2} + \frac{\text{sin}(2n\omega T)}{4n\omega} \\ & =\Gamma_{22} \end{align} $$     (8.1.5)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }


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

$$  \displaystyle \begin{align} \langle \text{sin}(n\omega\theta),\text{sin}(n\omega\theta) \rangle& = \int_0^T \text{sin}^2(n\omega\theta)d\theta \\ &= \int_0^T \frac{1}{2} - \frac{1}{2}\text{cos}(2n\omega\theta) d\theta \\ &=\left[\frac{\theta}{2} - \frac{\text{sin}(2n\omega\theta)}{4n\omega}\right]_0^T \\ &= \frac{T}{2} - \frac{\text{sin}(2n\omega T)}{4n\omega} \\ & =\Gamma_{33} \end{align} $$     (8.1.6)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }

And the off-diagonal terms, noting that due to symmetry of the integral, $$\Gamma_{ij} = \Gamma_{ji}$$ for $$i\neq j$$:


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

$$  \displaystyle \begin{align} \langle 1,\text{cos}(n\omega\theta) \rangle& = \int_0^T (1)(\text{cos}(n\omega\theta))d\theta \\ &= \frac{1}{n\omega}[\text{sin}(n\omega\theta)]_0^T \\ &= \frac{1}{n\omega}\text{sin}(n\omega T)\\ & =\Gamma_{12} = \Gamma_{21} \end{align} $$     (8.1.7)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }


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

$$  \displaystyle \begin{align} \langle 1,\text{sin}(n\omega\theta) \rangle& = \int_0^T (1)(\text{sin}(n\omega\theta))d\theta \\ &= -\frac{1}{n\omega}[\text{cos}(n\omega\theta)]_0^T \\ &= -\frac{1}{n\omega}\left(\text{cos}(n\omega T)-1\right) \\ & =\Gamma_{13} = \Gamma_{31} \end{align} $$     (8.1.8)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }


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

$$  \displaystyle \begin{align} \langle \text{cos}(n\omega\theta),\text{sin}(n\omega\theta) \rangle& = \int_0^T (\text{cos}(n\omega\theta))(\text{sin}(n\omega\theta))d\theta \\ &= \int_0^T \frac{1}{2}\text{sin}(2n\omega\theta) d\theta \\ &= -\frac{1}{4n\omega}[\text{cos}(2n\omega\theta)]_0^T \\ &= -\frac{1}{4n\omega}\left(\text{cos}(2n\omega T)-1\right) \\ & =\Gamma_{13} = \Gamma_{31} \end{align} $$     (8.1.9)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }

Substituting the results of Eq. 8.1.4-8.1.9 into Eq. 8.1.2 yields the Gram matrix for the Fourier basis functions:
 * {| style="width:100%" border="0"

$$  \displaystyle \mathbf{\Gamma} = \begin{bmatrix} 1 & \frac{1}{n\omega}\text{sin}(n\omega T) & -\frac{1}{n\omega}\left(\text{cos}(n\omega T)-1\right) \\ \frac{1}{n\omega}\text{sin}(n\omega T) & \frac{T}{2} + \frac{\text{sin}(2n\omega T)}{4n\omega} & -\frac{1}{4n\omega}\left(\text{cos}(2n\omega T)-1\right)\\ -\frac{1}{n\omega}\left(\text{cos}(n\omega T)-1\right) & -\frac{1}{4n\omega}\left(\text{cos}(2n\omega T)-1\right) & \frac{T}{2} - \frac{\text{sin}(2n\omega T)}{4n\omega} \end{bmatrix} $$     (8.1.10)
 * style="width:92%; padding:10px; border:2px solid #8888aa" |
 * style="width:92%; padding:10px; border:2px solid #8888aa" |
 * 
 * }

By inspection, it is clear that the columns of $$\mathbf{\Gamma}$$ are linearly independent as one cannot form one vector from a linear combination of the other two; thus, the Gram matrix for the Fourier basis functions is invertible for all values of n.

R8.1(cont)

Show that $$\left\{cos\theta,sin\theta\right\}$$ are linearly independent using the Wronskian; see (2)p.35-1

Solution (Note: Solved independently):

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

$$  \displaystyle W = \begin{vmatrix} u_1 & u_2\\ \dot{u_1} & \dot{u_2} \end{vmatrix} $$     (8.1.11) in which $$\dot{u}$$ represents the derivative of u. Thus, for the Fourier basis functions in Eq. 8.1.1,
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }
 * {| style="width:100%" border="0"

$$  \displaystyle \begin{align} W &= \begin{vmatrix} \text{cos}\theta & \text{sin}\theta\\ \dot{\text{cos}\theta } & \dot{\text{sin}\theta} \end{vmatrix}\\ &= \begin{vmatrix} \text{cos}\theta & \text{sin}\theta\\ -\text{sin}\theta & \text{cos}\theta \end{vmatrix} \\ &= \text{cos}^2\theta + \text{sin}^2\theta = 1 \neq 0 \end{align} $$     (8.1.12)
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

As the determinant is nonzero the basis functions are linearly independent.

<H3>R8.7</H3>

Consider the following polynomial:


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

$$  \displaystyle \begin{align} q &\in \mathcal{P}_n \Rightarrow q(x) = \sum_{i=0}^n c_ix^i \\ n &= 5; c_0 = -4,c_1=-7,c_2=3,c_3=2,c_4=-5,c_5=1 \end{align} $$     (8.1.13) Find $$d_i$$ such that
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }
 * {| style="width:100%" border="0"

$$  \displaystyle q(x) = \sum_{i=0}^n d_iP_i(x) \in \mathcal{P}_n $$     (8.1.14) '''and plot Eq. 8.1.12 and 8.1.13 on separate figures'''
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

Solution (Note: Solved independently):

The goal of this problem is essentially to complete change of basis such that the polynomial q(x) given in Eq. 8.1.13 is mapped onto the orthogonal basis of Legendre polynomials $$P_i$$. This requires the coefficients to the polynomials which can be obtained using Eq. (3)p.42-16 in the class notes, adapted here in Eq. 8.1.15:
 * {| style="width:100%" border="0"

$$  \displaystyle d_i = \frac{2i+1}{2} \int_{x=-1}^{x=1} P_i(x) q(x)dx $$     (8.1.15)
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right">
 * }

The Legendre polynomials are well known and can be found online; see for example Wolfram's website (http://mathworld.wolfram.com/LegendrePolynomial.html). Thus, it is only necessary to multiply the polynomials and integrate from -1 to 1; this yields the required coefficients $$d_0$$ through $$d_5$$. For brevity, the algebra for the first coefficient will be included and only the values of the remaining coefficients will be presented. All calculations were verified using Mathematica.


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

$$  \displaystyle \begin{align} d_0& = \frac{2(0)+1}{2} \int_{x=-1}^{x=1} (1) (x^5-5x^4+2x^3+3x^2-7x-4)dx \\ &= \frac{1}{2}\left[\frac{1}{6}x^6 - x^5 + \frac{1}{2} x^4 +x^3 -\frac{7}{2}x^2 -4x\right]_{-1}^1 \\ &= -4 \end{align} $$     (8.1.16)
 * style="width:92%; padding:10px; border:2px solid #8888aa" |
 * style="width:92%; padding:10px; border:2px solid #8888aa" |
 * <p style="text-align:right">
 * }

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

$$  \displaystyle d_1=-5.370; d_2= -0.857; d_3=1.244;d_4=-1.143;d_5=0.127 $$     (8.1.17)
 * style="width:92%; padding:10px; border:2px solid #8888aa" |
 * style="width:92%; padding:10px; border:2px solid #8888aa" |
 * <p style="text-align:right">
 * }

To verify that the mapping of q(x) onto the Legendre polynomial basis functions, the original polynomial and the summation of $$\sum_{i=0}^{n=5}d_i P_i$$ are plotted separately from $$-10<x<10$$. As expected, the figures are identical.