TExcelTAD
Home › Linear Algebra & Matrix Theory › Definition and Examples

Definition and Examples

A linear transformation is a function between vector spaces that respects addition and scaling. In Rn\mathbb{R}^n these were the maps x↦Ax\mathbf{x} \mapsto A\mathbf{x} (Linear Transformations). In general vector spaces the same definition covers differentiation, integration, evaluating a polynomial at a point, transposing a matrix and shifting a sequence. Recognising an operation as linear means everything you know about matrices applies to it.

The definition

Let VV and WW be vector spaces over the same field. A function T:V→WT: V \to W is linear if, for all u,v∈V\mathbf{u}, \mathbf{v} \in V and all scalars cc,

T(u+v)=T(u)+T(v)(additive)T(cv)=c T(v)(homogeneous)\begin{aligned} T(\mathbf{u} + \mathbf{v}) &= T(\mathbf{u}) + T(\mathbf{v}) && \text{(additive)} \\ T(c\mathbf{v}) &= c\,T(\mathbf{v}) && \text{(homogeneous)} \end{aligned}

Equivalently, T(au+bv)=aT(u)+bT(v)T(a\mathbf{u} + b\mathbf{v}) = aT(\mathbf{u}) + bT(\mathbf{v}): TT maps linear combinations to linear combinations. Two consequences hold for every linear map:

  • T(0)=0T(\mathbf{0}) = \mathbf{0}, since T(0)=T(0⋅0)=0⋅T(0)=0T(\mathbf{0}) = T(0 \cdot \mathbf{0}) = 0 \cdot T(\mathbf{0}) = \mathbf{0}. A map with T(0)≠0T(\mathbf{0}) \ne \mathbf{0} is never linear.
  • T(c1v1+⋯+ckvk)=c1T(v1)+⋯+ckT(vk)T(c_1\mathbf{v}_1 + \cdots + c_k\mathbf{v}_k) = c_1T(\mathbf{v}_1) + \cdots + c_kT(\mathbf{v}_k).

Examples

Map From → to Linear because
D(p)=p′D(p) = p' (derivative) Pn→Pn−1P_n \to P_{n-1} (p+q)′=p′+q′(p + q)' = p' + q', (cp)′=cp′(cp)' = cp'
J(p)=∫0xp(t) dtJ(p) = \int_0^x p(t)\,dt Pn→Pn+1P_n \to P_{n+1} the integral is additive and homogeneous
E2(p)=p(2)E_2(p) = p(2) (evaluation) Pn→RP_n \to \mathbb{R} (p+q)(2)=p(2)+q(2)(p + q)(2) = p(2) + q(2)
S(p)(x)=p(x+1)S(p)(x) = p(x + 1) (shift) Pn→PnP_n \to P_n substitution respects + and scaling
T(A)=ATT(A) = A^T (transpose) Mm×n→Mn×mM_{m \times n} \to M_{n \times m} (A+B)T=AT+BT(A + B)^T = A^T + B^T
tr⁡(A)\operatorname{tr}(A) (trace) Mn×n→RM_{n \times n} \to \mathbb{R} sum of diagonal entries
L(A)=MAL(A) = MA for a fixed matrix MM Mn×k→Mm×kM_{n \times k} \to M_{m \times k} M(A+B)=MA+MBM(A + B) = MA + MB
shift (a0,a1,a2,…)↦(a1,a2,…)(a_0, a_1, a_2, \ldots) \mapsto (a_1, a_2, \ldots) sequences → sequences term by term
y↦y′′+3y′+2yy \mapsto y'' + 3y' + 2y C2(R)→C(R)C^2(\mathbb{R}) \to C(\mathbb{R}) built from derivatives, sums and constants

The last row is why "linear differential equation" is called linear: the left side is a linear map applied to yy.

Non-examples

Map Fails because
T(p)=p+1T(p) = p + 1 T(0)=1≠0T(0) = 1 \ne 0
T(A)=det⁡AT(A) = \det A det⁡(2I2)=4≠2⋅det⁡I2=2\det(2I_2) = 4 \ne 2 \cdot \det I_2 = 2
T(f)=f2T(f) = f^2 (2f)2=4f2≠2f2(2f)^2 = 4f^2 \ne 2f^2
T(x,y)=(x,y)+(1,0)T(x, y) = (x, y) + (1, 0) (translation) T(0)≠0T(\mathbf{0}) \ne \mathbf{0}; this is why graphics needs homogeneous coordinates (Application: Perspective Rendering)
T(p)=p(0)⋅p(1)T(p) = p(0) \cdot p(1) product of two linear expressions

To show a map is not linear, one concrete counterexample is enough. SymPy can check the identities symbolically on general polynomials:

python · try it yourself
from sympy import symbols, diff, integrate, expand, simplify

x, t = symbols("x t")
a0, a1, a2, b0, b1, b2, c = symbols("a0 a1 a2 b0 b1 b2 c")
p = a0 + a1 * x + a2 * x**2           # a general element of P2
q = b0 + b1 * x + b2 * x**2

