You are on page 1of 7

1.

MATLAB
Program
commandwindow
clear
Clc

disp(' T1 T2 T3 T4 T5 T6 T')

A=[10 4 -2 -2 4 2 -9; 2 2 -4 2 6 -2 12; 4 -2 2 4 2 -6 60; 2 6 -6 -2 4 2 -45; -6 -2 4 6 2 6 48;


8 6 2 -12 -6 -4 -81]

%forward elimination%
%row1 above is the pivot equation%
A=[A(1,:); A(2,:)-A(1,:)*A(2,1)/A(1,1); A(3,:)-A(1,:)*A(3,1)/A(1,1); A(4,:)-
A(1,:)*A(4,1)/A(1,1); A(5,:)-A(1,:)*A(5,1)/A(1,1); A(6,:)-A(1,:)*A(6,1)/A(1,1)]

%using row2 above as the next pivot equation%


A=[A(1,:); A(2,:); A(3,:)-A(2,:)*A(3,2)/A(2,2); A(4,:)-A(2,:)*A(4,2)/A(2,2); A(5,:)-
A(2,:)*A(5,2)/A(2,2); A(6,:)-A(2,:)*A(6,2)/A(2,2)]

%using row3 above as the pivot equation%


A=[A(1,:); A(2,:); A(3,:); A(4,:)-A(3,:)*A(4,3)/A(3,3); A(5,:)-A(3,:)*A(5,3)/A(3,3); A(6,:)-
A(3,:)*A(6,3)/A(3,3)]

%using row4 as the pivot equation%


A=[A(1,:); A(2,:); A(3,:); A(4,:); A(5,:)-A(4,:)*A(5,4)/A(4,4); A(6,:)-A(4,:)*A(6,4)/A(4,4)]

%finally using row5 as the pivot equation%


A=[A(1,:); A(2,:); A(3,:); A(4,:); A(5,:); A(6,:)-A(5,:)*A(6,5)/A(5,5)]

%using backward substitution to find the values of T6,T5,T4,T3,T2 and T1 respectively%


T6=A(6,7)/A(6,6)
T5=(A(5,7)-T6*A(5,6))/A(5,5)
T4=(A(4,7)-T6*A(4,6)-T5*A(4,5))/A(4,4)
T3=(A(3,7)-T6*A(3,6)-T5*A(3,5)-T4*A(3,4))/A(3,3)
T2=(A(2,7)-T6*A(2,6)-T5*A(2,5)-T4*A(2,4)-T3*A(2,3))/A(2,2)
T1=(A(1,7)-T6*A(1,6)-T5*A(1,5)-T4*A(1,4)-T3*A(1,3)-T2*A(1,2))/A(1,1)

Output
T1 T2 T3 T4 T5 T6 T

A =

10 4 -2 -2 4 2 -9
2 2 -4 2 6 -2 12
4 -2 2 4 2 -6 60
2 6 -6 -2 4 2 -45
-6 -2 4 6 2 6 48
8 6 2 -12 -6 -4 -81

A =

10.0000 4.0000 -2.0000 -2.0000 4.0000 2.0000 -9.0000


0 1.2000 -3.6000 2.4000 5.2000 -2.4000 13.8000
0 -3.6000 2.8000 4.8000 0.4000 -6.8000 63.6000
0 5.2000 -5.6000 -1.6000 3.2000 1.6000 -43.2000
0 0.4000 2.8000 4.8000 4.4000 7.2000 42.6000
0 2.8000 3.6000 -10.4000 -9.2000 -5.6000 -73.8000
A =

10.0000 4.0000 -2.0000 -2.0000 4.0000 2.0000 -9.0000


0 1.2000 -3.6000 2.4000 5.2000 -2.4000 13.8000
0 0.0000 -8.0000 12.0000 16.0000 -14.0000 105.0000
0 0 10.0000 -12.0000 -19.3333 12.0000 -103.0000
0 0 4.0000 4.0000 2.6667 8.0000 38.0000
0 0 12.0000 -16.0000 -21.3333 0 -106.0000

A =

10.0000 4.0000 -2.0000 -2.0000 4.0000 2.0000 -9.0000


0 1.2000 -3.6000 2.4000 5.2000 -2.4000 13.8000
0 0.0000 -8.0000 12.0000 16.0000 -14.0000 105.0000
0 0.0000 0 3.0000 0.6667 -5.5000 28.2500
0 0.0000 0 10.0000 10.6667 1.0000 90.5000
0 0.0000 0 2.0000 2.6667 -21.0000 51.5000

A =

10.0000 4.0000 -2.0000 -2.0000 4.0000 2.0000 -9.0000


0 1.2000 -3.6000 2.4000 5.2000 -2.4000 13.8000
0 0.0000 -8.0000 12.0000 16.0000 -14.0000 105.0000
0 0.0000 0 3.0000 0.6667 -5.5000 28.2500
0 -0.0000 0 0 8.4444 19.3333 -3.6667
0 0.0000 0 0 2.2222 -17.3333 32.6667

