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

=Problem 5.2 Using appropriate basis functions (Polynomial, Fourier and Exponential basis functions) to obtain the trial solution from Weak Form=

Problem Statement
$$ \frac{\partial}{\partial x} \left[ (2+3x) \frac{\partial u}{\partial x} \right] + 5x = 0 $$, $$ \forall x \in \left[ 0,1 \right] $$, $$ u(1)=4 $$, $$ -\frac{\partial u(x=0)}{\partial x}=6 $$

$$ \Gamma_g = [1] $$, $$ \Gamma_h = [0] $$

Solve the above problem using Weight Function with appropriate basis function (Polynomial basis function, Fourier basis function and Exponential basis function) until convergence of $$u^h(0.5)$$ to $$10^{-6}$$.

Plot $$ u, u^h $$, convergence (error vs. n)

Solution
The strong form of $$\text{G1DM1}.0/\text{D1}$$ is:
 * {| style="width:100%" border="0"

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

\begin{align} & \frac{d}{dx}[(2+3x)\frac{du}{dx}]+5x=0,_ – ^ – \forall x\in (0,1) \\ & u(x=1)=4,_ – ^ – -\frac{du}{dx}(x=0)=6 \\ \end{align}

$$ We can derive the weak form as:
 * }
 * {| style="width:100%" border="0"

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

\begin{align} & \int\limits_{0}^{1}{\frac{\partial w}{\partial x}(2+3x)\frac{\partial u}{\partial x}}dx-\int\limits_{0}^{1}{5xwdx}-(12+18x)w\left| _{x=0} \right.=0,_ – ^ – \forall w(x=1)=0 \\ & u(x=1)=4 \\ \end{align}

$$ The discretized weak form is
 * }
 * {| style="width:100%" border="0"

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

\begin{align} & \underbrace{[\int\limits_{0}^{1}{\frac{\partial {{b}_{i}}(x)}{\partial x}(2+3x)\frac{\partial {{b}_{j}}(x)}{\partial x}}dx]}_{{d}_{i}}=\underbrace{[\int\limits_{0}^{1}{5x{{b}_{i}}(x)dx}+(12+18x){{b}_{i}}(x)\left| _{x=0} \right.]}_ \\ & {{d}_{0}}=4 \\ & i=1,2,\cdots \\ & j=1,2,\cdots \\ \end{align}

$$ The appropriate Polynomial basis function is
 * }
 * {| style="width:100%" border="0"

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

{{f}_{p}}=\{{{(x-1)}^{j}},j=0,1,2,\cdots \}

$$ The appropriate Fourier basis function is
 * }
 * {| style="width:100%" border="0"

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

{{f}_{F}}=\{\cos j(x-1)-1,\sin k(x-1),j=0,1,2,\cdots ,k=1,2,\cdots \}

$$ The appropriate Exponential basis function is
 * }
 * {| style="width:100%" border="0"

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

{{f}_{e}}=\{{{e}^{j(x-1)}}-1,j=0,1,2,\cdots \}

$$ The exact solution of governing equation is
 * }
 * {| 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(x)=-\frac{118}{27}\ln (\frac{2+3x}{5})+\frac{1}{36}(20x-15{{x}^{2}}+139)

$$
 * }

