Piecewise-Defined Functions

Some functions use different formulas for different parts of their domain. These are called piecewise-defined functions. The absolute value, signum, and floor functions are classic examples that appear throughout mathematics, engineering, and computer science.

Quick Reference

Function Formula Key property
Absolute value Always nonnegative; V-shaped graph
Signum Extracts the sign of
Floor / Greatest integer = largest integer Rounds down to nearest integer

Piecewise-Defined Functions

A piecewise-defined function is one that uses different formulas for different subsets of its domain.

For example, the function g: ℝ → ℝ defined by

is a piecewise-defined function.

The Absolute Value Function

The absolute value function is defined by

The absolute value gives the distance of from zero on the number line. Its graph is V-shaped with vertex at the origin.

The V-shaped graph of the absolute value function y = |x|.
Graph of .

The Signum (Sign) Function

The signum function (or sign function), denoted , is defined by

The signum function extracts the sign of a real number: positive inputs give , negative inputs give , and zero gives .

The graph of the signum function y = sgn(x), showing horizontal rays at y=1 and y=-1, and a point at the origin.
Graph of .

The Greatest Integer (Floor) Function

The greatest integer function (or floor function), denoted , is the largest integer less than or equal to . In other words, it rounds down to the nearest integer:

Examples:

Note that for negative numbers, rounding down means rounding away from zero.

  • The floor function maps (all integers).
  • Other notations: and .
The step-stair graph of the greatest integer (floor) function y = ⌊x⌋.
Graph of . Each step extends from one integer to the next, with the left endpoint included and right endpoint excluded.

Evaluating and Graphing Piecewise Functions

A function is defined by

Evaluate , , , and plot the graph.

Solution Since , use the middle formula: Since , use the middle formula: Since , use the bottom formula:
A graph of a piecewise-defined function with three distinct linear segments.
Graph of the piecewise function .

Frequently Asked Questions

How do I know which formula to use when evaluating a piecewise function? Find which piece's condition is satisfied by the input value and use that piece's formula. The conditions must cover all of the domain without overlapping. If a boundary point (like ) appears in the condition, check whether it belongs to the left piece, the right piece, or both (only one should claim it).

What is the difference between the floor and ceiling functions? The floor rounds down (toward ). The ceiling rounds up (toward ). For example, and ; and .

Where do piecewise functions appear in real life? Everywhere! Tax brackets are piecewise: different tax rates apply to different income ranges. Shipping costs are piecewise: flat rates per weight tier. Electricity rates are piecewise: tiered pricing by usage. The step-like graphs of such real-world functions are familiar from everyday bills and invoices.