You are on page 1of 19

ACTIVITY NO.

1
MATRIX OPERATORS AND DETERMINANTS
PART 1: Matrix Operations.
OBJECTIVES:

To apply matrix operations and determinants and convert it to scilab tools.


PROCEDURES:
Consider the Following Matrices
A=

8 3
5 11

12 8
B= 4 1
7 9
C=

13 2 10
5 11 7

D=

5 15 1
3 7 2
4 8 9

1
2
3
E=
4
5
6

7
8
9
10
11
12

13
14
15
16
17
18

19
20
21
22
23
24

25
26
27
28
29
30

NOTE: Write the Scilab. code / command and the respective


output for every item.
Evaluate the Following:
1.) B ( )
2.) A-CB
3.) D+BAC
4.) ( )
5.) () +
6.) Recreate Matrix E using the colon operator.
7.) Generate three 4 x 4 matrices from the elements of E.
store then under variables F, G and H.
8.) Generate the following matrix
matrices eye(), ones(), and zeros().

using

the

special

5 3 3 3 5
3 5 3 5 3
J= 3 3 0 3 3
3 5 3 5 3
5 3 3 3 5
PART II: Elementary Column and Row Operation.
Let k=E-3(eye(6,6)-2*ones(6,6))
9.) Create an upper triangular matrix using series of row
operations. Write the code/command and the respective
output in every step of the operation. NOTE: Comments can
be written using the //symbols.
I.e. --> A=5 // this is a comment.
PART III: Determinants.
Consider matrix K, evaluate the determinant of K:
10.) Using the det() function.
11.) Using the elementary row/column operations.
12.) Using Laplace Expansion.
13.) Using Chios Method.
NOTE: Show the command and the output for every step of the
solution for 11, 12, and 13.

DATA AND RESULTS:

PART 1: MATRIXOPERATIONs

1.) B ( )
ans

=
2388.
356.

1092.
- 43.

247.

492.
263.

880.

- 656.

2.) A-(C*B)
ans

- 70.
148.

193.
45.

3.) D+(B*A*C)
ans

=
2393.
359.
243.

1077.
- 50.

493.
261.

888.

- 665.

4.) ( )
ans

=
1083.

- 1466.

- 2073.
606.

5.) ( ) +
ans

=
201.

50.

- 50.

49.

- 26.

121.

65.

45.

- 142.

6.) Recreate Matrix E using the colon operator.


E=[1:6:25;2:6:26;3:6:27;4:6:28;5:6:29;6:6:30]
E

=
1.

7.

13.

19.

25.

2.

8.

14.

20.

26.

3.

9.

15.

21.

27.

4.

10.

16.

22.

28.

5.

11.

17.

23.

29.

6.

12.

18.

24.

30.

7.) Generate three 4 x 4 matrices from the elements of E.


store then under variables F, G and H.
F=[E(3:6,2:5)]
F

=
9.

15.

21.

27.

10.

16.

22.

28.

11.

17.

23.

29.

12.

18.

24.

30.

G=[E(2:5,1:4)]
G

=
2.

8.

14.

20.

3.

9.

15.

21.

4.

10.

16.

22.

5.

11.

17.

23.

H=[E(2:5,2:5)]
H

=
8.

14.

20.

26.

9.

15.

21.

27.

10.

16.

22.

28.

11.

17.

23.

29.

8.) Generate the following matrix


matrices eye(), ones(), and zeros().

using

the

special



J=


J=(-8*eye(5,5)+3*ones(5,5)+sparse([1,5;2,4;4,2;5,1],
[2,2,2,2]))
;J(3,3)=0
J

- 5.

3.

3.

3.

5.

3.

- 5.

3.

5.

3.

3.

3.

0.

3.

3.

3.

5.

3.

- 5.

3.

5.

3.

3.

3.

- 5.

PART II. Elementary Column and Row Operation.