Using Polynomial basis function
The trial solution is
 * {| style="width:100%" border="0"

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

u_{p}^{h}(x)={{d}_{0}}{{(x-1)}^{0}}+{{d}_{1}}{{(x-1)}^{1}}+{{d}_{2}}{{(x-1)}^{2}}+\cdots +{{d}_{j}}{{(x-1)}^{j}},_ – ^ – j=0,1,2,\cdots

$$ Since the trial solution must satisfy the essential boundary condition,$$u(x=1)=4$$, substituting $$x=1$$into the trial solution, we have $${{d}_{0}}=4$$. In order to solve for the rest coefficient$${{d}_{j}},_ – ^ – j=1,2,\cdots $$, we construct the stiffness matrix and force matrix as follow:
 * }
 * {| style="width:100%" border="0"

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

{{K}_{F\times F}}=[{{k}_{ij}}]=[\int\limits_{0}^{1}{i{{(x-1)}^{i-1}}(2+3x)j{{(x-1)}^{j-1}}}dx]

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

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

{{F}_{F\times 1}}=[{{f}_{i\times 1}}]=[\int\limits_{0}^{1}{5x{{(x-1)}^{i}}}+(12+18*0){{(0-1)}^{i}}]

$$ Using Matlab to construct above two matrices until satisfying the convergence criterion, we finally have
 * }
 * {| style="width:100%" border="0"

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

{{K}_{FF}}=\left( \begin{matrix}  3.5 & -3.0 & 2.75 & -2.6 & 2.5 & -2.4285714 & 2.375 & -2.3333333  \\   -3.0 & 3.6666667 & -3.9 & 4.0 & -4.047619 & 4.0714286 & -4.0833333 & 4.0888889  \\   2.75 & -3.9 & 4.5 & -4.8571429 & 5.0892857 & -5.25 & 5.3666667 & -5.4545455  \\   -2.6 & 4.0 & -4.8571429 & 5.4285714 & -5.8333333 & 6.1333333 & -6.3636364 & 6.5454545  \\   2.5 & -4.047619 & 5.0892857 & -5.8333333 & 6.3888889 & -6.8181818 & 7.1590909 & -7.4358974  \\   -2.4285714 & 4.0714286 & -5.25 & 6.1333333 & -6.8181818 & 7.3636364 & -7.8076923 & 8.1758242  \\   2.375 & -4.0833333 & 5.3666667 & -6.3636364 & 7.1590909 & -7.8076923 & 8.3461538 & -8.8  \\   -2.3333333 & 4.0888889 & -5.4545455 & 6.5454545 & -7.4358974 & 8.1758242 & -8.8 & 9.3333333  \\ \end{matrix} \right)

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

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

{{F}_{F\times 1}}={{\left( \begin{matrix}  -12.833333 & 12.416667 & -12.15 & 12.166667 & -12.119048 & 12.089286 & -12.069444 & 12.055556  \\ \end{matrix} \right)}^{T}}

$$ By the equation that$$Kd=F$$, we can solve the rest of $$d$$ as
 * }
 * {| 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}_{F\times 1}}={{\left( \begin{matrix}  -2.8999142 & 0.37306134 & -0.27987546 & 0.32403056 & 0.43872514 & 0.81068777 & 0.61312521 & 0.22992195  \\ \end{matrix} \right)}^{T}}

$$ Hence, the trial solution of the governing equation is
 * }
 * {| style="width:100%" border="0"

$$\displaystyle \begin{align} &u_{p}^{h}(x)=4-2.8999142(x-1)+0.37306134{{(x-1)}^{2}}-0.27987546{{(x-1)}^{3}}\\ & +0.32403056{{(x-1)}^{4}}+0.43872514{{(x-1)}^{5}}+0.81068777{{(x-1)}^{6}}\\ &+0.61312521{{(x-1)}^{7}}+0.22992195{{(x-1)}^{8}}\\ \end{align} $$
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * style="width:92%; padding:10px; border:2px solid #ff0000" |
 * }





