Two-Point Boundary Value Problems
Introduction
We consider boundary-value problems in which the conditions are specified at more than one point.
The crucial distinction between initial values problems and boundary value problems is that in the former case we are able to start
an acceptable solution at its beginning or initial values and just march it along by numerical integration to its end or final values.
A simple example of a second-order boundary-value problem is:
In the context of beam bending, we can have to solve a fourth-order system which has the form:
Here

Finite Difference Method
In order to solve the previous two-point differential problems, we will use the finite difference method.
For this, we firstly divide the range of integration

The values of the numerical
solution at the mesh points
We now have to make two approximations:
- The derivatives of
in the differential equations have to be replaced by their finite difference expressions (see below). - The differential equations have to be enforced only at the mesh points.
The boundary conditions of the problem are fixed. Consequently,
As a result, the differential equations are replaced by
Since the truncation error in a first central difference approximation is
Numerical Differentiation
In order to solve differential equations with boundaries conditions, we need to approximate the derivative terms. For this
we use finite differences. Numerical differentiation deals with the following problem: we are given the function
First Central Difference Approximations
The solutions of
First Noncentral Finite Difference Approximations
Central finite difference approximations are not always usable. For example, consider
the situation where the function is given at the
Errors in Finite Difference Approximations
Observe that in all finite difference expressions the sum of the coefficients is zero.
The effect on the roundoff error can be profound. If his very small, the values of
- Use double-precision arithmetic.
- Employ finite difference formulas that are accurate to at least
To illustrate the errors, let us compute the second derivative of
|
approximation value | error |
0.64 | 0.380 609 096 726 167 | 1.272965e-02 |
0.08 | 0.368 075 685 401 340 | 1.962442e-04 |
0.01 | 0.367 882 506 843 719 | 3.065672e-06 |
0.00125 | 0.367 879 489 040 490 | 4.786904e-08 |
0.000 156 25 | 0.367 879 438 272 211 | 2.899230e-09 |
1.953125e-05 | 0.367 879 401 892 423 | 3.927901e-08 |
2.44140625e-06 | 0.367 872 416 973 114 | 7.024198e-06 |
3.0517578125e-07 | 0.367 164 611 816 406 | 7.148293e-04 |
As we can see, the error is non linear with
The Shooting Method
An another methodoly to solve the two-point boundary problems is to used a shooting methodology. The basic idea of the shooting method is this: Instead of tying a general solution to a boundary value problem down at both points, one only ties it down at one end. In the case of a second order problem, this leaves a free parameter. For a given value of this free parameter, one then integrates out a solution to the differential equation. Specifically, you start at the tied-down boundary point and integrate out just like an initial value problem. When you get to the other boundary point, the error between your solution and the true boundary condition tells you how to adjust the free parameter. Repeat this process until a solution matching the second boundary condition is obtained. The shooting method tend to converge very quickly and it also works for non-linear differential equations. The disadvantage is that convergence is not guaranteed. To begin, given a boundary value problem:
The idea is to find the absent initial value
Exercice 1.
We want to solve this problem with the finite difference method for a given value
- By using the second order central finite difference approximation show that this problem yields the following algebraic equations:
- By taking the boundary conditions, show that we have to solve a
linear system.
where the for all are the unknows of the problem. - Solve this linear system with Python and compare the so obtained solution with the exact solution (see Introduction )
-
Calculate the maximum error according to the value of
.
import numpy as np
from numpy import linalg as LA
def FiniteDifference(m)
A = np.zeros((m-1,m-1),dtype = np.float64)
b = np.zeros((m-1), dtype = np.float64)
h=1/m
a=(1+2/(h*h))
c=-1/(h*h)
""" Definition of the matrix """
for i in range(m-1):
for j in range(m-1):
if i==j:
A[i,j]=a
if i==j+1 or i==j+1:
A[i,j]=c
b[m-2]=c
X = LA.solve(A,b)
X = np.append(X,1)
X = np.insert(X,0,0)
return X
def f(x)
# To do
return
m = 10
y = FiniteDifference(m)
x = np.linspace(0,1,m+1)
Y = f(x)
err = np.abs(Y-y)
err = np.delete(err,0)
err = np.delete(err,m-1)
print("min error= ",np.min(err)," max error= ",np.max(err))
|
|
|
0.0 | 0.0 | 0.0 |
0.1 | 0.085 244 69 | 0.085 233 70 |
0.2 | 0.171 341 82 | 0.171 320 45 |
0.3 | 0.259 152 38 | 0.259 121 84 |
0.4 | 0.349 554 46 | 0.349 516 60 |
0.5 | 0.443 452 08 | 0.443 409 44 |
0.6 | 0.541 784 22 | 0.541 740 07 |
0.7 | 0.645 534 21 | 0.645 492 62 |
0.8 | 0.755 739 53 | 0.755 705 48 |
0.9 | 0.873 502 26 | 0.873 481 69 |
1.0 | 1.0 | 1.0 |
As we can see in this Table, for
Exercice 2.
Let us given the following linear boundary value problem defined on
Write the linear system that we have to solve knowing the value of
. For this, you have to use the first backward difference approximation to deal with the second boundary condition. You have to use the central difference approximation in the interior mesh points.- Solve numerically this problem with different values of
. -
According to given values of
, calculate the maximum error between the approximated solution and the exact solution of this problem .
Exercice 3. "Beam deflection"
We consider in this exercice the following problem:
This beam carries a uniform load of intensity
We want to solve this problem with the finite difference method.
-
Define the central finite difference scheme for the fourth order derivative. Use the forward and backward difference approximations at the boundaries. You have to use the central difference approximation in the interior mesh points.
- Calculate the linear system obtained for a given
. - Determine the maximum displacement for
. Plot the solution. - Determine the maximum displacement for
. This case means that is compressive.
Exercice 4. "Heat equation"
Casting is a process in which a liquid metal is somehow delivered into a mold. The heat equation is a partial differential equation
that describes how the distribution of heat evolves over time in a solid medium,
as it spontaneously flows from places where it is higher towards places where it is lower.
This equation was first developed and solved by Joseph Fourier in 1822 to describe heat flow.
In this Figure, we assume that the temperature of the air or in the sand part is
For this, we need to solve the following heat equation with boundary conditions:
-
By denoting
the approximation of the temperature in the liquid metal at for time , write the finite difference scheme of the heat equation. For this, you have to use the central finite difference for the space variable and the forward finite difference for time variable. We assume that for with and .
As for any , we then have for any : It yields: where . -
Write this scheme in the follwoing form:
where matrix has to be defined and the vectors denote the temperature at each step time in the medium. Solve this linear system at each step time and draw all this temperature profiles. -
According to the values of
and the solution may diverge. For example, with , and the solution is unstable as we can see in the following Figure:Loosely speaking, a method of numerical integration is said to be stable if the effects of local errors do not accumulate catastrophically; that is, if the global error remains bounded. If the method is unstable, the global error will increase exponentially, eventually causing numerical overflow. Stability has nothing to do with accuracy; in fact, an inaccurate method can be very stable. To avoid this problem we want to solve the system by using the Crank-Nicolson's scheme where we substitute the second partial derivative in
by:Apply this scheme and draw the temperature evolution in the medium at each time step. With the same values:
, and we obtain the stable solution where each curve represents the temperature in the mold at each step time :
We have to solve at each time step the following linear system:
-
We want to see if this scheme is stable whatever the choice of
and . For this, show that: where is a symmetric matrix. Then, calculate the eigenvalues of by using the python numpy.linalg.eig function and conclude. -
The approximate solutions can still contain (decaying) spurious oscillations if the ratio of time step
times the thermal diffusivity to the square of space step, , is large. For this reason, whenever large time steps or high spatial resolution is necessary, the less accurate backward Euler method is often used, which is both stable and immune to oscillations. Try to see, if you have such spurious oscillations. In the following example, the method converges but the temperature becomes negative in some points which is not physically possible:
Exercice 5. "String Vibration"
We wish to solve the differential equation of a vibrating string
of constant linear mass
-
Discretized this equation at each
for all . We assume that and . Write the linear system obtained by using a central point finite difference method for the space variable and a forward finite difference method for the time variable. Write this system on the following form: where vector is the vibration amplitude of the string at each time step . We use a forward finite difference method to deal with the initial derivative condition.
As for any , we then have for any : It yields: where . To start the iterations, we then need to know the two vectors and . For this, we use the following condition: . It yields the following approximation: Hence, , which allows us to initialize the vector. The vector is initialized with . Consequently, , and is a tridiagonal matrix. -
We set
and . Solve each linear systems at each step time. We assume that and . - Draw the string evolution at each time step.
- Apply a Crank-Nicholson scheme type to this system. Conclude.
References
- J. Stoer and R. Bulirsch (1993), Introduction to Numerical Analysis. Springer-Verlag New York, Inc., 2nd edition
- S. D. Conte and Carl de Boor (1972), Elementary Numerical Analysis. McGraw-Hill, Inc., 2nd edition.
- F. B. Hildebrand (1968), Finite-difference Equations and Simulations. Prentice-Hall.