Example 3.  Solve   [Graphics:Images/GalerkinMod_gr_156.gif].  
3 (b).   Use the boundary values  [Graphics:Images/GalerkinMod_gr_159.gif]  and  [Graphics:Images/GalerkinMod_gr_160.gif].   

Solution 3 (b).

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

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


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

 

 

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

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


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

 

 

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

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


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

 

 

The residual is formed by substituting  [Graphics:../Images/GalerkinMod_gr_234.gif]  into  [Graphics:../Images/GalerkinMod_gr_235.gif].

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


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

 

 

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

Form the equations  [Graphics:../Images/GalerkinMod_gr_239.gif]    for  [Graphics:../Images/GalerkinMod_gr_240.gif].  

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


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

 

 

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

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


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

 

 

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

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


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

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

 

We are done.  

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

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


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

 

 

Plot the analytic solution.

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


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

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

 

 

Plot both the analytic and Galerkin solution.

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


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

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

 

 

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

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


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

 

[Graphics:../Images/GalerkinMod_gr_260.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.  

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


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

 

 

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

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

[Graphics:../Images/GalerkinMod_gr_264.gif]
[Graphics:../Images/GalerkinMod_gr_265.gif]

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

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

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

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


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

 

 

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

Aside.  We can check out the matrix form for setting up the Galerkin equations.  This is just for fun

The boundary values  [Graphics:../Images/GalerkinMod_gr_276.gif]  are used to form  [Graphics:../Images/GalerkinMod_gr_277.gif]  and there are [Graphics:../Images/GalerkinMod_gr_278.gif] equations to solve  

    [Graphics:../Images/GalerkinMod_gr_279.gif]    for  [Graphics:../Images/GalerkinMod_gr_280.gif].  

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

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

 

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

    [Graphics:../Images/GalerkinMod_gr_285.gif]    for  [Graphics:../Images/GalerkinMod_gr_286.gif].  

The matrix form of the solution is  

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


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

This is the same as we obtained above.  

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(c) John H. Mathews 2005