User:Eml5526.s11.team5.Dahiya

= Licensing =

= HW 1.1 =

Problem
Given the generic non-uniform section bar under force as shown below



 Figure 1 

Find
a) By taking infinitesimal slice of the bar (shown in red in Figure 1),$$ dx $$, develop expression for elastodynamic response.

b) Assume the cross sectional area to be rectangular

Solution
Free Body Diagram:



 Figure 2 

 Theory: 

In elastodynamic case, there are 2 major contributors that affect body's motion:


 * Static Forces
 * Body's Inertial effects (resistance to motion caused by Static forces)

In accord to conservation laws as well as Newton's 3rd law, these 2 opposing contributors must be equal to each other.


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

$$F_{static} = F_{dynamic} \Rightarrow \vartriangle F = ma $$ $$
 * style="width:95%" |
 * style="width:95%" |
 *  $$ \displaystyle (Eq. 1.1)
 * }

where:


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

$$ F = force \quad (N) $$ $$ 
 * style="width:95%" |
 * style="width:95%" |
 *  $$ \displaystyle
 * }
 * {| style="width:100%" border="0"

$$ m = mass \quad (kg) $$ $$ 
 * style="width:95%" |
 * style="width:95%" |
 *  $$ \displaystyle
 * }
 * {| style="width:100%" border="0"

$$ a = acceleration \quad(\frac{m}{s^2}) $$ $$
 * style="width:95%" |
 * style="width:95%" |
 *  $$ \displaystyle
 * }

The assumed differential element shape is of trapezoid with force acting on both of its bases. Dynamic equation that resulted is shown below:


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

$$ -p(x) + f(x + \frac {\vartriangle x}{2})\vartriangle x + p(x+\vartriangle x) = ( \hat m(x) * \vartriangle x) a(t) $$ $$
 * style="width:95%" |
 * style="width:95%" |
 *  $$ \displaystyle (Eq. 1.2)
 * }

where:


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

$$ \hat m = mass \ per \ unit \ length \ (\frac{kg}{m}) $$ $$
 * style="width:95%" |
 * style="width:95%" |
 *  $$ \displaystyle
 * }


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

$$ \frac {p(x+\vartriangle x) - p(x)}{\vartriangle x} + f(x + \frac {\vartriangle x}{2}) = \frac {( \hat m(x) *\vartriangle x)}{\vartriangle x} a(t) = \hat m(x) a(t) $$ $$
 * style="width:95%" |
 * style="width:95%" |
 *  $$ \displaystyle
 * }


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

$$ \Rightarrow a(t) = \frac{\vartriangle v(t)}{\vartriangle t} $$ $$
 * style="width:95%" |
 * style="width:95%" |
 *  $$ \displaystyle (Eq. 1.3)
 * }

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

$$ \Rightarrow \vartriangle v(t) = \frac{u(t + \vartriangle t) - u(t)}{\vartriangle t} $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle (Eq. 1.4)
 * }

Therefore:

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

$$ \frac {p(x+\vartriangle x) - p(x)}{\vartriangle x} + f(x + \frac {\vartriangle x}{2}) = \hat m(x) \frac{1}{\vartriangle t}\frac{u(t + \vartriangle t) - u(t)}{\vartriangle t} $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle (Eq. 1.5)
 * }

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

$$ \lim_{\vartriangle x \to 0} \frac {p(x+\vartriangle x) - p(x)}{\vartriangle x} + f(x + \frac {\vartriangle x}{2}) = \lim_{\vartriangle t \to 0} \hat m(x) \frac{1}{\vartriangle t}\frac{u(t + \vartriangle t) - u(t)}{\vartriangle t} $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle
 * }

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

$$ \Rightarrow \lim_{\vartriangle x \to 0} \frac {p(x+\vartriangle x) - p(x)}{\vartriangle x} = \frac {\partial p}{\partial x} $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle
 * }

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

$$ \Rightarrow \lim_{\vartriangle t \to 0} \frac{1}{\vartriangle t} = \frac{1}{\partial t} $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle
 * }

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

$$ \Rightarrow \lim_{\vartriangle t \to 0} \hat m \frac{u(t + \vartriangle t) - u(t)}{\vartriangle t} = \hat m(x) \frac {\partial u}{\partial t} $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle
 * }

Therefore, substituting back into equation we get:

$$ \frac {\partial p}{\partial x} + f(x) = \hat m(x) \frac{1}{\partial t} \frac {\partial u}{\partial t} \Rightarrow \frac {\partial p}{\partial x} + f(x) = \hat m(x) \frac {\partial^2 u}{\partial t^2} $$ $$ $$
 * <p style="text-align:right"> $$ \displaystyle
 * <p style="text-align:right;"> $$ \displaystyle (Eq. 1.6)

Force = Stress * Area,

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

$$ \begin{matrix} p(x) = \sigma(x) * A(x) \end{matrix} $$
 * style="width:95%" |
 * style="width:95%" |

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

Stress = Strain * Modulus of Elasticity,

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

$$ \begin{matrix} \sigma(x) = \epsilon(x) * E(x) \end{matrix} $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle (Eq. 1.8)
 * }

where

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

$$ \epsilon(x) = \frac {\partial u}{\partial x} $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle (Eq. 1.9)
 * }

From Equations 1.7-1.9:

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

$$ p(x) = E(x) * A(x) * \frac {\partial u}{\partial x}$$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle (Eq. 1.10)
 * }

Mass / Unit Length = Density * Area

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

$$ \hat m(x) = \rho(x) * A(x) $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle (Eq. 1.11)
 * }

Substituting the above relations we get

$$ \frac {\partial}{\partial x} \left[E(x)A(x)\frac{\partial u}{\partial x}\right] + f(x) = \rho(x) A(x) \frac {\partial^2 u} {\partial t^2} $$ $$ $$
 * <p style="text-align:right"> $$ \displaystyle
 * <p style="text-align:right;"> $$ \displaystyle (Eq. 1.12)

b) If we consider a case in which the bar has a rectangular cross section



 Figure 3 

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

$$ \begin{matrix} A(x) = h(x) * b \end{matrix} $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle
 * }

where

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

$$ h(x) = height \ of \ bar \ at \ x \ (m), $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle
 * }

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

$$ b = width \ of \ the \ bar \ (constant)\ (m) \ [i.e. \ Independent \ of \ x,t] $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle
 * }

Replacing $$ A(x) $$ with $$ h(x)*b $$ in our equation we get:

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

