Skip to content
Glacius
FoundationsConcept reference

Affine functions

A scalar affine function multiplies its input by a fixed slope and adds a fixed intercept.

On this page 7 sections
  1. Overview
  2. A service uses 5 credits to start, plus 2 credits per job
  3. At x=0, the scaled part is zero and f(0)=b
  4. Check your understanding
  5. Key takeaway
  6. Sources & further reading
  7. Concept connections

01A service uses 5 credits to start, plus 2 credits per job#

A service uses 5 credits to start, plus 2 credits per job. At 3 jobs, the job cost is 2×3=62\times3=6 credits; adding the starting cost gives 11.

The graph is f(x)=2x+5. Its vertical intercept is 5. At x=3 it reaches 11. From input 0 to 3, the run is 3 and the rise is 6; the slope is 2.The graph is f(x)=2x+5. Its vertical intercept is 5. At x=3 it reaches 11. From input 0 to 3, the run is 3 and the rise is 6; the slope is 2.
Figure 1The graph is f(x)=2x+5. Its vertical intercept is 5. At x=3 it reaches 11. From input 0 to 3, the run is 3 and the rise is 6; the slope is 2.
Link to this figure ↗Download SVGDownload PNG

The affine rule records both parts.

f(x)=mx+bf(x)=mx+b

mm is the slope, the output change per input unit. bb is the intercept, the output at x=0x=0. Here, m=2m=2 and b=5b=5.

Check your reasoning

For f(x)=2x+5f(x)=2x+5, what is f(4)f(4)?

Show answer and explanation
13

Multiply 4 by 2, then add 5: 8+5=138+5=13.

02At x=0, the scaled part is zero and f(0)=b#

At x=0x=0, the scaled part is zero and f(0)=bf(0)=b. An intercept can be negative: with m=3m=3 and b=2b=-2, f(2)=3(2)2=4f(2)=3(2)-2=4.

Check your reasoning

Slope is 3; intercept is −2. Which expression gives f(4)f(4)?

  1. A3(4)23(4)-2
  2. B2(4)+3-2(4)+3
  3. C3(42)3(4-2)
Show answer and explanation
3(4)23(4)-2

Multiply by 3, then add the intercept −2.

03Check your understanding#

Check your reasoning

A calibration rule has slope −2 and intercept 7. What output does it assign to input 3?

Show answer and explanation
1

Use (2)(3)+7=6+7=1(-2)(3)+7=-6+7=1.

Key takeaway

Multiply the input by the slope, then add the intercept once.

  • Evaluate a scalar affine rule from its slope and intercept

Sources & further reading

  1. [1]

Reference this concept

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

Glacius. “Affine functions.” Math behind ML. /learn/f-affine