Using Fourier basis function
The trial solution is
 * {| style="width:100%" border="0"

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

\begin{align} & u_{F}^{h}(x)={{d}_{0}}[\cos [0*(x-1)]-1]+{{d}_{1}}[\cos [1*(x-1)]-1]+{{d}_{2}}\sin [1*(x-1)]+\cdots \\ & \begin{matrix} {} & {} \\ \end{matrix}+{{d}_{j-1}}[\cos [\frac{j}{2}(x-1)]-1]+{{d}_{j}}\sin [\frac{j}{2}(x-1)],j=0,1,2,\cdots  \\ \end{align}

$$ Since the trial solution must satisfy the essential boundary condition,$$u(x=1)=4$$, substituting $$x=1$$into the trial solution, we have $${{d}_{0}}=4$$. In order to solve for the rest coefficient$${{d}_{j}},_ – ^ – j=1,2,\cdots $$, we construct the stiffness matrix and force matrix as follow:
 * }
 * {| style="width:100%" border="0"

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

{{K}_{F\times F}}=[{{k}_{ij}}]=[\left\{ \begin{matrix} \int\limits_{0}^{1}{i\cos i(x-1)(2+3x)j\cos j(x-1)}dx,_ – ^ – when_ – ^ – i,j_ – ^ – both_ – ^ – are_ – ^ – even_ – ^ – number \\ \int\limits_{0}^{1}{i\sin i(x-1)(2+3x)j\sin j(x-1)}dx,_ – ^ – when_ – ^ – i,j_ – ^ – both_ – ^ – are_ – ^ – odd_ – ^ – number \\ \int\limits_{0}^{1}{i\cos i(x-1)(2+3x)j\sin j(x-1)}dx,_ – ^ – others \\ \end{matrix} \right.]

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

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

{{F}_{F\times 1}}=[{{f}_{i\times 1}}]=[\left\{ \begin{matrix} \int\limits_{0}^{1}{5x\sin i(x-1)}dx-(12+18*0)\sin i(0-1),_ – ^ – when_ – ^ – i_ – ^ – is_ – ^ – even_ – ^ – number \\ \int\limits_{0}^{1}{5x[\cos i(x-1)-1]}dx-(12+18*0)[\cos i(0-1)-1],_ – ^ – when_ – ^ – i_ – ^ – is_ – ^ – odd_ – ^ – number \\ \end{matrix} \right.]

$$ Using Matlab to construct above two matrices until satisfying the convergence criterion, we finally have
 * }
 * {| style="width:100%" border="0"

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

{{K}_{FF}}=\left( \begin{matrix}  0.76429622 & 1.1170869 & 2.3046242 & 0.88463923 & 3.0596259 & -0.77317723 & 2.11004 & -2.5560312 & 0.05369072  \\   1.1170869 & 2.7357038 & 3.6746041 & 3.8194459 & 5.9293441 & 2.8545967 & 6.5624554 & 0.91960333 & 5.6382087  \\   2.3046242 & 3.6746041 & 7.1366861 & 3.4374446 & 10.078933 & -1.1801292 & 8.2449076 & -6.7904503 & 2.7731659  \\   0.88463923 & 3.8194459 & 3.4374446 & 6.8633139 & 7.1897654 & 8.2932776 & 11.08294 & 7.5263528 & 13.691415  \\   3.0596259 & 5.9293441 & 10.078933 & 7.1897654 & 16.154187 & 2.4145154 & 17.155544 & -5.6179262 & 12.527795  \\   -0.77317723 & 2.8545967 & -1.1801292 & 8.2932776 & 2.4145254 & 15.345813 & 11.121863 & 19.588876 & 21.368795  \\   2.11004 & 6.5624554 & 8.2449076 & 11.08294 & 17.155544 & 11.121863 & 25.591721 & 4.9199907 & 28.996706  \\   -2.5560312 & 0.91960333 & -6.7904503 & 7.5263528 & -5.6179262 & 19.588876 & 4.9199907 & 30.408279 & 21.377477  \\ 0.05369072 & 5.6382087 & 2.7731659 & 13.691415 & 12.527795 & 21.368795 & 28.996706 & 21.377477 & 44.420401 \\ \end{matrix} \right)

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

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

{{F}_{F\times 1}}={{\left( \begin{matrix}  -5.7178839 & -10.890297 & -17.723578 & -12.274947 & -25.274359 & -3.2817068 & -21.82696 & 7.5951292 & -10.952786  \\ \end{matrix} \right)}^{T}}

$$ By the equation that$$Kd=F$$, we can solve the rest of $$d$$ as
 * }
 * {| 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}_{F\times 1}}={{\left( \begin{matrix}  7.4103829 & -40.592257 & 10.904443 & 35.696817 & -12.476341 & -14.112008 & 4.7711925 & 2.1586481 & -0.6326032  \\ \end{matrix} \right)}^{T}}

$$ Hence, the trial solution of the governing equation is
 * }
 * {| style="width:100%" border="0"

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

\begin{align} & U_{F}^{h}(x)=\text{1}0.\text{9}0\text{4443cos}\left( \text{2x}-\text{2} \right)-\text{4}0.\text{592257sin}\left( \text{x}-\text{1} \right)-\text{12}.\text{476341cos}\left( \text{3x}-\text{3} \right) \\ & +\text{4}.\text{7711925cos}\left( \text{4x}-\text{4} \right)-0.\text{6326}0\text{32cos}\left( \text{5x}-\text{5} \right)+\text{35}.\text{696817sin}\left( \text{2x}-\text{2} \right) \\ & -\text{14}.\text{112}00\text{8sin}\left( \text{3x}-\text{3} \right)+\text{2}.\text{1586481sin}\left( \text{4x}-\text{4} \right)+\text{7}.\text{41}0\text{3829cos}\left( \text{x}-\text{1} \right)-\text{5}.\text{977}0\text{749} \\ \end{align}

$$
 * }





