The Algebra of Linear Transformations
Linear maps can be added, scaled and composed, and the results are again linear. With these operations, linear maps behave like matrices: you can form polynomials in a map such as , factor them, and invert them. Order matters, though, because composition is not commutative.
Sum, scalar multiple and composition
Let be linear and a scalar. Define
Both are linear. With these operations the set of all linear maps is itself a vector space, written . Its zero vector is the zero map, and if and , then , the same as for matrices.
If and are linear, the composition , , is linear as well:
Composition matches matrix multiplication: if and have matrices and , then has matrix (The Matrix of a Linear Transformation). So all the rules of Matrix Multiplication carry over: composition is associative, distributes over addition, and is not commutative.
Operators on polynomials
Two maps on the space of all polynomials will be our running example:
Composing them in the two orders gives different results. By the product rule, , while . Their difference is
This tiny identity is famous: in quantum mechanics, the position and momentum operators satisfy the same relation (up to a constant), and it is the origin of the uncertainty principle. It also shows that , so operators must be composed in the right order.
from sympy import symbols, diff, expand, Function
x = symbols("x")
D = lambda p: diff(p, x)
X = lambda p: x * p
compose = lambda S, T: (lambda p: S(T(p)))
p = 4 - x + 7 * x**3
print("(D o X)(p) =", expand(compose(D, X)(p)))
print("(X o D)(p) =", expand(compose(X, D)(p)))
print("difference =", expand(compose(D, X)(p) - compose(X, D)(p)), " (= p)")
f = Function("f")(x)
print("for any f: ", expand(compose(D, X)(f) - compose(X, D)(f)))(D o X)(p) = 28*x**3 - 2*x + 4
(X o D)(p) = 21*x**3 - x
difference = 7*x**3 - x + 4 (= p)
for any f: f(x)
Polynomials in an operator
Since we can add, scale and compose, any polynomial in makes sense: , and for we get . Products of polynomials in the same operator commute, so they factor like ordinary polynomials:
This factorization solves differential equations. The kernel of consists of the functions with , which is . So is solved by (killed by ) and (killed by ), and by every combination of them, exactly what the characteristic equation gives in Second-Order Linear Equations.
Inverses and one-sided inverses
is invertible (an isomorphism) if there is a linear with and . The inverse of a linear bijection is automatically linear. Isomorphic spaces are "the same space with different names": and are isomorphic via , which is why coordinates work.
The shift has inverse . The derivative on polynomials has no inverse (it kills constants), but the integral is a right inverse: , by the fundamental theorem of calculus. In the other order, , which is not the identity.
from sympy import symbols, diff, integrate, expand
x, t = symbols("x t")
D = lambda p: diff(p, x)
J = lambda p: integrate(p.subs(x, t), (t, 0, x))
S = lambda p: expand(p.subs(x, x + 1))
S_inv = lambda p: expand(p.subs(x, x - 1))
p = 5 + 2 * x - 3 * x**2
print("D(J(p)) =", expand(D(J(p))))
print("J(D(p)) =", expand(J(D(p))), " (lost the constant 5)")
print("S_inv(S(p)) =", S_inv(S(p)))D(J(p)) = -3*x**2 + 2*x + 5
J(D(p)) = -3*x**2 + 2*x (lost the constant 5)
S_inv(S(p)) = -3*x**2 + 2*x + 5
In a finite-dimensional space this cannot happen for a map . There, one-to-one, onto and invertible are all equivalent (by rank–nullity), so a one-sided inverse is automatically two-sided. The asymmetry of and needs the infinite-dimensional space (or the different spaces and ).
In software
- Pipelines: a graphics transform pipeline or a stack of linear layers is a composition; you can multiply the matrices once and apply the product, but the order must match the order of application (3D Graphics: Transform Pipelines).
- Operator libraries: SciPy's
LinearOperatorand PyTorch's linear modules let you add, scale and compose maps without ever building their matrices (Sparse Linear Algebra). - Differential operators in code: finite-difference stencils are matrices that approximate , and numerical solvers build as a sparse matrix.
- Undo: an invertible edit (a shift, a rotation, a scale) can be undone exactly by its inverse; a projection or a derivative cannot.
Exercises
Exercise 1: Apply an operator polynomial
Let . Compute , and .
Answer
, , .
Solution
Exercise 2: Do shift and derivative commute?
With , compute and . Do and commute in general?
Answer
Both give . Yes: on all differentiable functions.
Solution
Unlike and , the shift and the derivative commute. That is why convolution filters (which are combinations of shifts) can be analysed with derivatives and frequencies.
Exercise 3: Invert on
Let on . Use on to find , and compute .
Answer
; .
Solution
Like the geometric series , which stops because :
Exercise 4: Check with matrices
In the basis of , has matrix . Verify in SymPy that and apply it to .
Answer
Both sides give , and the image of , coordinates , is : the polynomial .
Solution
from sympy import Matrix, eye
D = Matrix([[0, 1, 0], [0, 0, 2], [0, 0, 0]])
inv = (eye(3) + D).inv()
print("(I + D)^-1 =", inv.tolist())
print("I - D + D^2 =", (eye(3) - D + D**2).tolist())
print("applied to x^2:", list(inv * Matrix([0, 0, 1])))(I + D)^-1 = [[1, -1, 2], [0, 1, -2], [0, 0, 1]]
I - D + D^2 = [[1, -1, 2], [0, 1, -2], [0, 0, 1]]
applied to x^2: [2, -2, 1]
Test yourself
If has matrix and has matrix , what is the matrix of (first , then )?
With and , what is ?
- 0
- The identity
On the space of all polynomials, where . What is ?
- Also
- The map
- The zero map