Solution of a Steady-State Heat Conduction Problem using the Ritz Method  
Author's Data: Housam BINOUS
Department of Chemical Engineering
National Institute of Applied Sciences and Technology
Tunis, TUNISIA
Email: binoushousam@yahoo.com

Reference :
M. N. Özisik, Heat Conduction, Wiley, New York, 1980.

Exact Solution

sol = 
      DSolve[{D[T[x], {x, 2}] + A T[x] + B x == 0, T[0] ==  0, 
          T[1] ==  0}, T[x], x]

Approximate Solution using the Ritz Method

T2[x_] :=  c1 (Subscript[ϕ, 1])[x] + c2 (Subscript[ϕ, 2])[x]

It = 
      Integrate[
        D[T2[x], {x, 1}]^2 - A T2[x]^2 - 2  B x T2[x], {x, 0, 
          1}]

(Subscript[ϕ, 1])[x_] := x (1 - x)

(Subscript[ϕ, 2])[x_] := x^2 (1 - x)

It

sol2 = 
      Solve[{D[It, {c1, 1}] == 0, D[It, {c2, 1}] == 0}, {c1, 
          c2}]

% /. A -> 1 /. B -> 1

Comparing Exact and Approximate Solutions

xd = Table[x, {x, 0.25, 0.85, 0.05}]

tbl1 = Table[First[T[x] /. sol], {x, 0.25, 0.85, 0.05}] /. 
          A -> 1 /. B -> 1

tbl2 = Table[First[T2[x] /. sol2], {x, 0.25, 0.85, 0.05}] /. 
          A -> 1 /. B -> 1

tbl3 = 100 (tbl2 - tbl1)/tbl1

Join[{{x,  Exact,  Approx,  Perc .   Error}}, 
        Transpose[{xd, tbl1, tbl2, tbl3}]] // MatrixForm

plt1 = 
      Plot[T[x] /. sol /. A -> 1 /. B -> 1, {x, 0, 1}, 
        PlotStyle -> RGBColor[1, 0, 0], 
        DisplayFunction ->  Identity]

plt2 = 
      Plot[T2[x] /. sol2 /. A -> 1 /. B -> 1, {x, 0, 1}, 
        PlotStyle -> RGBColor[0, 0, 1], 
        DisplayFunction ->  Identity]

Show[plt1, plt2, DisplayFunction ->  $DisplayFunction]