maps = {
    "D(p) = p'":       lambda f: diff(f, x),
    "J(p) = int_0^x":  lambda f: integrate(f.subs(x, t), (t, 0, x)),
    "S(p) = p(x+1)":   lambda f: f.subs(x, x + 1),
    "E(p) = p(2)":     lambda f: f.subs(x, 2),
    "N(p) = p^2":      lambda f: f**2,
    "A(p) = p + 1":    lambda f: f + 1,
}
for name, T in maps.items():
    additive = simplify(expand(T(p + q) - T(p) - T(q))) == 0
    homogeneous = simplify(expand(T(c * p) - c * T(p))) == 0
    print(f"{name:16} additive: {additive!s:5}  homogeneous: {homogeneous}")
D(p) = p'        additive: True   homogeneous: True
J(p) = int_0^x   additive: True   homogeneous: True
S(p) = p(x+1)    additive: True   homogeneous: True
E(p) = p(2)      additive: True   homogeneous: True
N(p) = p^2       additive: False  homogeneous: False
A(p) = p + 1     additive: False  homogeneous: False

Kernel and image

Every linear map T:V→WT: V \to W comes with two subspaces:

ker⁡T={v∈V:T(v)=0}a subspace of V(the null space)im⁡T={T(v):v∈V}a subspace of W(the range)\begin{aligned} \ker T &= \{\mathbf{v} \in V : T(\mathbf{v}) = \mathbf{0}\} && \text{a subspace of } V \quad \text{(the null space)} \\ \operatorname{im} T &= \{T(\mathbf{v}) : \mathbf{v} \in V\} && \text{a subspace of } W \quad \text{(the range)} \end{aligned}
Map Kernel Image
D:P3→P2D: P_3 \to P_2 constant polynomials (dim⁡1\dim 1) all of P2P_2 (dim⁡3\dim 3)
E2:P2→RE_2: P_2 \to \mathbb{R} polynomials with p(2)=0p(2) = 0 (dim⁡2\dim 2) R\mathbb{R} (dim⁡1\dim 1)
tr⁡:M2×2→R\operatorname{tr}: M_{2 \times 2} \to \mathbb{R} trace-zero matrices (dim⁡3\dim 3) R\mathbb{R} (dim⁡1\dim 1)
transpose on Mn×nM_{n \times n} {0}\{0\} all of Mn×nM_{n \times n}

In every row, dim⁡ker⁡T+dim⁡im⁡T=dim⁡V\dim \ker T + \dim \operatorname{im} T = \dim V. This is the rank–nullity theorem, the same one you know for matrices, and it holds for every linear map from a finite-dimensional space. TT is one-to-one exactly when ker⁡T={0}\ker T = \{\mathbf{0}\}: if T(u)=T(v)T(\mathbf{u}) = T(\mathbf{v}), then T(u−v)=0T(\mathbf{u} - \mathbf{v}) = \mathbf{0}.

python · try it yourself
from sympy import symbols, diff, Poly, Matrix

x = symbols("x")
basis = [1, x, x**2, x**3]
# express D(b) for each basis polynomial in the basis 1, x, x^2 of P2
cols = [[Poly(diff(b, x), x).coeff_monomial(x**k) for k in range(3)] for b in basis]
M = Matrix(cols).T
print("D as a matrix:", M.tolist())
print("rank (dim of image):", M.rank(), "  nullity (dim of kernel):", len(M.nullspace()))
print("kernel basis:", [list(v) for v in M.nullspace()], "-> the constant polynomial 1")
D as a matrix: [[0, 1, 0, 0], [0, 0, 2, 0], [0, 0, 0, 3]]
rank (dim of image): 3   nullity (dim of kernel): 1
kernel basis: [[1, 0, 0, 0]] -> the constant polynomial 1

Turning a map into a matrix like this is the subject of The Matrix of a Linear Transformation.

In software

  • Automatic differentiation: the derivative of a function at a point is a linear map (the Jacobian), and autodiff frameworks compose these linear maps (Automatic Differentiation).
  • Signal processing: filters, convolutions, the Fourier transform and resampling are linear maps on signals, which is why they can be analysed with frequencies and implemented as matrix or FFT operations.
  • Shaders and graphics: anything you can write as "multiply by a matrix" is linear; anything with "+ offset" is affine and needs one extra coordinate.
  • Testing: if your function should be linear, a property-based test of T(au+bv)=aT(u)+bT(v)T(a\mathbf{u} + b\mathbf{v}) = aT(\mathbf{u}) + bT(\mathbf{v}) on random inputs catches many bugs.

Exercises

Exercise 1: Linear or not?

Which are linear? (a) T(p)=x⋅p(x)T(p) = x \cdot p(x) on polynomials, (b) T(p)=p(0)+p′(0)T(p) = p(0) + p'(0), (c) T(A)=A+IT(A) = A + I on M2×2M_{2 \times 2}, (d) T(A)=AB−BAT(A) = AB - BA for a fixed BB.

