User:Eml5526.s11.team4/HW3

= Problem 3.1 - Residue Projection for Polynominals with shift=

Problem Statement
Consider Data Set 2 with the following parameters: $$ \begin{align} \Omega=]0,1[ \end{align} $$

$$ \begin{align} a_{2}=0 \end{align} $$

$$ \begin{align} f = 3 \end{align} $$

With boundary conditions given by: $$ \begin{align} \Gamma_{h}=\left\{x=0\right\}, h=4 \end{align} $$

$$ \begin{align} \Gamma_{g}=\left\{x=1\right\}, g=0 \end{align} $$

1.)Let n = 2, where the number of degrees of freedom is equal to n + 1 (ndof = 2 + 1 = 3)

2.) Find two equations that enforce the boundary conditions for: $$ \begin{align} u^h(x) = \sum_{j=0}^n{d_jb_j(x)} \end{align} $$

3.) Find an additional equation by projecting the residue on the basis function prescribed as: $$ \begin{align} \left\{b_{j}(x);j=0,1,...,n\right\}=\left\{(x+k)^{j}\right\} \end{align} $$ Where $$k=1$$ in order to serve as a shift to avoid a trivial solution ($$b_{j}'(x=0)=0$$)- UPDATE- See Problem 3.7.

4.)Display the equations in matrix form and observe the symmetry of the stiffness matrix $$\textbf{K}$$. $$ \begin{align} \textbf{Kd=F} \end{align} $$

5.)Solve for $$\textbf{d}$$.

6.)Construct $$u^h(x)$$ and plot $$u^h(x)$$ versus $$u(x)$$

7.)Repeat this problem for n = 4 and n = 6.

Exact Solution
After applying boundary conditions

For the case where $$ n = 2 $$
with

{| style="width:100%" border="0" $$ \begin{align} u^h(x) = & \sum_{j=0}^n d_jb_j(x)\\ &=d_0+d_1 (x+1)+ d_2 (x+1)^2 \end{align} $$
 * style="width:95%" |
 * style="width:95%" |

Boundary Conditions
Applying the boundary conditions produces two of the three necessary equations:

Additional Equation
The final equation is formed by projecting the residue onto the basis function as follows:

Since this is a steady state problem,

Which results in:

Matrix Form
There are now three equations for three unknowns which can be expressed in matrix form:

$$ \mathbf{K} $$ is not symmetric.

Solving the system produces the result:

For the case where $$ n = 4 $$
with

{| style="width:100%" border="0" $$ \begin{align} u^h(x) = & \sum_{j=0}^n d_jb_j(x)\\ &=d_0+d_1 (x+1)+ d_2 (x+1)^2+d_3(x+1)^3+d_4(x+1)^4 \end{align} $$
 * style="width:95%" |
 * style="width:95%" |

Boundary Conditions
Applying the boundary conditions produces two of the five necessary equations:

Additional Equations
The final three equations are formed by projecting the residue onto the basis function as follows (repeating 3 times):

Since this is a steady state problem,

Which results in:

Matrix Form
There are now five equations for five unknowns which can be expressed in matrix form:

$$ \mathbf{K} $$ is not symmetric.

Solving the system produces the result:

For the case where $$ n = 6 $$
with

{| style="width:100%" border="0" $$ \begin{align} u^h(x) = & \sum_{j=0}^n d_jb_j(x)\\ &=d_0+d_1 (x+1)+ d_2 (x+1)^2+d_3(x+1)^3+d_4(x+1)^4+d_5(x+1)^5+d_6(x+1)^6 \end{align} $$
 * style="width:95%" |
 * style="width:95%" |

Boundary Conditions
Applying the boundary conditions produces two of the seven necessary equations:

Additional Equations
The final five equations are formed by projecting the residue onto the basis function as follows (repeating 5 times):

Since this is a steady state problem,

Which results in:

Matrix Form
There are now seven equations for seven unknowns which can be expressed in matrix form:

$$ \mathbf{K} $$ is not symmetric.

Solving the system produces the result:

Assembling Equations
Now we apply our two boundary conditions, but before we do so we need to work in in a modified form. To do so we re-express

We will obtain $$n$$ equations using boundary conditions and projection, so that we will obtain a system of equations

Where $$\textbf{K}$$ is the direct assembly of $$\textbf{b}$$ vectors for each equation in the system. The right hand side is the vector $$\mathbf{r}$$ which consists of the right hand side constants, that is not containing a $$d_j$$ term. To find the vector $$\mathbf{d}$$ the system is then simply solved.

Boundary Conditions
We now add to our script the equations resulting from evaluating the boundary conditions on $$u^h$$

Additional Equations
The boundary conditions have added two equations to our system, but we need to have $$n$$ equations in our system. Thus we create $$n-1$$ equations by looking at the projection, note $$n$$ is base zero.

Our additional equations are found by projecting bases terms by the system operated on $$u^h$$, or:

We thus add our equations to the system based on the definition above

Solving
The last step is to simply solve for the coefficients and plot

$$n=2$$
Running the developed MATLAB script for $$n=2$$



$$n=4$$
Running the developed MATLAB script for $$n=4$$



$$n=6$$
Running the developed MATLAB script for $$n=6$$



Order of Convergence
The $$L^2$$ norm of the error is taken over the domain for $$n=2,3,4,5, \text{ and } 6$$ using the continuous definition of the norm.

Performing the integration for each approximation and plotting in log-log results in the plot below.