import sympy
a = sympy.Symbol('a')
h = sympy.Symbol('h')
g = sympy.Symbol('g')
b = sympy.Symbol('b')
f = sympy.Symbol('f')
c = sympy.Symbol('c')
A = sympy.Matrix([[a,h,g],[h,b,f],[g,f,c]])
print "Determinant of A is: ", A.det()
import numpy
A = numpy.array([[0,1,2,3],[1,0,3,0],[2,3,0,1],[3,0,1,2]])
print "Determinant of a is:",numpy.linalg.det(A)
import numpy
import sympy
a = sympy.Symbol('a');
b = sympy.Symbol('b');
c = sympy.Symbol('c');
A = sympy.Matrix([[a,a**2,a**3-1],[b,b**2,b**3-1],[c,c**2,c**3-1]])
print A.det()
import numpy
A = numpy.array([[21,17,7,10],[24,22,6,10],[6,8,2,3],[6,7,1,2]])
print "Determinanat of a is:",numpy.linalg.det(A)
import sympy
x = sympy.Symbol('x');
y = sympy.Symbol('y')
u = x**y
a = sympy.diff(u, y)
b = sympy.diff(a, x)
c = sympy.diff(b, x)
d = sympy.diff(u, x)
e = sympy.diff(d, y)
f = sympy.diff(e, x)
print "a: ", a
print "b: ", b
print "c: ", c
print "d: ", d
print "e: ", e
print "f: ", f
print "Clearly c = f"
import numpy
A = numpy.array([[1,3,0],[-1,2,1],[0,0,2]])
B = numpy.array([[2,3,4],[1,2,3],[-1,1,2]])
ma = numpy.matrix(A)
mb = numpy.matrix(B)
print "A*B="
print ma*mb
print ""
print "B*A="
print mb*ma
print "Clearly AB is not equal to BA"
import numpy
A = numpy.matrix([[3,2,2],[1,3,1],[5,3,4]])
C = numpy.matrix([[3,4,2],[1,6,1],[5,6,4]])
print "AB=C−−>B=inv(A)∗C"
print ""
B = numpy.linalg.inv(A)*C
print B
import numpy
A = numpy.array([[1,3,2],[2,0,-1],[1,2,3]])
I = numpy.eye(3)
A = numpy.matrix(A)
print "Aˆ3−4∗Aˆ2−3A+11*I="
print ""
print A**3-4*A**2-3*A+11*I
import numpy
0
A = numpy.matrix([[11,-25],[4, -9]])
n = int(raw_input("Enter the value of n: "))
print "Calculating A ^ n: "
print A**n
import numpy
A = numpy.matrix([[1,1,3],[1,3,-3],[-2,-4,-4]])
print "Inverse of A is: "
print numpy.linalg.inv(A)
import numpy
A = numpy.matrix([[1,2,3],[1,4,2],[2,6,5]])
print "Rank of A is:",numpy.linalg.matrix_rank(A)
import numpy
A = numpy.matrix([[0,1,-3,-1],[1,0,1,1],[3,1,0,2],[1,1,-2,0]])
print "Rank of A is:",numpy.linalg.matrix_rank(A)
import numpy
A = numpy.matrix([[1,1,3],[1,3,-3],[-2,-4,-4]])
print "Inverse of A is: "
print numpy.linalg.inv(A)
import numpy
A = numpy.matrix([[2,3,-1,-1],[1,-1,-2,-4],[3,1,3,-2],[6,3,0,-7]])
r,p = numpy.linalg.eigh ( A )
print "Rank of A is:",numpy.linalg.matrix_rank(A)
import numpy
A = numpy.matrix([[1,1,1],[4,3,-1],[3,5,3]])
print "Inverse of A is: "
print numpy.linalg.inv(A)
import numpy
print "The equations can be rewritten as AX=B where X=[ x1 ; x2 ; x3 ; x4 ] and "
A = numpy.matrix([[1,-1,1,1],[1,1,-1,1],[1,1,1,-1],[1,1,1,1]])
B = numpy.matrix([[2],[-4],[4],[0]])
print "Determinant of A="
print numpy.linalg.det(A)
print "Inverse of A ="
print numpy.linalg.inv(A)
print "X=",numpy.linalg.inv(A)*B
import numpy
print "The equations can be rewritten as AX=B where X=[x;y;z] and"
A = numpy.matrix([[5,3,7],[3,26,2],[7,2,10]])
B = numpy.matrix([[4],[9],[5]])
print "Determinant of A="
print numpy.linalg.det(A)
print "Since det(A)=0 , hence, this system of equation will have infinite solutions.. hence, the system is consistent"
import numpy
A = numpy.matrix([[1,2,3],[3,4,4],[7,10,12]])
p = numpy.linalg.matrix_rank(A)
print "Rank of A is",p
if p==3:
print "Equations have only a trivial solution : x=y=z=0"
else:
print "Equations have infinite no . of solutions."
import numpy
A = numpy.matrix([[4,2,1,3],[6,3,4,7],[2,1,0,1]])
p = numpy.linalg.matrix_rank(A)
print "Rank of A is",p
if p ==4:
print "Equations have only a trivial solution : x=y=z=0"
else:
print "Equations have infinite no. of solutions."
import numpy
print "The given equations can be written as Y=AX where"
A = numpy.matrix([[2,1,1],[1,1,2],[1,0,-2]])
print "Determinant of A is",numpy.linalg.det ( A )
print "Since, its non−singular, hence transformation is regular"
print"Inverse of A is"
print numpy.linalg.inv ( A )
import numpy
A = numpy.matrix([[-2./3,1./3,2./3],[2./3,2./3,1./3],[1./3,-2./3,2./3]])
print A
print "A transpose is equal to"
print A.transpose()
print "A∗(transpose of A)="
print A*A.transpose()
print "Hence, A is orthogonal"
import numpy
import math
A = numpy.matrix([[5,4],[1,2]])
print "Let R represents the matrix of transformation and P represents a diagonal matrix whose values are the eigenvalues of A. then"
P,R= numpy.linalg.eig(A)
U = numpy.zeros([2, 2])
print "R is normalised. let U represents unnormalised version of r"
U[0,0]= R[0,0]*math.sqrt(17)
U[0,1]= R[0,1]*math.sqrt(17)
U[0,1]= R[1,1]*math.sqrt(2)
print "Two eigen vectors are the two columns of U"
print U
import numpy,math
A = numpy.matrix([[1,1,3],[1,5,1],[3,1,1]])
U = numpy.zeros([3,3])
print "Let Rrepresents the matrix of transformation and Prepresents a diagonalmatrix whose values are the eigenvalues of A. then"
R,P = numpy.linalg.eig(A)
print "R is normalised. let U represents unnormalised version of r"
print R
U[0,0] = R[0]*math.sqrt(2)
U[0,1] = R[1]*math.sqrt(3)
U[0,2] = R[2]*math.sqrt(6)
print "Three eigen vectors are the three columns of U"
print U
import numpy,math
A = numpy.matrix([[3,1,4],[0,2,6],[0,0,5]])
U = numpy.zeros([3,3])
print "Let Rrepresents the matrix of transformation and Prepresents a diagonalmatrix whose values are the eigenvalues of A. then"
R,P = numpy.linalg.eig(A)
print "R is normalised. let U represents unnormalised version of r"
print R
U[0,0] = R[0]*math.sqrt(1)
U[0,1] = R[1]*math.sqrt(1)
U[0,2] = R[2]*math.sqrt(14)
print "Three eigen vectors are the three columns of U"
print U
import numpy
x = numpy.poly([0])
A = numpy.matrix([[1,4],[2,3]])
I = numpy.eye(2)
print "Eigen values of A are"
print numpy.linalg.eig(A)
print "Let"
a = -1;
b = 5;
print "Hence, the characteristic equation is ( x−a ) ( x−b)"
print ( x - a ) *( x - b )
print "Aˆ2−4∗A−5∗ I="
print A**2-4*A-5* I
print "Inverse of A="
print numpy.linalg.inv ( A )
import numpy
x = numpy.poly([0])
A = numpy.matrix([[1,1,3],[1,3,-3],[-2,-4,-4]])
print "Egenvalues of A are"
print numpy.linalg.eig(A)
print "Let"
a =4.2568381
b =0.4032794
c = -4.6601175
print "Hence, the characteristic equation is ( x−a ) ( x−b) ( x−c )"
p = (x-a)*(x-b)*(x-c)
print p
print "Inverse of A="
print numpy.linalg.inv(A)
import numpy
x = numpy.poly([0])
A = numpy.matrix([[2,1,1],[0,1,0],[1,1,2]])
I = numpy.eye(3)
print "Eigenvalues of A are"
print numpy.linalg.eig(A)
print "Let"
a =1
b =1
c =3
print "Hence, the characteristic equation is (x−a)(x−b)(x−c)="
p = (x-a)*(x-b)*(x-c)
print p
print "Aˆ8−5∗Aˆ7+7∗Aˆ6−3∗Aˆ5+Aˆ4−5∗Aˆ3+8∗Aˆ2−2∗A+I ="
print A**8-5*A**7+7*A**6-3*A**5+A**4-5*A**3+8*A**2-2*A+I
import numpy
A = numpy.matrix([[-1,2,-2],[1,2,1],[-1,-1,0]])
print "R is matrix of transformation and D is a diagonal matrix"
[R,D]= numpy.linalg.eigh(A)
print R
print D
import numpy,math
A = numpy.matrix([[3,1,4],[0,2,6],[0,0,5]])
P = numpy.zeros([3,3])
print "R is matrix of transformation and D is a diagonal matrix"
R,D = numpy.linalg.eig(A)
print "R is normalised, let P denotes unnormalised version of R . Then "
print R
P[0,0] = R[0]*math.sqrt(2)
P[0,1] = R[1]*math.sqrt(3)
P[0,2] = R[2]*math.sqrt(6)
print P
print "A^4= ",A**4
import numpy
print "3∗xˆ2+5∗yˆ2+3∗zˆ2−2∗y∗z+2∗z∗x−2∗x∗y"
print "The matrix of the given quadratic form is"
A = numpy.matrix([[3,-1,1],[-1,5,-1],[1,-1,3]])
print "Let R represents the matrix of transformation and Prepresents a diagonal matrix whose values are the eigenvalues of A. then"
[R,P] = numpy.linalg.eig(A)
print "So, canonical form is 2∗xˆ2+3∗yˆ2+6∗zˆ2"
import numpy
print "2∗x1∗x2+2∗x1∗x3−2∗x2∗x3"
print "The matrix of the given quadratic form is"
A = numpy.matrix([[0,1,1],[1,0,-1],[1,-1,0]])
print "Let R represents the matrix of transformation and P represents a diagonal matrix whose values are the eigenvalues of A. then"
[R,P] = numpy.linalg.eig(A)
print "so, canonical form is −2∗xˆ2+yˆ2+ zˆ2"
import numpy
'''
A=[2+%i 3 -1+3*%i;-5 %i 4-2*%i]
'''
A = numpy.matrix([[2+1j,3,-1+3*1j],[-5,1j,4-2*1j]])
#A = A.getH()
print "A∗=", A.getH()
print "AA∗=", A*(A.getH())
print "Clearly, AA∗ is hermitian matrix"
import numpy
A = numpy.matrix([[(1/2)*(1+1j),(1/2)*(-1+1j)],[(1/2)*(1+1j),(1/2)*(1-1j)]])
print "A∗=", A.getH()
print "AA∗=", A*(A.getH())
print "A∗A=", (A.getH())*A
import numpy
A = numpy.matrix([[0,1+2*1j],[-1+2*1j,0]])
I = numpy.eye(2)
print "I−A="
I-A
print "inverse of (I+A)="
print numpy.linalg.inv(I+A)
print "((I−A)(inverse(I+A)))∗((I−A)(inverse(I+A)))="
print (((I-A)*(numpy.linalg.inv(I+A))).T)*((I-A)*(numpy.linalg.inv(I+A)))
print "((I−A)(inverse(I+A)))((I−A)(inverse(I+A)))∗="
print ((I-A)*(numpy.linalg.inv(I+A)))*(((I-A)*(numpy.linalg.inv(I+A))).T)
print "Clearly, the product is an identity matrix.hence, it is a unitary matrix"