User:Egm6341.s11.team3.JA

= 2.9 =

Given

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

$$ \omega = ]0,1[ \quad $$ $$
 * style="width:95%" |
 * style="width:95%" |
 *  $$ \displaystyle (Eq. 2.3.1)
 * }


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

$$ a_2 = 2 \quad $$ $$
 * style="width:95%" |
 * style="width:95%" |
 *  $$ \displaystyle (Eq. 2.3.2)
 * }


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

$$ f = 3 \quad $$ $$
 * style="width:95%" |
 * style="width:95%" |
 *  $$ \displaystyle (Eq. 2.3.3)
 * }


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

$$ \frac{\partial{u}}{\partial{t}}(x,t) = 0 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 *  $$ \displaystyle (Eq. 2.3.4)
 * }


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

$$ \Gamma_g = 1 \quad $$, $$ g = 0 \quad $$ $$
 * style="width:95%" |
 * style="width:95%" |
 *  $$ \displaystyle
 * }


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

$$ u(x=1) = 0 \quad $$ $$
 * style="width:95%" |
 * style="width:95%" |
 *  $$ \displaystyle (Eq. 2.3.5)
 * }


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

$$ \Gamma_h = 0 \quad $$, $$ h = 4 \quad $$ $$
 * style="width:95%" |
 * style="width:95%" |
 *  $$ \displaystyle
 * }


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


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

$$ -\frac{du^h}{dx}(0) = 4 \quad $$ $$
 *  $$ \displaystyle (Eq. 2.3.6)
 * }

Find
Find approximate solution $$ u^n \quad $$ and compare it to exact one

Consider base function $$ b_j(x), j = 0, 1, 2, 3,... n \quad $$

<span id="(1)">
 * {| style="width:100%" border="0"

$$ b_j(x) = cos(jx+\phi) \quad $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle (Eq. 2.3.7)
 * }

Consider $$ \phi = \frac{\pi}{4} $$ and $$ \phi = \frac{\pi}{2} $$

(1) Let $$ n = 2 \Rightarrow ndof = n+1 = 3 \quad $$

Generate variables considered for $$ n = 2 \quad $$ case

(2) Find 2 eqs that enforce b.c.'s for $$ u^h(x) = \sum_{j -0}^{n} d_j b_j(x) $$

(3) Find 1 more eq. to solve for $$ \underline{d} = d_j (j = 0, 1, 2) $$ by projecting the residue $$ \underline{p}(u^h) $$ on a basis function $$ b_k(x) \quad $$ with $$ k = 0, 1, 2 \quad $$. The additional equation must be lineally independent from the above 2 equations in part (2).

(4) Display 3 equations in matrix form

<span id="(1)">
 * {| style="width:100%" border="0"

$$ \underline{K}\underline{d} = \underline{F} $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle (Eq. 2.3.8)
 * }

Observe if $$ \underline{K} $$ is symmetric

(5) Solve for $$ \underline{d} \quad $$

(6) Construct $$ u_n^k(x) $$ and plot $$ u_n^k(x) $$ vs. $$ ux) $$

(7) Repeat steps (1) to (6) for


 * (7.1) $$ n = 4 \quad $$
 * (7.2) $$ n = 6 \quad $$

(8) Compute $$ u_n^h (x = 0.5) \quad $$ for $$ n = 2, 4, 6 \quad $$

error

<span id="(1)">
 * {| style="width:100%" border="0"

$$ e_n(0.5) = u_n(0.5) - u_n^h(0.5) \quad $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle (Eq. 2.3.9)
 * }

Plot $$ e_n(0.5) \quad $$ vs. $$ n \quad $$

Solution
(1)

For $$ n = 2 \quad $$

<span id="(1)">
 * {| style="width:100%" border="0"

$$ \underline{b} =
 * style="width:95%" |
 * style="width:95%" |

\begin{bmatrix} b_0     & b_1 & b_2 \end{bmatrix}

$$ $$
 * <p style="text-align:right"> $$ \displaystyle (Eq. 2.3.10)
 * }

From base function expression $$ b_j(x) = cos(jx+\phi) \quad $$

