You are on page 1of 12

1st.

wxmx 1/1

Mathematics Practical

Name: Akshat Chaudhary


Roll No: 0445
Bsc(H) Computer Science

Find Cofactors, determinant, adjoint and inverse of a matrix.


A:matr ix([4 ,−2,5],[2,1,0],[1,2,3]);

4 −2 5

1 10
123

determinant(A);
2nd.wxmx 1 / 2

Question 2: Convert matrix into echelon form and find its rank.
A:matrix([1,1,−1],[2,−1,1],[−1,2,2]);
11

2 −1 −1 2

eA:echelon(A);
1 1 −1

0 1 −1

0 0 1

B:copymatrix(A);

1 1

2 −1

−1 2

B[3]:B[1]+B[3] $B;
1 1

2 −1

0 3

B[2]:−2·B[1]+B[2] $B;
1 1

0 −3

0 3

B[3]:B[3]+B[2] $B;
1 1

0 −3

0 0

B[2]:B[2]·−1/3 $B;
1 1 −1

0 1 −1

0 0 4

B[3]:B[3]·1/4 $B;
1 1 −1

0 1 −1

0 0 1
2nd.wxmx 2/2

rank(B);
3

3rd.wxmx 1/1

Question 3 : Solve the system of equation using gauss elimination.


linsolve([w+x+2·y=1, 2·w−x+z=−2, w−x−y−2·z=4, 2·w−x+2·y−z=0], [w,x,y,z]);
[w=1,x=2,y=−1,z=−2]
Ab:augcoefmatrix([w+x+2·y=1,2·w−x+z=−2,w−x−y−2·z=4,2·w−x+2·y−z=0],[w,x,y,z

linsolve([w+x+2·y=1,x+(4/3)·y−(1/3)·z=4/3,y+8·z=−17,z=−2],[w,x,y,z]);
[w=1,x=2,y=−1,z=−2]
2/2

4th.wxmx

Question 4 : Solve system of linear equations using gauss jordan


linsolve([w+x+2·y=1, 2·w−x+z=−2, w−x−y−2·z=4, 2·w−x+2·y−z=0], [w,x,y,z]);
[w=1,x=2,y=−1,z=−2]
Ab:augcoefmatrix([w+x+2·y=1,2·w−x+z=−2,w−x−y−2·z=4,2·w−x+2·y−z=0],
[w,x,y, z
11 2
0 −1

2 −1 0
1 2

1 −1 −1
−2 −4

2 −1 2
−1 0

D:Ab;
11 2
0 −1
2 −1 0 1
2
−1 −2
1 −1 −4

2 −1 2 −1
0
D[2]:D[2]−2·D[1];
[0,−3,−4,1,4]
D[3]:D[3]−D[1];
[0,−2,−3,−2,−3]
D[4]:D[4]−2·D[1];
[0,−3,−2,−1,2]
1/2

[0,0,2,−2,−2]
D[3]:D[3]·(−3);
4th.wxmx

[0,0,1,8,17
]

D[1]:D[1]−D[2];

D[4]:D[4]−2·D[3];
[0,0,0,−18,−36]
D[2]:D[2]−(4/3)·D[3];
[0,1,0,−11,−24]
D[1]:D[1]−(2/3)·D[3];
[1,0,0,−5,−11]
D[4]:D[4]/(−18);
[0,0,0,1,2]
D[3]:D[3]−8·D[4];
[0,0,1,0,1]
D[2]:D[2]+11·D[4];
[0,1,0,0,−2]
D[1]:D[1]+5·D[4];
[1,0,0,0,−1] D;
1000 −1

0100 −2

0010 1

0001 2
2/2

5th.wxmx

Question 5 : Verify the linear dependence of vectors. Generate a


linear combination of given vectors of Rn/ matrices of the samew
size.
v1:[1,2,1]; v2:[2,1,−4];
v3:[3,−2,1];

[1,2,1] [2,1,−4] [3,−2,1]


load("C:/Users/CSLab1/Desktop/mbe5.mac")$

0 errors, 0
warningsdisplay2d:true;
m:mcombine([matrix(v1),matrix(v2),matrix(v3)]);

1 23 true2 1
−2
1 −4 1

length(transpose(m));
3 rank(m);
3 s:columnspan(m);
1 2 3

columnspan2 1 −2

1 −4 1

[s1,s2,s3]:5 , span="[";
[5,5,5] v:[7,1,9];
[7,1,9] t:transpose(v);

arraym:addcol(m,t);

2 3 7
1/2

1 −2 1 −4 1 9

5th.wxmx

rank(m); 3
rank(arraym);
3
2/2

6th.wxmx

Question 6: Check the diagonalizable property of matrices and find


the find the corresponding eigen value and verify the
cayleyHamilton theorem.
load("C:/Users/PC/Desktop/mbe5.mac")$
B:matrix([2,2,1],[1,3,1],[1,2,2]);
[evals,evecs]=eigenvectors(B);

2 2 1

1 3 1[evals,evecs =]
1 2 2

[[5,1 ,] [1,2]], [[1,1,1]],

[[1,0,−1],[0,1,−2]] display2d: true; diagp(B);


[V1]:jordan_chain(B,5);
[V2,V3]:jordan_chain(B,1)
;

true true [[1,1,1]]


[[1,0,−1],[0,1,−2]]
P:mcombine([matrix(V1),matrix(V2),matrix(V3)]);
Pi:invert(P)
·D=Pi·B·P;

1 1 0

1 0 1

1 −1

−2
1/2

2 Pi 2
Pi 0

Pi 0 Pi

Pi −(2 Pi) −(4 Pi) expand(charpoly(B,x));

3 2
−x +7 x −11 x+5
−B^^3+7·B^^2−11·B+5·ident(3);
6th.wxmx

0 0 0

0 0 0

0 0 0
7th.wxmx 1/1

Question 7: Compute Gradient of a scalar field, Divergence and Curl


of a vector field.
load(vect); a:[2,3,4];
b:[−2,−1,1];
express(a.b)·3;
C:\maxima−5.39.0\share\maxima\5.39.0_2_g5a49f11_dirty\share\vector\vect.mac
[2,3,4] [−2,−1,1] −9 express(a~b);
[7,−10,4] express(grad(x^2+y^2+z^2));
d 2 2 2 d 2 2 2 d 2 2 2
[ (z +y +x ), (z +y +x ), (z +y +x )] dx dy dz
ev(%,diff);
[2 x,2 y,2 z]
f.ev(express(curl[x^2,y^2,z^2]),diff);
f.ev(express(div[x^2,y^2,z^2]),diff);

f . [0,0,0] f . (2 z+2 y+2 x)


express(laplacian(x^2·y^2·z^2));

2 2 2
d 22 2 d 2 2 2 d 2 2 2
(x y z )+ (x y z )+ (x y z )
2 2 2 dz dy dx
ev(%,diff);
2 2 2 2 2 2
2 y z +2 x z +2 x y

You might also like