Chapter 6
Boundary-Value Problems 6.1 Introduction
The solution of an ordinary differential equation requires auxiliary conditions. For an nthorder 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 (1 Solution y = x ; y(1) = 2, y(3) = 1
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 (1 The above equation can be rearranged to yi-1 [2 + x2(1 ]yi + yi+1 = x2xi ]y1 + y2 = .521.5 ]y2 + y3 = .522 ]y3 + y4 = .522.5 6-1 yi = xi i = 1, 2, 3
i = 1, xi = 1.5 y0 [2 + .52(1 i = 2, xi = 2.0 y1 [2 + .52(1 i = 3, xi = 2.5 y2 [2 + .52(1
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 = x = 0.2. We now have 9 unknowns that can be solved from the following system Ay = r where
A=
y= r=
T 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 6-2
ai = 1, i = 1, , 9 bi = [2 + x2(1 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: ], i = 1, , 9
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); end 6-3
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