Homework #1
MEAM501_1998 FALL

We shall solve the boundary value problem

-T(∂_x) (∂_x) u+ku=f     in     (0,L)
u(0)=u(L)=0

by the weighted residual method. If the test functionl space is approximated by

(Subscript[φ, 1]),(Subscript[φ, 2]),.....,(Subscript[φ, m])

and if the trial space is approximated by

(Subscript[ϕ, 1]),(Subscript[ϕ, 2]),.....,(Subscript[ϕ, n])

then, the weighted residual formulation yields the discrete system

\(TraditionalForm
      \`∑\+\(j = 1\)\%n
          ∫\_0\%L
            \((\(-T\)\ ∂\_x\ \(∂\_x\ ϕ\_j\) + 
                kϕ\_j)\) \(φ\_i\) dx\)(Subscript[u, j])=\(TraditionalForm
      \`∑\+\(j = 1\)\%n
          ∫\_0\%L\( fφ\_i\) dx\)     ,     i=1,2,.....,m

Problem (3)

\(m = 5; 
n = 7; 
Kij = Table[0, {i, 1, m}, {j, 1, n}]; 

    fi = Table[0, {i, 1, m}]; 
L = 1; 

    fj = Table[Sin[j*Pi*x/L], {j, 1, n}]; 

    yi = Table[x^\((i - 1)\), {i, 1, m}]; 
T = 1; 
k = Exp[\(-x\)]; 

    f = 1 + Sin[3*Pi*x/L]; 

    Block[{i, j}, 
	
      Do[fi[\([i]\)] = NIntegrate[f*yi[\([i]\)], {x, 0, L}]; 
		
        Do[resj = \(-T\)*D[D[fj[\([j]\)], x], x] + k*fj[\([j]\)]; 
			
          Kij[\([i, j]\)] = NIntegrate[resj*yi[\([i]\)], {x, 0, L}], {j, 1, 
            n}], {i, 1, m}]]\)\(		Kij\)\(		fi\)\(		uj = PseudoInverse[Kij].fi\)\(		u = uj.fj; 
		Plot[u, {x, 0, L}, PlotRange -> All]\)

Comparison of the results : (m,n) = (10,7), (7,7), and (5,7)

Show[{g1, g2, g3}]

Result by (m,n) = (10,10) but using only sine functions

Problem (4)

\(m = 5; 
n = 7; 
Kij = Table[0, {i, 1, m}, {j, 1, n}]; 

    fi = Table[0, {i, 1, m}]; 
L = 1; 

    fj = Table[Sin[j*Pi*x/L], {j, 1, n}]; 

    yi = Table[i*L/\((m + 1)\), {i, 1, m}]; 
T = 1; 
k = Exp[\(-x\)]; 

    f = 1 + Sin[3*Pi*x/L]; 

    Block[{i, j}, 
	
      Do[fi[\([i]\)] = N[f /. {x -> yi[\([i]\)]}]; 
		
        Do[resj = \(-T\)*D[D[fj[\([j]\)], x], x] + k*fj[\([j]\)]; 
			
          Kij[\([i, j]\)] = N[resj /. {x -> yi[\([i]\)]}], {j, 1, n}], {i, 1, 
          m}]]\)\(		Kij\)\(		fi\)\(		uj = PseudoInverse[Kij].fi\)\(		u = uj.fj; 
		Plot[u, {x, 0, L}, PlotRange -> All]\)

Comparison of the Three Results : (m,n) = (10,7), (7,7), and (5,7)

Show[{g1, g2, g3}]

Problem (5)

\(m = 5; 
n = 7; 
Kij = Table[0, {i, 1, m}, {j, 1, n}]; 

    fi = Table[0, {i, 1, m}]; 
L = 1; 
fj = Table[x^j, {j, 1, n}]; 

    yi = Table[x^\((i - 1)\), {i, 1, m}]; 
T = 1; 
k = Exp[\(-x\)]; 

    f = 1 + Sin[3*Pi*x/L]; 

    Block[{i, j}, 
	
      Do[fi[\([i]\)] = NIntegrate[f*yi[\([i]\)], {x, 0, L}]; 
		
        Do[left1 = 
            T*D[fj[\([j]\)], x]*D[yi[\([i]\)], x] + 
              k*fj[\([j]\)]*yi[\([i]\)]; 
			
          Kij[\([i, j]\)] = 
            NIntegrate[left1, {x, 0, L}] + 
                \((T*D[fj[\([j]\)], x]*yi[\([i]\)])\) /. {x -> 0}, {j, 1, 
            n}], {i, 1, m}]]\)\(		Kij\)\(		fi\)\(		uj = PseudoInverse[Kij].fi\)\(		u = uj.fj; 
		Plot[u, {x, 0, L}, PlotRange -> All]\)

Comparison of the Three Results : (m,n) = (10,7), (7,7), and (5,7)

Show[{g1, g2, g3}]