User:Eml5526.s11.team3.hylon/Homework 4

=Problem4.1 Solve for trial solution of the PDE using sine basis=

Problem Statement
Given $${{b}_{i}}(x)=[1,\sin (x),\sin (2x),\cdots ]$$.

$$1).$$ Find two equations that enforce boundary conditions for $${{u}^{h}}(x)=\sum\limits_{j=0}^{n}{{{d}_{j}}{{b}_{j}}(x)}$$.

Natural boundary condition: $$-\frac{d{{u}^{h}}(x=0)}{dx}=4$$;

essential boundary condition: $${{u}^{h}}(x=1)=0$$.

$$2).$$ Find one more equation to solve for $$\underline{d}=\left\{ {{d}_{j}} \right\} (j=0,1,2)$$by project the residue $$P({{u}^{h}})$$ on a basis function $${{b}_{k}}(x)$$ with $$k=0,1,2 $$, such that the additional equation is linear independent from the above two equations in $$(1)$$. $$3).$$ Display three equations in matrix form $$\underline{K}\underline{d}=\underline{F}$$, observe symmetric property of $$\underline{K}$$. $$4).$$ Solve for $$\underline{d}$$. $$5).$$ Construct $$u_{2}^{h}(x)$$ and plot $$u_{2}^{h}(x)$$ vs. $$u_{2}^ – (x)$$. $$6).$$Compute $$u_{2}^{h}(x=0.5)$$ and Error $${{e}_{2}}(x=0.5)=u(x=0.5)-{{u}^{h}}(x=0.5)$$. $$7).$$ Repeat $$1)-6)$$ for $$n=4,n=6$$. $$8).$$ Plot $${{e}_{2}}(x=0.5)$$ vs. $$n$$ Refer to lecture slide [[media:fe1.s11.mtg18.djvu|18-2]] for more information.

Solution
When n =2

1.

Equation enforcing natural boundary condition:


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

$$\displaystyle
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * style="width:92%; padding:10px; border:2px solid #ff0000" |

{{d}_{1}}+2{{d}_{2}}=-4

$$
 * }

Equation enforcing essential boundary condition:
 * {| style="width:100%" border="0"

$$\displaystyle
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * style="width:92%; padding:10px; border:2px solid #ff0000" |

{{d}_{0}}+0.8415{{d}_{1}}+0.9093{{d}_{2}}=0

$$
 * }

2.

Equation from projection:


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

$$\displaystyle
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * style="width:92%; padding:10px; border:2px solid #ff0000" |

0.9194{{d}_{1}}+5.6646{{d}_{2}}=3

$$
 * }

3.

Display three equations in matrix form:


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

$$\displaystyle
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * style="width:92%; padding:10px; border:2px solid #ff0000" |

\left( \begin{matrix}  0 & 1 & 2  \\   1 & 0.8415 & 0.9093  \\   0 & 0.9194 & 5.6646  \\ \end{matrix} \right)\left( \begin{matrix}   {{d}_{0}}  \\   {{d}_{1}}  \\   {{d}_{2}}  \\ \end{matrix} \right)=\left( \begin{matrix}   -4  \\   0  \\   3  \\ \end{matrix} \right)

$$
 * }

$$K$$ is non-symmetric.

4.


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

$$\displaystyle
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * style="width:92%; padding:10px; border:2px solid #ff0000" |

\left( \begin{matrix}  {{d}_{0}}  \\   {{d}_{1}}  \\   {{d}_{2}}  \\ \end{matrix} \right)={{\left( \begin{matrix}   0 & 1 & 2  \\   1 & 0.8415 & 0.9093  \\   0 & 0.9194 & 5.6646  \\ \end{matrix} \right)}^{-1}}\left( \begin{matrix}   -4  \\   0  \\   3  \\ \end{matrix} \right)=\left( \begin{matrix}   4.7162  \\   -7.4908  \\   1.7454  \\ \end{matrix} \right)

$$
 * }

5.

The approximate solution:


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

