Example 3.  Solve   [Graphics:Images/GalerkinMod_gr_156.gif].  
3 (a).   Use the boundary values  [Graphics:Images/GalerkinMod_gr_157.gif]  and  [Graphics:Images/GalerkinMod_gr_158.gif].   

Solution 3 (a).

Form the linear operator, the differential equation and the boundary values.

[Graphics:../Images/GalerkinMod_gr_161.gif]


[Graphics:../Images/GalerkinMod_gr_162.gif]

 

 

The first function [Graphics:../Images/GalerkinMod_gr_163.gif] will be chosen to be the straight line between the boundary points.

[Graphics:../Images/GalerkinMod_gr_164.gif]


[Graphics:../Images/GalerkinMod_gr_165.gif]

 

 

The other n function [Graphics:../Images/GalerkinMod_gr_166.gif] will be chosen to be zero at the endpoints.

[Graphics:../Images/GalerkinMod_gr_167.gif]


[Graphics:../Images/GalerkinMod_gr_168.gif]

 

 

The residual is formed by substituting  [Graphics:../Images/GalerkinMod_gr_169.gif]  into  [Graphics:../Images/GalerkinMod_gr_170.gif].

[Graphics:../Images/GalerkinMod_gr_171.gif]


[Graphics:../Images/GalerkinMod_gr_172.gif]

 

 

Galerkin's requirement is that the inner product of the residual with [Graphics:../Images/GalerkinMod_gr_173.gif] is zero.

Form the equations  [Graphics:../Images/GalerkinMod_gr_174.gif]    for  [Graphics:../Images/GalerkinMod_gr_175.gif].  

[Graphics:../Images/GalerkinMod_gr_176.gif]


[Graphics:../Images/GalerkinMod_gr_177.gif]

 

 

We must solve for the coefficients   [Graphics:../Images/GalerkinMod_gr_178.gif].

[Graphics:../Images/GalerkinMod_gr_179.gif]


[Graphics:../Images/GalerkinMod_gr_180.gif]

 

 

Use  [Graphics:../Images/GalerkinMod_gr_181.gif]  to form the Galerkin solution.

[Graphics:../Images/GalerkinMod_gr_182.gif]


[Graphics:../Images/GalerkinMod_gr_183.gif]

[Graphics:../Images/GalerkinMod_gr_184.gif]

 

We are done.  

Aside.  We can use Mathematica to find the analytic solution.  This is just for fun !

[Graphics:../Images/GalerkinMod_gr_185.gif]


[Graphics:../Images/GalerkinMod_gr_186.gif]

 

 

Plot the analytic solution.

[Graphics:../Images/GalerkinMod_gr_187.gif]


[Graphics:../Images/GalerkinMod_gr_188.gif]

[Graphics:../Images/GalerkinMod_gr_189.gif]

 

 

Plot both the analytic and Galerkin solution.

[Graphics:../Images/GalerkinMod_gr_190.gif]


[Graphics:../Images/GalerkinMod_gr_191.gif]

[Graphics:../Images/GalerkinMod_gr_192.gif]

 

 

Check out the difference between the analytic solution and the Galerkin solution.

[Graphics:../Images/GalerkinMod_gr_193.gif]

[Graphics:../Images/GalerkinMod_gr_194.gif]

[Graphics:../Images/GalerkinMod_gr_195.gif]

 

So the Galerkin solution is very accurate.

Warning.  We must proceed with caution when using Galerkin's method because the linear system might be ill conditioned.  

[Graphics:../Images/GalerkinMod_gr_196.gif]


[Graphics:../Images/GalerkinMod_gr_197.gif]

 

 

    The condition number of the above system can be determined by Mathematica.

[Graphics:../Images/GalerkinMod_gr_198.gif]

[Graphics:../Images/GalerkinMod_gr_199.gif]

 

Fact.  Given the linear system  [Graphics:../Images/GalerkinMod_gr_200.gif].  If   [Graphics:../Images/GalerkinMod_gr_201.gif]  are input with machine precision then a bound for the error in the computed solution  [Graphics:../Images/GalerkinMod_gr_202.gif]  is given by

        
[Graphics:../Images/GalerkinMod_gr_203.gif]

where
[Graphics:../Images/GalerkinMod_gr_204.gif] is machine epsilon for the computer.  The computed solution  [Graphics:../Images/GalerkinMod_gr_205.gif]  loses about  [Graphics:../Images/GalerkinMod_gr_206.gif]  decimal digits of accuracy relative to precision of input.

[Graphics:../Images/GalerkinMod_gr_207.gif]


[Graphics:../Images/GalerkinMod_gr_208.gif]

 

 

Caveat.  Mathematica uses extended precision sixteen digit numbers, the solution  [Graphics:../Images/GalerkinMod_gr_209.gif]  retains most of this accuracy.  

We are really done.  

Aside.  We can calculate the coefficients  [Graphics:../Images/GalerkinMod_gr_210.gif]  by directly setting up the matrix  [Graphics:../Images/GalerkinMod_gr_211.gif] vector [Graphics:../Images/GalerkinMod_gr_212.gif].  This is just for fun !  

The boundary values  [Graphics:../Images/GalerkinMod_gr_213.gif]  are used to form  [Graphics:../Images/GalerkinMod_gr_214.gif]  and there are [Graphics:../Images/GalerkinMod_gr_215.gif] equations to solve  

    [Graphics:../Images/GalerkinMod_gr_216.gif]    for  [Graphics:../Images/GalerkinMod_gr_217.gif].  

[Graphics:../Images/GalerkinMod_gr_218.gif]

[Graphics:../Images/GalerkinMod_gr_219.gif]

 

Since the linear operator is  [Graphics:../Images/GalerkinMod_gr_220.gif]  we have  [Graphics:../Images/GalerkinMod_gr_221.gif]  which must be entered into the integrals on the right hand side.

    [Graphics:../Images/GalerkinMod_gr_222.gif]    for  [Graphics:../Images/GalerkinMod_gr_223.gif].  

The matrix form of the solution is  

[Graphics:../Images/GalerkinMod_gr_224.gif]


[Graphics:../Images/GalerkinMod_gr_225.gif]

This is the same as we obtained above.  

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(c) John H. Mathews 2005