How to write a piecewise function

A piecewise function uses different formulas on different intervals of its domain, written as one function with a brace and a condition for each piece. To write one you need four things:

An outdoor staircase with ten red steps between pale walls
A staircase of separate steps, like the pieces of a piecewise function.Photo: GerardoPatinho / Pixabay
  1. 1

    The breakpoints

    Where the rule changes.

  2. 2

    A formula per piece

    One expression for each interval.

  3. 3

    Conditions

    Inequalities that say where each applies.

  4. 4

    No overlap

    Each x belongs to exactly one piece.

Do your homework in Evernote. The AI Assistant explains any problem you photograph, step by step.

Keep your formulas in Evernote

How to write a piecewise function in 5 steps

  1. 1

    Find where the rule changes

    Read the problem or the graph for breakpoints: a price that changes after 2 GB, a line that bends at x = 0.

  2. 2

    Write the formula for each interval

    Work out each rule separately, as if it were its own function.

  3. 3

    Write the conditions

    Use inequalities for each interval. Decide which piece includes each breakpoint, using ≤ on one side and < on the other.

  4. 4

    Put them in one brace

    Write f(x) = { formula 1, if condition 1; formula 2, if condition 2 }, one row per piece.

  5. 5

    Test a value in each piece

    Check one x from each interval, and the breakpoints, against the problem or the graph.

Piecewise function example

A phone data plan

A plan costs $20 a month for up to 2 GB of data, plus $10 for each GB over 2. Write the cost as a function of x GB, and find the cost for 3.5 GB.

  1. 1Breakpointx = 2 GB
  2. 2FormulasUp to 2 GB: 20. Over 2 GB: 20 + 10(x − 2)
  3. 3Conditions0 ≤ x ≤ 2 and x > 2
  4. 4Functionf(x) = 20, if 0 ≤ x ≤ 2
    f(x) = 20 + 10(x − 2), if x > 2
  5. 5Testf(1) = 20; f(2) = 20; f(3.5) = 20 + 10(1.5) = 35

The cost for 3.5 GB is f(3.5) = $35

The two pieces meet at x = 2 (both give $20), so the graph has no jump there.

Common piecewise functions

Each one is a single function made of simpler pieces.

FunctionPiecewise formNote
Absolute value|x| = x if x ≥ 0; −x if x < 0A V shape with its corner at 0
Tiered price20 if 0 ≤ x ≤ 2; 20 + 10(x − 2) if x > 2Continuous at the breakpoint
Step function1 if 0 < x ≤ 1; 2 if 1 < x ≤ 2; 3 if 2 < x ≤ 3Jumps at each whole number
Jump at a pointx + 1 if x < 0; x² if x ≥ 0Left side approaches 1, right side starts at 0

OpenStax Calculus Volume 1, section 1.2 "Basic Classes of Functions" (piecewise-defined functions), and College Algebra 2e, section 3.2.

Trusted by Millions Worldwide

4.4

2,100+ reviews on G2

4.4

8,200+ reviews on Capterra

4.4

73,000+ reviews on App Store

248M

Registered users

Piecewise function questions

What is a piecewise function?

A function defined by different formulas on different parts of its domain. It is still one function: each input gets exactly one output.

How do I evaluate a piecewise function?

Find the condition that the x-value meets, then use only that piece's formula. For the plan above, f(3.5) uses the second piece.

How do I write a piecewise function from a graph?

Split the graph where it changes shape. Find the equation of each part (for example a line: use slope and a point), then use open and closed dots to choose < or ≤.

Can the pieces overlap?

No. If one x were in two pieces with different outputs, it would not be a function. Breakpoints belong to one piece only.

What do open and closed circles mean?

A closed (filled) circle means the endpoint is included, ≤ or ≥. An open circle means it is not, < or >.

Is a piecewise function continuous?

Only if the pieces meet at every breakpoint. Check that the formulas on each side give the same value there.

How to keep your function notes with Evernote

Keep a Math notebook with your algebra formula sheet and a note for each problem you photograph.

  1. 1

    Build a formula sheet.

    Ask the AI Assistant to add the piecewise function rule to your algebra formula sheet, with one worked example. It writes the formula in a formula block, so it reads like the textbook.

  2. 2

    Explain a problem.

    Add a photo of your algebra problem, such as the phone data plan, and ask the Assistant to explain it step by step. It reads the photo and adds the steps under it.

  3. 3

    Practice before the test.

    Ask the Assistant for a repeating practice task, such as 10 piecewise function problems every Tuesday and Thursday until the test. You get a reminder each time.

  • You can also search for a word in your photographed worksheets and find the page.
  • You can also draw a graph by hand in a sketch block.
  • You can also ask the AI Assistant to write practice problems from your notes, with answers.

Keep every formula and worked example in one place

Build a formula sheet, photograph a problem for a step-by-step explanation, and practice on a schedule before the test.

Start for free