Chapter 6

Boundary-Value Problems

6.1 Introduction

The solution of an ordinary differential equation requires auxiliary conditions. For an nth-order equation, n conditions are required. If all the conditions are specified at the same value of the independent variable, we have an initial-value problem. If the conditions are known at different values of the independent variable, usually at the extreme points or boundaries of a system, we have a boundary-value problem.

Example 6.1-1 ______

Solve the following ordinary differential equation (ODE) using finite difference with Dx = 0.5

- (1 - y = x ; y(1) = 2, y(3) = - 1

Solution

There are five nodes with Dx = 0.5: y0, y1, y2, y3, and y4. However there are only three unknowns since y0 = y(1) = 2 and y4 = y(3) = - 1. In finite difference form, the ODE becomes

- (1 - yi = xi i = 1, 2, 3

The above equation can be rearranged to

yi-1 - [2 + Dx2(1 - ]yi + yi+1 = Dx2xi

i = 1, xi = 1.5 Þ y0 - [2 + .52(1 - ]y1 + y2 = .52´1.5

i = 2, xi = 2.0 Þ y1 - [2 + .52(1 - ]y2 + y3 = .52´2

i = 3, xi = 2.5 Þ y2 - [2 + .52(1 - ]y3 + y4 = .52´2.5

In matrix notation

=

The three linear equations can be solved for the three unknowns to obtain

y1 = 0.5520, y2 = - 0.4244, and y3 = - 0.9644

Let solve the problem again with h = Dx = 0.2. We now have 9 unknowns that can be solved from the following system

Ay = r

where

A =

y = T

r = T

Applying finite difference method to an ordinary differential equation, we obtain tridiagonal matrix equations of the form

=

For example 6.1-1, we have

ai = 1, i = 1, ¼, 9

bi = - [2 + Dx2(1 - ], i = 1, ¼, 9

ci = 1, i = 1, ¼, 9

r1 = Dx2x1 - y0; ri = Dx2xi, i = 2, ¼, 8; r9 = Dx2x9 - y10

The Thomas algorithm can be used to obtain the solutions for tridiagonal matrix system as follows:

b1 = b1

g1 = r1/b1

For i = 2, ¼, n

bi = bi - (ai ci-1/bi-1)

gi = (ri - ai gi-1)/bi

yn = gn

For j = 1, ¼, n-1

yn-j = gn-j - cn-j yn-j+1/bn-j

End

Table 6.1-1 lists the MATLAB program using the Thomas algorithm to solve example 6.1-1.

Table 6.1-1 Matlab program using the Thomas algorithm ------

%

% Example 6.1-1

x=1.2:.2:2.8;

h=.2;n=length(x);

b=-(2+h*h*(1-x/5));

c=ones(1,n);a=c;

r=h*h*x;

r(1)=r(1)-2;r(n)=r(n)+1;

beta=c;gam=c;y=c;

beta(1)=b(1);gam(1)=r(1)/beta(1);

for i=2:n

beta(i)=b(i)-a(i)*c(i-1)/beta(i-1);

gam(i)=(r(i)-a(i)*gam(i-1))/beta(i);

end

y(n)=gam(n);

for j=1:n-1

y(n-j)=gam(n-j)-c(n-j)*y(n-j+1)/beta(n-j);

end

disp('y =');disp(y')

y =

1.3513

0.7918

0.3110

-0.0974

-0.4362

-0.7055

-0.9025

-1.0224

-1.0579

6-4