Skip to content
Glacius
Linear algebraConcept reference

Affine maps

An affine map applies a linear map and then adds a fixed output vector.

On this page 9 sections
  1. Overview
  2. An affine map applies a matrix, then adds a fixed output vector
  3. After the matrix step, two outputs are P=(1,2) and Q=(2,4)
  4. Check your understanding
  5. Check your understanding
  6. Key takeaway
  7. Further questions
  8. Sources & further reading
  9. Concept connections
This translation is the affine example T(x)=Ix+b with b=(3,−1). P=(1,2) moves to (4,1); Q=(2,4) moves to (5,3). The two offset arrows have the same direction and length. Both coordinate axes use equal units.This translation is the affine example T(x)=Ix+b with b=(3,−1). P=(1,2) moves to (4,1); Q=(2,4) moves to (5,3). The two offset arrows have the same direction and length. Both coordinate axes use equal units.
Figure 1This translation is the affine example T(x)=Ix+b with b=(3,−1). P=(1,2) moves to (4,1); Q=(2,4) moves to (5,3). The two offset arrows have the same direction and length. Both coordinate axes use equal units.
Link to this figure ↗Download SVGDownload PNG

01An affine map applies a matrix, then adds a fixed output vector#

An affine map applies a matrix, then adds a fixed output vector. The matrix controls the linear part; the added vector shifts every output.

Write the two contributions separately.

T(x)=Ax+bT(x)=Ax+b

Let A have rows (2,1) and (0,1), with b=(3,-1). For x=(1,2), the row dot products give Ax=(4,2).

Add 3 to the first entry and -1 to the second.

T(x)=(7,1)T(x)=(7,1)
Check your reasoning

For T(x)=(4x12,x1+x2+3)T(x)=(4x_1-2,x_1+x_2+3), which is the linear part?

  1. A(4x12,x1+x2)(4x_1-2,x_1+x_2)
  2. B(4x1,x1+x2)(4x_1,x_1+x_2)
  3. C(2,3)(-2,3)
Show answer and explanation
(4x1,x1+x2)(4x_1,x_1+x_2)

The linear part contains the input terms. The offset is (-2,3).

02After the matrix step, two outputs are P=(1,2) and Q=(2,4)#

After the matrix step, two outputs are P=(1,2) and Q=(2,4). Adding b=(3,-1) moves each three units right and one unit down.

Two matrix outputs P=(1,2) and Q=(2,4) each move three units right and one unit down. They arrive at (4,1) and (5,3).Two matrix outputs P=(1,2) and Q=(2,4) each move three units right and one unit down. They arrive at (4,1) and (5,3).
Figure 2Two matrix outputs P=(1,2) and Q=(2,4) each move three units right and one unit down. They arrive at (4,1) and (5,3).
Link to this figure ↗Download SVGDownload PNG

For an affine map, T(0)=b because A0=0. A nonzero offset prevents linearity. When b=0, the map is simply the linear map Ax.

Check your reasoning

T(x)=Ax+(0,5). Why is this map not linear?

  1. AA has to be square.
  2. BT(0) must equal A.
  3. CT(0)=(0,5) is nonzero.
Show answer and explanation
T(0)=(0,5) is nonzero.

Every linear map sends zero to zero; this offset moves it to (0,5).

03Check your understanding#

Check your reasoning

A supplied score map gives Wx=(6,-2), then adds fixed bias b=(-1,4). What is the second output?

Show answer and explanation
2

Add the second offset to the second matrix output: -2+4=2.

04Check your understanding#

Check your reasoning

A doubles vectors; b=(1,-1). Someone uses A(x+b) for Ax+b. Which repair works?

  1. AAdd b afterward.
  2. BDouble b too.
  3. CSubtract b first.
Show answer and explanation
Add b afterward.

Keep b outside A so its value stays (1,-1).

Key takeaway

Apply the matrix, then add its fixed output offset.

  • Separate the matrix action from the translation.

Further questions

Can an affine map also be linear?
Yes. When its fixed offset is zero, T(x)=Ax is linear.
Where do I read the fixed offset?
For a supplied affine map, evaluate it at the zero vector: T(0)=b.

Sources & further reading

  1. [1]
  2. [2]

Reference this concept

Link to this page, a section, or an individual figure.

Glacius. “Affine maps.” Math behind ML. /learn/la-affine-map