Absolute Value as a Piecewise Function

Category: Functions   Level: 201

|x| = -x (x < 0), x (x ≥ 0)

The absolute value is two lines glued at the origin. Keep the right half of y = x and the left half of y = −x, and the V shape appears.

Step through it

Watch it

Animated walkthrough

Step by step

Step 1: Draw two lines

Start with y = x and y = −x. Each one is a full line, and each one is wrong half the time.

y = x, y = -x

Step 1: Draw two lines

Step 2: Keep the right half of y = x

For x ≥ 0 the number is already positive, so |x| = x. Keep that half and drop the rest.

|3| = 3

Step 2: Keep the right half of y = x

Step 3: Keep the left half of y = -x

For x < 0 the minus sign flips a negative into a positive: −(−3) = 3. Keep the left half of y = −x.

|-3| = -(-3) = 3

Step 3: Keep the left half of y = -x

Step 4: Read the V

The two halves meet at the origin, the corner of the V. The graph never dips below the x-axis, because distance from zero is never negative.

|x| ≥ 0 for every x

Step 4: Read the V

All steps at once

Storyboard

Generate it yourself

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

Source: svgmath/diagrams/function_families.py