Smart Calculator

Piecewise Function Calculator

Piecewise Function Calculator & Grapher – Plot Functions by Interval

Define multiple function expressions with domain intervals, visualize them on an interactive graph, and handle open/closed endpoints, discontinuities, and asymptotes with precision.

Piecewise Function Definition
Define each piece of your piecewise function with expressions and domains
Piece 1
Piece 2
Piece 3
Interactive Graph
What is a Piecewise Function?

A piecewise function is a function that is defined by different expressions over different intervals of its domain. Each "piece" of the function applies to a specific range of input values, allowing for complex behaviors like discontinuities, different growth rates, and varied mathematical relationships.

Piecewise functions are commonly used to model real-world situations where different rules apply under different conditions, such as tax brackets, shipping costs, or physical phenomena with distinct phases.

How to Use the Calculator
  1. Define each piece by entering a mathematical expression (use x as the variable)
  2. Specify the domain for each piece using inequality notation (<=, <, >, >=)
  3. Choose colors for each piece to distinguish them on the graph
  4. Set the viewing window by adjusting Min/Max X and Y values
  5. Configure graph options (grid, axes, labels)
  6. Click "Plot Function" to visualize your piecewise function
  7. Use "Example" to load a sample piecewise function
Piecewise Function Formula & Rules
f(x) = {
  f₁(x),   if domain 1
  f₂(x),   if domain 2
  ⋮
  fₙ(x),   if domain n
}

Domain Notation:

  • Closed interval: a <= x <= b (includes endpoints)
  • Open interval: a < x < b (excludes endpoints)
  • Half-open: a <= x < b or a < x <= b
  • Unbounded: x > a, x <= b, etc.
  • Point domain: x = a (single point)

Endpoint Behavior:

  • Filled circle: Point is included (<=, >=, =)
  • Open circle: Point is excluded (<, >)
  • Discontinuities: Gaps where no piece is defined
  • Asymptotes: Vertical lines where function approaches ±∞
Example

Example piecewise function:

f(x) = {
  x²,          for -2 <= x < 0 (red)
  sin(x),      for 0 <= x <= 3 (blue)
  1/(x-2),   for 3 < x <= 5 (green)
}

Steps:

  1. Parse domain intervals and check for validity
  2. Plot each expression in its specified color within its domain
  3. Show filled circles at included endpoints, open circles at excluded endpoints
  4. Handle discontinuity at x=2 for the third piece (vertical asymptote)
  5. Display graph with legend showing expression → domain mapping

Output: Interactive graph showing three distinct pieces with proper endpoint markers, plus a table of sample evaluation points demonstrating which piece applies at different x-values.

FAQ

What is a piecewise function?

A piecewise function is a function defined by multiple sub-functions, each applying to a specific interval of the domain. It allows for different mathematical behaviors across different ranges of input values.

How do you graph piecewise functions?

Graph each piece separately within its specified domain, paying careful attention to endpoint inclusion/exclusion. Use filled circles for included endpoints and open circles for excluded endpoints. Connect continuous pieces and leave gaps for discontinuities.

What's the difference between open and closed intervals?

Closed intervals (<=, >=) include their endpoints, shown with filled circles. Open intervals (<, >) exclude their endpoints, shown with open circles. Half-open intervals include one endpoint but not the other.

Can piecewise functions be discontinuous?

Yes, piecewise functions can have discontinuities where pieces don't connect, have different values at boundaries, or where no piece is defined. They can also have vertical asymptotes where function values approach infinity.