Solution of the Linear Boundary Value Problem
In this article, one of two approaches to solving second order boundary value problems is discussed. The method presented here utilizes a very simple matrix formulation, but this simplicity is largely lost if nonlinear problems are treated with it. Thus this program should be used only with linear problems of the form

The region a≤t≤b is first divided into n+1 equally spaced intervals of length Δt. The differential equation is then represented as a (central) difference equation, e.g. the jth point along the region is represented as

There are n equations of the form (2), one for each interior point of the region a≤t≤b; there is also one unknown value of X for each interior point. This means that there are n simultaneous linear equations in n unknowns X1,X2, . . . Xn. This set can be written as

Defining di = -2 f(ti) (Δt)² and bi = g(ti) (Δt)², the set can be written thus:

The coefficient matrix is tridiagonal, and can be solved with the method for such systems outlined in a previous section. The matrix method has an accuracy on the order of (Δt)², hence the easiest way for ensuring reasonable answers is simply to obtain solutions for progressively smaller values of Δt, until the results indicate adequate convergence.
THE PROGRAM
Program BVP directly utilizes the ideas discussed above. Before di and bi can be computed, the (problem specific) functions f(t) and g(t) of equation (1) must be input into the program, within the quotation marks of statements 25 and 26, respectively. These functions will of course change from one problem to another. Once these changes to the program are made, the “RUN” mode can be entered. At this point, five pieces of data are prompted by the program: (1) the number of segments which the region a≤t≤b will be divided into, i.e. the number n-1 of points at which calculations will be made; the value of t at the left end of the region (a); the value of t at the right end of the region (b); the value of X at the right end of the region (X(a)); and the value of X at the left end of the region (X(b)). After this data is entered, execution will proceed, and the results are printed out in a table of t and X values.
EXAMPLE
Consider the boundary value problem

First, the program is altered at lines 25 and 26. The right hand side of line 25 will read “-(1-T/5)” and the right hand side of line 26 will read “T”. The “RUN” mode is entered. Five prompts, which require five responses, begin to appear. The first of these is: “INPUT N-NO. SEGMENTS”. The value 10 is entered. The second prompt is “INPUT TEND1”. The value 0 is entered here. The third prompt is “INPUT TEND2”. The response is 1. The fourth prompt is “INPUT X(TEND1)”. Here, 0 is entered. Finally, the last “INPUT X(TEND2)”. The value 2 is entered. The solution is printed out as:
T X 0 0 0.1 0.15826359 0.2 0.31907816 0.3 0.48495588 0.4 0.65839218 0.5 0.8418857 0.6 1.0379562 0.7 1.2491507 0.8 1.478108 0.9 1.7274714 1 2
1 REM BVP
2 DIM A(100,4)
3 PRINT "INPUT N-NO. SEGMENTS"
4 INPUT N
5 PRINT "INPUT TEND1"
6 INPUT TEND1
7 PRINT "INPUT TEND2"
8 INPUT TEND2
9 PRINT "INPUT X(TEND1)"
10 INPUT X0
11 PRINT "INPUT X(TEND2)"
12 INPUT X1
13 FAST
14 LET DH=(TEND2-TEND1)/(N)
15 LET DH2=DH*DH
16 LET NM2=N-2
17 LET NM1=N-1
18 REM **********************
19 REM **********************
20 REM CHANGE THE ARGUMENTS OF
21 REM THE FUNCTIONS F$ AND G$
22 REM WITH EACH NEW PROBLEM
23 REM **********************
24 REM **********************
25 LET F$="-(1-T/5)"
26 LET G$="T"
27 REM **********************
28 REM **********************
29 REM ********************
30 LET T=TEND1
31 FOR K=1 TO NM1
32 LET A(K,1)=1
33 LET A(K,3)=1
34 LET T=T+DH
35 LET A(K,2)=-(2-DH2*VAL F$)
36 LET A(K,4)=DH2*VAL G$
37 NEXT K
38 LET A(1,4)=A(1,4)-X0
39 LET A(NM1,4)=A(NM1,4)-X1
40 GOSUB 50
41 PRINT "T X"
42 PRINT TEND1;" ";X0
43 LET P=TEND1
44 FOR J=1 TO NM1
45 LET P=P+DH
46 PRINT P;" ";A(J,4)
47 NEXT J
48 PRINT TEND2;" ";X1
49 STOP
50 REM SUBROUTINE
51 FOR I=2 TO NM1
52 LET A(I,1)=A(I,1)/A(I-1,2)
53 LET A(I,2)=A(I,2)-A(I,1)*A(I-1,3)
54 LET A(I,4)=A(I,4)-A(I,1)*A(I-1,4)
55 NEXT I
56 REM BEGIN BACK SUBSTITUTION
57 LET A(NM1,4)=A(NM1,4)/A(NM1,2)
58 FOR J=NM2 TO 1 STEP -1
59 LET A(J,4)=(A(J,4)-A(J,3)*A(J+1,4))/A(J,2)
60 NEXT J
61 RETURN
Interested in Solving Matrix Eigenvalue problems or Computing Concentration Gradients with your TS?
I am currently completing a book of numerical programs entitle SUM (Small Users Mathematics) – A Compendium of BASIC Numerical Programs for the Small Systems User. These programs have all been written an tested on the T/S 1000, so they’ll work on your 2068 (or, for that matter, can be easily adapted to any machine using MBASIC). I intend to market the book for $15.00, however, as a special prepublication offer, the book will go for $10.00, postage paid. Send checks and inquiries to Box c-6, 767 Hopetown Road, Chillicothe, Ohio 45601. Publication date is scheduled for July, 1984.
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.