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 University Question Papers and Evaluation Scheme -Mathematics for Machine learning CST 284 KTU 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...

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(...

5.1 Optimization using Gradient Descent

Since machine learning algorithms are implemented on a computer, the mathematical formulations are expressed as numerical optimization methods.Training a machine learning model often boils down to finding a good set of parameters. The notion of “good” is determined by the objective function or the probabilistic model. Given an objective function, finding the best value is done using optimization algorithms. There are two main branches of continuous optimization constrained and unconstrained. By convention, most objective functions in machine learning are intended to be minimized, that is, the best value is the minimum value. Intuitively finding the best value is like finding the valleys of the objective function, and the gradients point us uphill. The idea is to move downhill (opposite to the gradient) and hope to find the deepest point. For unconstrained optimization, this is the only concept we need,but there are several design choices. For constrained optimization, we need to intr...