Page 258 - MATLAB an introduction with applications
P. 258
Numerical Methods ——— 243
Number of eigenvalues less than lamda = 0.000000 are 1
» sturn
Enter guess value lambda
–1
sturn sequence p(–1.000000) is
1
3
9
19
53
Number of eigenvalues less than lamda = – 1.000000 are 0
Hence, lowest eigen value lies between 0 and –1.
Example E4.20: Use Gaussian elimination scheme to solve the set of equations:
2x + x – 3x = 11
2
1
3
4x – 2x + 3x = 8
3
1
2
–2x + 2x – x = –6
3
2
1
Solution:
Writing the equation in the form of [A]X = B and applying forward elimination and back-substitution, we obtain
2 1 –3 11
U = 0– 4 9 and right hand side = –14
0 0 2.75 –5
3
Finally, the solution from back substitution becomes X = –1
–2
The complete MATLAB program is given below:
% Ax = b
% A - matrix for the left hand side.
% b - vector for the right hand side
% This performs Gaussian elminiation to find x.
% MATRIX DEFINITION
A = [2 1 –3;4 –2 3; –2 2 –1];
b = [11;8;–6];
N = max(size(A));
% Perform Gaussian (FORWARD) elimination
for j = 2:N,
for i = j:N,
m = A(i,j–1)/A(j–1,j–1);
A(i,:) = A(i,:) –A(j–1,:)*m;