In case you haven’t met, a piecewise function is simply a function defined by multiple sub-functions. Each sub-function applies to a specific interval of the main function’s domain. Think of it as a choose-your-own-adventure novel, but for numbers.
Desmos makes this absurdly easy. You type something like y = {x < 0: x^2, x >= 0: sqrt(x)}, and suddenly, the graph splits into two distinct personalities. The left side is a gentle parabola; the right side is a stubborn square root curve. No judgment. Just pure, visual poetry.
The secret sauce is the curly braces { }. Inside, you write your condition, then a colon, then the expression. Desmos reads it like a calm robot: “If this is true, do that. Otherwise, do this other thing.” It’s that simple.
A Love Letter to the “Otherwise”
Here’s a pro tip that will make you feel like a wizard: you don’t have to define every interval. The final part of a piecewise function can be an “otherwise” statement. For example: y = {x < 1: 0, x > 5: 10, 5}. This creates a function that is 0 before 1, 10 after 5, and—magically—a flat 5 for everything in between.
It’s the most generous piecewise function you’ll ever meet. It doesn’t ask for exact boundaries; it just fills in the gaps. This is the Taylor Swift “Shake It Off” approach to math—acknowledge the extremes, and let the middle ground be something pure and simple.
Try it. It feels like cheating, but it’s not. It’s elegant laziness, and the math gods approve.