Graphics Programs Reference
In-Depth Information
At the mid-span the boundary conditions areequivalentto
y
n
+
1
=
y
n
−
1
and
2
h
3
(
y
n
+
2
=
2
y
n
+
1
−
2
y
n
−
1
+
y
n
−
2
+
−
1
/
2)
Substitutioninto Eqs. (8.13d) and (8.13e) yields
y
n
−
3
−
4
y
n
−
2
+
7
y
n
−
1
−
4
y
n
=
0
(d)
h
3
2
y
n
−
2
−
8
y
n
−
1
+
6
y
n
=
(e)
The coefficient matrix of Eqs. (a)-(e) can be madesymmetric by dividing Eq. (e) by 2.
The result is
⎡
⎣
⎤
⎦
⎡
⎣
⎤
⎦
⎡
⎣
⎤
⎦
1
00
y
1
y
2
y
3
.
y
n
−
2
y
n
−
1
y
n
0
0
0
.
0
0
0
7
−
4
1
0
−
4
6
−
4
1
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
=
1
−
4
6
−
4
1
1
−
4
7
−
4
5
h
3
1
−
4
3
0
.
The abovesystem of equationscan be solvedwith the decomposition and back
substitutionroutines in the functions
LUdec5
and
LUsol5
—see Art.2.4.Recall that
these functions work with the vectors
d
,
e
and
f
thatform the diagonals of upper the
half of the coefficient matrix. The program that sets up and solves the equations is
function fDiff8
% Finite difference method for the 4th-order,
% linear boundary value problem in Example 8.8.
xStart = 0; xStop = 0.5; % Range of integration.
n=21; %Numberofmeshpoints.
freq = 1; % Printout frequency.
h = (xStop - xStart)/(n-1);
x = linspace(xStart,xStop,n)';
[d,e,f,b] = fDiffEqs(x,h,n);
[d,e,f] = LUdec5(d,e,f);
printSol(x,LUsol5(d,e,f,b),freq)
function [d,e,f,b] = fDiffEqs(x,h,n)
% Sets up the pentadiagonal coefficient matrix and the
% constant vector of the finite difference equations.
d = ones(n,1)*6;
Search WWH ::
Custom Search