$$ \frac {\partial}{\partial x} \left[E(x)h(x)*b*\frac{\partial u}{\partial x}\right] + f(x) = \rho(x) h(x)*b* \frac {\partial^2 u} {\partial t^2} $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle
 * }

$$ b $$ is independent and can be brought outside the partial derivative of the first term

The equation is divided by $$ b $$ to give

$$ \frac {\partial}{\partial x} \left[E(x)h(x)\frac{\partial u}{\partial x}\right] + \frac{f(x)}{b} = \rho(x) h(x) \frac {\partial^2 u} {\partial t^2} $$ $$ $$
 * <p style="text-align:right"> $$ \displaystyle
 * <p style="text-align:right;"> $$ \displaystyle (Eq. 1.13)

= 6.1 [ Solving G1DM1.0/D1(b) using weak form with QLEBF (Quadratic Lagrangian Element Basis Functions)] =

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

$$ \frac{\partial}{\partial x} \left[ (2+3x) \frac{\partial u}{\partial x} \right] + 5x = 0 \ \ \forall x \in \left] 0,1 \right[ $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.1)
 * }

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

$$u \ at \ {x=0} \ is \ 4 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.2)
 * }

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

$$  \frac{\partial u}{\partial x} \  at \ x = 1 \ is \ \frac{12}{5} $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.3)
 * }

Find: Approximate solution using weak form and its comparison to exact solution

 * Consider basis function QLEBF satisfying constraint basis solution


 * Compute $$ u_n^h (x = 0.5) \quad $$ for $$ n = 2, 4, 6..... \quad $$ until convergence of $$ u^h (0.5)\ to \ 0(10^{-6}) $$


 * 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. 6.1.4)
 * }


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

Solution
Strong form

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

$$ \frac{\partial}{\partial x} \left[ (2+3x) \frac{\partial u}{\partial x} \right] + 5x = 0 \ \ \forall x \in \left] 0,1 \right[ $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                       (Eq. 6.1.5)
 * }

Boundary conditions

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

$$u \ at \ {x=0} \ is \ 4 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.6)
 * }

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

$$  \frac{\partial u}{\partial x} \  at \ x = 1 \ is \ \frac{12}{5} $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.7)
 * }

Finding of the Exact Solution
The exact solution of the displacement can be found as follows.

Integrating eqn 5.2.5, we get

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

$$ (2+3x)\frac{\partial u}{\partial x} + \frac{5x^2}{2} = c_1 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.8)
 * }

Substituting the natural B.C in the above equation, we get,

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

$$ c_1 = 14.5 \quad$$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.9)
 * }

Therefore eqn 5.1.8 becomes,

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

$$ (2+3x)\frac{\partial u}{\partial x} + \frac{5x^2}{2} = 14.5 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.10)
 * }

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

$$\frac{\partial u}{\partial x} = \frac{14.5-\frac{5x^2}{2}}{(2+3x)} $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.11)
 * }

Integrating the above equation, we get,Reference : www.wolframalpha.com

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

$$u = \frac{1}{108}(-45x^2 + 60x + 482 log (2+3x) +60 ) + c_2 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.12)
 * }

Substituting the Essential B.C in the above equation, we get,

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

$$c_2 = 0.3509542497 \quad$$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.13)
 * }

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

$$u = \frac{1}{108}(-45x^2 + 60x + 482 log (2+3x) +60 ) + 0.3509542497 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.14)
 * }

Finding of the Approximate Solution using Weak form with QLEBF
Weak Form

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

$$  \sum_{i} c_i \left [ \sum_{j} \left \{ \tilde{K_{ij}} \tilde{d_j} \right \} - \tilde{F_i} \right ] = 0 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.15)
 * }

where,

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

$$\tilde{K_{ij}} = \int_{0}^{1} b_i' \ a_2 \ b_j ' \ dx $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.16)
 * }

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

$$ \tilde{F_i} = b_i (\alpha )h + \int_{0}^{1} b_i f dx $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.17)
 * }

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


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

Ist Basis Function: $$b_{1}^{(1)}=L_{1,3}=\frac{(x-x_{2}).(x-x_{3})}{(x_{1}-x_{2}).(x_{1}-x_{3})}=\frac{(x-0.25).(x-0.5)}{(0-0.25).(0-0.5)}=8x^{2}-6x+1 $$

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

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


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

IInd Basis Function: $$b_{2}^{(1)}=L_{2,3}=\frac{(x-x_{1}).(x-x_{3})}{(x_{2}-x_{1}).(x_{2}-x_{3})}=\frac{(x-0).(x-0.5)}{(0.25-0).(0.25-0.5)}=-16x^{2}+8x $$

$$ <span id="(1)">
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.19)
 * }
 * {| style="width:100%" border="0"


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

IIIrd Basis Function : $$b_{3}^{(1)}=L_{3,3}=\frac{(x-x_{1}).(x-x_{2})}{(x_{3}-x_{1}).(x_{3}-x_{2})}=\frac{(x-0).(x-0.25)}{(0.5-0).(0.5-0.25)}=8x^{2}-2x $$

$$ <span id="(1)">
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.20)
 * }
 * {| style="width:100%" border="0"


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

$${b_{1}^{(1)}}'=16x-6, \quad\quad {b_{2}^{(1)}}'=-32x+8 , \quad\quad {b_{3}^{(1)}}'=16x-2 $$

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

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


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

As we know from the definition of K matrix <span id="(1)">
 * }
 * {| style="width:100%" border="0"

$$ \mathbf{K_{ij}^{(1)}}=\int_{\alpha }^{\beta }{b_{i}^{(1)}}'.a_{2}.{b_{j}^{(1)}}'dx $$
 * style="width:95%" |
 * style="width:95%" |

$$ <span id="(1)">
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.21)
 * }
 * {| style="width:100%" border="0"

So, the elements of K matrix are:
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$ \mathbf{K_{11}^{(1)}}=\int_{0 }^{0.5 }(16x-6).(2+3x).(16x-6)dx=10.8333 $$ $$ <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.21)
 * }
 * {| style="width:100%" border="0"

$$ \mathbf{K_{12}^{(1)}}=\mathbf{K_{21}^{(1)}}=\int_{0 }^{0.5 }(16x-6).(2+3x).(-32x+8)dx=-12.6667 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.22)
 * }

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

$$ \mathbf{K_{13}^{1}}=\mathbf{K_{31}^{(1)}}=\int_{0 }^{0.5 }(16x-6).(2+3x).(16x-2)dx=1.83333 $$ $$ <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.23)
 * }
 * {| style="width:100%" border="0"

$$ \mathbf{K_{22}^{(1)}}=\int_{0 }^{0.5 }(-32x+8).(2+3x).(-32x+8)dx=29.3333 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.24)
 * }

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