$$\displaystyle
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * style="width:92%; padding:10px; border:2px solid #ff0000" |

\text{u}_{2}^{h}\text{(x)=4}\text{.7162-7}\text{.4908sin(x)+1}\text{.7454sin(2x)}

$$
 * }

6.

Error between exact solution and approximate solution at point x=0.5.


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

$$\displaystyle
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * style="width:92%; padding:10px; border:2px solid #ff0000" |

error(x=0.5)=-0.0311

$$
 * }



When n =4

1.

Equation enforcing natural boundary condition:


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

$$\displaystyle
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * style="width:92%; padding:10px; border:2px solid #ff0000" |

{{d}_{1}}+2{{d}_{2}}+3{{d}_{3}}+4{{d}_{4}}=-4

$$
 * }

Equation enforcing essential boundary condition:
 * {| style="width:100%" border="0"

$$\displaystyle
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * style="width:92%; padding:10px; border:2px solid #ff0000" |

{{d}_{0}}+0.8415{{d}_{1}}+0.9093{{d}_{2}}+0.1411{{d}_{3}}-0.7568{{d}_{4}}=0

$$
 * }

2.

Equations from projection:


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

$$\displaystyle
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * style="width:92%; padding:10px; border:2px solid #ff0000" |

0.9194{{d}_{1}}+\text{5}.\text{6646}{{d}_{2}}+\text{11}.\text{9400}{{d}_{3}}+\text{13}.\text{2291}{{d}_{4}}=3

$$
 * }


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

$$\displaystyle
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * style="width:92%; padding:10px; border:2px solid #ff0000" |

0.\text{5454}{{d}_{1}}+\text{3}.\text{1777}{{d}_{2}}+\text{5}.\text{7946}{{d}_{3}}+\text{3}.\text{8212}{{d}_{4}}=\text{1}.\text{379}0\text{9}

$$
 * }


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

$$\displaystyle
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * style="width:92%; padding:10px; border:2px solid #ff0000" |

0.\text{7944}{{d}_{1}}+\text{4}.\text{7568}{{d}_{2}}+\text{9}.\text{2993}{{d}_{3}}+\text{8}.0\text{195}{{d}_{4}}=\text{2}.\text{1242}

$$
 * }

3.

Display five equations in matrix form:


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

$$\displaystyle
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * style="width:92%; padding:10px; border:2px solid #ff0000" |

\left( \begin{matrix}  0 & 1 & 2 & 3 & 4  \\   1 & 0.\text{8415} & 0.\text{9}0\text{93} & 0.\text{1411} & -0.\text{7568}0  \\   0 & 0.\text{9194} & \text{5}.\text{6646} & \text{11}.\text{9400} & \text{13}.\text{2291}  \\   0 & 0.\text{5454} & \text{3}.\text{1777} & \text{5}.\text{7946} & \text{3}.\text{8212}  \\   0 & 0.\text{7944} & \text{4}.\text{7568} & \text{9}.\text{2993} & \text{8}.0\text{195}  \\ \end{matrix} \right)\left( \begin{matrix}   {{d}_{0}}  \\   {{d}_{1}}  \\   {{d}_{2}}  \\   {{d}_{3}}  \\   {{d}_{4}}  \\ \end{matrix} \right)=\left( \begin{matrix}   -4  \\   0  \\   3  \\   \text{1}.\text{379}1  \\   \text{2}.\text{1242}  \\ \end{matrix} \right)

$$
 * }

$$K$$ is non-symmetric.

4.


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

$$\displaystyle
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * style="width:92%; padding:10px; border:2px solid #ff0000" |

