Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Boundary-Value Problems: Example 6.1-1

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 4

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 x =
0.5

d2y x
(1 ) y = x ; y(1) = 2,
dx 2
5
y(3) = 1

Solution

y0 y1 y2 y3 y4

x 1 1 .5 2 2 .5 3

There are five nodes with x = 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

yi 1 2 yi yi 1 x
(1 i ) yi = xi i = 1, 2, 3
x 2
5

The above equation can be rearranged to

xi
yi-1 [2 + x2(1 ) ]yi + yi+1 = x2xi
5

1.5
i = 1, xi = 1.5 y0 [2 + .52(1 ) ]y1 + y2 = .521.5
5

2
i = 2, xi = 2.0 y1 [2 + .52(1 ) ]y2 + y3 = .522
5

1
2 .5
i = 3, xi = 2.5 y2 [2 + .52(1 ) ]y3 + y4 = .522.5
5
In matrix notation

2.175 1 0 y1 1.625
1 2.150 1 y
2 = 0.5
0 1 2.125 y 1.625
3

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 = x = 0.2. We now have 9 unknowns that can be solved
from the following system

Ay = r

where

A =
2.0304 1 0 0 0 0 0 0 0
1 2.0288 1 0 0 0 0 0 0

0 1 2.0272 1 0 0 0 0 0

0 0 1 2.0256 1 0 0 0 0
0 0 0 1 2.0240 1 0 0 0

0 0 0 0 1 2.0224 1 0 0
0 0 0 0 0 1 2.0208 1 0

0 0 0 0 0 0 1 2.0192 1
0 0 0 0 0 0 0 1 2.0176

y = y1 y 2 y 3 y 4 y5 y 6 y 7 y8 y 9 T
r = 1.952 0.056 0.064 0.072 0.080 0.088 0.096 0.104 1.112 T

Applying finite difference method to an ordinary differential equation, we obtain tridiagonal


matrix equations of the form

b1 c1 0 0 y1 r1
a b2 c2 0 0 y r
2 2 2
0 a3 b3 c3 0 y3 r3
=

0 0 a n 1 bn 1 cn 1 y n 1 rn 1

0 0 an bn y n rn

For example 6.1-1, we have


2
ai = 1, i = 1, , 9

xi
bi = [2 + x2(1 ) ], i = 1, , 9
5

ci = 1, i = 1, , 9

r1 = x2x1 y0; ri = x2xi, i = 2, , 8; r9 = x2x9 y10

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

1 = b1

1 = r1/1

For i = 2, , n

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

i = (ri ai i-1)/i

yn = n

For j = 1, , n1

yn-j = n-j cn-j yn-j+1/n-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);

3
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

You might also like