$$ \mathbf{K_{23}^{(1)}}=\int_{0 }^{0.5 }(-32x+8).(2+3x).(16x-2)dx=-16.6667 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.25)
 * }

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

$$ \mathbf{K_{33}^{(1)}}=\int_{0 }^{0.5 }(16x-2).(2+3x).(16x-2)dx=14.83333 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.26)
 * }

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

S0, the Element Stiffness Matrix or Local Stiffness Matrix for the Element 1 is :
 * style="width:95%" |
 * style="width:95%" |
 * }

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


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

$$ \mathbf{k^{(1)}}=\begin{bmatrix} 10.8333 & -12.6667 & 1.83333 \\ -12.6667 & 29.3333 & -16.6667 \\  1.83333 & -16.6667  & 14.83333 \end{bmatrix}

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

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

As we know from the definition of weak form the Force Matrix is given by:
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$ \tilde{F_i} = b_i (\alpha )h + \int_{0}^{1} b_i f dx $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.28)
 * }

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

So, the elements of force matrix are: <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"

$$ f_{1}^{(1)}=\int_{0}^{0.5}(8x^{2}-6x+1).(5x)dx=0 $$
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$ f_{2}^{(1)}=\int_{0}^{0.5}(-16x^{2}+8x).(5x)dx=0.416667 $$
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$ f_{3}^{(1)}=\int_{0}^{0.5}(8x^{2}-2x).(5x)dx=0.2083333 $$
 * style="width:95%" |
 * style="width:95%" |
 * }

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

So, the Element Force Matrix for Element 1 is:
 * style="width:95%" |
 * style="width:95%" |
 * }

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


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

$$ \mathbf{f^{(1)}}=\begin{bmatrix} 0\\ 0.416667\\ 0.208333 \end{bmatrix} $$ $$
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.29)
 * }

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

The transformation from Local to Global is given by: <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"

So, the global K and F matrices for Element 1 are given as:
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$ \mathbf{K^{e}}= \mathbf{L^{e^{T}}}.\mathbf{k^{e}}.\mathbf{L^{e}} $$ $$ <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.30)
 * }
 * {| style="width:100%" border="0"

$$ \mathbf{F^{e}}=\mathbf{L^{e^{T}}}.\mathbf{f^{e}} $$ $$ <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.31)
 * }
 * {| style="width:100%" border="0"

For Element 1 $$ \mathbf{L^{e}}=\mathbf{L^{1}} $$.
 * style="width:95%" |
 * style="width:95%" |
 * }

$$ \mathbf{L^{e}} \quad $$ For Element 1
<span id="(1)">
 * {| style="width:100%" border="0"

$$ \mathbf{L^{1}}=\begin{bmatrix} 1 &0 &0  &0  &0 \\ 0 &1  &0  &0  &0 \\ 0 &0  &1  &0  &0 \end{bmatrix} $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.32)
 * }

Global K,F matrices For Element 1
<span id="(1)">
 * {| style="width:100%" border="0"

$$ \mathbf{K^{1}}= \mathbf{L^{1^{T}}}.\mathbf{k^{1}}.\mathbf{L^{1}} $$
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$\mathbf{K^{1}}=\begin{bmatrix} 1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1\\ 0 & 0 & 0\\ 0 & 0 & 0 \end{bmatrix}\begin{bmatrix} 10.8333 & -12.6667 & 1.83333 \\ -12.6667 & 29.3333 & -16.6667 \\  1.83333 & -16.6667  & 14.83333 \end{bmatrix}\begin{bmatrix} 1 &0 &0  &0  &0 \\ 0 &1  &0  &0  &0 \\ 0 &0  &1  &0  &0 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }

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


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

$$ \Rightarrow \mathbf{K^{1}}=\begin{bmatrix} 10.8333 &-12.6667 &1.8333    &0  &0 \\ -12.667 &29.33333  &-16.6667  &0  &0 \\ 1.8333  & -16.6667 & 14.83333 &0  &0 \\ 0 &0  &0  &0  &0 \\ 0 &0  &0  &0  &0 \end{bmatrix}$$ $$
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.32)
 * }

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

$$ \mathbf{F^{1}}=\mathbf{L^{1^{T}}}.\mathbf{f^{1}} $$
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$\mathbf{F^{1}}=\begin{bmatrix} 1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1\\ 0 & 0 & 0\\ 0 & 0 & 0 \end{bmatrix}\begin{bmatrix} 0\\ 0.416667\\ 0.208333 \end{bmatrix} $$ <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"


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

$$ \Rightarrow \mathbf{F^{1}}=\begin{bmatrix} 0\\ 0.416667\\ 0.208333\\ 0\\ 0 \end{bmatrix} $$ $$
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.33)
 * }

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


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

Ist Basis Function: $$b_{1}^{(2)}=\frac{(x-x_{4}).(x-x_{5})}{(x_{3}-x_{4}).(x_{3}-x_{5})}=\frac{(x-0.75).(x-1)}{(0.5-0.75).(0.5-1)}=8x^{2}-14x+6 $$

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

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


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

IInd Basis Function: $$b_{2}^{(2)}=\frac{(x-x_{3}).(x-x_{5})}{(x_{4}-x_{3}).(x_{4}-x_{5})}=\frac{(x-0.5).(x-1)}{(0.75-0.5).(0.75-1)}=-16x^{2}+24x-8 $$

$$ <span id="(1)">
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.35)
 * }
 * {| style="width:100%" border="0"


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

IIIrd Basis Function : $$b_{3}^{(2)}=\frac{(x-x_{3}).(x-x_{4})}{(x_{5}-x_{3}).(x_{5}-x_{4})}=\frac{(x-0.5).(x-0.75)}{(1-0.5).(1-0.75)}=8x^{2}-10x+3 $$

$$ <span id="(1)">
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.36)
 * }
 * {| style="width:100%" border="0"


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

$${b_{1}^{(2)}}'=16x-14, \quad\quad {b_{2}^{(2)}}'=-32x+24 , \quad\quad {b_{3}^{(2)}}'=16x-10 $$

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

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


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

As we know from the definition of K matrix <span id="(1)">
 * }
 * {| style="width:100%" border="0"

$$ \mathbf{K_{ij}^{(2)}}=\int_{\alpha }^{\beta }{b_{i}^{(2)}}'.a_{2}.{b_{j}^{(2)}}'dx $$
 * style="width:95%" |
 * style="width:95%" |

$$ <span id="(1)">
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.38)
 * }
 * {| style="width:100%" border="0"

So, the elements of local k matrix (for Element 2) are:
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$ \mathbf{k_{11}^{(2)}}=\int_{0.5 }^{1 }(16x-14).(2+3x).(16x-14)dx=17.8333 $$ $$ <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.39)
 * }
 * {| style="width:100%" border="0"

$$ \mathbf{k_{12}^{(2)}}=\mathbf{k_{21}^{(2)}}=\int_{0.5 }^{1}(16x-14).(2+3x).(-32x+24)dx=-20.6667 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.40)
 * }

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

