TExcelTAD
Home › Linear Algebra & Matrix Theory › Linear Transformations Defined on a Basis

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 v1,…,vn\mathbf{v}_1, \ldots, \mathbf{v}_n be a basis of VV, and let w1,…,wn\mathbf{w}_1, \ldots, \mathbf{w}_n be any vectors in WW (they need not be different, independent or nonzero). Then there is exactly one linear map T:V→WT: V \to W with

T(v1)=w1,T(v2)=w2,…,T(vn)=wnT(\mathbf{v}_1) = \mathbf{w}_1, \quad T(\mathbf{v}_2) = \mathbf{w}_2, \quad \ldots, \quad T(\mathbf{v}_n) = \mathbf{w}_n

Why. Every v∈V\mathbf{v} \in V has unique coordinates, v=c1v1+⋯+cnvn\mathbf{v} = c_1\mathbf{v}_1 + \cdots + c_n\mathbf{v}_n (Basis and Dimension). Linearity forces

T(v)=c1w1+c2w2+⋯+cnwnT(\mathbf{v}) = c_1\mathbf{w}_1 + c_2\mathbf{w}_2 + \cdots + c_n\mathbf{w}_n

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 au+bva\mathbf{u} + b\mathbf{v} are a[u]+b[v]a[\mathbf{u}] + b[\mathbf{v}]. ∎

Both halves matter. Uniqueness: two linear maps that agree on a basis agree everywhere, so to test whether S=TS = T it is enough to check nn vectors. Existence: any assignment on a basis extends to a linear map, with no conditions to check.

Example in R2\mathbb{R}^2: from basis images to a matrix

Find the linear T:R2→R2T: \mathbb{R}^2 \to \mathbb{R}^2 with T(1,1)=(3,1)T(1, 1) = (3, 1) and T(1,−1)=(1,3)T(1, -1) = (1, 3). The vectors (1,1)(1, 1) and (1,−1)(1, -1) form a basis. To find T(x,y)T(x, y), first find the coordinates of (x,y)(x, y) in that basis, then combine the images:

(x,y)=x+y2⋅(1,1)+x−y2⋅(1,−1)T(x,y)=x+y2⋅(3,1)+x−y2⋅(1,3)=(2x+y,2x−y)\begin{aligned} (x, y) &= \frac{x + y}{2} \cdot (1, 1) + \frac{x - y}{2} \cdot (1, -1) \\ T(x, y) &= \frac{x + y}{2} \cdot (3, 1) + \frac{x - y}{2} \cdot (1, 3) = (2x + y, 2x - y) \end{aligned}

In matrix form, with B=[v1v2]B = \begin{bmatrix} \mathbf{v}_1 & \mathbf{v}_2 \end{bmatrix} (basis vectors as columns) and W=[w1w2]W = \begin{bmatrix} \mathbf{w}_1 & \mathbf{w}_2 \end{bmatrix} (their images), the conditions say AB=WAB = W, so

A=WB−1=[3113]⋅12[111−1]=[212−1]A = WB^{-1} = \begin{bmatrix} 3 & 1 \\ 1 & 3 \end{bmatrix} \cdot \frac{1}{2}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix} = \begin{bmatrix} 2 & 1 \\ 2 & -1 \end{bmatrix}
python · try it yourself
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 T:P2→RT: P_2 \to \mathbb{R} on the basis 1,x,x21, x, x^2 by

T(1)=1,T(x)=12,T(x2)=13T(1) = 1, \qquad T(x) = \frac{1}{2}, \qquad T(x^2) = \frac{1}{3}

By the theorem this extends to exactly one linear map: T(a+bx+cx2)=a+b2+c3T(a + bx + cx^2) = a + \frac{b}{2} + \frac{c}{3}. The integral p↦∫01p(x) dxp \mapsto \int_0^1 p(x)\,dx is linear and has the same values on the basis (∫01xk dx=1k+1\int_0^1 x^k\,dx = \frac{1}{k + 1}), so by uniqueness TT is that integral. Checking three numbers proved an identity for every quadratic.

