from edumath.linear_algebra import matrix_vector_product
A = [[1, 1], [0, 1]]
v = [2, 3]
print(matrix_vector_product(A, v))[5. 3.]
A linear transformation is a function that takes vectors as inputs and returns vectors as outputs while preserving addition and scalar multiplication. In symbols, a transformation \(T\) is linear when
\[ T(\mathbf{u}+\mathbf{v})=T(\mathbf{u})+T(\mathbf{v}) \]
and
\[ T(c\mathbf{v})=cT(\mathbf{v}). \]
Matrices are the most common way to represent linear transformations.
By the end of this lesson, you should be able to:
If
\[ A=\begin{bmatrix}2&0\\0&3\end{bmatrix}, \]
then the rule \(T(\mathbf{x})=A\mathbf{x}\) sends
\[ \begin{bmatrix}x\\y\end{bmatrix} \mapsto \begin{bmatrix}2x\\3y\end{bmatrix}. \]
So this transformation stretches horizontal coordinates by 2 and vertical coordinates by 3.
The standard basis vectors in the plane are
\[ \mathbf{e}_1=\begin{bmatrix}1\\0\end{bmatrix}, \qquad \mathbf{e}_2=\begin{bmatrix}0\\1\end{bmatrix}. \]
Every vector \(\begin{bmatrix}x\\y\end{bmatrix}\) can be written as
\[ x\mathbf{e}_1+y\mathbf{e}_2. \]
Because a linear transformation preserves combinations, once you know where \(\mathbf{e}_1\) and \(\mathbf{e}_2\) go, you know the transformation of every vector.
For a \(2\times2\) matrix, the first column is where \(\mathbf{e}_1\) goes and the second column is where \(\mathbf{e}_2\) goes.
\[ \begin{bmatrix}2&0\\0&2\end{bmatrix} \]
doubles every vector.
\[ \begin{bmatrix}1&0\\0&-1\end{bmatrix} \]
keeps \(x\) the same and flips the sign of \(y\).
\[ \begin{bmatrix}1&0\\0&0\end{bmatrix} \]
sends \((x,y)\) to \((x,0)\).
\[ \begin{bmatrix}1&1\\0&1\end{bmatrix} \]
sends \((x,y)\) to \((x+y,y)\). It slants the plane without changing horizontal levels.
Let
\[ A=\begin{bmatrix}1&0\\0&-1\end{bmatrix}. \]
Apply \(A\) to a general vector:
\[ A\begin{bmatrix}x\\y\end{bmatrix} = \begin{bmatrix}x\\-y\end{bmatrix}. \]
The \(x\)-coordinate is unchanged, and the \(y\)-coordinate changes sign. Points above the x-axis move below it, and points below move above it. This is a reflection over the x-axis.
Linear transformations always preserve:
They do not necessarily preserve length, angle, or area. Some do, but many do not.
A transformation can be linear even if it changes lengths and angles. Linearity is about preserving addition and scalar multiplication, not about preserving geometry exactly.
A matrix transformation is a rule: input vector in, output vector out. The columns show what happens to the standard basis vectors.
Guess first. If \(T(x,y)=(2x,3y)\), what happens to the point \((1,1)\)?
Guided exercise.
Let
\[ A=\begin{bmatrix}2&0\\0&3\end{bmatrix}, \qquad \mathbf{v}=\begin{bmatrix}1\\4\end{bmatrix}. \]
Compute
\[ A\mathbf{v}=\begin{bmatrix}2(1)+0(4)\\0(1)+3(4)\end{bmatrix} =\begin{bmatrix}2\\12\end{bmatrix}. \]
So the vector moves from \((1,4)\) to \((2,12)\) under the transformation.
Checkpoint. Compute \(\begin{bmatrix}1&1\\0&1\end{bmatrix}\begin{bmatrix}3\\2\end{bmatrix}\) and interpret the movement.
Guess first. For \(A=\begin{bmatrix}2&5\\1&3\end{bmatrix}\), where does \(\mathbf{e}_1\) go?
Guided exercise.
The first column tells where \(\mathbf{e}_1\) goes, and the second column tells where \(\mathbf{e}_2\) goes:
\[ \mathbf{e}_1\mapsto\begin{bmatrix}2\\1\end{bmatrix}, \qquad \mathbf{e}_2\mapsto\begin{bmatrix}5\\3\end{bmatrix}. \]
Then any vector \(\begin{bmatrix}x\\y\end{bmatrix}\) maps to \(x\) times the first column plus \(y\) times the second column.
Checkpoint. For \(A=\begin{bmatrix}0&1\\-1&0\end{bmatrix}\), find the images of \(\mathbf{e}_1\) and \(\mathbf{e}_2\).
Guess first. What does \(T(x,y)=(x,0)\) do to the plane?
Guided exercise.
The transformation \(T(x,y)=(x,0)\) keeps the horizontal coordinate and removes the vertical coordinate. Every point lands on the x-axis, so this is projection onto the x-axis.
Compare common forms:
(x, y) -> (2x, 2y) scaling by 2
(x, y) -> (x, -y) reflection over the x-axis
(x, y) -> (x, 0) projection onto the x-axis
(x, y) -> (x+y, y) horizontal shear
Checkpoint. Identify \(T(x,y)=(-x,y)\) and \(T(x,y)=(x+2y,y)\).
Guess first. Can a linear transformation send \((0,0)\) to \((1,0)\)?
Guided exercise.
Every linear transformation must satisfy \(T(\mathbf{0})=\mathbf{0}\). The rule
\[ T(x,y)=(x+1,y) \]
sends \((0,0)\) to \((1,0)\), so it cannot be linear. It is a translation, not a linear transformation.
Checkpoint. Decide whether \(T(x,y)=(3x,3y)\) can be linear, and whether \(S(x,y)=(x,y-2)\) can be linear. Use the zero-vector test.
Guess first. If a matrix doubles every vector, what happens after applying it three times?
Guided exercise.
The scaling matrix
\[ A=\begin{bmatrix}2&0\\0&2\end{bmatrix} \]
doubles every vector. Applying it three times multiplies the vector by \(2\cdot2\cdot2=8\).
Checkpoint. If \(A=\begin{bmatrix}1&0\\0&-1\end{bmatrix}\) reflects over the x-axis, what happens when you apply \(A\) twice?
Guess the geometric action from a matrix or a property.
The edumath plotting helpers create Matplotlib scenes that can be rendered in Python environments. SymPy can verify the algebra exactly.
[5. 3.]
\(\displaystyle \left[\begin{matrix}x + y\\y\end{matrix}\right]\)