Definition and Examples
A linear transformation is a function between vector spaces that respects addition and scaling. In these were the maps (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 and be vector spaces over the same field. A function is linear if, for all and all scalars ,
Equivalently, : maps linear combinations to linear combinations. Two consequences hold for every linear map:
- , since . A map with is never linear.
- .
Examples
| Map | From → to | Linear because |
|---|---|---|
| (derivative) | , | |
| the integral is additive and homogeneous | ||
| (evaluation) | ||
| (shift) | substitution respects + and scaling | |
| (transpose) | ||
| (trace) | sum of diagonal entries | |
| for a fixed matrix | ||
| shift | sequences → sequences | term by term |
| 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 .
Non-examples
| Map | Fails because |
|---|---|
| (translation) | ; this is why graphics needs homogeneous coordinates (Application: Perspective Rendering) |
| 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:
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 comes with two subspaces:
| Map | Kernel | Image |
|---|---|---|
| constant polynomials () | all of () | |
| polynomials with () | () | |
| trace-zero matrices () | () | |
| transpose on | all of |
In every row, . 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. is one-to-one exactly when : if , then .
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 on random inputs catches many bugs.
Exercises
Exercise 1: Linear or not?
Which are linear? (a) on polynomials, (b) , (c) on , (d) for a fixed .
Answer
(a), (b) and (d) are linear; (c) is not.
Solution
(a) and . (b) both and are linear in , and sums of linear maps are linear. (c) . (d) , and scalars pull out the same way.
Exercise 2: A kernel
Find the kernel of and a basis for it.
Answer
, dimension 3, basis , , .
Solution
means , with free. Rank–nullity check: .
Exercise 3: Evaluation at two points
, . Is it linear? Find its kernel.
Answer
Linear; .
Solution
Each coordinate is an evaluation, which is linear. with and gives , so . Rank–nullity: , so the image is all of .
Exercise 4: A differential operator
on . Check that and are in the kernel, and compute in SymPy.
Answer
; .
Solution
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 to is linear?
(the derivative) has a kernel of dimension 1. What is the dimension of its image?
- 5
- 3
- 4
- 1
Why is not linear?
- , not
- is not defined for all matrices