Application: Lagrange interpolation

Pick three distinct points x0,x1,x2x_0, x_1, x_2. The evaluation map E:P2→R3E: P_2 \to \mathbb{R}^3, E(p)=(p(x0),p(x1),p(x2))E(p) = (p(x_0), p(x_1), p(x_2)), is linear. Its kernel is {0}\{0\}, because a nonzero polynomial of degree ≤2\le 2 has at most two roots. By rank–nullity it is onto R3\mathbb{R}^3 as well, so it is an isomorphism.

Its inverse is easiest to define on the standard basis e0,e1,e2\mathbf{e}_0, \mathbf{e}_1, \mathbf{e}_2 of R3\mathbb{R}^3: send ej\mathbf{e}_j to the polynomial LjL_j that is 1 at xjx_j and 0 at the other two points,

Lj(x)=∏k≠jx−xkxj−xk(the Lagrange basis polynomials)E−1(y0,y1,y2)=y0L0+y1L1+y2L2\begin{aligned} L_j(x) &= \prod_{k \ne j} \frac{x - x_k}{x_j - x_k} && \text{(the Lagrange basis polynomials)} \\ E^{-1}(y_0, y_1, y_2) &= y_0L_0 + y_1L_1 + y_2L_2 \end{aligned}

That is the Lagrange interpolation formula: the unique quadratic through three given points. It works the same for n+1n + 1 points and degree nn.