A =

10.0000 4.0000 -2.0000 -2.0000 4.0000 2.0000 -9.0000


0 1.2000 -3.6000 2.4000 5.2000 -2.4000 13.8000
0 0.0000 -8.0000 12.0000 16.0000 -14.0000 105.0000
0 0.0000 0 3.0000 0.6667 -5.5000 28.2500
0 -0.0000 0 0 8.4444 19.3333 -3.6667
0 0.0000 0 0 0 -22.4211 33.6316

T6 =

-1.5000

T5 =

3.0000

T4 =

6
T3 =

4.5000

T2 =

-3.0000

T1 =

1.5000

>>

2. MATCAD
Program1

forward elimination: row1 is the pivot equation

Output1

using row2 as the next pivot equation


Program2

Output 2

using row3 above as the pivot equation

Program3

Output3

using row4 as the pivot equation


Program4

Output4

finally using row5 as the pivot equation

Program5

Output5

using backward substitution to find the values of T6,T5,T4,T3,T2 and T1 respectively

Program6
Output6

3. EXCEL
A B C D E F G H I
1
2 T1 T2 T3 T4 T5 T6 T Program
3 10 4 -2 -2 4 2 -9
4 2 2 -4 2 6 -2 12
5 4 -2 2 4 2 -6 60
6 2 6 -6 -2 4 2 -45
7 -6 -2 4 6 2 6 48
8 8 6 2 -12 -6 -4 -81

Using forward elimination:


9
row1 above is the pivot equation

10 T1 T2 T3 T4 T5 T6 T
11 10 4 -2 -2 4 2 -9
12 0 1.2 -3.6 2.4 5.2 -2.4 13.8 =B4-B3*$B$4/$B$3
13 0 -3.6 2.8 4.8 0.4 -6.8 63.6 =B5-B3*$B$5/$B$3
14 0 5.2 -5.6 -1.6 3.2 1.6 -43.2 =B6-B3*$B$6/$B$3
15 0 0.4 2.8 4.8 4.4 7.2 42.6 =B7-B3*$B$7/$B$3
16 0 2.8 3.6 -10.4 -9.2 -5.6 -73.8 =B8-B3*$B$8/$B$3
17 using row2 above as the next pivot equation
18 T1 T2 T3 T4 T5 T6 T
19 10 4 -2 -2 4 2 -9
20 0 1.2 -3.6 2.4 5.2 -2.4 13.8
21 0 0 -8 12 16 -14 105 =C13-C12*$C$13/$C$12
22 0 0 10 -12 -19.33333333 12 -103 =C14-C12*$C$14/$C$12
23 0 0 4 4 2.666666667 8 38 =C15-C12*$C$15/$C$12
24 0 0 12 -16 -21.33333333 0 -106 =C16-C12*$C$16/$C$12
25 using row3 above as the pivot equation
26 T1 T2 T3 T4 T5 T6 T
27 10 4 -2 -2 4 2 -9
28 0 1.2 -3.6 2.4 5.2 -2.4 13.8
29 0 0 -8 12 16 -14 105
30 0 0 0 3 0.666666667 -5.5 28.25 =D22-D21*$D$22/$D$21
31 0 0 0 10 10.66666667 1 90.5 =D23-D21*$D$23/$D$21
32 0 0 0 2 2.666666667 -21 51.5 =D24-D21*$D$24/$D$21
33 using row4 as the pivot equation
34 T1 T2 T3 T4 T5 T6 T
35 10 4 -2 -2 4 2 -9
36 0 1.2 -3.6 2.4 5.2 -2.4 13.8
37 0 0 -8 12 16 -14 105
38 0 0 0 3 0.666666667 -5.5 28.25
39 0 0 0 0 8.444444444 19.33333333 -3.666666667 =E31-E30*$E$31/$E$30
40 0 0 0 0 2.222222222 -17.33333333 32.66666667 =E32-E30*$E$32/$E$30
41 finally using row5 as the pivot equation
42 T1 T2 T3 T4 T5 T6 T
43 10 4 -2 -2 4 2 -9
44 0 1.2 -3.6 2.4 5.2 -2.4 13.8
45 0 0 -8 12 16 -14 105
46 0 0 0 3 0.666666667 -5.5 28.25
47 0 0 0 0 8.444444444 19.33333333 -3.666666667
48 0 0 0 0 0 -22.42105263 33.63157895 =F40-F39*$F$40/$F$39
49 using backward substitution to find the values of T6,T5,T4,T3,T2 and T1 respectively
=(H43-G43*C55-F43*C54-E43*C53-D43*C52-
50 T1 1.5
C43*C51)/B43
51 T2 -3 =(H44-G44*C55-F44*C54-E44*C53-D44*C52)/C44
52 T3 4.5 =(H45-G45*C55-F45*C54-E45*C53)/D45
53 T4 6 =(H46-G46*C55-F46*C54)/E46
54 T5 3 =(H47-G47*C55)/F47
55 T6 -1.5 =H48/G48

You might also like