 Finite Element Method in Solving ODE -- Rayleigh-Ritz Method
In this page we will introduce the Rayleigh-Ritz Method to solve boundary value problem of ODE. We will focus on the application of this method to linear equations of the following form
 - d dx (p(x) dy dx ) + q(x) y = f(x),        for 0 £ x £ 1
with boundary condition y(0) = y(1) = 0. Here
 p(x) ³ c > 0,
and
 q(x) ³ 0,
for each x in [0, 1]. Also p(x) Î C1[0,1], and that q(x), f(x) Î C[0, 1]. From theory we know this boundary value problem has a unique solution whihc is a minimizer of the functional:
 I : C01 [0,1] ® R
defined as
 I[u] = ó õ 1 0 {p(x) [u¢(x)]2+ q(x) [u(x)]2 - 2f(x)u(x)} dx
The idea of Rayleigh-Ritz approximation is to minimize the integral over an finite dimensional space that consists of all linear combinations of the linearly independent base functions
 f1(x), f2(x), ¼, fn(x)

with fi (0) = fi (1) = 0, for each i = 1, 2, ¼, n. Notice with this condition, the approximate solution u(x) = åi = 1ncifi(x) automatically satisfies the boundary condtions. That is the beautify of Finite Element method, it facilitates us to treat boundary condition easily by selecting base functions that satisfy the required boundary condition.

Approximation to the solution of the boundary problem is then obtained by find constants

 c1, c2, c3 , ¼, cn
to minimize
 I[f]
 =
 I[ n å i = 1 cifi]
 =
 ó õ 1 0 {p(x)[ n å i = 1 cifi¢(x)]2 + q(x)[ n å i = 1 cifi(x)]2 -2f(x) n å i = 1 cif(x)}dx.
Notice here f1(x), f2(x), ¼, fn(x) are fixed functions. The only things vary in the above integration are c1, c2, c3 , ¼, cn. Hence we can consider I as a function of parameters c1, c2, c3 , ¼, cn. Our goal is to find the values of c1, c2, c3 , ¼, cn so that I achieves its minimum. From Calculus, we know that the necessary condition for I to have minimum value at c1, c2, c3 , ¼, cn is that the partial derivatives of I with repect to c1, c2, c3, ¼, cn are zero.

That is

 ¶I ¶cj = 0     for each j = 1, 2, ·, n

Now to compute the partial derivative. Let

 F(c1, c2, c3 , ¼, cn ) = [ n å i = 1 ciqi(x)]2

with qi fixed. From chain rule in partial derivative we have,

 ¶F ¶cj = 2qj(x) [ n å i = 1 ciqi(x)].
Replacing q(x) with fi¢(x) and fi(x) in the first and second terms of I respectively, we can find the partial derivative of I with respect to cj as Substitute these into the derivative for I we have:
 ¶I ¶cj = 2 n å i = 1 ó õ 1 0 [{p(x)fi¢(x)fj¢(x) + q(x)fi(x)fj(x)}dx] ci -2 ó õ 1 0 f(x)fj(x)dx

This is a linear system of equations for unknown parameters c1, c2, c3, ¼, cn, which we can write in a traditional matrix form as Ac = b. Here A = (aij) with

 aij = ó õ 1 0 [{p(x)fi¢(x)fj¢(x) + q(x)fi(x)fj(x)}dx]    for 1 £ i, j £ n.
And b = (b1, b2, b3, ¼, bn) with
 bi ó õ 1 0 f(x)fi(x)dx     for 1 £ i £ n.
And c = (c1, c2, c3, ¼, cn ) is the unknown vector.

The simplest choice of the base functions involves piecewise linear polynomials. The first step is to form a partication of [0, 1] by choosing points x1, x2, x3, ¼, xn, xn+1 with

 0 = x1, x2, x3, ¼, xn, xn+1 = 1.
fi(x) =  ì
ï
ï
ï
ï
ï
í
ï
ï
ï
ï
ï
î
0,           0 £ x £ xi-1
 x - xi-1 hi-1 ,     xi-1 < x £ xi
 xi+1- x hi ,     xi < x £ xi+1
0,           xi+1£ x £ 1
Notice that fi(x)  has the following properties:
1) fi(xi)  =  1
2) fi(x) >  0  for  x in  xi-1  < x < xi+1
3) fi(x)  =  0  for  x out side  xi-1  < x < xi+1
4) The graph of fi(x) is an upside down V.
The derivative of fi(xi)  is
fi¢(x) =  ì
ï
ï
ï
ï
ï
í
ï
ï
ï
ï
ï
î
0,           0 £ x £ xi-1
 1 hi-1 ,     xi-1 < x £ xi
 - 1 hi ,     xi < x £ xi+1
0,           xi+1 £ x £ 1
Because fi(x)  and fi'(x)  are not nonzero only on (xi -1xi+1) ,  so fi (x) fj(x) =   0     and fi'(x) fj'(x)   =   0 for  0< x £ 1 except when j is  i - 1, i, or i + 1.  As a consequence, the linear system Ac = b reduces to an n x  n tridiagonal linear system. The nonzero entries in A are
1) For i = 1, 2, . . . , n
 aii = ó õ 1 0 { p(x)[fi¢(x)]2 + q(x)[fi(x)]2 } dx
 = ( 1 hi-1 )2 ó õ xi xi-1 p(x) dx + ( 1 hi )2 ó õ xi+1 xi p(x) dx
 + ( 1 hi-1 )2 ó õ xi xi-1 (x - xi-1)2 q(x)dx + ( 1 hi )2 ó õ xi+1 xi (xi+1 - x)2 q(x) dx.
2) For  i = 1, 2, . . . , n-1
 ai,i+1 = ó õ 1 0 {p(x)f¢i(x)f¢i+1(x) + q(x)fi(x)fi+1(x) } dx
 = -( 1 hi )2 ó õ xi+1 xi p(x) dx + ( 1 hi )2 ó õ xi+1 xi (xi+1 - x)(x - xi) q(x) dx
3) For i = 2, 3, . . . , n
 ai,i-1 = ó õ 1 0 {p(x)f¢i(x)f¢i-1(x) + q(x)fi(x)fi-1(x) } dx
 = -( 1 hi-1 )2 ó õ xi xi-1 p(x) dx + ( 1 hi )2 ó õ xi xi-1 (xi - x)(x - xi-1) q(x) dx

The entries in b are:

 bi = ó õ 1 0 f(x)fi(x) dx
 = 1 hi-1 ó õ xi xi-1 (x - xi-1)f(x) dx + 1 hi ó õ xi+1 xi (xi+1 - x)f(x) dx