Piecewise Functions

Category: Functions   Level: 201

f(x) = x + 4 (x < -1), 1 (-1 ≤ x ≤ 2), x - 3 (x > 2)

A piecewise function uses different rules on different stretches of x. Solid dots mark endpoints that belong to a piece, and hollow dots mark endpoints that do not.

Step through it

Watch it

Animated walkthrough

Step by step

Step 1: Split the x-axis

The rule changes at x = −1 and at x = 2. Those two cuts split the x-axis into three stretches, and each stretch gets its own rule.

cuts at x = -1 and x = 2

Step 1: Split the x-axis

Step 2: Draw the first piece

Left of −1, f(x) = x + 4. The line would reach 3 at x = −1, but −1 is not in this piece, so the end gets a hollow dot.

x + 4 → 3 at x = -1, open end

Step 2: Draw the first piece

Step 3: Draw the middle piece

From −1 to 2 the function is flat at 1. Both ends belong to this piece, so both get solid dots.

f(x) = 1 on -1 ≤ x ≤ 2

Step 3: Draw the middle piece

Step 4: Draw the last piece

Right of 2, f(x) = x − 3. It starts just above x = 2 at height −1, so that end is hollow too.

x - 3 → -1 at x = 2, open end

Step 4: Draw the last piece

Step 5: Read values at the cuts

At a cut, use the solid dot. So f(−1) = 1, not 3, and f(2) = 1, not −1. A vertical line at a cut hits one solid dot, so f is still a function.

f(-1) = 1, f(2) = 1, f(5) = 2

Step 5: Read values at the cuts

All steps at once

Storyboard

Generate it yourself

cd svg-generator
python3 -m svgmath render piecewise-function --out /tmp/piecewise-function

Source: svgmath/diagrams/function_families.py