$$ \mathbf{k_{13}^{(2)}}=\mathbf{k_{31}^{(2)}}=\int_{0.5 }^{1}(16x-14).(2+3x).(16x-10)dx=2.83333 $$ $$ <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.41)
 * }
 * {| style="width:100%" border="0"

$$ \mathbf{k_{22}^{(2)}}=\int_{0.5 }^{1}(-32x+24).(2+3x).(-32x+24)dx=45.3333 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.42)
 * }

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

$$ \mathbf{k_{23}^{(2)}}=\int_{0.5 }^{1 }(-32x+24).(2+3x).(16x-10)dx=-24.6667 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.42)
 * }

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

$$ \mathbf{k_{33}^{(2)}}=\int_{0.5 }^{1}(16x-10).(2+3x).(16x-10)dx=21.83333 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.43)
 * }

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

S0, the Element Stiffness Matrix or Local Stiffness Matrix for the Element 2 is :
 * style="width:95%" |
 * style="width:95%" |
 * }

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


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

$$ \mathbf{k^{(2)}}=\begin{bmatrix} 17.8333 & -20.6667 & 2.83333 \\ -20.6667 & 45.3333 & -24.6667 \\  2.83333 & -24.6667  & 21.83333 \end{bmatrix}

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

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

As we know from the definition of weak form the Force Matrix is given by:
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$ \tilde{f_i} = b_i (\alpha )h + \int_{0.5}^{1} b_i f dx $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.45)
 * }

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

So, the elements of force matrix are: <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"

$$ f_{1}^{(2)}=\int_{0.5}^{1}(8x^{2}-14x+6).(5x)dx=0.28333 $$
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$ f_{2}^{(2)}=\int_{0.5}^{1}(-16x^{2}+24x-8).(5x)dx=1.25 $$
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$ f_{3}^{(2)}=(1).(12)\int_{0.5}^{1}(8x^{2}-10x+3).(5x)dx=12.416667 $$
 * style="width:95%" |
 * style="width:95%" |
 * }

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

So, the Element Force Matrix for Element 2 is:
 * style="width:95%" |
 * style="width:95%" |
 * }

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


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

$$ \mathbf{f^{(2)}}=\begin{bmatrix} 0.208333\\ 1.25\\ 12.416667 \end{bmatrix} $$ $$
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.46)
 * }

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

The transformation from Local to Global is given by: <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"


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

Global K,F matrices For Element 2
So, the global K and F matrices for Element 2 are given as:
 * }

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

$$ \mathbf{K^{(e)}}= \mathbf{L^{(e)^{T}}}.\mathbf{k^{(e)}}.\mathbf{L^{(e)}} $$ $$ <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.47)
 * }
 * {| style="width:100%" border="0"

$$ \mathbf{F^{(e)}}=\mathbf{L^{(e)^{T}}}.\mathbf{f^{(e)}} $$ $$ <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.48)
 * }
 * {| style="width:100%" border="0"

For Element 2 $$ \mathbf{L^{(e)}}=\mathbf{L^{(2)}} $$.
 * style="width:95%" |
 * style="width:95%" |
 * }

$$ \mathbf{L^{(e)}} $$ For Element 2
<span id="(1)">
 * {| style="width:100%" border="0"


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

$$ \mathbf{L^{(2)}}=\begin{bmatrix} 0 &0 &1  &0  &0 \\ 0 &0  &0  &1  &0 \\ 0 &0  &0  &0  &1 \end{bmatrix} $$ $$
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.49)
 * }

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

$$ \mathbf{K^{(2)}}= \mathbf{L^{(2)^{T}}}.\mathbf{k^{(2)}}.\mathbf{L^{(2)}} $$
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$\mathbf{K^{(2)}}=\begin{bmatrix} 0 & 0 & 0\\ 0 & 0 & 0\\ 1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1 \end{bmatrix}\begin{bmatrix} 17.8333 & -20.6667 & 2.83333 \\ -20.6667 & 45.3333 & -24.6667 \\  2.83333 & -24.6667  & 21.83333 \end{bmatrix}\begin{bmatrix} 0 &0 &1  &0  &0 \\ 0 &0  &0  &1  &0 \\ 0 &0  &0  &0  &1 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }

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


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

$$ \Rightarrow \mathbf{K^{(2)}}=\begin{bmatrix} 0 &0 &0   &0  &0 \\ 0 &0  &0   &0  &0 \\ 0 &0  & 17.83333 &-20.6667  &2.83333 \\ 0 &0  &-20.6667  &45.3333  &-24.6667 \\ 0 &0  &2.83333  &-24.6667  &21.83333 \end{bmatrix}$$ $$
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.50)
 * }

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

$$ \mathbf{F^{(2)}}=\mathbf{L^{(2)^{T}}}.\mathbf{f^{(2)}} $$
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$\mathbf{F^{(2)}}=\begin{bmatrix} 0 & 0 & 0\\ 0 & 0 & 0\\ 1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1 \end{bmatrix}\begin{bmatrix} 0.208333\\ 1.25\\ 12.46667 \end{bmatrix} $$ <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"


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

$$ \Rightarrow \mathbf{F^{(2)}}=\begin{bmatrix} 0\\ 0\\ 0.208333\\ 1.25\\ 12.46667 \end{bmatrix} $$ $$
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.51)
 * }

Global K matrix for 2 elements
<span id="(1)">
 * {| style="width:100%" border="0"

The Global K matrix for 2 elements is given by: <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"

$$ \mathbf{\tilde{K}}=\sum_{e=1}^{2}\mathbf{K^{e}} $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.52)
 * }

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

$$ \Rightarrow \mathbf{\tilde{K}}=\mathbf{\tilde{K}^{(1)}}+\mathbf{\tilde{K}^{(2)}} $$
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$ \Rightarrow \tilde{K}=\begin{bmatrix} 10.8333 &-12.6667 &1.8333    &0  &0 \\ -12.667 &29.33333  &-16.6667  &0  &0 \\ 1.83333 &-16.6667  & 32.6666 &-20.6667  &2.83333 \\ 0 &0  &-20.6667  &45.3333  &-24.6667 \\ 0 &0  &2.83333  &-24.6667  &21.83333 \end{bmatrix} $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.53)
 * }

