Skip to main content

1.12 Image and Kernel

The image and kernel of a linear mapping are vector subspaces with certain important properties

Definition:  Image and Kernel

For $\Phi: V \to W $, we define the kernel or null space

$ker(\Phi)=\Phi^{-1}(0_w)=\{v \in V: \Phi(v)=0_w\}$

and image or range

$Im(\Phi) =\Phi(V)=\{w \in W| \exists v \in V: \Phi(v)=w\}$

We also call $V$ and $W$ as domain and codomain of $\Phi$, respectively.

Intuitively, the kernel is the set of vectors in $v \in V$ that $\Phi$ maps onto the neutral element $0_w \in W$. The image is the set of vectors $w \in W$  that can be “reached” by $\Phi$ from any vector in $V$ . An illustration is given in figure.


Remark: Consider a linear mapping $\Phi: V \to W$, where $V,W$ are vector spaces.

  • It always holds that $\Phi(0_v)=0_w$ and therefore $0_v \in ker(\Phi)$.In particular the null space is never empty.
  • $Im(\Phi) \subseteq W$ is a subspace of $W$, and $ker(\Phi) \subseteq V$ is a subspace of $V$.

Remark(Null space and Column space)

Let us consider $A \in \mathbb{R}^{m \times n}$ and a linear mapping $\Phi: \mathbb{R}^n \to \mathbb{R}^m, x \to Ax$

  • for $A=[a_1,\ldots,a_n]$, where $a_i$ are the columns of $A_i$, we obtain$Im(\Phi)={Ax:x \in \mathbb{R}^n}=\sum_{i=1}^n x_ia_i : x_1,\ldots,x_n \in \mathbb{R}$             $=span[a_1,\ldots,a_n] \subseteq \mathbb{R}^m$
  • i.e., the image is the span of the columns of $A$, also called the column space. Therefore, the column space(image) is a subspace of $\mathbb{R}^m$ ,where $m$ is the height of the matrix.
  • $rk(A)=dim(Im(\Phi))$
  • The kernel/null space $ker(\Phi)$ is the general solution to the homogenious system of linear equations $Ax=0$ and captures all possible linear combination of elements in $\mathbb{R}^n$ that produces $0 \in \mathbb{R}^m$
  • The kernel is a subspace of $\mathbb{R}^n$, where $n$ is the width of the matrix.
  • The kernel focuses on the relationship among the columns, and we can use it to determine whether/how we can express a column as a linear combination of other columns
Rank Nullity Theorem
For vector spaces $V,W$ and a linear mapping $\Phi:V \to W$ it holds that

$dim(ker(\Phi))+ dim(Im(\Phi))= dim(V)$
The rank nullity theorem is also referred to as the fundamental theorem of linear mapping.

If  $dim(Im(\Phi)) < dim(V)$, then $ker(\Phi)$ is non trivial, i.e, the kernel contains more than $0_v$ and $dim(ker(\Phi)) \ge 1$.

If $A_\phi$ is the transformation matrix of $\Phi$ with respect to an ordered basis and $dim(Im(\Phi)) < dim(V)$, then the system of linear equations $A_\phi x=0$ has infinitely many solutions.

If $dim(V)=dim(W)$, then the following three way equivalence holds
$\Phi$ is injective
$\Phi$ is surjective
$\Phi$ is bijective
since $Im(\Phi) \subseteq W$






import sympy as sp
import numpy as np
row1=[1,2,-1,0]
row2=[1,0,0,1]
M = sp.Matrix((row1,row2))
print("Transformation Matrix")
display(M)
print("Reduced Echelon Form")
display(M.rref())

O/P
Transformation Matrix
$\displaystyle \left[\begin{matrix}1 & 2 & -1 & 0\\1 & 0 & 0 & 1\end{matrix}\right]$
Reduced Echelon Form
(Matrix([ [1, 0, 0, 1], 
             [0, 1, -1/2, -1/2]]), (0, 1))

Note: from the reduced echelon form we can find out the null space.

We can also sympy package nullspace method to find null space
# import sympy
from sympy import *
M = Matrix([[1, 2, -1, 0], [1, 0, 0, 1]])
display(M)
# Use sympy.nullspace() method
M_nullspace = M.nullspace()
print("Nullspace of a matrix : ")
display(M_nullspace)

O/P
$\displaystyle \left[\begin{matrix}1 & 2 & -1 & 0\\1 & 0 & 0 & 1\end{matrix}\right]$
Nullspace of a matrix :
[Matrix([ [ 0], [1/2], [ 1], [ 0]]), 
 Matrix([ [ -1], [1/2], [ 0], [ 1]])]



Example:
Find the Image and Kernel of a linear mapping $A=\begin{bmatrix}
2 &3 \\
6 & 9
\end{bmatrix}$

After row reduction the echelon form is
$A=\begin{bmatrix}
2 &3 \\
0 & 0
\end{bmatrix}$

$A=\begin{bmatrix}
1 &3/2 \\
0 & 0
\end{bmatrix}$

So the pivot column indicate linear independent vector

$Im(A)=span(\begin{bmatrix}
2 \\
6 \\
\end{bmatrix})$

The null space is spanned by

$Null(A)=span(\begin{bmatrix}
3/2 \\
-1 \\
\end{bmatrix})$

Example ( university question)
Consider the transformation $T (x, y) = (x + y, x + 2y, 2x + 3y)$. Obtain ker $T$ and use this to calculate the nullity. Also find the transformation matrix for $T$.

The transformation matrix is

$T=\begin{bmatrix}
1 & 1 \\
1 & 2 \\
2 & 3
\end{bmatrix}$

The null space consist of  the trivial vector 
$\begin{bmatrix}0 \\
0\\
\end{bmatrix}$

