Linear Transformations Defined on a Basis
A linear map is completely determined by what it does to a basis, and you are free to send the basis vectors anywhere you like. This is the most practical fact about linear maps: to define one, pick the images of a few basis vectors; to compute one, expand the input in that basis. Polynomial interpolation is a nice application.
The theorem
Let be a basis of , and let be any vectors in (they need not be different, independent or nonzero). Then there is exactly one linear map with
Why. Every has unique coordinates, (Basis and Dimension). Linearity forces
so there is at most one such map. Conversely, this formula defines a map, and it is linear because coordinates are linear: the coordinates of are . ∎
Both halves matter. Uniqueness: two linear maps that agree on a basis agree everywhere, so to test whether it is enough to check vectors. Existence: any assignment on a basis extends to a linear map, with no conditions to check.
Example in : from basis images to a matrix
Find the linear with and . The vectors and form a basis. To find , first find the coordinates of in that basis, then combine the images:
In matrix form, with (basis vectors as columns) and (their images), the conditions say , so
from sympy import Matrix
B = Matrix([[1, 1], [1, -1]]) # basis vectors as columns
W = Matrix([[3, 1], [1, 3]]) # their required images as columns
A = W * B.inv()
print("A =", A.tolist())
print("A(1,1) =", list(A * Matrix([1, 1])), " A(1,-1) =", list(A * Matrix([1, -1])))
print("T(5, 2) =", list(A * Matrix([5, 2])))A = [[2, 1], [2, -1]]
A(1,1) = [3, 1] A(1,-1) = [1, 3]
T(5, 2) = [12, 8]
Example on polynomials: a map that turns out to be an integral
Define on the basis by
By the theorem this extends to exactly one linear map: . The integral is linear and has the same values on the basis (), so by uniqueness is that integral. Checking three numbers proved an identity for every quadratic.
Application: Lagrange interpolation
Pick three distinct points . The evaluation map , , is linear. Its kernel is , because a nonzero polynomial of degree has at most two roots. By rank–nullity it is onto as well, so it is an isomorphism.
Its inverse is easiest to define on the standard basis of : send to the polynomial that is 1 at and 0 at the other two points,
That is the Lagrange interpolation formula: the unique quadratic through three given points. It works the same for points and degree .
from sympy import symbols, prod, expand
x = symbols("x")
xs = [0, 1, 3]
L = [prod((x - xk) / (xj - xk) for xk in xs if xk != xj) for xj in xs]
for j, Lj in enumerate(L):
print(f"L{j} = {expand(Lj)} values: {[Lj.subs(x, p) for p in xs]}")
ys = [2, 0, 8]
p = expand(sum(y * Lj for y, Lj in zip(ys, L)))
print("interpolant:", p, " values:", [p.subs(x, v) for v in xs])L0 = x**2/3 - 4*x/3 + 1 values: [1, 0, 0]
L1 = -x**2/2 + 3*x/2 values: [0, 1, 0]
L2 = x**2/6 - x/6 values: [0, 0, 1]
interpolant: 2*x**2 - 4*x + 2 values: [2, 0, 8]
The values of each at the three points form a row of the identity matrix, and the interpolant for the values is .
When values do not define a map
The theorem needs a basis. With other lists, things go wrong in two ways:
| Values given on… | Problem | Example |
|---|---|---|
| a dependent list | values may contradict linearity | , , : impossible, linearity forces |
| a list that does not span | many maps fit | on says nothing about |
In software
- Graphics: a 2D or 3D linear transform is fixed by where it sends the basis vectors, which is why the columns of a transform matrix are the images of the , , axes. "Fit the transform that maps these 3 points to those 3 points" is (add a translation and you get an affine fit).
- Interpolation and splines: Lagrange and Newton forms, Bézier curves and finite-element shape functions all define a function by its values or control points on a basis (SciPy Interpolation).
- Testing linear code: to check that a linear function matches its specification, it is enough to test it on a basis, provided you know it is linear.
- Neural networks: a linear layer is defined by weight columns, one per input basis vector; the forward pass expands the input in that basis (Neural Network Layers as Matrices).
Exercises
Exercise 1: Basis images to a formula
is linear with and . Find and the matrix of .
Answer
; matrix .
Solution
Exercise 2: Impossible values
Is there a linear with and ? What about and ?
Answer
No for the first; yes (exactly one) for the second, namely .
Solution
forces . In the second case and form a basis (), so any values work. with and gives , .
Exercise 3: Recognise the map
is linear with , , . What is , and what is ?
Answer
is the derivative ; .
Solution
has the same values on the basis, so by uniqueness. .
Exercise 4: Interpolate
Find the quadratic through , , by solving for the coefficients, then confirm it with Lagrange polynomials in SymPy.
Answer
.
Solution
from sympy import symbols, prod, expand
x = symbols("x")
pts = [(-1, 3), (0, 1), (2, 9)]
xs = [px for px, _ in pts]
L = [prod((x - xk) / (xj - xk) for xk in xs if xk != xj) for xj in xs]
print(expand(sum(y * Lj for (_, y), Lj in zip(pts, L))))2*x**2 + 1
Test yourself
is a basis of and are arbitrary vectors in . How many linear maps satisfy ?
- None, unless the are independent
- Exactly one
- Infinitely many
- Exactly three
Which statement is a consequence of the uniqueness half of the theorem?
- Every linear map is invertible
- Two linear maps that agree on a basis are equal
- Linear maps preserve lengths
- The images of a basis must be a basis
If and , what is the matrix of in the standard basis?