In [1]:
from sympy import *
init_printing(use_latex='mathjax')
x, y, z = symbols('x,y,z')
r, theta = symbols('r,theta', positive=True)
In [2]:
rot = Matrix([[r*cos(theta), -r*sin(theta)],
[r*sin(theta), r*cos(theta)]])
rot
Out[2]:
In [3]:
rot.det()
Out[3]:
In [4]:
rot.inv()
Out[4]:
In [5]:
rot.singular_values()
Out[5]:
In [7]:
# Create a matrix and use the `.inv` method to find the inverse
In [8]:
rot * 2
Out[8]:
In [9]:
rot * rot
Out[9]:
In [10]:
v = Matrix([[x], [y]])
v
Out[10]:
In [11]:
rot * v
Out[11]:
In [12]:
M = Matrix([[1, x], [y, 1]])
M
Out[12]:
In [13]:
M.inv()
Out[13]:
Now verify that this is the true inverse by multiplying the matrix times its inverse. Do you get the identity matrix back?
In [14]:
# Multiply `M` by its inverse. Do you get back the identity matrix?
In [15]:
# Find the methods to compute eigenvectors and eigenvalues. Use these methods on `M`
In [16]:
rot[0, 0]
Out[16]:
In [17]:
rot[:, 0]
Out[17]:
In [18]:
rot[1, :]
Out[18]:
In [19]:
rot[0, 0] += 1
rot
Out[19]:
In [20]:
simplify(rot.det())
Out[20]:
In [21]:
rot.singular_values()
Out[21]:
In [22]:
# Play with matrices