How to Write a Piecewise Function from a Graph: Step-by-Step Guide

By culbreath Editorial · 2026-10-09 · 5 min read

A piecewise function describes a graph that follows different rules over different intervals of the domain. To write a piecewise function from a graph, you analyze each segment separately: determine the equation for that segment and specify where it applies. This means identifying changes in behavior, finding the correct expression for each part—such as linear, constant, or quadratic—and clearly stating the domain for each piece.

Identify the Different Parts of the Graph

Start by locating where the graph changes. Look for shifts in slope, jumps, or distinct shapes. Each segment represents a separate rule. Open circles mean a point is not included; closed circles mean it is. These markers help define exact domain boundaries.

For example, if a line ends at $ x = 2 $ with a closed circle and another begins with an open circle at the same $ x $-value, only the closed side includes $ x = 2 $. This prevents overlap and ensures each input maps to exactly one output, preserving the function’s definition.

Segments may connect, jump, or end abruptly. Horizontal lines indicate constant values. Straight slanted lines suggest linear equations. Note whether segments touch at endpoints—this affects how domains are written.

Determine the Equation for Each Segment

Once segments are identified, find the equation for each.

For linear parts, use two clear points on the line. Calculate slope $ m = \frac{y_2 - y_1}{x_2 - x_1} $, then use point-slope form: $ y - y_1 = m(x - x_1) $. Simplify to slope-intercept form if needed.

If a segment is horizontal, the output doesn’t change. The equation is simply $ y = c $, where $ c $ is the constant $ y $-value.

For curved pieces like parabolas, more advanced methods may be needed, but most graphs at this level use linear or constant segments.

Always verify your equation by plugging in known points from the graph. If the result matches, the equation fits.

Define the Domain for Each Piece

Each equation applies only over a specific interval. Use $ x $-values to define these domains precisely.

Suppose a segment starts at $ x = -1 $ with a closed circle and ends at $ x = 3 $ with an open circle. The domain is $ -1 \leq x < 3 $. Closed circles use $ \leq $ or $ \geq $; open ones use $ < $ or $ > $.

Avoid overlapping domains. If one piece ends at $ x = 2 $ with a closed circle and the next starts at $ x = 2 $ with an open circle, only the first includes $ x = 2 $. The second must start with $ x > 2 $.

Isolated points—like a single dot at $ (4, 5) $—are valid. Write them as $ f(x) = 5 $ for $ x = 4 $.

Make sure every part of the graph is covered, with no gaps.

Example: Writing a Piecewise Function from a Graph

Consider a graph with three parts:

  1. A line from $ (-4, 0) $ to $ (0, 4) $, with closed circles at both ends.
  2. A horizontal line at $ y = 2 $ from $ x = 0 $ (open circle) to $ x = 3 $ (closed circle).
  3. A single point at $ (4, 5) $.

Step 1: Identify segments.

  • First segment: slanted line.
  • Second: horizontal line.
  • Third: isolated point.

Step 2: Find equations.

  • First line: slope $ m = \frac{4 - 0}{0 - (-4)} = 1 $. Using point $ (0, 4) $, equation is $ y = x + 4 $.
  • Second: constant at $ y = 2 $.
  • Third: $ y = 5 $ at $ x = 4 $.

Step 3: Define domains.

  • First: from $ x = -4 $ to $ x = 0 $, both closed → $ -4 \leq x \leq 0 $.
  • Second: starts after $ x = 0 $, ends at $ x = 3 $, closed → $ 0 < x \leq 3 $.
  • Third: single point → $ x = 4 $.

Step 4: Write the function.

$$ f(x) = \begin{cases} x + 4, & -4 \leq x \leq 0 \ 2, & 0 < x \leq 3 \ 5, & x = 4 \end{cases} $$

Verification:

  • At $ x = 0 $: first piece applies → $ f(0) = 0 + 4 = 4 $.
  • At $ x = 1 $: second piece → $ f(1) = 2 $.
  • At $ x = 3 $: still in second piece → $ f(3) = 2 $.
  • At $ x = 4 $: third piece → $ f(4) = 5 $.
  • At $ x = 0.1 $: second piece → $ f(0.1) = 2 $, since $ 0.1 > 0 $.
  • No overlaps or gaps.

This matches the graph exactly.

Key Takeaways

  • A piecewise function is built by analyzing each segment of a graph separately.
  • Identify where the graph changes and use open or closed circles to determine domain boundaries.
  • Find the equation for each segment using slope, intercepts, or known forms like constant or linear.
  • Write the final function with a brace, listing each expression and its exact domain.
  • Always check that domains do not overlap and that all parts of the graph are included.
  • Practice with real graphs improves accuracy—use tools like Desmos or Khan Academy for interactive learning.

Frequently Asked Questions

How do you write a piecewise function from a graph?
To write a piecewise function from a graph, identify the different intervals on the x-axis where the function behaves differently. For each interval, determine the equation of the line or curve and specify its domain using inequalities.
What are the steps to find the equations for each part of a piecewise function from a graph?
First, locate the breakpoints where the graph changes behavior. Then, for each segment, find the slope and y-intercept or use points to write the equation, and define the function rule along with its corresponding domain.
How do you determine the domain for each piece of a piecewise function?
Look at the x-values over which each segment of the graph extends. Use solid dots to include endpoints and open dots to exclude them, then write the domain for each piece using inequality notation.
Can a piecewise function include both linear and nonlinear parts?
Yes, a piecewise function can combine linear, quadratic, constant, or other types of functions. Each segment is defined by its own rule over a specific interval of the domain.
What does an open circle vs. a closed circle mean on a piecewise graph?
An open circle indicates that the endpoint is not included in the interval, while a closed circle means it is included. This helps determine whether inequalities in the domain are strict or inclusive.
piecewise functiongraphing functionsalgebramath helpfunction notation

References

← Back to home