Given the linear transformation $T(x,y,z,w)=(x+2y-z,x+w) $, find the basis each for Ker(T) and Range(T) ( University Question)

The transformation matrix is
$\begin{bmatrix}
1 & 2 & -1 & 0 \\
1 & 0 & 0 & 1 \\
\end{bmatrix}$

After row reduction, the reduced echelon form is
$\begin{bmatrix}
1 & 2 & -1 & 0 \\
0 & -2 & 1 & 1 \\
\end{bmatrix} R2= R2-R1$

$\begin{bmatrix}
1 & 0 & 0 & 1 \\
0 & -2 & 1 & 1 \\
\end{bmatrix}  R1=R1+R2$

$\begin{bmatrix}
1 & 0 & 0 & 1 \\
0 & 1 & -1/2 & -1/2 \\
\end{bmatrix}  R2=R2/-2$

Basis for Range(T) is $\begin{bmatrix}
1 \\
1\\
\end{bmatrix}\begin{bmatrix}
2 \\
0 \\
\end{bmatrix} $
Basis for Ker(T) is $\begin{bmatrix}
0 \\
-1/2 \\
-1\\
0
\end{bmatrix}\begin{bmatrix}
1 \\
-1/2 \\
0\\
-1
\end{bmatrix} $
 
 Let $T$ be the linear transformation from $R^2$ to $R^3$ defined by $T(v)=Av$, with standard matrix $A=\begin{bmatrix} 2& -6 & 4 \\ 1 & -1 & 2 \end{bmatrix}$. Find the kernel and image of $T$.
After row reduction, the reduced echelon form is
 
$A=\begin{bmatrix} 2& -6 & 4 \\ 1 & -1 & 2 \end{bmatrix}$
 
$R1=R1/2$
 $A=\begin{bmatrix} 1& -3& 2 \\ 1 & -1 & 2 \end{bmatrix}$
 
 
$R2=R2-R1$
 $A=\begin{bmatrix} 1& -3& 2 \\ 0 & 2 & 0 \end{bmatrix}$
 
$R2=R2/2$
 $A=\begin{bmatrix} 1& -3& 2 \\ 0 & 1 & 0 \end{bmatrix}$
 
 
$R1=R2*3 + R1$
 $A=\begin{bmatrix} 1& 0& 2 \\ 0 & 1 & 0 \end{bmatrix}$
 
Basis for Range(T) is $\begin{bmatrix}
2 \\
1\\
\end{bmatrix}\begin{bmatrix}
-6 \\
-1 \\
\end{bmatrix} $
Basis for Ker(T) is 
$\begin{bmatrix}
2 \\
0 \\
-1\\
\end{bmatrix}$

Comments

Popular posts from this blog

Mathematics for Machine Learning- CST 284 - KTU Minor Notes - Dr Binu V P

  Introduction About Me Syllabus Course Outcomes and Model Question Paper Question Paper July 2021 and evaluation scheme Question Paper June 2022 and evaluation scheme Overview of Machine Learning What is Machine Learning (video) Learn the Seven Steps in Machine Learning (video) Linear Algebra in Machine Learning Module I- Linear Algebra 1.Geometry of Linear Equations (video-Gilbert Strang) 2.Elimination with Matrices (video-Gilbert Strang) 3.Solving System of equations using Gauss Elimination Method 4.Row Echelon form and Reduced Row Echelon Form -Python Code 5.Solving system of equations Python code 6. Practice problems Gauss Elimination ( contact) 7.Finding Inverse using Gauss Jordan Elimination  (video) 8.Finding Inverse using Gauss Jordan Elimination-Python code Vectors in Machine Learning- Basics 9.Vector spaces and sub spaces 10.Linear Independence 11.Linear Independence, Basis and Dimension (video) 12.Generating set basis and span 13.Rank of a Matrix 14.Linear Mapping and Matri

4.3 Sum Rule, Product Rule, and Bayes’ Theorem

 We think of probability theory as an extension to logical reasoning Probabilistic modeling  provides a principled foundation for designing machine learning methods. Once we have defined probability distributions corresponding to the uncertainties of the data and our problem, it turns out that there are only two fundamental rules, the sum rule and the product rule. Let $p(x,y)$ is the joint distribution of the two random variables $x, y$. The distributions $p(x)$ and $p(y)$ are the corresponding marginal distributions, and $p(y |x)$ is the conditional distribution of $y$ given $x$. Sum Rule The addition rule states the probability of two events is the sum of the probability that either will happen minus the probability that both will happen. The addition rule is: $P(A∪B)=P(A)+P(B)−P(A∩B)$ Suppose $A$ and $B$ are disjoint, their intersection is empty. Then the probability of their intersection is zero. In symbols:  $P(A∩B)=0$  The addition law then simplifies to: $P(A∪B)=P(A)+P(B)$  wh

1.1 Solving system of equations using Gauss Elimination Method

Elementary Transformations Key to solving a system of linear equations are elementary transformations that keep the solution set the same, but that transform the equation system into a simpler form: Exchange of two equations (rows in the matrix representing the system of equations) Multiplication of an equation (row) with a constant  Addition of two equations (rows) Add a scalar multiple of one row to the other. Row Echelon Form A matrix is in row-echelon form if All rows that contain only zeros are at the bottom of the matrix; correspondingly,all rows that contain at least one nonzero element are on top of rows that contain only zeros. Looking at nonzero rows only, the first nonzero number from the left pivot (also called the pivot or the leading coefficient) is always strictly to the right of the  pivot of the row above it. The row-echelon form is where the leading (first non-zero) entry of each row has only zeroes below it. These leading entries are called pivots Example: $\begin