Let k=E-3*(eye(6,6)-2*ones(6,6))
9.) Create an upper triangular matrix using series of row
operations. Write the code/command and the respective
output in every step of the operation. NOTE: Comments can
be written using the //symbols.
I.e. --> A=5 // this is a comment.
Let K=E-3(eye(6,6)-2*ones(6,6)
E =
1. 7.

13. 19. 25. 31.

2. 8.

14. 20. 26. 32.

3. 9.

15. 21. 27. 33.

4. 10. 16. 22. 28. 34.


5. 11. 17. 23. 29. 35.
6. 12. 18. 24. 30. 36.

-->F=eye(6,6)
F

=
1.

0.

0.

0.

0.

0.

0.

1.

0.

0.

0.

0.

0.

0.

1.

0.

0.

0.

0.

0.

0.

1.

0.

0.

0.

0.

0.

0.

1.

0.

0.

0.

0.

0.

0.

1.

-->G=2*ones(6,6)
G

=
2.

2.

2.

2.

2.

2.

2.

2.

2.

2.

2.

2.

2.

2.

2.

2.

2.

2.

2.

2.

2.

2.

2.

2.

2.

2.

2.

2.

2.

2.

2.

2.

2.

2.

2.

2.

-->3*(F-G)
ans

- 3.

- 6.

- 6.

- 6.

- 6.

- 6.

- 6.

- 3.

- 6.

- 6.

- 6.

- 6.

- 6.

- 6.

- 3.

- 6.

- 6.

- 6.

- 6.

- 6.

- 6.

- 3.

- 6.

- 6.

- 6.

- 6.

- 6.

- 6.

- 3.

- 6.

- 6.

- 6.

- 6.

- 6.

- 6.

- 3.

-->K=E-ans
K=
4.

13.

19.

25.

31.

37.

8.

11.

20.

26.

32.

38.

9.

15.

18.

27.

33.

39.

10.

16.

22.

25.

34.

40.

11.

17.

23.

29.

32.

41.

12.

18.

24.

30.

36.

39.

4.

13.

19.

25.

31.

37.

8.

11.

20.

26.

32.

38.

9.

15.

18.

27.

33.

39.

10.

16.

22.

25.

34.

40.

11.

17.

23.

29.

32.

41.

12.

18.

24.

30.

36.

39.

--> K

-->K(2,:)=K(2,:)-[2*K(1,:)]
K

=
4.

13.

19.

25.

31.

37.

0.

- 15.

- 18.

- 24.

- 30.

- 36.

9.

15.

18.

27.

33.

39.

10.

16.

22.

25.

34.

40.

11.

17.

23.

29.

32.

41.

12.

18.

24.

30.

36.

39.

-->K(3,:)=K(3,:)+[(-9/4)*K(1,:)]
K

=
4.

13.

19.

25.

31.

37.

0.

- 15.

- 18.

- 24.

- 30.

- 36.

0.

- 14.25

- 24.75

- 29.25

- 36.75

- 44.25

10.

16.

22.

25.

34.

40.

11.

17.

23.

29.

32.

41.

12.

18.

24.

30.

36.

39.

-->K(4,:)=K(4,:)+[(-10/4)*K(1,:)]
K

=
4.

13.

19.

25.

31.

37.

0.

- 15.

- 18.

- 24.

- 30.

- 36.

0.

- 14.25

- 24.75

- 29.25

- 36.75

- 44.25

0.

- 16.5

- 25.5

- 37.5

- 43.5

- 52.5

11.

17.

23.

29.

32.

41.

12.

18.

24.

30.

36.

39.

-->K(5,:)=K(5,:)+[(-11/4)*K(1,:)]
K

=
4.

13.

19.

25.

31.

37.

0.

- 15.

- 18.

- 24.

- 30.

- 36.

0.

- 14.25

- 24.75

- 29.25

- 36.75

- 44.25

0.

- 16.5

- 25.5

- 37.5

- 43.5

- 52.5

0.

- 18.75

- 29.25

- 39.75

- 53.25

- 60.75

12.

18.

24.

30.

36.

39.

-->K(6,:)=K(6,:)+[(-12/4)*K(1,:)]
K

=
4.

13.

19.

25.

31.

37.

0.

- 15.

- 18.

- 24.

- 30.

- 36.

0.

- 14.25

- 24.75

- 29.25

- 36.75

- 44.25

0.

- 16.5

- 25.5

- 37.5

- 43.5

- 52.5

0.

- 18.75

- 29.25

- 39.75

- 53.25

- 60.75

0.

- 21.

- 33.

- 45.

- 57.

- 72.

-->K(3,:)=K(3,:)-[(14.25/15)*K(2,:)];
K(4,:)=K(4,:)-[(16.5/15)*K(2,:)];
K(5,:)=K(5,:)-[(18.75/15)*K(2,:)];
K(6,:)=K(6,:)-[(21/15)*K(2,:)];
K =
4.

13.

0.
0.
0.
0.
0.

- 15.
0.
0.
0.
0.

19.
-

18.
7.65
5.7
6.75
7.8

25.
-

24.
6.45
11.1
9.75
11.4

31.
-

37.

30.
8.25
10.5
15.75
15.

36.
10.05
12.9
15.75
21.6

-->K(4,:)=K(4,:)-[(5.7/7.65)*K(3,:)];
K(5,:)=K(5,:)-[(6.75/7.65)*K(3,:)];
K(6,:)=K(6,:)-[(7.8/7.65)*K(3,:)];
K =
4.

13.

19.

25.

31.

37.

0.

- 15.

- 18.

- 24.

- 30.

- 36.

0.

0.

- 7.65

- 6.45

- 8.25

- 10.05

0.

0.

2.665D-15

- 6.2941176

- 4.3529412

- 5.4117647

0.

0.

1.776D-15

- 4.0588235

- 8.4705882

- 6.8823529

0.

0.

8.882D-16

- 4.8235294

- 6.5882353

- 11.352941

-->K(5,:)=K(5,:)-[(4.0588235/6.2941176)*K(4,:)];
K(6,:)=K(6,:)-[(4.8235294/6.2941176)*K(4,:)];
K =
4.

13.

19.

25.

31.

37.

0.

- 15.

- 18.

- 24.

- 30.

- 36.

0.

0.

- 7.65

- 6.45

- 8.25

- 10.05

0.

0.

2.665D-15

- 6.2941176

0.

0.

5.811D-17

9.346D-10

0.

0.

- 1.154D-15

2.430D-08

- 4.3529412

- 5.4117647

- 5.6635514

- 3.3925234

- 3.2523364

- 7.2056075

-->K(6,:)=K(6,:)-[(3.2523364/5.6635514)*K(5,:)];

=
4.

13.

19.

25.

31.

37.

0.

- 15.

- 18.

- 24.

- 30.

- 36.

0.

0.

- 7.65

- 6.45

- 8.25

- 10.05

0.

0.

2.665D-15

- 6.2941176

- 4.3529412

- 5.4117647

0.

0.

5.811D-17

9.346D-10

- 5.6635514

- 3.3925234

0.

0.

- 1.187D-15

2.376D-08

- 3.109D-08

- 5.2574258

PART III: DETERMINANTS


10. Using the det( ) function.
K

=
4.

13.

19.

25.

31.

37.

8.

11.

20.

26.

32.

38.

9.

15.

18.

27.

33.

39.

10.

16.

22.

25.

34.

40.

11.

17.

23.

29.

32.

41.

12.

18.

24.

30.

36.

39.

-->det(K)
ans

-86022.

11. Using elementary row/ column operations


K

=
4.

13.

19.

25.

31.

37.

8.

11.

20.

26.

32.

38.

9.

15.

18.

27.

33.

39.

10.

16.

22.

25.

34.

40.

11.

17.

23.

29.

32.

41.

12.

18.

24.

30.

36.

39.

-->K(2,:)=K(2,:)-[2*K(1,:)]
K

=
4.

13.

19.

25.

31.

37.

0.

- 15.

- 18.

- 24.

- 30.

- 36.

9.

15.

18.

27.

33.

39.

10.

16.

22.

25.

34.

40.

11.

17.

23.

29.

32.

41.

12.

18.

24.

30.

36.

39.

-->K(3,:)=K(3,:)+[(-9/4)*K(1,:)]
K

=
4.

13.

19.

25.

31.

37.

0.

- 15.

- 18.

- 24.

- 30.

- 36.

0.

- 14.25

- 24.75

- 29.25

- 36.75

- 44.25

10.

16.

22.

25.

34.

40.

11.

17.

23.

29.

32.

41.

12.

18.

24.

30.

36.

39.

-->K(4,:)=K(4,:)+[(-10/4)*K(1,:)]
K

=
4.

13.

19.

25.

31.

37.

0.

- 15.

- 18.

- 24.

- 30.

- 36.

0.

- 14.25

- 24.75

- 29.25

- 36.75

- 44.25

0.

- 16.5

- 25.5

- 37.5

- 43.5

- 52.5

11.

17.

23.

29.

32.

41.

12.

18.

24.

30.

36.

39.

-->K(5,:)=K(5,:)+[(-11/4)*K(1,:)]
K

=
4.

13.

19.

25.

31.

37.

0.

- 15.

- 18.

- 24.

- 30.

- 36.

0.

- 14.25

- 24.75

- 29.25

- 36.75

- 44.25

0.

- 16.5

- 25.5

- 37.5

- 43.5

- 52.5

0.

- 18.75

- 29.25

- 39.75

- 53.25

- 60.75

12.

18.

24.

30.

36.

39.

-->K(6,:)=K(6,:)+[(-12/4)*K(1,:)]
K

=
4.

13.

19.

25.

31.

37.

0.

- 15.

- 18.

- 24.

- 30.

- 36.

0.

- 14.25

- 24.75

- 29.25

- 36.75

- 44.25

0.

- 16.5

- 25.5

- 37.5

- 43.5

- 52.5

0.

- 18.75

- 29.25

- 39.75

- 53.25

- 60.75

0.

- 21.

- 33.

- 45.

- 57.

- 72.

-->K(3,:)=K(3,:)-[(14.25/15)*K(2,:)];
K(4,:)=K(4,:)-[(16.5/15)*K(2,:)];
K(5,:)=K(5,:)-[(18.75/15)*K(2,:)];
K(6,:)=K(6,:)-[(21/15)*K(2,:)];
K =
4.
13.
19.
25.
31.

37.

0.
0.

- 15.
0.

- 18.
- 7.65

- 24.
- 6.45

- 30.
- 8.25

- 36.
- 10.05

0.
0.

0.
0.

- 5.7
- 6.75

- 11.1
- 9.75

- 10.5
- 15.75

- 12.9
- 15.75

0.

0.

- 7.8

- 11.4

- 15.

- 21.6

-->K(4,:)=K(4,:)-[(5.7/7.65)*K(3,:)];
K(5,:)=K(5,:)-[(6.75/7.65)*K(3,:)];
K(6,:)=K(6,:)-[(7.8/7.65)*K(3,:)];
K =
4.

13.

19.

25.

31.

37.

0.

- 15.

- 18.

- 24.

- 30.

- 36.

0.

0.

- 7.65

- 6.45

- 8.25

- 10.05

0.

0.

2.665D-15

- 6.2941176

- 4.3529412

- 5.4117647

0.

0.

1.776D-15

- 4.0588235

- 8.4705882

- 6.8823529

0.

0.

8.882D-16

- 4.8235294

- 6.5882353

- 11.352941

-->K(5,:)=K(5,:)-[(4.0588235/6.2941176)*K(4,:)];
K(6,:)=K(6,:)-[(4.8235294/6.2941176)*K(4,:)];
K =
4.

13.

19.

25.

31.

37.

0.

- 15.

- 18.

- 24.

- 30.

- 36.

0.

0.

- 7.65

- 6.45

- 8.25

- 10.05

0.

0.

2.665D-15

- 6.2941176

- 4.3529412

- 5.4117647

0.

0.

5.811D-17

9.346D-10

- 5.6635514

- 3.3925234

0.

0.

- 1.154D-15

2.430D-08

- 3.2523364

- 7.2056075

-->K(6,:)=K(6,:)-[(3.2523364/5.6635514)*K(5,:)];
K =
4.

13.

19.

25.

31.

37.

0.

- 15.

- 18.

- 24.

- 30.

- 36.

0.

0.

- 7.65

- 6.45

- 8.25

- 10.05

0.

0.

2.665D-15

- 6.2941176

- 4.3529412

- 5.4117647

0.

0.

5.811D-17

9.346D-10

- 5.6635514

- 3.3925234

0.

0.

- 1.187D-15

2.376D-08

- 3.109D-08

- 5.2574258

-->DETK=4*-15*-7.65*-6.2941176*-5.6635514*-5.2574258
DETK

- 86022.

12. Using Laplace Expansions


-->A=H(2:6,2:6)
A

=
11.

20.

26.

32.

38.

15.

18.

27.

33.

39.

16.

22.

25.

34.

40.

17.

23.

29.

32.

41.

18.

24.

30.

36.

39.

-->B=[H(1,2:6);H(3:6,2:6)]
B

=
13.

19.

25.

31.

37.

15.

18.

27.

33.

39.

16.

22.

25.

34.

40.

17.

23.

29.

32.

41.

18.

24.

30.

36.

39.

-->C=[H(1:2,2:6);H(4:6,2:6)]
C

=
13.

19.

25.

31.

37.

11.

20.

26.

32.

38.

16.

22.

25.

34.

40.

17.

23.

29.

32.

41.

18.

24.

30.

36.

39.

-->D=[H(1:3,2:6);H(5:6,2:6)]
D

=
13.

19.

25.

31.

37.

11.

20.

26.

32.

38.

15.

18.

27.

33.

39.

17.

23.

29.

32.

41.

18.

24.

30.

36.

39.

-->E=[H(1:5,2:6)]
E

=
13.

19.

25.

31.

37.

11.

20.

26.

32.

38.

15.

18.

27.

33.

39.

16.

22.

25.

34.

40.

17.

23.

29.

32.

41.

-->F=[H(1:5,2:6)]
F

=
13.

19.

25.

31.

37.

11.

20.

26.

32.

38.

15.

18.

27.

33.

39.

16.

22.

25.

34.

40.

17.

23.

29.

32.

41.

13.) Using Chios Method.


