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
xxxxxxxxxx
md"# Notebook 5 -- Math 2121, Fall 2020
Helper methods
xxxxxxxxxx
md"##### Helper methods"
pprint (generic function with 1 method)
xxxxxxxxxx
function pprint(tagx, tagy, rx, ry)
mesh_inputs (generic function with 1 method)
xxxxxxxxxx
function mesh_inputs(n, x, y)
input_plot (generic function with 1 method)
xxxxxxxxxx
function input_plot(rx, ry, inputs, title)
transformation_plot (generic function with 2 methods)
xxxxxxxxxx
function transformation_plot(U, x, y, mesh_inputs, title, lims=(-2,2))
Creating a linear transformation from
xxxxxxxxxx
md"##### Creating a linear transformation from $\mathbb{R}^1 \to \mathbb{R}^2$"
random_linear_transformation (generic function with 1 method)
xxxxxxxxxx
function random_linear_transformation(;n, m)
#2 (generic function with 1 method)
xxxxxxxxxx
T = random_linear_transformation(n=1, m=2)
Input in
x
=
xxxxxxxxxx
begin
xxxxxxxxxx
begin
0.1
-1.0
xxxxxxxxxx
# A = T([1])
T([1])
true
xxxxxxxxxx
T([x]) == x * T([1])
The pictures above show a random linear transformation
When we vary the input value
Changing
If
xxxxxxxxxx
md"The pictures above show a random linear transformation $T: \mathbb{R}^1 \to \mathbb{R}^2$.
Creating a linear transformation from
xxxxxxxxxx
md"##### Creating a linear transformation from $\mathbb{R}^2\to \mathbb{R}^2$"
#2 (generic function with 1 method)
xxxxxxxxxx
U = random_linear_transformation(n=2, m=2)
Display: sum
mesh
xxxxxxxxxx
md"""**Display**:
Input vectors in
x1
= y1
=
x2
= y2
=
rotate =
xxxxxxxxxx
begin
x = [ 1.0] y = [ 0.0]
[ 0.0] [ 1.0]
xxxxxxxxxx
begin
U(x) = [ 0.8] U(y) = [ 0.2]
[-0.2] [-0.3]
xxxxxxxxxx
pprint("U(x)", "U(y)", U(rx), U(ry))
xxxxxxxxxx
2×2 Array{Float64,2}:
0.8 0.2
-0.2 -0.3
xxxxxxxxxx
hcat(U([1; 0]), U([0; 1]))
true
xxxxxxxxxx
x1 * 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
xxxxxxxxxx
md"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
=
xxxxxxxxxx
begin
2×2 Array{Int64,2}:
1 0
0 1
xxxxxxxxxx
A = [a11 a12; a21 a22]
xxxxxxxxxx
Input vectors in
x1
= y1
=
x2
= y2
=
rotate =
xxxxxxxxxx
begin
x = [ 1.0] y = [ 0.0]
[ 0.0] [ 1.0]
xxxxxxxxxx
begin
xxxxxxxxxx
Nonlinear transformations
Finally, let's compare with plots of functions
xxxxxxxxxx
md"##### Nonlinear transformations
random_quadratic_transformation (generic function with 1 method)
xxxxxxxxxx
function random_quadratic_transformation(n, m)
(::Main.workspace741.var"#f#8"{Int64,Int64,Array{Array{Float64,2},1}}) (generic function with 1 method)
xxxxxxxxxx
Q = random_quadratic_transformation(2, 2)
Input vectors in
x1
= y1
=
x2
= y2
=
rotate =
xxxxxxxxxx
begin
x = [ 1.0] y = [ 0.0]
[ 0.0] [ 1.0]
xxxxxxxxxx
begin
Q(x) = [-0.18] Q(y) = [ 1.13]
[ 1.91] [-1.68]
xxxxxxxxxx
pprint("Q(x)", "Q(y)", Q(qrx), Q(qry))
xxxxxxxxxx
Note that parallelograms are not preserved by this transformation.
xxxxxxxxxx
md"Note that parallelograms are not preserved by this transformation."