Linear Algebra
Table of Contents
$$
\begin{align*}
4x_{1} − 5x_{2} &= −13\\
−2x_{1} + 3x_{2} &= 9
\end{align*}
$$
Won’t worry here about how to compute inverse, but it’s very siminp.linargr to the standard method for solving linear equations
We will use a numpy
to compute
import numpy as np
A = np.array([[4, -5],[-2, 3]])
print(A)
A = np.array([[4, -5],
[-2, 3]])
print(A)
A[0]
A[1]
A[0,1]
A[0][1]
b = np.array([[-13],[9]])
print(b)
$A^{-1} b$: matrix multiplication
x = np.linalg.inv(A).dot(b)
print(x)
x = np.linalg.inv(A) @ b
print(x)
A = np.asmatrix(A)
b = np.asmatrix(b)
x = A.I*b
print(x)
x = np.array([[1],
[1]])
y = np.array([[2],
[3]])
a = x.T.dot(y)
print(a) # double list
print(a[0]) # list
print(a[0][0]) # scalar or number
print(x.T @ y)
x = np.asmatrix(x)
y = np.asmatrix(y)
print(x.T*y)
A vector norm is any function $f : \mathbb{R}^{n} \rightarrow \mathbb{R}$ with
x = np.array([[4],
[3]])
np.linalg.norm(x, 2)
np.linalg.norm(x, 1)
$$
\begin{bmatrix}
a_{11} & a_{12}\\
a_{21} & a_{22}\\
\end{bmatrix}
\begin{bmatrix}
x_{1}\\
x_{2}
\end{bmatrix} =
\begin{bmatrix}
b_{1}\\
b_{2}\\
\end{bmatrix}
$$
$$
\begin{bmatrix}
a_{11} & a_{12}\\
\end{bmatrix}
\begin{bmatrix}
x_{1}\\
x_{2}
\end{bmatrix}=b_1
$$
$$
\begin{bmatrix}
a_{11} & a_{12}\\
a_{21} & a_{22}\\
a_{31} & a_{32}\\
\end{bmatrix}
\begin{bmatrix}
x_{1}\\
x_{2}
\end{bmatrix} =
\begin{bmatrix}
b_{1}\\
b_{2}\\
b_{3}\\
\end{bmatrix}
$$
Find $X$ that minimizes $\lVert E \rVert$ or $\lVert E \rVert^2$
i.e. optimization problem
Projection of $B$ onto a subspace $U$ of span of $A_1$ and $A_2$
Orthogonality
import numpy as np
A = np.matrix([[1,0],
[0,1],
[0,0]])
B = np.matrix([[1],
[1],
[1]])
X = (A.T*A).I*A.T*B
print(X)
Bstar = A*X
print(Bstar)
%%html
<center><iframe src="https://www.youtube.com/embed/oUatnjbSr7k?rel=0"
width="420" height="315" frameborder="0" allowfullscreen></iframe></center>
%%html
<center><iframe src="https://www.youtube.com/embed/tZVSMKFldkg?rel=0"
width="420" height="315" frameborder="0" allowfullscreen></iframe></center>
%%html
<center><iframe src="https://www.youtube.com/embed/OYGdbnvrlFU?rel=0"
width="420" height="315" frameborder="0" allowfullscreen></iframe></center>
%%html
<center><iframe src="https://www.youtube.com/embed/ndxMENgjk8M?rel=0"
width="420" height="315" frameborder="0" allowfullscreen></iframe></center>
%%html
<center><iframe src="https://www.youtube.com/embed/3Vs3UKwQJp0?rel=0"
width="420" height="315" frameborder="0" allowfullscreen></iframe></center>
%%html
<center><iframe src="https://www.youtube.com/embed/aT6dlUIHCgo?rel=0"
width="420" height="315" frameborder="0" allowfullscreen></iframe></center>
%%html
<center><iframe src="https://www.youtube.com/embed/K63Eh-eONH8?rel=0"
width="420" height="315" frameborder="0" allowfullscreen></iframe></center>
%%javascript
$.getScript('https://kmahelona.github.io/ipython_notebook_goodies/ipython_notebook_toc.js')