Global F matrix for 2 elements
<span id="(1)">
 * {| style="width:100%" border="0"

The Global F matrix for 2 elements is given by: <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"

$$ \mathbf{\tilde{F}}=\sum_{e=1}^{2}\mathbf{F^{e}} $$ $$ <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.54)
 * }
 * {| style="width:100%" border="0"

$$ \Rightarrow \mathbf{\tilde{F}}=\mathbf{\tilde{F}^{(1)}}+\mathbf{\tilde{F}^{(2)}} $$
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$ \Rightarrow \tilde{F}=\begin{bmatrix} 0\\ 0.416667\\ 0.416667\\ 1.25\\ 12.41667 \end{bmatrix} $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.55)
 * }

Global d matrix for 2 elements
<span id="(1)">
 * {| style="width:100%" border="0"

As we know, <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"

$$ \mathbf{\tilde{K}}.\mathbf{\tilde{d}}=\mathbf{\tilde{F}} $$ <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"

$$\Rightarrow \mathbf{\tilde{d}}=\mathbf{\tilde{K}^{-1}}.\mathbf{\tilde{F}} $$ <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"

So. the $$ \mathbf{\tilde{d}} $$ is :
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$ \mathbf{\tilde{d}}=\begin{bmatrix} 4\\ 5.5312\\ 6.6698\\ 7.5446\\ 8.2268 \end{bmatrix} $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.1.56)
 * }

At $$ x = 0.5 \quad $$ ,

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

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

The exact solution can be found from the eqn. 6.1.14. It is given by ,

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

$$ u(0.5) = 6.671155 \quad$$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle
 * }

Hence the error we get for $$ no. \quad of \quad elements \quad (n) = 2 $$ is ,

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

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

MATLAB code with output
The K,d and F matrix for 2 elements only are as follows:

K =

10.8333 -12.6667    1.8333         0         0  -12.6667   29.3333  -16.6667         0         0    1.8333  -16.6667   32.6667  -20.6667    2.8333         0         0  -20.6667   45.3333  -24.6667         0         0    2.8333  -24.6667   21.8333

F =

[0   0.416666666666667    0.416666666666667    1.25000000000000    12.416666666666667]^T

d =

[4   5.53116172316385     6.66984463276837     7.54458967938842     8.22680850223224]^T

The outputs for convergence are as follows:

@x=0.5 Exact U=6.671156e+000

U(weak form) for n=2 = 6.669845e+000

Error at n=2 is 1.311013e-003

@x=0.5 Exact U=6.671156e+000

U(weak form) for n=4 = 6.671055e+000

Error at n=4 is 1.003161e-004

@x=0.5 Exact U=6.671156e+000

U(weak form) for n=6 = 6.671135e+000

Error at n=6 is 2.076369e-005

@x=0.5 Exact U=6.671156e+000

U(weak form) for n=8 = 6.671149e+000

Error at n=8 is 6.685488e-006

@x=0.5 Exact U=6.671156e+000

U(weak form) for n=10 = 6.671153e+000

Error at n=10 is 2.761216e-006

@x=0.5 Exact U=6.671156e+000

U(weak form) for n=12 = 6.671154e+000

Error at n=12 is 1.337704e-006

@x=0.5 Exact U=6.671156e+000

U(weak form) for n=14 = 6.671155e+000

Error at n=14 is 7.240625e-007

u,u^h vs x Plot


= 6.2 [ Solving G1DM1.0/D1 using weak form with QLEBF (Quadratic Lagrangian Element Basis Functions)] =

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

$$ \frac{\partial}{\partial x} \left[ (2+3x) \frac{\partial u}{\partial x} \right] + 5x = 0 \ \ \forall x \in \left] 0,1 \right[ $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.1)
 * }

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

$$u \ at \ {x=1} \ is \ 4 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.2)
 * }

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

$$  \frac{\partial u}{\partial x} \  at \ x = 0 \ is \ -6 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.3)
 * }

Find: Approximate solution using weak form and its comparison to exact solution
 Find approximate solution using weak form and compare it to exact one


 * Consider QLEBF basis function satisfying constraint basis solution


 * Compute $$ u_n^h (x = 0.5) \quad $$ for $$ n = 2, 4, 6..... \quad $$ until convergence of $$ u^h (0.5)\ to \ 0(10^{-6}) $$


 * 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. 6.2.4)
 * }


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

Solution
Strong form

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

$$ \frac{\partial}{\partial x} \left[ (2+3x) \frac{\partial u}{\partial x} \right] + 5x = 0 \ \ \forall x \in \left] 0,1 \right[ $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                       (Eq. 6.2.5)
 * }

Boundary conditions

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

$$u \ at \ {x=1} \ is \ 4 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.6)
 * }

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

$$  \frac{\partial u}{\partial x} \  at \ x = 0 \ is \ -6 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.7)
 * }

Finding of the Exact Solution
The exact solution of the displacement can be found as follows.

Differentiating eqn 5.2.5, we get,

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

$$ (2+3x)\frac{\partial u}{\partial x} + \frac{5x^2}{2} = c_1 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.8)
 * }

Substituting the natural B.C in the above equation, we get,

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

$$ c_1 = -12 \quad$$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.9)
 * }

Therefore eqn 5.2.8 becomes,

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

$$ (2+3x)\frac{\partial u}{\partial x} + \frac{5x^2}{2} = -12 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.10)
 * }

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

$$\frac{\partial u}{\partial x} = \frac{-12-\frac{5x^2}{2}}{(2+3x)} $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.11)
 * }

Integrating the above equation, we get,

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

$$u = \frac{1}{108}(-45x^2 + 60x - 472 log (2+3x) +60 ) + c_2 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.12)
 * }

Substituting the Essential B.C in the above equation, we get,

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

$$c_2 = 10.3394 \quad$$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.13)
 * }

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

$$u = \frac{1}{108}(-45x^2 + 60x - 472 log (2+3x) +60 ) + 10.3393953 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.14)
 * }

Finding of the Approximate Solution using Weak form with QLEBF
Weak Form

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

$$  \sum_{i} c_i \left [ \sum_{j} \left \{ \tilde{K_{ij}} \tilde{d_j} \right \} - \tilde{F_i} \right ] = 0 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.15)
 * }

where,

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

