# Chapter 7 - The rational and jordan forms¶

## Page 239 Example 7.3¶

In [3]:
from numpy import array
from sympy import Symbol,Matrix
A = Matrix(([5, -6, -6],[-1, 4 ,2],[3, -6, -4]))
print 'A = \n',A
x=Symbol('x')
f = A.charpoly(x).as_expr()
print 'Characteristic polynomial for linear operator T on R**3 will be:'
print 'f = ',f
print 'or'
print '(x-1)(x-2)**2'
print 'The minimal polynomial for T is:'
p = (x-1)*(x-2)#
print 'p = ',p
print 'or'
print 'p = (x-1)(x-2)'
print 'So in cyclic decomposition of T, a1 will have p as its T-annihilator.'
print 'Another vector a2 that generate cyclic subspace of dimension 1 will have its T-annihilator as p2.'
p2 = x-2#
print 'p2 = ',p2
print 'pp2 = ',p*p2
print 'i.e., pp2 = f'
print 'Therefore, A is similar to B'
B = array([[0, -2, 0],[1, 3, 0],[0, 0 ,2]])
print 'B = \n',B
print 'Thus, we can see thet Matrix of T in ordered basis is B'

A =
Matrix([[5, -6, -6], [-1, 4, 2], [3, -6, -4]])
Characteristic polynomial for linear operator T on R**3 will be:
f =  x**3 - 5*x**2 + 8*x - 4
or
(x-1)(x-2)**2
The minimal polynomial for T is:
p =  (x - 2)*(x - 1)
or
p = (x-1)(x-2)
So in cyclic decomposition of T, a1 will have p as its T-annihilator.
Another vector a2 that generate cyclic subspace of dimension 1 will have its T-annihilator as p2.
p2 =  x - 2
pp2 =  (x - 2)**2*(x - 1)
i.e., pp2 = f
Therefore, A is similar to B
B =
[[ 0 -2  0]
[ 1  3  0]
[ 0  0  2]]
Thus, we can see thet Matrix of T in ordered basis is B


## Page 247 Example 7.6¶

In [4]:
from numpy import array
from sympy import Symbol,Matrix

print 'A = '
print '2   0   0'
print 'a   2   0'
print 'b   c   -1'
a = 1#
b = 0#
c = 0#
A = Matrix(([2, 0, 0],[a, 2, 0],[b, c, -1]))
print 'A = \n',A
print 'Characteristic polynomial for A is:'
x=Symbol('x')
print 'p = ',A.charpoly(x).as_expr()
print 'In this case, minimal polynomial is same as characteristic polynomial.'
print '-----------------------------------------'
a = 0#
b = 0#
c = 0#
A = Matrix(([2, 0, 0],[a, 2, 0],[b, c, -1]))
print 'A = \n',A
print 'Characteristic polynomial for A is:'
x=Symbol('x')
print 'p = ',A.charpoly(x).as_expr()
print 'In this case, minimal polynomial is:',
print '(x-2)(x+1)'
print 'or'
s = (x-2)*(x+1)#
print s
print '(A-2I)(A+I) = '
print '0    0   0'
print '3a   0   0'
print 'ac   0   0'
print 'if a = 0, A is similar to diagonal matrix.'

A =
2   0   0
a   2   0
b   c   -1
A =
Matrix([[2, 0, 0], [1, 2, 0], [0, 0, -1]])
Characteristic polynomial for A is:
p =  x**3 - 3*x**2 + 4
In this case, minimal polynomial is same as characteristic polynomial.
-----------------------------------------
A =
Matrix([[2, 0, 0], [0, 2, 0], [0, 0, -1]])
Characteristic polynomial for A is:
p =  x**3 - 3*x**2 + 4
In this case, minimal polynomial is: (x-2)(x+1)
or
(x - 2)*(x + 1)
(A-2I)(A+I) =
0    0   0
3a   0   0
ac   0   0
if a = 0, A is similar to diagonal matrix.


## Page 247 Example 7.7¶

In [5]:
from numpy import array
from sympy import Symbol,Matrix
print 'A = '
print '2   0   0   0'
print '1   2   0   0'
print '0   0   2   0'
print '0   0   a   2'
print 'Considering a = 1'
A = Matrix(([2, 0 ,0 ,0],[1, 2, 0, 0],[0, 0 ,2 ,0],[0, 0, 1, 2]))
x=Symbol('x')
p = A.charpoly(x).as_expr()
print 'Characteristic polynomial for A is:'
print 'p = ',p
print 'or'
print '(x-2)**4'
print 'Minimal polynomial for A ='
print '(x-2)**2'
print 'For a = 0 and a = 1, characteristic and minimal polynomial are same.'
print 'But for a=0, the solution space of (A - 2I) has 3 dimension whereas for a = 1, it has 2 dimension. '

A =
2   0   0   0
1   2   0   0
0   0   2   0
0   0   a   2
Considering a = 1
Characteristic polynomial for A is:
p =  x**4 - 8*x**3 + 24*x**2 - 32*x + 16
or
(x-2)**4
Minimal polynomial for A =
(x-2)**2
For a = 0 and a = 1, characteristic and minimal polynomial are same.
But for a=0, the solution space of (A - 2I) has 3 dimension whereas for a = 1, it has 2 dimension.