from numpy import array,identity
from sympy import Symbol
print 'C is the field of complex numbers'
x = Symbol("x")
def f(x):
ff= x**2 + 2
return ff
print 'f = ',f(x)
#part a
print 'if a = C and z belongs to C, then f(z) = z**2 + 2'
print 'f(2) = ',f(2)
print 'f(1+1J/1-1J) = ',f((1+1J)/(1-1J))
print '----------------------------------------'
#part b
print 'If a is the algebra of all 2*2 matrices over C and'
B = array([[1 ,0],[-1, 2]])
print 'B = \n',B
print 2*identity(2) + B**2,'then, f(B) = '
print '----------------------------------------'
#part c
print 'If a is algebra of all linear operators on C**3'
print 'And T is element of a as:'
print 'T(c1,c2,c3) = (i*2**1/2*c1,c2,i*2**1/2*c3)'
print 'Then, f(T)(c1,c2,c3) = (0,3*c2,0)'
print '----------------------------------------'
#part d
print 'If a is the algebra of all polynomials over C'
def g(x):
gg= x**4 + 3*1J
return gg
print 'And, g = ',g(x)
print 'Then f(g) = ',g(2)
from sympy import Symbol
x = Symbol('x')
p1 = x + 2#
p2 = x**2 + 8*x + 16#
print 'M = (x+2)F[x] + (x**2 + 8x + 16)F[x]'
print 'We assert, M = F[x]'
print 'M contains:',
t = p2 - x*p1#
print t
print 'And hence M contains:',
print t - 6*p1
print 'Thus the scalar polynomial 1 belongs to M as well all its multiples.'
from sympy import Symbol
x = Symbol('x')
#part a
p1 = x + 2#
p2 = x**2 + 8*x + 16#
print 'p1 = ',p1
print 'p2 = ',p2
print 'M = (x+2)F[x] + (x**2 + 8x + 16)F[x]'
print 'We assert, M = F[x]'
print 'M contains:',
t = p2 - x*p1#
print t
print 'And hence M contains:',
print t - 6*p1
print 'Thus the scalar polynomial 1 belongs to M as well all its multiples'
print 'So, gcd(p1,p2) = 1'
print '----------------------------------------------'
#part b
p1 = (x - 2)**2*(x+1J)#
p2 = (x-2)*(x**2 + 1)#
print 'p1 = ',p1
print 'p2 = ',p2
print 'M = (x - 2)**2*(x+1J)F[x] + (x-2)*(x**2 + 1'
print 'The ideal M contains p1 - p2 i.e.,',
print p1 - p2
print 'Hence it contains (x-2)(x+i), which is monic and divides both,'
print 'So, gcd(p1,p2) = (x-2)(x+i)'
print '----------------------------------------------'
from sympy import Symbol
x = Symbol('x')
print 'M is the ideal in F[x] generated by:'
print '(x-1)*(x+2)**2'
print '(x+2)**2*(x+3)'
print '(x-3)','and'
p1 = (x-1)*(x+2)**2#
p2 = (x+2)**2*(x-3)#
p3 = (x-3)#
print 'M = (x-1)*(x+2)**2 F[x] + (x+2)**2*(x-3) + (x-3)'
print 'Then M contains:',
t = 1/2*(x+2)**2*((x-1) - (x-3))#
print t
print 'i.e., M contains (x+2)**2'
print 'and since, (x+2)**2 = (x-3)(x-7) - 17'
print 'So M contains the scalar polynomial 1.'
print 'So, M = F[x] and given polynomials are relatively prime.'
from sympy import Symbol
x = Symbol('x')
P = x**2 + 1#
print P,'P = '
print 'P is reducible over complex numbers as: ',
print '=',P
print '(x-i)(x+i)'
print 'Whereas, P is irreducible over real numbers as:',
print '=',P
print '(ax + b)(a''x + b'')'
print 'For, a,a'',b,b'' to be in R,'
print 'aa'' = 1'
print 'ab'' + ba'' = 0'
print 'bb'' = 1'
print '=> a**2 + b**2 = 0'
print '=> a = b = 0'