\left( \begin{matrix}  {{d}_{0}}  \\   {{d}_{1}}  \\   {{d}_{2}}  \\   {{d}_{3}}  \\   {{d}_{4}}  \\ \end{matrix} \right)={{\left( \begin{matrix}   0 & 1 & 2 & 3 & 4  \\   1 & 0.\text{8415} & 0.\text{9}0\text{93} & 0.\text{1411} & -0.\text{7568}  \\   0 & 0.\text{9194} & \text{5}.\text{6646} & \text{11}.\text{9400} & \text{13}.\text{2291}  \\   0 & 0.\text{5454} & \text{3}.\text{1777} & \text{5}.\text{7946} & \text{3}.\text{8212}  \\   0 & 0.\text{7944} & \text{4}.\text{7568} & \text{9}.\text{2993} & \text{8}.0\text{1949}  \\ \end{matrix} \right)}^{-1}}\left( \begin{matrix}   -4  \\   0  \\   3  \\   \text{1}.\text{379}1  \\   \text{2}.\text{1242}  \\ \end{matrix} \right)=\left( \begin{matrix}   \text{4}.\text{7491}  \\   -\text{13}.\text{1144}  \\   \text{8}.\text{2}0\text{87}  \\   -\text{3}.\text{6116}  \\   0.\text{8830}  \\ \end{matrix} \right)

$$
 * }

5.

The approximate solution:


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

$$\displaystyle
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * style="width:92%; padding:10px; border:2px solid #ff0000" |

\text{u}_{4}^{h}\text{(x)=4}.\text{7491}-\text{ 13}.\text{1144sin}\left( \text{x} \right)\text{ }+\text{8}.\text{2}0\text{87sin}\left( \text{2x} \right)\text{ }-\text{ 3}.\text{6116sin}\left( \text{3x} \right)\text{ }+\text{ }0.\text{8830sin}\left( \text{4x} \right)

$$
 * }

6.

Error between exact solution and approximate solution at point x=0.5.


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

$$\displaystyle
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * style="width:92%; padding:10px; border:2px solid #ff0000" |

\text{ error(x=0}\text{.5)=0}\text{.0069}

$$
 * }



When n =6

1.

Equation enforcing natural boundary condition:


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

$$\displaystyle
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * style="width:92%; padding:10px; border:2px solid #ff0000" |

1{{d}_{1}}+2{{d}_{2}}+3{{d}_{3}}+4{{d}_{4}}+5{{d}_{5}}+6{{d}_{6}}=-4

$$
 * }

Equation enforcing essential boundary condition:
 * {| style="width:100%" border="0"

$$\displaystyle
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * style="width:92%; padding:10px; border:2px solid #ff0000" |

{{d}_{0}}+0.8415{{d}_{1}}+0.9093{{d}_{2}}+0.1411{{d}_{3}}-0.7568{{d}_{4}}-0.9589{{d}_{5}}-0.2794{{d}_{6}}=0

$$
 * }

2.

Equations from projection:


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

$$\displaystyle
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * style="width:92%; padding:10px; border:2px solid #ff0000" |

0.9194{{d}_{1}}+5.6646{{d}_{2}}+11.9400{{d}_{3}}+13.2291{{d}_{4}}+7.1634{{d}_{5}}+0.4780{{d}_{6}}=3

$$
 * }


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

$$\displaystyle
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * style="width:92%; padding:10px; border:2px solid #ff0000" |

0.5454{{d}_{1}}+3.1777{{d}_{2}}+5.7946{{d}_{3}}+3.8212{{d}_{4}}-3.5658{{d}_{5}}-10.2830{{d}_{6}}=1.3791

$$
 * }


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

$$\displaystyle
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * style="width:92%; padding:10px; border:2px solid #ff0000" |

0.7944{{d}_{1}}+4.7568{{d}_{2}}+9.2993{{d}_{3}}+8.0195{{d}_{4}}-1.1704{{d}_{5}}-11.2633{{d}_{6}}=2.1242

$$
 * }


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

$$\displaystyle 0.6438{{d}_{1}}+4.1330{{d}_{2}}+9.4191{{d}_{3}}+11.9619{{d}_{4}}+8.2745{{d}_{5}}+0.0450{{d}_{6}}=1.9900
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * style="width:92%; padding:10px; border:2px solid #ff0000" |

$$
 * }


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

$$\displaystyle
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * style="width:92%; padding:10px; border:2px solid #ff0000" |

