Example
3. Solve
.
3 (a). Use the
boundary values
and
.
Solution 3 (a).
Form the linear operator, the differential equation and the boundary values.
![[Graphics:../Images/GalerkinMod_gr_162.gif]](../Images/GalerkinMod_gr_162.gif)
The first function
will be chosen to be the straight line between the boundary
points.
![[Graphics:../Images/GalerkinMod_gr_165.gif]](../Images/GalerkinMod_gr_165.gif)
The other n function
will be chosen to be zero at the endpoints.
![[Graphics:../Images/GalerkinMod_gr_168.gif]](../Images/GalerkinMod_gr_168.gif)
The residual is formed by substituting
into
.
![[Graphics:../Images/GalerkinMod_gr_172.gif]](../Images/GalerkinMod_gr_172.gif)
Galerkin's requirement is that the inner product of the residual
with
is zero.
Form the equations
for
.
![[Graphics:../Images/GalerkinMod_gr_177.gif]](../Images/GalerkinMod_gr_177.gif)
We must solve for the coefficients
.
![[Graphics:../Images/GalerkinMod_gr_180.gif]](../Images/GalerkinMod_gr_180.gif)
Use
to
form the Galerkin solution.
![[Graphics:../Images/GalerkinMod_gr_183.gif]](../Images/GalerkinMod_gr_183.gif)
![[Graphics:../Images/GalerkinMod_gr_184.gif]](../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_186.gif]](../Images/GalerkinMod_gr_186.gif)
Plot the analytic solution.
![[Graphics:../Images/GalerkinMod_gr_188.gif]](../Images/GalerkinMod_gr_188.gif)
![[Graphics:../Images/GalerkinMod_gr_189.gif]](../Images/GalerkinMod_gr_189.gif)
Plot both the analytic and Galerkin solution.
![[Graphics:../Images/GalerkinMod_gr_191.gif]](../Images/GalerkinMod_gr_191.gif)
![[Graphics:../Images/GalerkinMod_gr_192.gif]](../Images/GalerkinMod_gr_192.gif)
Check out the difference between the analytic solution and the Galerkin solution.
![[Graphics:../Images/GalerkinMod_gr_193.gif]](../Images/GalerkinMod_gr_193.gif)
![[Graphics:../Images/GalerkinMod_gr_194.gif]](../Images/GalerkinMod_gr_194.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_197.gif]](../Images/GalerkinMod_gr_197.gif)
The condition number of the above system can be determined by Mathematica.
![]()
Fact. Given
the linear system
. If
are
input with machine precision then a bound for the error in the
computed solution
is
given by
where
is machine epsilon for the
computer. The computed
solution
loses
about
decimal
digits of accuracy relative to precision of input.
![[Graphics:../Images/GalerkinMod_gr_208.gif]](../Images/GalerkinMod_gr_208.gif)
Caveat. Mathematica
uses extended precision sixteen digit numbers, the
solution
retains
most of this accuracy.
We are really done.
Aside. We can
calculate the coefficients
by
directly setting up the matrix
vector
. This
is just for fun !
The boundary values
are
used to form
and
there are
equations to solve
for
.
![[Graphics:../Images/GalerkinMod_gr_219.gif]](../Images/GalerkinMod_gr_219.gif)
Since the linear operator is
we
have
which
must be entered into the integrals on the right hand side.
for
.
The matrix form of the solution is
![[Graphics:../Images/GalerkinMod_gr_225.gif]](../Images/GalerkinMod_gr_225.gif)
This is the same as we obtained above.
(c) John H. Mathews 2005