1) What a piecewise function is
A piecewise function is written as:
\[
f(x)=
\begin{cases}
f_1(x) & \text{if condition 1 holds} \\
f_2(x) & \text{if condition 2 holds} \\
\vdots \\
f_n(x) & \text{otherwise}
\end{cases}
\]
You should design the conditions so that together they cover the domain you care about (and ideally do not overlap).
If conditions overlap, the calculator (and many programming languages) will use the first matching case.
2) Common example: absolute value
The absolute value function is naturally piecewise:
\[
|x|=
\begin{cases}
-x & \text{if } x<0\\
x & \text{if } x\ge 0
\end{cases}
\]
This creates the well-known “V-shape” with a seamless join at \(x=0\).
3) Evaluating \(f(x_0)\)
- Start at the first condition.
- If it is true for \(x=x_0\), use that expression and stop.
- If false, move to the next condition.
- If no condition matches and there is no “otherwise”, then \(f(x_0)\) is undefined.
4) Boundaries and continuity
The interesting behavior happens at boundary points (breakpoints), where one formula stops and another begins.
At a boundary \(c\), we compare:
\[
f(c^-)=\lim_{x\to c^-} f(x), \qquad
f(c^+)=\lim_{x\to c^+} f(x), \qquad
f(c).
\]
- Continuous at \(c\): \(f(c^-)=f(c^+)=f(c)\).
- Jump discontinuity: \(f(c^-)\neq f(c^+)\) (a vertical “jump”).
- Removable discontinuity: \(f(c^-)=f(c^+)\) but \(f(c)\) is missing or different (a “hole”).
5) Table of values around breakpoints
A fast way to understand a piecewise function is to evaluate it at:
- each breakpoint \(c\)
- just to the left \(c-\varepsilon\) and just to the right \(c+\varepsilon\)
- midpoints between consecutive breakpoints
This gives an immediate “local picture” of continuity and jumps.
6) “Smooth piecewise?” (approximation idea)
Sometimes we want a single smooth-looking curve that approximates the piecewise definition.
One numerical trick is to blend neighboring pieces across each boundary using a smooth switching function
(like a sigmoid) over a small width \(\delta\). The calculator can overlay such a smoothed curve while still showing
the true piecewise graph.
7) Condition syntax supported by the calculator
- Single comparisons:
x<0, x<=2, x>=pi, x>-1
- Chained bounds:
-2<=x<1, 0<x<=3
- Final catch-all:
otherwise
Constants may use pi, e, and numeric expressions like pi/2.
Expressions may use functions such as sqrt, ln, sin, cos, abs, exp.