Cayley Hamilton Theorem: Source Code
Cayley Hamilton Theorem: Source Code
Aim:
To write a MATLAB program to verify Cayley Hamilton theorem for the matrix Also
Main Commands:
syms - to define symbolic variables and fynctions
Source Code:
syms A s
A=[7 2 -2; -6 -1 2; 6 2 -1];
I=[1 0 0; 0 1 0; 0 0 1];
charpoly(A,s)==0
ans =
verification=A^3-5*A^2+7*A-3*I
verification = 3×3
0 0 0
0 0 0
0 0 0
format rational
inv_A=(1/3)*(A^2-5*A+7*I)
inv_A =
-1 -2/3 2/3
2 5/3 -2/3
-2 -2/3 5/3
A_power4=5*A^3-7*A^2+3*A
A_power4 =
241 80 -80
-240 -79 80
240 80 -79
Aim:
To write a MATLAB program to verify Cayley Hamilton theorem for the matrix Also compute
Main Commands:
1
syms - to define symbolic variables and fynctions
Source Code:
syms A s
A=[2 1 1; 0 1 0; 1 1 2];
I=[1 0 0; 0 1 0; 0 0 1];
charpoly(A,s)==0
ans =
verification=A^3-5*A^2+7*A-3*I
verification =
0 0 0
0 0 0
0 0 0
format rational
inv_A=(1/3)*(A^2-5*A+7*I)
inv_A =
2/3 -1/3 -1/3
0 1 0
-1/3 -1/3 2/3
A_power4=5*A^3-7*A^2+3*A
A_power4 =
41 40 40
0 1 0
40 40 41
Aim:
To write a MATLAB program to verify Cayley Hamilton theorem for the matrix Also compute
Main Commands:
syms - to define symbolic variables and fynctions
Source Code:
syms A s
A=[-2 2 -3; 2 1 -6; -1 -2 0];
I=[1 0 0; 0 1 0; 0 0 1];
charpoly(A,s)==0
2
ans =
verification=A^3+A^2-21*A-45*I
verification =
0 0 0
0 0 0
0 0 0
format rational
inv_A=(1/45)*(A^2+A-21*I)
inv_A =
-4/15 2/15 -1/5
2/15 -1/15 -2/5
-1/15 -2/15 -2/15
A_power4=-A^3+21*A^2+45*A
A_power4 =
149 136 -204
136 353 -408
-68 -136 285
Aim:
To write a MATLAB program to verify Cayley Hamilton theorem for the matrix Also compute
Main Commands:
syms - to define symbolic variables and fynctions
Source Code:
syms s
A=[1 1 3; 1 3 -3; 2 -4 -4];
I=[1 0 0; 0 1 0; 0 0 1];
charpoly(A,s)==0
ans =
verification=A^3-32*A+56*I
verification =
0 0 0
0 0 0
0 0 0
format rational
inv_A=(1/56)*(-A^2+32*I)
3
inv_A =
3/7 1/7 3/14
1/28 5/28 -3/28
5/28 -3/28 -1/28
A_power4=32*A^2-56*A
A_power4 =
200 -312 -552
-120 536 360
-432 416 1312
DIAGONALIZATION OF MATRICES
Aim:
Main Commands:
syms - to define symbolic variables and fynctions
Source Code:
syms s
A =[1 1 3;1 5 1;3 1 1]
A =
1 1 3
1 5 1
3 1 1
charpoly(A,s)==0
ans =
eig(A)
ans =
-2
3
6
M =
4
-1 1 1
* -1 2
1 1 1
N =
-985/1393 780/1351 881/2158
* -780/1351 881/1079
985/1393 780/1351 881/2158
D =
-2 0 0
0 3 0
0 0 6
Aim:
Main Commands:
syms - to define symbolic variables and fynctions
Source Code:
syms s
A =[2 1 -1; 1 1 -2; -1 -2 1]
A =
2 1 -1
1 1 -2
-1 -2 1
charpoly(A,s)==0
ans =
eig(A)
ans =
-1
1
4
M =
5
* 1393/985 -1393/985
1 -985/1393 -1393/985
1 985/1393 1393/985
N =
* 881/1079 -780/1351
985/1393 -881/2158 -780/1351
985/1393 881/2158 780/1351
D =
-1 0 0
0 1 0
0 0 4
Aim:
Main Commands:
syms - to define symbolic variables and fynctions
Source Code:
syms s
A =[2 1 -1; 1 1 -2; -1 -2 1]
A =
2 1 -1
1 1 -2
-1 -2 1
charpoly(A,s)==0
ans =
eig(A)
ans =
-1
1
4
M =
6
* 1393/985 -1393/985
1 -985/1393 -1393/985
1 985/1393 1393/985
N =
* 881/1079 -780/1351
985/1393 -881/2158 -780/1351
985/1393 881/2158 780/1351
D =
-1 0 0
0 1 0
0 0 4
Aim:
Main Commands:
syms - to define symbolic variables and fynctions
Source Code:
syms s
A =[3 -1 1; -1 5 -1; 1 -1 3]
A =
3 -1 1
-1 5 -1
1 -1 3
charpoly(A,s)==0
ans =
eig(A)
ans =
2
3
6
M =
7
1 -1 1
* -1 -2
-1 -1 1
N =
985/1393 -780/1351 881/2158
* -780/1351 -881/1079
-985/1393 -780/1351 881/2158
D =
2 0 0
0 3 0
0 0 6
Aim:
Main Commands:
syms - to define symbolic variables and fynctions
Source Code:
syms s
A =[2 0 4; 0 6 0; 4 0 2]
A =
2 0 4
0 6 0
4 0 2
charpoly(A,s)==0
ans =
eig(A)
ans =
-2
6
6
M =
8
1 1079/881 0
0 0 -2158/881
-1 1079/881 0
N =
985/1393 985/1393 0
0 0 -1
-985/1393 985/1393 0
D =
-2 0 0
0 6 0
0 0 6