# Linear Algebra/Linear Transformations

A linear transformation is an important concept in mathematics because many real world phenomena can be approximated by linear models.
Unlike a linear function, a linear transformation works on vectors as well as numbers.

## Motivations and definitions

Say we have the vector ${\begin{pmatrix}1\\0\end{pmatrix}}$ in $\mathbb {R} ^{2}$, and we rotate it through 90 degrees, to obtain the vector ${\begin{pmatrix}0\\1\end{pmatrix}}$.
Another example instead of rotating a vector, we stretch it, so a vector $\mathbf {v}$ becomes $2\mathbf {v}$, for example. ${\begin{pmatrix}2\\3\end{pmatrix}}$ becomes ${\begin{pmatrix}4\\6\end{pmatrix}}$
Or, if we look at the projection of one vector onto the x axis - extracting its x component - , e.g. from ${\begin{pmatrix}2\\3\end{pmatrix}}$ we get ${\begin{pmatrix}2\\0\end{pmatrix}}$
These examples are all an example of a mapping between two vectors, and are all linear transformations. If the rule transforming the matrix is called $T$, we often write $T\mathbf {v}$ for the mapping of the vector $\mathbf {v}$ by the rule $T$. $T$ is often called the transformation.
Note we do not always write brackets like when we write functions. However we should write brackets, especially when we want to express the mapping of the sum or the product or the combination of many vectors.

## Definitions
### Linear Operators

Suppose one has a field K, and let x be an element of that field. Let O be a function taking values from K where O(x) is an element of a field J. Define O to be a linear form if and only if:
* O(x+y)=O(x)+O(y)
* O(λx)=λO(x)

### Linear Forms

Suppose one has a vector space V, and let x be an element of that vector space. Let F be a function taking values from V where F(x) is an element of a field K. Define F to be a linear form if and only if:
* F(x+y)=F(x)+F(y)
* F(λx)=λF(x)

### Linear Transformation

This time, instead of a field, let us consider functions from one vector space into another vector space. Let T be a function taking values from one vector space V where L(V) are elements of another vector space. Define L to be a linear transformation when it:
* preserves scalar multiplication: T(λx) = λTx
* preserves addition: T(x+y) = Tx + Ty
Note that not all transformations are linear. Many simple transformations that are in the real world are also non-linear. Their study is more difficult, and will not be done here. For example, the transformation S (whose input and output are both vectors in R$^2$) defined by
$S\mathbf {x} =S{\begin{pmatrix}x\\y\end{pmatrix}}={\begin{pmatrix}xy\\\cos(y)\end{pmatrix}}$
We can learn about nonlinear transformations by studying easier, linear ones.
We often describe a transformation T in the following way
    $T:V\rightarrow W$
This means that T, whatever transformation it may be, maps vectors in the vector space V to a vector in the vector space W.
The actual transformation could be written, for instance, as
    $T{\begin{pmatrix}x\\y\end{pmatrix}}={\begin{pmatrix}x+y\\x-y\end{pmatrix}}$

## Examples and proofs

Here are some examples of some linear transformations. At the same time, let's look at how we can prove that a transformation we may find is linear or not.

### Projection

Let us take the projection of vectors in R$^2$ to vectors on the x-axis. Let's call this transformation T.
We know that T maps vectors from R$^2$ to R$^2$, so we can say
    $T:\mathbb {R} ^{2}\rightarrow \mathbb {R} ^{2}$
and we can then write the transformation itself as
    $T{\begin{pmatrix}x_{0}\\x_{1}\end{pmatrix}}={\begin{pmatrix}x_{0}\\0\end{pmatrix}}$
Clearly this is linear. (Can you see why, without looking below?)
Let's go through a proof that the conditions in the definitions are established.

#### Scalar multiplication is preserved

We wish to show that for all vectors v and all scalars λ, T(λv)=λT(v).
Let
    $\mathbf {v} ={\begin{pmatrix}v_{0}\\v_{1}\end{pmatrix}}$.
Then
    $\lambda \mathbf {v} ={\begin{pmatrix}\lambda v_{0}\\\lambda v_{1}\end{pmatrix}}$
Now
    $T(\lambda \mathbf {v} )=T{\begin{pmatrix}\lambda v_{0}\\\lambda v_{1}\end{pmatrix}}=$
    ${\begin{pmatrix}\lambda v_{0}\\0\end{pmatrix}}$
If we work out λT(v) and find it is the same vector, we have proved our result.
    $\lambda T\mathbf {v} =\lambda {\begin{pmatrix}v_{0}\\0\end{pmatrix}}=$
    ${\begin{pmatrix}\lambda v_{0}\\0\end{pmatrix}}$
This is the same vector as above, so under the transformation T, scalar multiplication is preserved.

#### Addition is preserved

