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 [4]:
rot.det()
Out[4]:
In [5]:
rot.inv()
Out[5]:
In [6]:
rot.singular_values()
Out[6]:
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 [14]:
rot[0, 0]
Out[14]:
In [15]:
rot[:, 0]
Out[15]:
In [17]:
rot[1, :]
Out[17]:
In [18]:
rot[0, 0] += 1
rot
Out[18]:
In [19]:
simplify(rot.det())
Out[19]:
In [20]:
rot.singular_values()
Out[20]:
In [21]:
# Play with matrices