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'
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.'
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. '