-->L=1/(K(1,1)^(size(K,2)-2))
L=0.0039063
-->
K=[det(K(1:2,1:2)),det(K(1:2,1:2:3)),det(K(1:2,1:3:4)),det(K(1:2,1:4:5)),d
et(K(1:2,1:5:6));det(K(1:2:3,1:2)),det(K(1:2:3,1:2:3)),det(K(1:2:3,1:3:4)),
det(K(1:2:3,1:4:5)),det(K(1:2:3,1:5:6));det(K(1:3:4,1:2)),det(K(1:3:4,1:2:
3)),det(K(1:3:4,1:3:4)),det(K(1:3:4,1:4:5)),det(K(1:3:4,1:5:6));det(K(1:4:
5,1:2)),det(K(1:4:5,1:2:3)),det(K(1:4:5,1:3:4)),det(K(1:4:5,1:4:5)),det(K(1
:4:5,1:5:6));det(K(1:5:6,1:2)),det(K(1:5:6,1:2:3)),det(K(1:5:6,1:3:4)),det(
K(1:5:6,1:4:5)),det(K(1:5:6,1:5:6))]
K=
-60.

-72.

-96.

-120.

-144.

-57.

-99.

-117.

-147.

-177.

-66.

-102.

-150.

-174.

-210.

-75.