$$\tilde{K_{ij}} = \int_{0}^{1} b_i' \ a_2 \ b_j ' \ dx $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.16)
 * }

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

$$ \tilde{F_i} = b_i (\alpha )h + \int_{0}^{1} b_i f dx $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.17)
 * }

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


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

Ist Basis Function: $$b_{1}^{(1)}=L_{1,3}=\frac{(x-x_{2}).(x-x_{3})}{(x_{1}-x_{2}).(x_{1}-x_{3})}=\frac{(x-0.25).(x-0.5)}{(0-0.25).(0-0.5)}=8x^{2}-6x+1 $$

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

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


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

IInd Basis Function: $$b_{2}^{(1)}=L_{2,3}=\frac{(x-x_{1}).(x-x_{3})}{(x_{2}-x_{1}).(x_{2}-x_{3})}=\frac{(x-0).(x-0.5)}{(0.25-0).(0.25-0.5)}=-16x^{2}+8x $$

$$ <span id="(1)">
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.19)
 * }
 * {| style="width:100%" border="0"


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

IIIrd Basis Function : $$b_{3}^{(1)}=L_{3,3}=\frac{(x-x_{1}).(x-x_{2})}{(x_{3}-x_{1}).(x_{3}-x_{2})}=\frac{(x-0).(x-0.25)}{(0.5-0).(0.5-0.25)}=8x^{2}-2x $$

$$ <span id="(1)">
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.20)
 * }
 * {| style="width:100%" border="0"


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

$${b_{1}^{(1)}}'=16x-6, \quad\quad {b_{2}^{(1)}}'=-32x+8 , \quad\quad {b_{3}^{(1)}}'=16x-2 $$

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

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


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

As we know from the definition of K matrix <span id="(1)">
 * }
 * {| style="width:100%" border="0"

$$ \mathbf{K_{ij}^{(1)}}=\int_{\alpha }^{\beta }{b_{i}^{(1)}}'.a_{2}.{b_{j}^{(1)}}'dx $$
 * style="width:95%" |
 * style="width:95%" |

$$ <span id="(1)">
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.21)
 * }
 * {| style="width:100%" border="0"

So, the elements of K matrix are:
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$ \mathbf{K_{11}^{(1)}}=\int_{0 }^{0.5 }(16x-6).(2+3x).(16x-6)dx=10.8333 $$ $$ <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.21)
 * }
 * {| style="width:100%" border="0"

$$ \mathbf{K_{12}^{(1)}}=\mathbf{K_{21}^{(1)}}=\int_{0 }^{0.5 }(16x-6).(2+3x).(-32x+8)dx=-12.6667 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.22)
 * }

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

$$ \mathbf{K_{13}^{1}}=\mathbf{K_{31}^{(1)}}=\int_{0 }^{0.5 }(16x-6).(2+3x).(16x-2)dx=1.83333 $$ $$ <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.23)
 * }
 * {| style="width:100%" border="0"

$$ \mathbf{K_{22}^{(1)}}=\int_{0 }^{0.5 }(-32x+8).(2+3x).(-32x+8)dx=29.3333 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.24)
 * }

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

$$ \mathbf{K_{23}^{(1)}}=\int_{0 }^{0.5 }(-32x+8).(2+3x).(16x-2)dx=-16.6667 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.25)
 * }

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

$$ \mathbf{K_{33}^{(1)}}=\int_{0 }^{0.5 }(16x-2).(2+3x).(16x-2)dx=14.83333 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.26)
 * }

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

S0, the Element Stiffness Matrix or Local Stiffness Matrix for the Element 1 is :
 * style="width:95%" |
 * style="width:95%" |
 * }

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


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

$$ \mathbf{k^{(1)}}=\begin{bmatrix} 10.8333 & -12.6667 & 1.83333 \\ -12.6667 & 29.3333 & -16.6667 \\  1.83333 & -16.6667  & 14.83333 \end{bmatrix}

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

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

As we know from the definition of weak form the Force Matrix is given by:
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$ \tilde{F_i} = b_i (\alpha )h + \int_{0}^{1} b_i f dx $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.28)
 * }

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

So, the elements of force matrix are: <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"

$$ f_{1}^{(1)}=(1).(12)+\int_{0}^{0.5}(8x^{2}-6x+1).(5x)dx=12 $$
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$ f_{2}^{(1)}=\int_{0}^{0.5}(-16x^{2}+8x).(5x)dx=0.416667 $$
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$ f_{3}^{(1)}=\int_{0}^{0.5}(8x^{2}-2x).(5x)dx=0.2083333 $$
 * style="width:95%" |
 * style="width:95%" |
 * }

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

So, the Element Force Matrix for Element 1 is:
 * style="width:95%" |
 * style="width:95%" |
 * }

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


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

$$ \mathbf{f^{(1)}}=\begin{bmatrix} 12\\ 0.416667\\ 0.208333 \end{bmatrix} $$ $$
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.29)
 * }

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

The transformation from Local to Global is given by: <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"

So, the global K and F matrices for Element 1 are given as:
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$ \mathbf{K^{e}}= \mathbf{L^{e^{T}}}.\mathbf{k^{e}}.\mathbf{L^{e}} $$ $$ <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.30)
 * }
 * {| style="width:100%" border="0"

$$ \mathbf{F^{e}}=\mathbf{L^{e^{T}}}.\mathbf{f^{e}} $$ $$ <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.31)
 * }
 * {| style="width:100%" border="0"

For Element 1 $$ \mathbf{L^{e}}=\mathbf{L^{1}} $$.
 * style="width:95%" |
 * style="width:95%" |
 * }

$$ \mathbf{L^{e}} \quad $$ For Element 1
<span id="(1)">
 * {| style="width:100%" border="0"

$$ \mathbf{L^{1}}=\begin{bmatrix} 1 &0 &0  &0  &0 \\ 0 &1  &0  &0  &0 \\ 0 &0  &1  &0  &0 \end{bmatrix} $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.32)
 * }

Global K,F matrices For Element 1
<span id="(1)">
 * {| style="width:100%" border="0"

$$ \mathbf{K^{1}}= \mathbf{L^{1^{T}}}.\mathbf{k^{1}}.\mathbf{L^{1}} $$
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$\mathbf{K^{1}}=\begin{bmatrix} 1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1\\ 0 & 0 & 0\\ 0 & 0 & 0 \end{bmatrix}\begin{bmatrix} 10.8333 & -12.6667 & 1.83333 \\ -12.6667 & 29.3333 & -16.6667 \\  1.83333 & -16.6667  & 14.83333 \end{bmatrix}\begin{bmatrix} 1 &0 &0  &0  &0 \\ 0 &1  &0  &0  &0 \\ 0 &0  &1  &0  &0 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }

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


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