We wish to show for all vectors x and y, T(x+y)=Tx+Ty.
Let
    $\mathbf {x} ={\begin{pmatrix}x_{0}\\x_{1}\end{pmatrix}}$.
and
    $\mathbf {y} ={\begin{pmatrix}y_{0}\\y_{1}\end{pmatrix}}$.
Now
    $T(\mathbf {x} +\mathbf {y} )=T\left({\begin{pmatrix}x_{0}\\x_{1}\end{pmatrix}}+{\begin{pmatrix}y_{0}\\y_{1}\end{pmatrix}}\right)=$
    $T{\begin{pmatrix}x_{0}+y_{0}\\x_{1}+y_{1}\end{pmatrix}}=$
    ${\begin{pmatrix}x_{0}+y_{0}\\0\end{pmatrix}}$
Now if we can show Tx+Ty is this vector above, we have proved this result. Proceed, then,
    $T{\begin{pmatrix}x_{0}\\x_{1}\end{pmatrix}}+T{\begin{pmatrix}y_{0}\\y_{1}\end{pmatrix}}={\begin{pmatrix}x_{0}\\0\end{pmatrix}}+{\begin{pmatrix}y_{0}\\0\end{pmatrix}}=$
    ${\begin{pmatrix}x_{0}+y_{0}\\0\end{pmatrix}}$
So we have that the transformation T preserves addition.

#### Zero vector is preserved

Clearly we have
    $T{\begin{pmatrix}0\\0\end{pmatrix}}={\begin{pmatrix}0\\0\end{pmatrix}}$

#### Conclusion

We have shown T preserves addition, scalar multiplication and the zero vector. So T must be linear.

## Disproof of linearity

When we want to disprove linearity - that is, to prove that a transformation is not linear, we need only find one counter-example.
If we can find just one case in which the transformation does not preserve addition, scalar multiplication, or the zero vector, we can conclude that the transformation is not linear.
For example, consider the transformation
    $T{\begin{pmatrix}x\\y\end{pmatrix}}={\begin{pmatrix}x^{3}\\y^{2}\end{pmatrix}}$
We suspect it is not linear. To prove it is not linear, take the vector
    $\mathbf {v} ={\begin{pmatrix}2\\2\end{pmatrix}}$
then
    $T(2\mathbf {v} )={\begin{pmatrix}64\\16\end{pmatrix}}$
but
    $2T(\mathbf {v} )={\begin{pmatrix}16\\8\end{pmatrix}}$
so we can immediately say T is not linear because it doesn't preserve scalar multiplication.

### Problem set

Given the above, determine whether the following transformations are in fact linear or not. Write down each transformation in the form T:V -> W, and identify V and W. (Answers follow to even-numbered questions):
* $T{\begin{pmatrix}v_{0}\\v_{1}\end{pmatrix}}={\begin{pmatrix}v_{0}^{2}+v_{1}\\v_{1}\end{pmatrix}}$
* $T{\begin{pmatrix}v_{0}\\v_{1}\end{pmatrix}}={\begin{pmatrix}1\\v_{0}\end{pmatrix}}$
* $T{\begin{pmatrix}v_{0}\\v_{1}\end{pmatrix}}=\mathbf {0}$
* $T{\begin{pmatrix}v_{0}\\v_{1}\\v_{2}\end{pmatrix}}={\begin{pmatrix}v_{0}-v_{2}\\v_{1}\end{pmatrix}}$

#### Answers

    2. No. A check whether the zero vector is preserved readily confirms this fact. T : R$^2$ -> R$^2$
    4. Yes. T : R$^3$ -> R$^2$.

## Images and kernels

We have some fundamental concepts underlying linear transformations, such as the kernel and the image of a linear transformation, which are analogous to the zeros and range of a function.

### Kernel

The kernel of a linear transformation T: V -> W is the set of all vectors in V which are mapped to the zero vector in W, ie.,
    $\mathrm {ker} \ T=\{v\in V\ |\ T\mathbf {v} =\mathbf {0} \}$
Coincidentally because of the matr to the matrix equation Ax=0.
The kernel of a transform T: V->W is always a subspace of V. The dimension of a transform or a matrix is called the nullity.

### Image

The image of a linear transformation T:V->W is the set of all vectors in W which were mapped from vectors in V. For example with the trivial mapping T:V->W such that Tx=0, the image would be 0. (What would the kernel be?)
More formally, we say that the image of a transformation T:V->W is the set
    $\mathrm {im} \ T=\{w\in W\ |\ w=T\mathbf {v} \ \mathrm {and} \ \mathbf {v} \in V\}$

## Isomorphism

A linear transformation T:V -> W is an isomorphic transformation if it is:
* one-to-one and onto.
* kernel(T) = {0} and the range(T) = W.
* an inverse of T exists.
* dim(V) = dim(W).