In [ ]:
In [ ]:
In [49]:
# Recall the linear transformation P we constructed above
M_P = Matrix([[1,1],
[1,1]])/2
def P(vec):
"""Compute the projection of vector `vec` onto line y=x."""
return M_P*vec
In [50]:
# null space of M_P == kernel of P
M_P.nullspace()
Out[50]:
In [51]:
# any vector from the null space gets mapped to the zero vector
n = M_P.nullspace()[0]
P(n)
Out[51]:
In [52]:
# column space of M_P == image of P
M_P.columnspace()
Out[52]:
In [53]:
# all outputs of P lie on the line y=x so are multiples of [1,1]
v = Vector([4,5])
P(v)
Out[53]:
The above examples consist of a single vector, but in general a vector space can consist of linear combination of multiple vectors:
$$ V = \textrm{span}(\vec{v}_1, \vec{v}_2 ) = \{ \alpha\vec{v}_1 + \beta\vec{v}_2, \forall \alpha, \beta \in \mathbb{R} \}. $$When a matrix is multiplied by one of its eigenvectors the output is the same eigenvector multiplied by a constant
$$ A\vec{e}_\lambda =\lambda\vec{e}_\lambda. $$The constant $\lambda$ is called an eigenvalue of $A$.
In [ ]:
# Recall the P, the projection onto the y=x plane and its matrix M_P
M_P
In [ ]:
M_P.eigenvals()
In [ ]:
M_P.eigenvects()
In [ ]:
evec0 = M_P.eigenvects()[0][2][0]
evec1 = M_P.eigenvects()[1][2][0]
plot_line([1,1],[0,0])
plot_vecs(evec0, evec1)
In [ ]:
M_P*evec0 # == 0*evec0
In [ ]:
M_P*evec1 # == 1*evec1
In [ ]:
In [ ]:
# diagonal
D = Matrix([[1,0],
[0,4]])
D
In [ ]:
# upper triangular
U = Matrix([[1,2],
[0,3]])
U
In [ ]:
# symmetric
S = Matrix([[1,2],
[2,3]])
S == S.T
In [ ]:
A = Matrix([ [4,2],
[1,3] ])
A
In [ ]:
# decompose matrix into eigenvectors and eigenvalues
Q, Lambda = A.diagonalize()
Q, Lambda, simplify( Q*Lambda*Q.inv() )
In [ ]:
# decompoe matrix A into a lower-triangular and upper triangular
L, U, _ = A.LUdecomposition()
L, U, L*U
In [ ]:
Q, R = A.QRdecomposition()
Q, R, Q*R
In [ ]:
Q*Q.T
In [ ]:
# Finite field of two elements F_2 = {0,1} (Binary numbers)
(1+6) % 2
# applications to cryptography, error correcting codes, etc.
In [ ]:
# Complex field z = a+bi, where i = sqrt(-1)
v = Vector([1, I])
v
In [ ]:
v.H
In [ ]:
# used in communication theory and quantum mechanics