Example
2. Solve
, with
the initial condition
.
Solution 2.
Form the linear operator, the differential equation and the initial condition.
![[Graphics:../Images/GalerkinMod_gr_78.gif]](../Images/GalerkinMod_gr_78.gif)
We will solve the I. V. P. by choosing n
functions
. The
trial solution is a linear combination of the basis functions.
![[Graphics:../Images/GalerkinMod_gr_81.gif]](../Images/GalerkinMod_gr_81.gif)
The residual is formed by substituting
into
.
![[Graphics:../Images/GalerkinMod_gr_85.gif]](../Images/GalerkinMod_gr_85.gif)
Galerkin's requirement is that the inner product of the residual
with
is
zero.
This leads to a linear system in the
coefficients
of
the trial function.
![[Graphics:../Images/GalerkinMod_gr_89.gif]](../Images/GalerkinMod_gr_89.gif)
We must solve for the coefficients
.
![]()
![[Graphics:../Images/GalerkinMod_gr_93.gif]](../Images/GalerkinMod_gr_93.gif)
![]()
![]()
![[Graphics:../Images/GalerkinMod_gr_96.gif]](../Images/GalerkinMod_gr_96.gif)
Use
to
form the Galerkin solution.
![[Graphics:../Images/GalerkinMod_gr_99.gif]](../Images/GalerkinMod_gr_99.gif)
![[Graphics:../Images/GalerkinMod_gr_100.gif]](../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_102.gif]](../Images/GalerkinMod_gr_102.gif)
Plot the analytic solution.
![[Graphics:../Images/GalerkinMod_gr_104.gif]](../Images/GalerkinMod_gr_104.gif)
![[Graphics:../Images/GalerkinMod_gr_105.gif]](../Images/GalerkinMod_gr_105.gif)
Plot both the analytic and Galerkin solution.
![[Graphics:../Images/GalerkinMod_gr_107.gif]](../Images/GalerkinMod_gr_107.gif)
![[Graphics:../Images/GalerkinMod_gr_108.gif]](../Images/GalerkinMod_gr_108.gif)
Check out the difference between the analytic solution and the Galerkin solution.
![[Graphics:../Images/GalerkinMod_gr_109.gif]](../Images/GalerkinMod_gr_109.gif)
![[Graphics:../Images/GalerkinMod_gr_110.gif]](../Images/GalerkinMod_gr_110.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_113.gif]](../Images/GalerkinMod_gr_113.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_124.gif]](../Images/GalerkinMod_gr_124.gif)
Caveat. Although
Mathematica uses extended precision sixteen digit numbers,
there is a possibility that the solution
might
not have this much accuracy.
We are really done.
Aside. We can
calculate the coefficients
by
directly setting up the matrix
vector
. This
is just for fun !
If we are solving an initial value problem with
we
have
and
there are
equations to solve
for
.
![]()
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 now
given.
![[Graphics:../Images/GalerkinMod_gr_141.gif]](../Images/GalerkinMod_gr_141.gif)
This is the same as we obtained previously.
(c) John H. Mathews 2005