$$ \Rightarrow \mathbf{K^{1}}=\begin{bmatrix} 10.8333 &-12.6667 &1.8333    &0  &0 \\ -12.667 &29.33333  &-16.6667  &0  &0 \\ 1.8333  & -16.6667 & 14.83333 &0  &0 \\ 0 &0  &0  &0  &0 \\ 0 &0  &0  &0  &0 \end{bmatrix}$$ $$
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.32)
 * }

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

$$ \mathbf{F^{1}}=\mathbf{L^{1^{T}}}.\mathbf{f^{1}} $$
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$\mathbf{F^{1}}=\begin{bmatrix} 1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1\\ 0 & 0 & 0\\ 0 & 0 & 0 \end{bmatrix}\begin{bmatrix} 12\\ 0.416667\\ 0.208333 \end{bmatrix} $$ <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"


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

$$ \Rightarrow \mathbf{F^{1}}=\begin{bmatrix} 12\\ 0.416667\\ 0.208333\\ 0\\ 0 \end{bmatrix} $$ $$
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.33)
 * }

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


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

Ist Basis Function: $$b_{1}^{(2)}=\frac{(x-x_{4}).(x-x_{5})}{(x_{3}-x_{4}).(x_{3}-x_{5})}=\frac{(x-0.75).(x-1)}{(0.5-0.75).(0.5-1)}=8x^{2}-14x+6 $$

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

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


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

IInd Basis Function: $$b_{2}^{(2)}=\frac{(x-x_{3}).(x-x_{5})}{(x_{4}-x_{3}).(x_{4}-x_{5})}=\frac{(x-0.5).(x-1)}{(0.75-0.5).(0.75-1)}=-16x^{2}+24x-8 $$

$$ <span id="(1)">
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.35)
 * }
 * {| style="width:100%" border="0"


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

IIIrd Basis Function : $$b_{3}^{(2)}=\frac{(x-x_{3}).(x-x_{4})}{(x_{5}-x_{3}).(x_{5}-x_{4})}=\frac{(x-0.5).(x-0.75)}{(1-0.5).(1-0.75)}=8x^{2}-10x+3 $$

$$ <span id="(1)">
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.36)
 * }
 * {| style="width:100%" border="0"


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

$${b_{1}^{(2)}}'=16x-14, \quad\quad {b_{2}^{(2)}}'=-32x+24 , \quad\quad {b_{3}^{(2)}}'=16x-10 $$

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

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


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

As we know from the definition of K matrix <span id="(1)">
 * }
 * {| style="width:100%" border="0"

$$ \mathbf{K_{ij}^{(2)}}=\int_{\alpha }^{\beta }{b_{i}^{(2)}}'.a_{2}.{b_{j}^{(2)}}'dx $$
 * style="width:95%" |
 * style="width:95%" |

$$ <span id="(1)">
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.38)
 * }
 * {| style="width:100%" border="0"

So, the elements of local k matrix (for Element 2) are:
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$ \mathbf{k_{11}^{(2)}}=\int_{0.5 }^{1 }(16x-14).(2+3x).(16x-14)dx=17.8333 $$ $$ <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.39)
 * }
 * {| style="width:100%" border="0"

$$ \mathbf{k_{12}^{(2)}}=\mathbf{k_{21}^{(2)}}=\int_{0.5 }^{1}(16x-14).(2+3x).(-32x+24)dx=-20.6667 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.40)
 * }

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

$$ \mathbf{k_{13}^{(2)}}=\mathbf{k_{31}^{(2)}}=\int_{0.5 }^{1}(16x-14).(2+3x).(16x-10)dx=2.83333 $$ $$ <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.41)
 * }
 * {| style="width:100%" border="0"

$$ \mathbf{k_{22}^{(2)}}=\int_{0.5 }^{1}(-32x+24).(2+3x).(-32x+24)dx=45.3333 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.42)
 * }

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

$$ \mathbf{k_{23}^{(2)}}=\int_{0.5 }^{1 }(-32x+24).(2+3x).(16x-10)dx=-24.6667 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.42)
 * }

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

$$ \mathbf{k_{33}^{(2)}}=\int_{0.5 }^{1}(16x-10).(2+3x).(16x-10)dx=21.83333 $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.43)
 * }

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

S0, the Element Stiffness Matrix or Local Stiffness Matrix for the Element 2 is :
 * style="width:95%" |
 * style="width:95%" |
 * }

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


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

$$ \mathbf{k^{(2)}}=\begin{bmatrix} 17.8333 & -20.6667 & 2.83333 \\ -20.6667 & 45.3333 & -24.6667 \\  2.83333 & -24.6667  & 21.83333 \end{bmatrix}

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

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

As we know from the definition of weak form the Force Matrix is given by:
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$ \tilde{f_i} = b_i (\alpha )h + \int_{0.5}^{1} b_i f dx $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.45)
 * }

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

So, the elements of force matrix are: <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"

$$ f_{1}^{(2)}=\int_{0.5}^{1}(8x^{2}-14x+6).(5x)dx=0.28333 $$
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$ f_{2}^{(2)}=\int_{0.5}^{1}(-16x^{2}+24x-8).(5x)dx=1.25 $$
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$ f_{3}^{(2)}=\int_{0.5}^{1}(8x^{2}-10x+3).(5x)dx=0.416667 $$
 * style="width:95%" |
 * style="width:95%" |
 * }

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

So, the Element Force Matrix for Element 2 is:
 * style="width:95%" |
 * style="width:95%" |
 * }

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


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

$$ \mathbf{f^{(2)}}=\begin{bmatrix} 0.208333\\ 1.25\\ 0.416667 \end{bmatrix} $$ $$
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.46)
 * }

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

The transformation from Local to Global is given by: <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"


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

Global K,F matrices For Element 2
So, the global K and F matrices for Element 2 are given as:
 * }

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

$$ \mathbf{K^{(e)}}= \mathbf{L^{(e)^{T}}}.\mathbf{k^{(e)}}.\mathbf{L^{(e)}} $$ $$ <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.47)
 * }
 * {| style="width:100%" border="0"

$$ \mathbf{F^{(e)}}=\mathbf{L^{(e)^{T}}}.\mathbf{f^{(e)}} $$ $$ <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.48)
 * }
 * {| style="width:100%" border="0"

For Element 2 $$ \mathbf{L^{(e)}}=\mathbf{L^{(2)}} $$.
 * style="width:95%" |
 * style="width:95%" |
 * }

