from __future__ import division
from numpy.linalg import det,norm
from numpy import mat, add, dot, multiply, inner
u=mat([[2,3,-4]])
v=mat([[1,-5,8]])
print "u+v = ",add(u,v)
print "5*u = ",multiply(5,u)
print "-v = ",multiply(-1,v)
print "2*u-3*v = ",add(multiply(2,u),multiply(-3,v))
print 'dot product of the two vectors, k = u.v = ',inner(u,v)
l=norm(u)#
print 'norm or length of the vector u = ',round(l,4)
from __future__ import division
from numpy.linalg import det,norm
from numpy import mat, add, dot, multiply, inner
u=mat([[5],[3],[-4]])
v=mat([[3],[-1],[-2]])
print "2*u-3*v =\n",add(multiply(2,u),multiply(-3,v))
print 'The dot product of the two vectors u and v is:', sum(multiply(u,v))
l=norm(u)#
print 'norm or length of the vector u = ',round(l,4)
from __future__ import division
from numpy.linalg import det,norm
from numpy import mat, add, dot, multiply, inner
A=mat([[1,-2,3],[0,4,5]])
B=mat([[4,6,8],[1,-3,-7]])
k=add(A,B)
print 'The addition of the two matrices A and B is:\n',k
m=multiply(3,A)
print '\nThe multiplication of a vector with a scalar is:\n',m
p=add(multiply(2,A),multiply(-3,B))
print "\n2*A-3*B = \n",p
from __future__ import division
from numpy.linalg import det,norm
from numpy import mat, add, dot, multiply, inner
a=mat([[7,-4,5]])
b=mat([[3,2,-1]])
k=inner(a,b)
print 'product of a and b is : ',k
p=mat([[6,-1,8,3]])
q=mat([[4,-9,-2,5]])
l=inner(p,q)
print 'product of p and q is:',l
from __future__ import division
from numpy.linalg import det,norm
from numpy import mat, add, dot, multiply, inner
A=mat([[1 ,3],[2, -1]])
B=mat([[2, 0, -4],[5, -2, 6]])
print "A*B = \n", dot(A,B)
A=mat([[1, 2],[3, 4]])
B=mat([[5, 6],[0, -2]])
print "A*B = \n",dot(A,B)
print "B*A = \n", dot(B,A)
print 'matrix mulitplication is not commutative since AB may not be equal to BA'
from __future__ import division
from numpy.linalg import det,norm
from numpy import mat, add, dot, multiply, inner
from numpy import identity as idt
A=mat([[1, 2],[3, -4]])
A2=dot(A,A) #multiplying A by itself
A3=dot(A2,A)
f=add(add(multiply(2,A2),multiply(-3,A)),multiply(5,idt(2)))
print 'for the function f(x)=2x**2-3x+5,f(A) is :\n',f
g=add(add(A2,multiply(3,A)),multiply(-10,idt(2)))
print 'for the function g(x)=x**2+3x-10,g(A) is\n',g
from __future__ import division
from numpy.linalg import det,norm
from numpy import mat, add, dot, multiply, inner
A=mat([[1 ,0 ,2],[2 ,-1, 3],[4, 1, 8]])
B=mat([[-11, 2 ,2],[-4, 0 ,1],[6, -1, -1]])
print "A*b = \n",dot(A,B)
print 'since A*B is identity matrix,A and B are invertible and inverse of each other'
from __future__ import division
from numpy.linalg import det,norm
from numpy import mat, add, dot, multiply, inner
A=mat([[5 ,4],[2, 3]])
print 'determinant of A',det(A)
B=mat([[2, 1],[-4, 6]])
print 'determinant of B',det(B)
C=mat([[2, 1, 3],[4, 6, -1],[5 ,1 ,0]])
print 'determinant of C',det(C)
from __future__ import division
from numpy.linalg import det,norm,solve
from numpy import mat, add, dot, multiply, inner,divide
A=mat([[1, 2, 1],[2, 5, -1],[3, -2, -1]]) #left hand side of the system of equations
B=mat([[3] ,[-4] ,[5]]) #right hand side or the constants in the equations
X=divide(A,B) # #unique solution for the system of equations
X = solve(A, B)
print "x = ",X[0]
print "y = ",X[1]
print "z = ",X[2]
from __future__ import division
from numpy import mat
A=mat([[1 ,0 ,2],[2, -1, 3],[4, 1, 8]])
A_inv = A**-1
print "Inverse of A = \n", A_inv