python · try it yourself
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 LjL_j at the three points form a row of the identity matrix, and the interpolant for the values (2,0,8)(2, 0, 8) is 2x2−4x+2=2(x−1)22x^2 - 4x + 2 = 2(x - 1)^2.

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 T(1,0)=(1,0)T(1, 0) = (1, 0), T(0,1)=(0,1)T(0, 1) = (0, 1), T(1,1)=(5,5)T(1, 1) = (5, 5): impossible, linearity forces T(1,1)=(1,1)T(1, 1) = (1, 1)
a list that does not span many maps fit T(1,0,0)=1T(1, 0, 0) = 1 on R3\mathbb{R}^3 says nothing about T(0,1,0)T(0, 1, 0)

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 xx, yy, zz axes. "Fit the transform that maps these 3 points to those 3 points" is A=WB−1A = WB^{-1} (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 nn 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

T:R2→R2T: \mathbb{R}^2 \to \mathbb{R}^2 is linear with T(1,2)=(1,0)T(1, 2) = (1, 0) and T(0,1)=(2,1)T(0, 1) = (2, 1). Find T(3,4)T(3, 4) and the matrix of TT.

Answer

T(3,4)=(−1,−2)T(3, 4) = (-1, -2); matrix [−32−21]\begin{bmatrix} -3 & 2 \\ -2 & 1 \end{bmatrix}.

Solution
(3,4)=3⋅(1,2)−2⋅(0,1)→T(3,4)=3⋅(1,0)−2⋅(2,1)=(−1,−2)B=[1021],B−1=[10−21],W=[1201]A=WB−1=[1−420−21]=[−32−21]check: A(1,2)=(−3+4,−2+2)=(1,0)✓\begin{aligned} &(3, 4) = 3 \cdot (1, 2) - 2 \cdot (0, 1) \quad \to \quad T(3, 4) = 3 \cdot (1, 0) - 2 \cdot (2, 1) = (-1, -2) \\ &B = \begin{bmatrix} 1 & 0 \\ 2 & 1 \end{bmatrix}, \quad B^{-1} = \begin{bmatrix} 1 & 0 \\ -2 & 1 \end{bmatrix}, \quad W = \begin{bmatrix} 1 & 2 \\ 0 & 1 \end{bmatrix} \\ &A = WB^{-1} = \begin{bmatrix} 1 - 4 & 2 \\ 0 - 2 & 1 \end{bmatrix} = \begin{bmatrix} -3 & 2 \\ -2 & 1 \end{bmatrix} \\ &\text{check: } A(1, 2) = (-3 + 4, -2 + 2) = (1, 0) \quad \checkmark \end{aligned}

Exercise 2: Impossible values

Is there a linear T:R2→RT: \mathbb{R}^2 \to \mathbb{R} with T(1,1)=2T(1, 1) = 2 and T(2,2)=5T(2, 2) = 5? What about T(1,1)=2T(1, 1) = 2 and T(2,3)=5T(2, 3) = 5?

Answer

No for the first; yes (exactly one) for the second, namely T(x,y)=x+yT(x, y) = x + y.

Solution

(2,2)=2⋅(1,1)(2, 2) = 2 \cdot (1, 1) forces T(2,2)=4≠5T(2, 2) = 4 \ne 5. In the second case (1,1)(1, 1) and (2,3)(2, 3) form a basis (det⁡=3−2=1≠0\det = 3 - 2 = 1 \ne 0), so any values work. T(x,y)=ax+byT(x, y) = ax + by with a+b=2a + b = 2 and 2a+3b=52a + 3b = 5 gives b=1b = 1, a=1a = 1.

Exercise 3: Recognise the map

T:P2→P2T: P_2 \to P_2 is linear with T(1)=0T(1) = 0, T(x)=1T(x) = 1, T(x2)=2xT(x^2) = 2x. What is TT, and what is T(3−x+4x2)T(3 - x + 4x^2)?

Answer

TT is the derivative DD; T(3−x+4x2)=−1+8xT(3 - x + 4x^2) = -1 + 8x.

Solution

DD has the same values on the basis, so T=DT = D by uniqueness. T(3−x+4x2)=3⋅0−1⋅1+4⋅2x=−1+8xT(3 - x + 4x^2) = 3 \cdot 0 - 1 \cdot 1 + 4 \cdot 2x = -1 + 8x.

Exercise 4: Interpolate

Find the quadratic through (−1,3)(-1, 3), (0,1)(0, 1), (2,9)(2, 9) by solving for the coefficients, then confirm it with Lagrange polynomials in SymPy.

Answer

p(x)=2x2+1p(x) = 2x^2 + 1.

Solution
p=a+bx+cx2p(0)=a=1p(−1)=1−b+c=3→c−b=2p(2)=1+2b+4c=9→b+2c=4adding: 3c=6→c=2, b=0\begin{aligned} p &= a + bx + cx^2 \\ p(0) &= a = 1 \\ p(-1) &= 1 - b + c = 3 && \to \quad c - b = 2 \\ p(2) &= 1 + 2b + 4c = 9 && \to \quad b + 2c = 4 \\ &\text{adding: } 3c = 6 && \to \quad c = 2, \ b = 0 \end{aligned}
python · try it yourself
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

v1,v2,v3\mathbf{v}_1, \mathbf{v}_2, \mathbf{v}_3 is a basis of VV and w1,w2,w3\mathbf{w}_1, \mathbf{w}_2, \mathbf{w}_3 are arbitrary vectors in WW. How many linear maps T:V→WT: V \to W satisfy T(vi)=wiT(\mathbf{v}_i) = \mathbf{w}_i?

  1. None, unless the wi\mathbf{w}_i are independent
  2. Exactly one
  3. Infinitely many
  4. Exactly three

Which statement is a consequence of the uniqueness half of the theorem?

  1. Every linear map is invertible
  2. Two linear maps that agree on a basis are equal
  3. Linear maps preserve lengths
  4. The images of a basis must be a basis

If T(1,0)=(2,5)T(1, 0) = (2, 5) and T(0,1)=(−1,4)T(0, 1) = (-1, 4), what is the matrix of TT in the standard basis?

  1. [25−14]\begin{bmatrix} 2 & 5 \\ -1 & 4 \end{bmatrix}
  2. [2−154]\begin{bmatrix} 2 & -1 \\ 5 & 4 \end{bmatrix}
  3. [524−1]\begin{bmatrix} 5 & 2 \\ 4 & -1 \end{bmatrix}
  4. [−1245]\begin{bmatrix} -1 & 2 \\ 4 & 5 \end{bmatrix}