Guide

Component guide

A live reference and regression test for lesson-authoring components.

Motivation

A vector is an element of a vector space. Its norm is ∥x∥2=x⊤x\norm{\vb{x}}_2 = \sqrt{\vb{x}\T\vb{x}} and its SVD is

A=UΣV⊤,E[X]=∫x  ⁣dP(x).\mat{A} = \mat{U}\mat{\Sigma}\mat{V}\T, \qquad \E[X] = \int x \, \dd P(x).

Sample text for checking the serif reading font, with bold, italic, and inline code. A broken reference m42.nada.

Proof

By induction on dimension nn. The n=1n = 1 case is trivial.

∎
Key idea
Every linear transformation is a rotation, a stretch, and another rotation.

Code

import numpy as np
print(np.eye(2))
[ ]First cellBrowser
import numpy as np
A = np.array([[2.0, 1.0], [1.0, 3.0]])
w, V = np.linalg.eigh(A)
print("eigenvalues:", w)
A @ V
[ ]Figure with matplotlibBrowser
import matplotlib.pyplot as plt
t = np.linspace(0, 2*np.pi, 200)
plt.plot(np.cos(t), np.sin(t), label="circle")
plt.plot(*(A @ np.vstack([np.cos(t), np.sin(t)])), label="A · circle")
plt.axis("equal"); plt.legend(); plt.title("Image of the unit circle")
plt.show()
[ ]On the GPULocal GPU
import torch
torch.cuda.is_available()
This cell needs the local lab (PyTorch with your GPU). Start it with npm run lab and open the connection link.
∥x∥2=x⊤x\norm{\vb{x}}^2 = \vb{x}\T\vb{x}
Definition of the Euclidean norm.
1/3
Quiz
What is the rank of (1224)\begin{pmatrix}1 & 2\\ 2 & 4\end{pmatrix}?
Numeric
Calculate ∥(3,4)∥2\norm{(3, 4)}_2.
Code
Implement norma(x) to return the Euclidean norm without using np.linalg.norm.
def norma(x):
  # your code here
  pass
Shift+Enter to run
Proof
Prove: If A\mat{A} is symmetric, x⊤Ay=y⊤Ax\vb{x}\T\mat{A}\vb{y} = \vb{y}\T\mat{A}\vb{x}.
0
Let A=A⊤\mat{A} = \mat{A}\T and x,y∈Rn\vb{x}, \vb{y} \in \R^n.

Step 1 of 3. What do we know about a scalar?

MethodCostStable
LUO(n3)\bigO(n^3)with pivoting
QRO(n3)\bigO(n^3)yes