$$ \mathbf{L^{(e)}} $$ For Element 2
<span id="(1)">
 * {| style="width:100%" border="0"


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

$$ \mathbf{L^{(2)}}=\begin{bmatrix} 0 &0 &1  &0  &0 \\ 0 &0  &0  &1  &0 \\ 0 &0  &0  &0  &1 \end{bmatrix} $$ $$
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.49)
 * }

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

$$ \mathbf{K^{(2)}}= \mathbf{L^{(2)^{T}}}.\mathbf{k^{(2)}}.\mathbf{L^{(2)}} $$
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$\mathbf{K^{(2)}}=\begin{bmatrix} 0 & 0 & 0\\ 0 & 0 & 0\\ 1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1 \end{bmatrix}\begin{bmatrix} 17.8333 & -20.6667 & 2.83333 \\ -20.6667 & 45.3333 & -24.6667 \\  2.83333 & -24.6667  & 21.83333 \end{bmatrix}\begin{bmatrix} 0 &0 &1  &0  &0 \\ 0 &0  &0  &1  &0 \\ 0 &0  &0  &0  &1 \end{bmatrix} $$
 * style="width:95%" |
 * style="width:95%" |
 * }

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


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

$$ \Rightarrow \mathbf{K^{(2)}}=\begin{bmatrix} 0 &0 &0   &0  &0 \\ 0 &0  &0   &0  &0 \\ 0 &0  & 17.83333 &-20.6667  &2.83333 \\ 0 &0  &-20.6667  &45.3333  &-24.6667 \\ 0 &0  &2.83333  &-24.6667  &21.83333 \end{bmatrix}$$ $$
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.50)
 * }

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

$$ \mathbf{F^{(2)}}=\mathbf{L^{(2)^{T}}}.\mathbf{f^{(2)}} $$
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$\mathbf{F^{(2)}}=\begin{bmatrix} 0 & 0 & 0\\ 0 & 0 & 0\\ 1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1 \end{bmatrix}\begin{bmatrix} 0.208333\\ 1.25\\ 0.416667 \end{bmatrix} $$ <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"


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

$$ \Rightarrow \mathbf{F^{(2)}}=\begin{bmatrix} 0\\ 0\\ 0.208333\\ 1.25\\ 0.416667 \end{bmatrix} $$ $$
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.51)
 * }

Global K matrix for 2 elements
<span id="(1)">
 * {| style="width:100%" border="0"

The Global K matrix for 2 elements is given by: <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"

$$ \mathbf{\tilde{K}}=\sum_{e=1}^{2}\mathbf{K^{e}} $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.52)
 * }

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

$$ \Rightarrow \mathbf{\tilde{K}}=\mathbf{\tilde{K}^{(1)}}+\mathbf{\tilde{K}^{(2)}} $$
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$ \Rightarrow \tilde{K}=\begin{bmatrix} 10.8333 &-12.6667 &1.8333    &0  &0 \\ -12.667 &29.33333  &-16.6667  &0  &0 \\ 1.83333 &-16.6667  & 32.6666 &-20.6667  &2.83333 \\ 0 &0  &-20.6667  &45.3333  &-24.6667 \\ 0 &0  &2.83333  &-24.6667  &21.83333 \end{bmatrix} $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.53)
 * }

Global F matrix for 2 elements
<span id="(1)">
 * {| style="width:100%" border="0"

The Global F matrix for 2 elements is given by: <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"

$$ \mathbf{\tilde{F}}=\sum_{e=1}^{2}\mathbf{F^{e}} $$ $$ <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.54)
 * }
 * {| style="width:100%" border="0"

$$ \Rightarrow \mathbf{\tilde{F}}=\mathbf{\tilde{F}^{(1)}}+\mathbf{\tilde{F}^{(2)}} $$
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$ \Rightarrow \tilde{F}=\begin{bmatrix} 12\\ 0.416667\\ 0.416667\\ 1.25\\ 0.41667 \end{bmatrix} $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.55)
 * }

Global d matrix for 2 elements
<span id="(1)">
 * {| style="width:100%" border="0"

As we know, <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"

$$ \mathbf{\tilde{K}}.\mathbf{\tilde{d}}=\mathbf{\tilde{F}} $$ <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"

$$\Rightarrow \mathbf{\tilde{d}}=\mathbf{\tilde{K}^{-1}}.\mathbf{\tilde{F}} $$ <span id="(1)">
 * style="width:95%" |
 * style="width:95%" |
 * }
 * {| style="width:100%" border="0"

So. the $$ \mathbf{\tilde{d}} $$ is :
 * style="width:95%" |
 * style="width:95%" |
 * }

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

$$ \mathbf{\tilde{d}}=\begin{bmatrix} 7.8642\\ 6.5882\\ 5.5934\\ 4.7540\\ 4 \end{bmatrix} $$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle                                                                          (Eq. 6.2.56)
 * }

At $$ x = 0.5 \quad $$ ,

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

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

The exact solution can be found from the eqn. 6.2.14. It is given by ,

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

$$ u(0.5) = 5.59352829 \quad$$ $$
 * style="width:95%" |
 * style="width:95%" |
 * <p style="text-align:right"> $$ \displaystyle
 * }

Hence the error we get for $$ no. \quad of \quad elements \quad (n) = 2 $$ is ,

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

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

MATLAB code with output
The K,d and F matrix for 2 elements are as follows:

K =

10.8333 -12.6667    1.8333         0         0  -12.6667   29.3333  -16.6667         0         0    1.8333  -16.6667   32.6667  -20.6667    2.8333         0         0  -20.6667   45.3333  -24.6667         0         0    2.8333  -24.6667   21.8333

F =

[12 0.416666666666667 0.416666666666667 1.25000000000000 0.416666666666667]^T

d =

[7.8642  6.5882   5.5934   4.7540   4]^T

The outputs for two elements are as follows:

@x=0.5 Exact U=5.593524e+000

U(weak form) for n=2 = 5.593386e+000

Error at n=2 is 1.380272e-004

@x=0.5 Exact U=5.593524e+000

U(weak form) for n=4 = 5.593514e+000

Error at n=4 is 9.391941e-006

@x=0.5 Exact U=5.593524e+000

U(weak form) for n=6 = 5.593522e+000

Error at n=6 is 1.871865e-006

@x=0.5 Exact U=5.593524e+000

U(weak form) for n=8 = 5.593523e+000

Error at n=8 is 5.817644e-007