0.2388{{d}_{1}}+2.0049{{d}_{2}}+6.7285{{d}_{3}}+14.0213{{d}_{4}}+19.8920{{d}_{5}}+18.3258{{d}_{6}}=1.2402

$$
 * }

3.

Display seven equations in matrix form:


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

$$\displaystyle \left( \begin{matrix}  0 & 1 & 2 & 3 & 4 & 5 & 6  \\   1 & 0.8415 & 0.9093 & 0.1411 & -0.7568 & -0.9589 & -0.2794  \\   0 & 0.9194 & 5.6646 & 11.9400 & 13.2291 & 7.1634 & 0.4780  \\   0 & 0.5454 & 3.1777 & 5.7946 & 3.8212 & -3.5658 & -10.2830  \\   0 & 0.7944 & 4.7568 & 9.2993 & 8.0195 & -1.1704 & -11.2633  \\   0 & 0.6438 & 4.1330 & 9.4191 & 11.9619 & 8.2745 & 0.0450  \\   0 & 0.2388 & 2.0049 & 6.7285 & 14.0213 & 19.8920 & 18.3258  \\ \end{matrix} \right)\left( \begin{matrix}   {{d}_{0}}  \\   {{d}_{1}}  \\   {{d}_{2}}  \\   {{d}_{3}}  \\   {{d}_{4}}  \\   {{d}_{5}}  \\   {{d}_{6}}  \\ \end{matrix} \right)=\left( \begin{matrix}   -4  \\   0  \\   3  \\   1.3791  \\   2.1242  \\   1.9900  \\   1.2402  \\ \end{matrix} \right)
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * style="width:92%; padding:10px; border:2px solid #ff0000" |

$$
 * }

$$K$$ is non-symmetric.

4.


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

$$\displaystyle
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * style="width:92%; padding:10px; border:2px solid #ff0000" |

\left( \begin{matrix}  {{d}_{0}}  \\   {{d}_{1}}  \\   {{d}_{2}}  \\   {{d}_{3}}  \\   {{d}_{4}}  \\   {{d}_{5}}  \\   {{d}_{6}}  \\ \end{matrix} \right)={{\left( \begin{matrix}   0 & 1 & 2 & 3 & 4 & 5 & 6  \\   1 & 0.8415 & 0.9093 & 0.1411 & -0.7568 & -0.9589 & -0.2794  \\   0 & 0.9194 & 5.6646 & 11.9400 & 13.2291 & 7.1634 & 0.4780  \\   0 & 0.5454 & 3.1777 & 5.7946 & 3.8212 & -3.5658 & -10.2830  \\   0 & 0.7944 & 4.7568 & 9.2993 & 8.0195 & -1.1704 & -11.2633  \\   0 & 0.6438 & 4.1330 & 9.4191 & 11.9619 & 8.2745 & 0.0450  \\   0 & 0.2388 & 2.0049 & 6.7285 & 14.0213 & 19.8920 & 18.3258  \\ \end{matrix} \right)}^{-1}}\left( \begin{matrix}   -4  \\   0  \\   3  \\   1.3791  \\   2.1242  \\   1.9900  \\   1.2402  \\ \end{matrix} \right)=\left( \begin{matrix}   4.7500  \\   -257.2133  \\   341.5391  \\   -261.6497  \\   128.7012  \\   -38.5828  \\   5.5312  \\ \end{matrix} \right)

$$
 * }

5.

The approximate solution:


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

$$\displaystyle
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * style="width:92%; padding:10px; border:2px solid #ff0000" |

u_{6}^{h}(x)=4.75-257.2133\sin (x)+341.5391\sin (2x)-261.6497\sin (3x)+128.7012\sin (4x)-38.5828\sin (5x)+5.5312\sin (6x)

$$
 * }

6.

Error between exact solution and approximate solution at point x=0.5.


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

$$\displaystyle
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * style="width:92%; padding:10px; border:2px solid #ff0000" |

\text{ error(x=0}\text{.5)=0}\text{.0086}

$$
 * }



Plot of Error(x=0.5) Vs. n