Notebook 5 – Math 2121, Fall 2020
In today's notebook we'll explore the plots of some linear transformations.
Running this notebook (optional)
If you have Pluto up and running, you can access the notebook we are currently viewing by entering this link (right click -> Copy Link) in the Open from file menu in Pluto.
Linear transformations
A linear transformation
If you have an
Does every linear transformation arise in this way? (Yes.)
Can a linear transformation have more than one standard matrix? (No.)
Given a linear transformation, how do you find its standard matrix?
Let's investigate these questions when
xxxxxxxxxxmd"# Notebook 5 -- Math 2121, Fall 2020Helper methods
xxxxxxxxxxmd"##### Helper methods"pprint (generic function with 1 method)xxxxxxxxxxfunction pprint(tagx, tagy, rx, ry)mesh_inputs (generic function with 1 method)xxxxxxxxxxfunction mesh_inputs(n, x, y)input_plot (generic function with 1 method)xxxxxxxxxxfunction input_plot(rx, ry, inputs, title)transformation_plot (generic function with 2 methods)xxxxxxxxxxfunction transformation_plot(U, x, y, mesh_inputs, title, lims=(-2,2))Creating a linear transformation from
xxxxxxxxxxmd"##### Creating a linear transformation from $\mathbb{R}^1 \to \mathbb{R}^2$"random_linear_transformation (generic function with 1 method)xxxxxxxxxxfunction random_linear_transformation(;n, m)#2 (generic function with 1 method)xxxxxxxxxxT = random_linear_transformation(n=1, m=2)Input in
x =
xxxxxxxxxxbegin xxxxxxxxxxbegin0.1
-1.0
xxxxxxxxxx# A = T([1])T([1])truexxxxxxxxxxT([x]) == x * T([1])The pictures above show a random linear transformation
When we vary the input value
Changing
If
xxxxxxxxxxmd"The pictures above show a random linear transformation $T: \mathbb{R}^1 \to \mathbb{R}^2$. Creating a linear transformation from
xxxxxxxxxxmd"##### Creating a linear transformation from $\mathbb{R}^2\to \mathbb{R}^2$"#2 (generic function with 1 method)xxxxxxxxxxU = random_linear_transformation(n=2, m=2)Display: sum mesh
xxxxxxxxxxmd"""**Display**: Input vectors in
x1 = y1 =
x2 = y2 =
rotate =
xxxxxxxxxxbeginx = [ 1.0] y = [ 0.0]
[ 0.0] [ 1.0]xxxxxxxxxxbeginU(x) = [ 0.8] U(y) = [ 0.2]
[-0.2] [-0.3]xxxxxxxxxxpprint("U(x)", "U(y)", U(rx), U(ry))xxxxxxxxxx2×2 Array{Float64,2}:
0.8 0.2
-0.2 -0.3xxxxxxxxxxhcat(U([1; 0]), U([0; 1]))truexxxxxxxxxxx1 * U([1; 0]) + x2 * U([0; 1]) == U([x1; x2])The pictures above show a random linear transformation
The key property of this transformation is that it preserves parallelograms: the output of all points in the parallelogram with sides
Another crucial aspect of linear transformations is that if
We can test this for
xxxxxxxxxxmd"The pictures above show a random linear transformation $U: \mathbb{R}^2 \to \mathbb{R}^2$. The key property of this transformation is that it preserves parallelograms: the output of all points in the parallelogram with sides $x$ and $y$ is just the parallelogram with sides $U(x)$ and $U(y)$.Another crucial aspect of linear transformations is that if $U_1 : \mathbb{R}^m \to \mathbb{R}^p$ and $U_2 : \mathbb{R}^n \to \mathbb{R}^m$ are both linear, then the function $U(x) = U_1(U_2(x))$ is a linear transformation $U : \mathbb{R}^n \to \mathbb{R}^p$. We can test this for $n=m=p=2$."Creating a linear transformation from a matrix
A_11 = A_12 =
A_21 = A_22 =
xxxxxxxxxxbegin2×2 Array{Int64,2}:
1 0
0 1xxxxxxxxxxA = [a11 a12; a21 a22]xxxxxxxxxxInput vectors in
x1 = y1 =
x2 = y2 =
rotate =
xxxxxxxxxxbeginx = [ 1.0] y = [ 0.0]
[ 0.0] [ 1.0]xxxxxxxxxxbeginxxxxxxxxxxNonlinear transformations
Finally, let's compare with plots of functions
xxxxxxxxxxmd"##### Nonlinear transformationsrandom_quadratic_transformation (generic function with 1 method)xxxxxxxxxxfunction random_quadratic_transformation(n, m)(::Main.workspace741.var"#f#8"{Int64,Int64,Array{Array{Float64,2},1}}) (generic function with 1 method)xxxxxxxxxxQ = random_quadratic_transformation(2, 2)Input vectors in
x1 = y1 =
x2 = y2 =
rotate =
xxxxxxxxxxbeginx = [ 1.0] y = [ 0.0]
[ 0.0] [ 1.0]xxxxxxxxxxbeginQ(x) = [-0.18] Q(y) = [ 1.13]
[ 1.91] [-1.68]xxxxxxxxxxpprint("Q(x)", "Q(y)", Q(qrx), Q(qry))xxxxxxxxxxNote that parallelograms are not preserved by this transformation.
xxxxxxxxxxmd"Note that parallelograms are not preserved by this transformation."