Example 2.  Solve   [Graphics:Images/GalerkinMod_gr_75.gif],   with the initial condition   [Graphics:Images/GalerkinMod_gr_76.gif].  

Solution 2.

Form the linear operator, the differential equation and the initial condition.

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


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

 

 

We will solve the I. V. P. by choosing n functions [Graphics:../Images/GalerkinMod_gr_79.gif].   The trial solution is a linear combination of the basis functions.

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


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

 

 

The residual is formed by substituting  [Graphics:../Images/GalerkinMod_gr_82.gif]  into  [Graphics:../Images/GalerkinMod_gr_83.gif].

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


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

 

 

Galerkin's requirement is that the inner product of the residual with  [Graphics:../Images/GalerkinMod_gr_86.gif]  is zero.
This leads to a linear system in the coefficients  [Graphics:../Images/GalerkinMod_gr_87.gif]  of the trial function.

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


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

 

 

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

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


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

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

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

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

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

 

 

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

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


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

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

 

We are done.  

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

Use Mathematica to solve the initial value problem.

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


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

 

 

Plot the analytic solution.

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


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

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

 

 

Plot both the analytic and Galerkin solution.

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


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

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

 

 

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

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

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

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

 

So the Galerkin solution appears to be good.

Warning.  We must proceed with caution when using Galerkin's method because the linear system might be ill conditioned, i.e. the solution is highly sensitive to round off errors in the matrix and vector.  Let us investigate the situation for this example.

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


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

 

 

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

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

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

 

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

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

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

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


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

 

 

Caveat.  Although Mathematica uses extended precision sixteen digit numbers, there is a possibility that the solution  [Graphics:../Images/GalerkinMod_gr_125.gif]  might not have this much accuracy.  

We are really done.  

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

If we are solving an initial value problem with [Graphics:../Images/GalerkinMod_gr_129.gif]  we have  [Graphics:../Images/GalerkinMod_gr_130.gif]  and there are [Graphics:../Images/GalerkinMod_gr_131.gif] equations to solve

    [Graphics:../Images/GalerkinMod_gr_132.gif]    for  [Graphics:../Images/GalerkinMod_gr_133.gif].  

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

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

 

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

    [Graphics:../Images/GalerkinMod_gr_138.gif]    for  [Graphics:../Images/GalerkinMod_gr_139.gif].  

The matrix form of the solution is now given.    

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


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

This is the same as we obtained previously.  

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(c) John H. Mathews 2005