Using Exponential basis function
The trial solution is
 * {| style="width:100%" border="0"

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

u_{e}^{h}(x)={{d}_{0}}({{e}^{0*(x-1)}}-1)+{{d}_{1}}({{e}^{1*(x-1)}}-1)+{{d}_{2}}({{e}^{2*(x-1)}}-1)+\cdots +{{d}_{j}}({{e}^{j*(x-1)}}-1),_ – ^ – j=0,1,2,\cdots

$$ Since the trial solution must satisfy the essential boundary condition,$$u(x=1)=4$$, substituting $$x=1$$into the trial solution, we have $${{d}_{0}}=4$$. In order to solve for the rest coefficient$${{d}_{j}},_ – ^ – j=1,2,\cdots $$, we construct the stiffness matrix and force matrix as follow:
 * }
 * {| style="width:100%" border="0"

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

{{K}_{F\times F}}=[{{k}_{ij}}]=[\int\limits_{0}^{1}{i{{e}^{i(x-1)}}(2+3x)j{{e}^{j(x-1)}}}dx]

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

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

{{F}_{F\times 1}}=[{{f}_{i\times 1}}]=[\int\limits_{0}^{1}{5x[{{e}^{i(x-1)}}-1]dx}-(12+18*0)[{{e}^{i(0-1)}}-1]]

$$ Use Matlab to construct above two matrices until satisfying the convergence criterion, the trial solution at point x=0.5 can’t converge to$${{10}^{-6}}$$. The plot of convergence using 26 exponential basis functions as follow:
 * }



If we make the convergence criterion a little larger, that’s to $${{10}^{-5}}$$, we can get following results.



By the equation that$$Kd=F$$, we can solve the rest of $$d$$ as Hence, the trial solution of the governing equation is
 * {| style="width:100%" border="0"

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

\begin{align} & u_{e}^{h}(x)=-\text{55}0.\text{21555}{{\text{e}}^{\left( \text{x}-\text{1} \right)}}+\text{2394}.\text{6264}{{\text{e}}^{\left( \text{2x}-\text{2} \right)}}-\text{5543}.\text{4261}{{\text{e}}^{\left( \text{3x}-\text{3} \right)}}+\text{572}0.\text{8768}{{\text{e}}^{\left( \text{4x}-\text{4} \right)}} \\ & +\text{2321}.\text{5781}{{\text{e}}^{\left( \text{5x }-\text{5} \right)}}-\text{11751}.\text{37}{{\text{e}}^{\left( \text{6x}-\text{6} \right)}}+\text{4594}.\text{3739}{{\text{e}}^{\left( \text{7x}-\text{7} \right)}}+\text{19997}.\text{55}{{\text{e}}^{\left( \text{8x}-\text{8} \right)}} \\ & -\text{36338}.\text{561}{{\text{e}}^{\left( \text{9x}-\text{9} \right)}}+\text{286}0\text{2}.\text{493}{{\text{e}}^{\left( \text{1}0\text{x}-\text{1}0 \right)}}-\text{11373}.\text{731}{{\text{e}}^{\left( \text{11x}-\text{11} \right)}}+\text{1866}.\text{4427}{{\text{e}}^{\left( \text{12x}-\text{12} \right)}}+\text{63}.\text{363186} \\ \end{align}

$$
 * }





Comment
When we use the exponential basis function($$e^{(i(x-1))}-1$$) to obtain the trial solution from discretized weak form, the error at point x=0.5 never converges to $$10^{-6}$$. But if we change the accuracy to $$10^{-5}$$, it will converges to this far very fast.Among the two criterion for convergence, the continuity is satisfied, while the completeness is not. It's possible because that the exponential basis function doesn't contain a linear term or it can't used to approximate a linear function. So it's incomplete. There is also another problem rises from this assumption. Since there is certain equivalent relationship between exponential basis function and Fourier basis function, the same may also happen for Fourier basis function. But the Fourier basis function does converge to the accuracy of $$10^{-6}$$ here. Since it's much expensive to run the code for Fourier basis function, especially to a much accurate convergence, we don't have the chance to testify this inference.