13. Definition and examples; linearity conditions

📖 Reading · 10 min
💡 Every code box below is live — edit it and hit Run.

Module 17 studied vector spaces as static objects. This module studies the functions between them that respect their structure — and it turns out matrix-vector multiplication (§16.2) has been an example of exactly this all along, just not named as one yet.

Definition

A function T:V\to W between vector spaces is a linear transformation if it preserves both vector-space operations:

T(\vec u+\vec v)=T(\vec u)+T(\vec v)\qquad\text{(additivity)} T(c\vec v)=cT(\vec v)\qquad\text{(homogeneity)}

for all \vec u,\vec v\in V and scalars c. Together, these are equivalent to the single condition that T preserves every linear combination:

T(c_1\vec v_1+\cdots+c_k\vec v_k)=c_1T(\vec v_1)+\cdots+c_kT(\vec v_k)

An immediate consequence: T(\vec0)=\vec0 always, for any linear T — take c=0 in homogeneity: T(\vec0)=T(0\cdot\vec v)=0\cdot T(\vec v)=\vec0. This gives an instant test to rule out non-linearity: if T(\vec0)\neq\vec0, T cannot be linear, full stop (though T(\vec0)=\vec0 alone does not prove linearity — it's necessary, not sufficient).

Examples

  • Matrix-vector multiplication: T(\vec x)=A\vec x for a fixed matrix A is linear, directly from §16.2's distributive properties: A(\vec u+\vec v)=A\vec u+A\vec v and A(c\vec v)=cA\vec v. Every example below either is this, or turns out to secretly be this, once §18.1 supplies the matrix.
  • Differentiation T(p)=p' on P_n: (p+q)'=p'+q' and (cp)'=cp' — both standard calculus facts, restated as linearity of the derivative operator.
  • Definite integration T(f)=\int_a^bf(x)\,dx on C[a,b]: linear by the same two calculus rules for integrals.
  • The zero transformation T(\vec v)=\vec0 for every \vec v, and the identity transformation T(\vec v)=\vec v: both trivially linear, and both useful as extreme cases to test a claim against.
  • Rotation, reflection, scaling of the plane about the origin: shown linear geometrically in §18.2, and given explicit matrices there.

Non-examples

  • T(x)=x+1 on \mathbb{R} (an affine, not linear, map): T(0)=1\neq0, failing the necessary condition above immediately. This is the single most common source of "almost linear" functions that aren't — anything with a constant term added on.
  • T(x,y)=(x^2,y): T(2,0)=(4,0), but 2\,T(1,0)=2(1,0)=(2,0)\neq(4,0) — fails homogeneity. Any squaring, product of coordinates, or other nonlinear combination breaks linearity the same way §17.0 broke subspace membership for y=x^2.
  • T(x,y)=(|x|,y): T(-1,0)=(1,0), but -1\cdot T(1,0)=-1(1,0)=(-1,0)\neq(1,0) — fails homogeneity for negative scalars specifically, a common trap since additivity alone can look fine on non-negative inputs.

Determined entirely by action on a basis

A linear transformation is completely determined by where it sends a basis. If \{\vec b_1,\dots,\vec b_n\} is a basis of V and T(\vec b_1),\dots,T(\vec b_n) are specified, then for any \vec v\in V, write \vec v=c_1\vec b_1+\cdots+c_n\vec b_n (possible and unique, by §17.2) and linearity forces

T(\vec v)=c_1T(\vec b_1)+\cdots+c_nT(\vec b_n)

— no other consistent choice exists. This is the single most useful fact in this lesson: it means specifying a linear transformation on infinitely many vectors reduces to specifying it on just n of them, and it's exactly what makes §18.1's matrix representation possible: the matrix's columns are nothing but T applied to each standard basis vector.

Doing it in Python

Checking linearity numerically (a numerical check can refute linearity by finding a counterexample, but can never prove it for every input — proof requires the algebraic argument above):

import numpy as np

def T_linear(v):
    x, y = v
    return np.array([2*x - y, x + 3*y])

def T_nonlinear(v):
    x, y = v
    return np.array([x**2, y])

u, v = np.array([1., 2.]), np.array([3., -1.])
c = 5.0

print("linear T:  T(u+v) == T(u)+T(v):",
      np.allclose(T_linear(u + v), T_linear(u) + T_linear(v)))
print("linear T:  T(c*u) == c*T(u):   ",
      np.allclose(T_linear(c * u), c * T_linear(u)))

print("\nnonlinear T:  T(u+v) == T(u)+T(v):",
      np.allclose(T_nonlinear(u + v), T_nonlinear(u) + T_nonlinear(v)))
linear T:  T(u+v) == T(u)+T(v): True
linear T:  T(c*u) == c*T(u):    True

nonlinear T:  T(u+v) == T(u)+T(v): False

Reconstructing T(\vec v) purely from its action on a basis, confirming the "determined entirely by a basis" claim:

import numpy as np

# T is only specified by T(e1) and T(e2) -- nothing else
Te1 = np.array([2., 1.])
Te2 = np.array([-1., 3.])

def T(v):
    x, y = v
    return x * Te1 + y * Te2   # linearity forces exactly this formula

v = np.array([4., -2.])
print("T(v) built from basis images:", list(T(v)))

# Cross-check against the "obvious" matrix form
A = np.column_stack([Te1, Te2])
print("A @ v:                      ", list(A @ v))
T(v) built from basis images: [10.0, -2.0]
A @ v:                       [10.0, -2.0]

Worked example

Is T(x,y,z)=(x+2y,\,3z-y,\,x-z) linear? If so, find T(1,0,0), T(0,1,0), T(0,0,1).

Check the general form: every output component is a sum of constant multiples of x,y,z with no squares, products, or constants added — the hallmark of linearity, worth confirming directly: T(\vec u+\vec v) component-by-component, e.g. first component ( u_1+v_1)+2(u_2+v_2)=(u_1+2u_2)+(v_1+2v_2), matches T(\vec u)_1+T(\vec v)_1 — and identically for the other two components and for scaling.

\boxed{T\text{ is linear}}

T(1,0,0)=(1,0,1), T(0,1,0)=(2,-1,0), T(0,0,1)=(0,3,-1).

Sanity check. By the basis-determination fact, T(2,1,3) should equal 2T(1,0,0)+1T(0,1,0)+3T(0,0,1)=2(1,0,1)+(2,-1,0)+3(0,3,-1)=(2,0,2)+(2,-1,0)+(0,9,-3)=(4,8,-1). Direct substitution: T(2,1,3)=(2+2,\,9-1,\,2-3)=(4,8,-1) ✓ — both routes agree exactly.

Your turn

1. Is T(x,y)=(3x,\,x-y,\,0) linear? If so, describe it in words.

2. Is T(x,y)=(xy,\,x+y) linear?

3. True or false: if T(\vec0)=\vec0, then T must be linear.

Solutions

1. Yes, linear — every output is a constant-coefficient combination of x,y with no products or constants. It maps \mathbb{R}^2 into \mathbb{R}^3, i.e. V=\mathbb{R}^2, W=\mathbb{R}^3; nothing requires V and W to have the same dimension.

2. No. The first component, xy, is a product of the two variables — check T(1,0)+T(0,1)=(0,1)+(0,1)=(0,2), but T(1,1)=(1,2): T(1,0)+T(0,1)\neq T(1,1), so additivity fails concretely (matching the general rule that any product of coordinates breaks linearity).

3. False. T(\vec0)=\vec0 is necessary but not sufficient — e.g. T(x,y)=(x^2,y) satisfies T(0,0)=(0,0) but was already shown non-linear above (fails homogeneity at (2,0) vs. 2T(1,0)). A one-sided implication can never be strengthened to an equivalence just because no counterexample was checked for the other direction.

Check yourself in code

Given T specified only by T(1,0)=(2,-1,3) and T(0,1)=(0,4,-2), compute T(5,-3) using linearity, and verify against the matrix form A\vec v for A built from those two images as columns.

Print exactly this:

T(v) from linearity: [10.0, -17.0, 21.0]
A @ v:                [10.0, -17.0, 21.0]
match: True
import numpy as np

Te1 = np.array([2., -1., 3.])
Te2 = np.array([0., 4., -2.])
v = np.array([5., -3.])

Tv = v[0] * Te1 + v[1] * Te2
print("T(v) from linearity:", list(Tv))
# build A from Te1, Te2 as columns, print "A @ v:" the same way, then whether they match
import numpy as np

Te1 = np.array([2., -1., 3.])
Te2 = np.array([0., 4., -2.])
v = np.array([5., -3.])

Tv = v[0] * Te1 + v[1] * Te2
print("T(v) from linearity:", list(Tv))

A = np.column_stack([Te1, Te2])
Av = A @ v
print("A @ v:               ", list(Av))
print("match:", bool(np.allclose(Tv, Av)))

A linear transformation preserves addition and scalar multiplication — equivalently, preserves every linear combination — and T(\vec0)=\vec0 is a quick necessary (not sufficient) test. Crucially, T is completely determined by its action on any basis of its domain, which is exactly what makes it possible to package T as a single matrix, next.

Next: turning "determined by a basis" into an explicit matrix representation — the columns of T's matrix are exactly the images of the standard basis vectors.