<span id="(1)">
 * {| style="width:100%" border="0"

$$ \underline{b} =
 * style="width:95%" |
 * style="width:95%" |

\begin{bmatrix} cos(0x+\phi)     & cos(1x+\phi) & cos(2x+\phi) \end{bmatrix}

=

\begin{bmatrix} cos(\phi)     & cos(x+\phi) & cos(2x+\phi) \end{bmatrix}

$$ $$
 * <p style="text-align:right"> $$ \displaystyle (Eq. 2.3.11)
 * }

Unknown function

<span id="(1)">
 * {| style="width:100%" border="0"

$$ \underline{d} =
 * style="width:95%" |
 * style="width:95%" |

\begin{bmatrix} d_0     & d_1 & d_2 \end{bmatrix} $$ $$
 * <p style="text-align:right"> $$ \displaystyle (Eq. 2.3.12)
 * }

Approximate solution

(2)

at B.C. $$ u(1) = 0 \quad $$

<span id="(1)">
 * {| style="width:100%" border="0"

$$ u^h = \sum_{i=0}^{n=2} d_ib_i $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle (Eq. 2.3.13)
 * }

<span id="(1)">
 * {| style="width:100%" border="0"

$$ u^h(x) = d_0cos(\phi) + d_1cos(x+\phi) + d_2cos(2x+\phi) \quad $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle (Eq. 2.3.14)
 * }

<span id="(1)">
 * {| style="width:100%" border="0"

$$ u^h(1) = 0 = d_0cos(\phi) + d_1cos(1+\phi) + d_2cos(2+\phi) =
 * style="width:95%" |
 * style="width:95%" |

\begin{bmatrix} cos(\phi)     & cos(1+\phi) & cos(2+\phi) \end{bmatrix}

\begin{bmatrix} d_0     \\ d_1 \\ d_2 \end{bmatrix} $$ $$
 * <p style="text-align:right"> $$ \displaystyle
 * }

at B.C $$ \frac{du}{dx}(0) = 4 $$