Answer

(a), (b) and (d) are linear; (c) is not.

Solution

(a) x(p+q)=xp+xqx(p + q) = xp + xq and x(cp)=c(xp)x(cp) = c(xp). (b) both p(0)p(0) and p′(0)p'(0) are linear in pp, and sums of linear maps are linear. (c) T(0)=I≠0T(0) = I \ne 0. (d) (A1+A2)B−B(A1+A2)=(A1B−BA1)+(A2B−BA2)(A_1 + A_2)B - B(A_1 + A_2) = (A_1B - BA_1) + (A_2B - BA_2), and scalars pull out the same way.

Exercise 2: A kernel

Find the kernel of tr⁡:M2×2→R\operatorname{tr}: M_{2 \times 2} \to \mathbb{R} and a basis for it.

Answer

ker⁡tr⁡={[abc−a]}\ker \operatorname{tr} = \left\{\begin{bmatrix} a & b \\ c & -a \end{bmatrix}\right\}, dimension 3, basis [100−1]\begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}, [0100]\begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix}, [0010]\begin{bmatrix} 0 & 0 \\ 1 & 0 \end{bmatrix}.

Solution

tr⁡[abcd]=a+d=0\operatorname{tr}\begin{bmatrix} a & b \\ c & d \end{bmatrix} = a + d = 0 means d=−ad = -a, with a,b,ca, b, c free. Rank–nullity check: dim⁡M2×2=4=3 (kernel)+1 (image R)\dim M_{2 \times 2} = 4 = 3\ (\text{kernel}) + 1\ (\text{image } \mathbb{R}).

Exercise 3: Evaluation at two points

T:P2→R2T: P_2 \to \mathbb{R}^2, T(p)=(p(0),p(1))T(p) = (p(0), p(1)). Is it linear? Find its kernel.

Answer

Linear; ker⁡T=span⁡{x2−x}={c⋅x(x−1)}\ker T = \operatorname{span}\{x^2 - x\} = \{c \cdot x(x - 1)\}.

Solution

Each coordinate is an evaluation, which is linear. p=a+bx+cx2p = a + bx + cx^2 with p(0)=a=0p(0) = a = 0 and p(1)=a+b+c=0p(1) = a + b + c = 0 gives b=−cb = -c, so p=c(x2−x)p = c(x^2 - x). Rank–nullity: 3=1+23 = 1 + 2, so the image is all of R2\mathbb{R}^2.

Exercise 4: A differential operator

L(y)=y′′−4yL(y) = y'' - 4y on C2(R)C^2(\mathbb{R}). Check that e2xe^{2x} and e−2xe^{-2x} are in the kernel, and compute L(x3)L(x^3) in SymPy.

Answer

L(e2x)=L(e−2x)=0L(e^{2x}) = L(e^{-2x}) = 0; L(x3)=6x−4x3L(x^3) = 6x - 4x^3.

Solution
(e2x)′′=4e2x→4e2x−4e2x=0;(e−2x)′′=4e−2x→0(x3)′′=6x→L(x3)=6x−4x3\begin{aligned} (e^{2x})'' &= 4e^{2x} \quad \to \quad 4e^{2x} - 4e^{2x} = 0; \qquad (e^{-2x})'' = 4e^{-2x} \quad \to \quad 0 \\ (x^3)'' &= 6x \quad \to \quad L(x^3) = 6x - 4x^3 \end{aligned}
python · try it yourself
from sympy import symbols, exp, diff, simplify

x = symbols("x")
L = lambda y: simplify(diff(y, x, 2) - 4 * y)
for y in [exp(2 * x), exp(-2 * x), 3 * exp(2 * x) - 5 * exp(-2 * x), x**3]:
    print(f"L({y}) = {L(y)}")
L(exp(2*x)) = 0
L(exp(-2*x)) = 0
L(3*exp(2*x) - 5*exp(-2*x)) = 0
L(x**3) = -4*x**3 + 6*x

Test yourself

Which map from P2P_2 to P2P_2 is linear?

  1. p↦p+xp \mapsto p + x
  2. p↦p(x)2p \mapsto p(x)^2
  3. p↦p(x+3)p \mapsto p(x + 3)
  4. p↦1p \mapsto 1

D:P4→P3D: P_4 \to P_3 (the derivative) has a kernel of dimension 1. What is the dimension of its image?

  1. 5
  2. 3
  3. 4
  4. 1

Why is det⁡:M2×2→R\det: M_{2 \times 2} \to \mathbb{R} not linear?

  1. det⁡(0)≠0\det(0) \ne 0
  2. det⁡(cA)=c2det⁡(A)\det(cA) = c^2 \det(A), not cdet⁡(A)c \det(A)
  3. det⁡\det is not defined for all matrices
  4. det⁡(AT)≠det⁡(A)\det(A^T) \ne \det(A)