-117.

-159.

-213.

-243.

- 84.

- 132.

- 180.

- 228.

- 288.

-->1/4^(6-2)*det(K)//TO CHECK
ans =
- 86022.
-->Z=
[det([K(1,1),K(1,2);K(2,1),K(2,2)]),det([K(1,1),K(1,3);K(2,1),K(2,3)]),det([K(1,1),K
(1,4);K(2,1),K(2,4)]),det([K(1,1),K(1,5);K(2,1),K(2,5)])];
-->Y=
[det([K(1,1),K(1,2);K(3,1),K(3,2)]),det([K(1,1),K(1,3);K(3,1),K(3,3)]),det([K(1,1),K
(1,4);K(3,1),K(3,4)]),det([K(1,1),K(1,5);K(3,1),K(3,5)])];
-->X=
[det([K(1,1),K(1,2);K(4,1),K(4,2)]),det([K(1,1),K(1,3);K(4,1),K(4,3)]),det([K(1,1),K
(1,4);K(4,1),K(4,4)]),det([K(1,1),K(1,5);K(4,1),K(4,5)])];

-->W=
[det([K(1,1),K(1,2);K(5,1),K(5,2)]),det([K(1,1),K(1,3);K(5,1),K(5,3)]),det([K(1,1),K
(1,4);K(5,1),K(5,4)]),det([K(1,1),K(1,5);K(5,1),K(5,5)])];
-->K=[Z;Y;X;W];
-->K
K =
1836. 1548. 1980. 2412.
1368. 2664. 2520. 3096.
1620. 2340. 3780. 3780.
1872. 2736. 3600. 5184.
-->1/4^(6-2)*-1/60^(5-2)*det(K)//to check
ans =
- 86022.
-->I=
[det([K(1,1),K(1,2);K(2,1),K(2,2)]),det([K(1,1),K(1,3);K(2,1),K(2,3)]),det([K(1,1),K
(1,4);K(2,1),K(2,4)])];
-->O=
[det([K(1,1),K(1,2);K(3,1),K(3,2)]),det([K(1,1),K(1,3);K(3,1),K(3,3)]),det([K(1,1),K
(1,4);K(3,1),K(3,4)])];
-->P=
[det([K(1,1),K(1,2);K(4,1),K(4,2)]),det([K(1,1),K(1,3);K(4,1),K(4,3)]),det([K(1,1),K
(1,4);K(4,1),K(4,4)])];

-->K=[I;O;P];
-->K
K =
2773440. 1918080. 2384640.
1788480. 3732480. 3032640.
2125440. 2903040. 5002560.
-->1/4^(6-2)*-1/60^(5-2)*1/1836^(4-2)*det(K),TO CHECK
ans =
- 86022.

RECOMMENDATION:
When executing commands in Scilab., the commands must have their
proper commas and colons/brackets in order to avoid errors.
There are special matrices that can be use to make the operation much
easier and simpler. The eye() or (i)dentity, eye() produces an identity matrix

with undefined dimensions. Dimensions will be defined when this identity


matrix is added to a matrix with fixed dimensions. The ones(),Returns a
matrix made of ones. The zeros(),Creates matrix of zeros (same
as 0*ones).
If there are any commands that are not applicable in any of the
problems operated by the Scilab, the HELP command will be very useful.
The HELP command will give you information about the commands and
related commands that can be used to operate a system of equation to
solve that problem.

You might also like