<span id="(1)">
 * {| style="width:100%" border="0"

$$ (u')^h(x) = \frac{du}{dx} = \sum_{i=0}^{n=2} d_ib_i' $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle (Eq. 2.3.15)
 * }

<span id="(1)">
 * {| style="width:100%" border="0"

$$ \underline{b}' =
 * style="width:95%" |
 * style="width:95%" |

\begin{bmatrix} 0     & -sin(x+ \phi) & -2sin(2x+\phi) \end{bmatrix}

$$ $$
 * <p style="text-align:right"> $$ \displaystyle (Eq. 2.3.16)
 * }

<span id="(1)">
 * {| style="width:100%" border="0"

$$ (u')^h(0) = - 4 = d_00 - d_1sin(\phi) - d_22sin(\phi) =
 * style="width:95%" |
 * style="width:95%" |

\begin{bmatrix} 0     & sin(\phi) & 2sin(\phi) \end{bmatrix}

\begin{bmatrix} d_0     \\ d_1 \\ d_2 \end{bmatrix} $$ $$
 * <p style="text-align:right"> $$ \displaystyle
 * }

(3)

By projecting the residue part of a function on the bases, 3rd equation can be generated:

From the definition of elastodynamics case of ODE function $$ P_u(x) \quad $$

Rewriting $$ Eq. 2.3.7 \quad $$

<span id="(1)">
 * {| style="width:100%" border="0"

$$ b_j(x) = cos(jx+\phi) \quad $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle
 * }

In this, more specific, "self adjoin" case

<span id="(1)">
 * {| style="width:100%" border="0"

$$ P(u^h) :=[a_2u']' + a_0u - g = 0 \quad $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle (Eq. 2.3.17)
 * }

noting

$$ g = 0 \Rightarrow \quad $$ no forcing function (steady state)

$$ a_0u = f = 3 \quad $$ (given)

$$ a_2 = 2 \quad $$ (given)

$$ P(u^h) :=[2u']' + 3 = 0 \Rightarrow \quad $$ since $$ u \quad $$ is given as constant 2 (not function of "x")

<span id="(1)">
 * {| style="width:100%" border="0"


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

$$ P(u^h) :=2u'' + 3 = 0\quad = 2\frac{d^2u}{dx} +3 = 0 $$ $$
 * <p style="text-align:right"> $$ \displaystyle (Eq. 2.3.18)
 * }

From $$ Eq. xxx $$, $$ u^h \quad $$ was defined as

<span id="(1)">
 * {| style="width:100%" border="0"

$$ u^h = \sum_{i=0}^{n=2} d_ib_i = d_0cos(\phi) + d_1cos(x+\phi) + d_2cos(2x+\phi) $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle (Eq. 2.3.19)
 * }

Taking $$ 2^{nd} \quad $$ derivative with respect to "x"

<span id="(1)">
 * {| style="width:100%" border="0"

$$ u^{h''} = 0 - d_1cos(x+\phi) - 4d_2cos(2x+\phi) \quad $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle (Eq. 2.3.20)
 * }

Therefore

<span id="(1)">
 * {| style="width:100%" border="0"

$$ P(u^h) := 2(0 - d_1cos(x+\phi) - 4d_2cos(2x+\phi)) +3 \quad $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle (Eq. 2.3.21)
 * }

Afterwords, noting that

<span id="(1)">
 * {| style="width:100%" border="0"

$$ \int_\omega w P(u^h) dx := 0 \Rightarrow w_i = b_i \Rightarrow \int_\omega b_i P(u^h) dx := 0 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle (Eq. 2.3.22)
 * }

which is also noted in $$ 10-4, Eq. (2) \quad $$

and substituting for $$ P(u^h) \quad $$ equation above, we get

<span id="(1)">
 * {| style="width:100%" border="0"


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

$$ \int_\omega b_i ([2(0 - d_1cos(x+\phi) - 4d_2cos(2x+\phi))] +3 dx) := 0 \quad $$ $$
 * <p style="text-align:right"> $$ \displaystyle (Eq. 2.3.23)
 * }

<span id="(1)">
 * {| style="width:100%" border="0"


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

$$ \int_\omega b_i [2(0 - d_1cos(x+\phi) - 4d_2cos(2x+\phi))] dx := \int_\omega b_i -3 dx \quad $$ $$
 * <p style="text-align:right"> $$ \displaystyle (Eq. 2.3.24)
 * }

recalling that $$ \underline{b} =

\begin{bmatrix} cos(\phi)  \\ cos(x+\phi) \\ cos(2x+\phi) \end{bmatrix} $$

and taking any of the equations as the last needed equation, for example $$ b_1 \quad $$, we get

<span id="(1)">
 * {| style="width:100%" border="0"

$$ \int_\omega
 * style="width:95%" |
 * style="width:95%" |

\begin{bmatrix} cos(\phi)  \\ cos(x+\phi) \\ cos(2x+\phi) \end{bmatrix}

[2(0 - d_1cos(x+\phi) - 4d_2cos(2x+\phi))] dx := \int_\omega

\begin{bmatrix} cos(\phi)  \\ cos(x+\phi) \\ cos(2x+\phi) \end{bmatrix} -3 dx \quad $$ $$
 * <p style="text-align:right"> $$ \displaystyle (Eq. 2.3.25)
 * }

Doing symbolic integration and evaluating interval on $$ \omega = ]0,1[ \quad $$ we get

The outputs are as follow:

$$ \int_\omega

\begin{bmatrix} cos(\phi)  \\ cos(x+\phi) \\ cos(2x+\phi) \end{bmatrix}

[2(0 - d_1cos(x+\phi) - 4d_2cos(2x+\phi))] dx := $$ 0   0.3818   -1.0137         0    0.2919    0.7126         0    0.1781    2.3464

$$ \int_\omega

\begin{bmatrix} cos(\phi)  \\ cos(x+\phi) \\ cos(2x+\phi) \end{bmatrix} -3 dx \quad := $$

2.1213   0.8099   -0.5376



(4)

Assembling the matrix $$ \underline{K} \underline{d} = \underline{F} \quad $$ from 2 B.C. constrains and 1 more equation generated by weighting factor method:

<span id="(1)">
 * {| style="width:100%" border="0"

$$ \begin{bmatrix} cos(\phi)     & cos(x+\phi) & cos(2x+\phi) \\ 0     & sin(\phi) & 2sin(\phi) \\ 0 &   0.3818  & -1.0137     \end{bmatrix}
 * style="width:95%" |
 * style="width:95%" |

\begin{bmatrix} d_0     \\ d_1 \\ d_2 \end{bmatrix}

=

\begin{bmatrix} 0\\ 4 \\ 2.1213   \end{bmatrix} $$ $$
 * <p style="text-align:right"> $$ \displaystyle (Eq. 2.3.26)
 * }

For "K" matrix: 0.7071  -0.2130   -0.9372                           0    0.7071    1.4142               0    0.3818   -1.0137

For "F" matrix:

0   4.0000    2.1213

(5)

Solving for $$ \underline{d} = \underline{K}^{-1} F\quad $$ at $$ \phi = \frac{\pi}{4} \quad $$ we get

(tried to solve for $$ \phi = \frac{\pi}{2} \quad $$, matrix approx. value came if not exact, then really close to exact and the warning of matlab was issued about singularity)

d = 1.7193   5.6137    0.0216

(6)

Constructed $$ u^h \quad $$ matrix on matlab by using formula $$ u^h = \sum_{i=0}^{n=2} d_ib_i $$

0.02156*cos(phi + 2.0*x) + 5.614*cos(phi + x) + 1.719*cos(phi)

Exact solution:

Given a general expression for 2nd Order ODE

<span id="(1)">
 * {| style="width:100%" border="0"

$$ a_2(x)y'' + a_1(x)y + a_0(x)y = g(x) \quad $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle (Eq. 2.3.27)
 * }

and taking a more specific case ("Self adjoin") for this specific problem, we have

<span id="(1)">
 * {| style="width:100%" border="0"

$$ [a_2(x)y']' + a_0(x)y = g(x) \quad $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle (Eq. 2.3.17)
 * }

$$ g(x) = 0 \Rightarrow \quad $$ no forcing function (steady state)

$$ a_0(x)y = f(x) = 3 \quad $$ (given)

$$ a_2 = 2 \quad $$ (given)

Therefore $$ Eq. 2.3.17 \quad $$ becomes

<span id="(1)">
 * {| style="width:100%" border="0"


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

$$ [2y']' + 3 = 0 \quad $$ $$
 * <p style="text-align:right"> $$ \displaystyle (Eq. 2.3.28)
 * }

<span id="(1)">
 * {| style="width:100%" border="0"


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

$$ \frac{du}{dx}(\frac{du}{dx}2) + 3 = 0 $$ $$
 * <p style="text-align:right"> $$ \displaystyle
 * }

<span id="(1)">
 * {| style="width:100%" border="0"

$$ \int \frac{du}{dx}2 = \int -3 dx $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle
 * }

<span id="(1)">
 * {| style="width:100%" border="0"

$$ \frac{du}{dx}2 = -3x + c_1' \Rightarrow \frac{du}{dx} = -1.5x + c_1 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle (Eq. 2.3.29)
 * }

at B.C of $$ -\frac{du}{dx}(0) = 4 \Rightarrow $$

<span id="(1)">
 * {| style="width:100%" border="0"


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

$$ -4 = -1.5(0) + c_1 \Rightarrow c_1 = -4$$ $$
 * <p style="text-align:right"> $$ \displaystyle
 * }

<span id="(1)">
 * {| style="width:100%" border="0"


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

$$ \int {du} = \int (-1.5x - 4) dx $$ $$
 * <p style="text-align:right"> $$ \displaystyle
 * }

<span id="(1)">
 * {| style="width:100%" border="0"

$$ u = \frac{-1.5}{2}x^2 - 4x + c_2 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle (Eq. 2.3.30)
 * }

at B.C of $$ u(1) = 0 \Rightarrow $$

<span id="(1)">
 * {| style="width:100%" border="0"


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

$$ 0 = \frac{-1.5}{2}(1)^2 - 4(1) + c_2 \Rightarrow c_2 = -4.75$$ $$
 * <p style="text-align:right"> $$ \displaystyle
 * }

<span id="(1)">
 * {| style="width:100%" border="0"

$$ u(x) = -0.75x^2 - 4x - 4.75 \quad $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle (Eq. 2.3.31)
 * }

So taken in account the exact solution formula, different plot were generated for different n values (n = 2, 4, 6)

Different 'u' values plotted on 1 graph for different member number 'n'

Highly zoomed in view, by zooming in it is clear that n =4 is good enough approximation for these series.

Error came out to be ex = n=2       n=4       n=6 -0.2291  -0.0102    0.0000



= ref=