How To Do Piecewise In Desmos
So, there I was, staring at a graph that looked like a confused toddler had been given a crayon and a sugar rush. My math teacher wanted me to plot a function that changes its mind halfway through. I felt like I was trying to teach a cat to fetch—possible, but not obvious. Then I discovered piecewise functions in Desmos, and it felt like finding the cheat code for your favorite video game.
The "Aha!" Moment with Curly Braces
Piecewise functions are just functions with a split personality. They behave one way before a certain point, and a completely different way after. In Desmos, the secret weapon is the curly brace {}.
Think of it like this: Desmos speaks math, but you have to whisper in its ear with the right syntax. You don’t need to write long, messy conditional statements. You just need to tell it: "Hey, for this range of x, use this formula." And then add another brace for the next range.
Must Read
- Did Kelly Clarkson Just Get Julia Roberts Treatment? The Untold Truth Behind Brooklyn’s $15m Animatronic Bird Drama
- The 5-minute Visit That Broke The Internet: How Kelly Clarkson Sparked A $15 Million Mechanical Bird War
- Petty Revenge Or Viral Genius? Brooklyn Store Slaps $15,000,000 Tag On Molly The Bird After Kelly Clarkson Backlash
The basic formula looks like this: y = {condition1: formula1, condition2: formula2}. That’s it. No magic spells, no hidden menus. Seriously, try it right now—open Desmos and type it in.
Your First Piecewise: The "Temperature Check"
Let’s say you want a graph that stays at y = 1 if x is less than 0, then jumps to y = 2 when x is 0 or more. That’s a simple step function. Type this into a new expression line: y = {x < 0: 1, x >= 0: 2}.
Boom. You see a horizontal line at 1, then a sudden jump to 2. Desmos automatically plots the gap or the closed dot depending on your inequality (yes, it’s that smart). Notice I used < and >=—you can use any standard inequality sign.
Side note: I once spent ten minutes wondering why my graph was blank. Turns out, I typed a comma instead of a colon. Commas separate the pieces; colons create the condition and the output pair. Don’t be that person.
Adding More than Two Pieces
You can have as many pieces as you want, like a mathematical Frankenstein’s monster. For example, a function that’s x + 1 when x is less than -2, 3 when x is between -2 and 2, and x - 1 when x is greater than 2.

Type: y = {x < -2: x + 1, -2 <= x < 2: 3, x >= 2: x - 1}. Desmos handles the overlapping conditions like a pro—just make sure your intervals don’t accidentally argue (like having the same x value in two different pieces).
Pro tip: If you’re doing a piecewise that uses a variable from a slider (like a), you can animate it. Imagine a graph that changes its behavior as you slide a number. It’s like watching a slow-motion train wreck, but in a beautiful way.
Dealing with "Floating" Pieces and Closed Circles
Sometimes you want a piece that is just a single point—like a lonely dot in the middle of nowhere. Use the point syntax: (2, 3) with a condition. For example, y = {x = 2: 3} will plot just the point (2, 3).
What about closed vs. open circles at the boundaries? Desmos uses your inequality sign to decide. If you use <= or >=, the dot is filled (closed). If you use < or >, it’s an open circle. Physics teachers love this for showing "jump discontinuities." You’ll feel like a wizard.
Another side comment: Want to hide the open circle’s "hole"? You can’t really, but you can add a separate point manually using a table if you’re desperate. But honestly, embrace the holes—they make your graph look edgy and academic.
Real Talk: Why You’d Bother
Piecewise functions aren’t just for torturing students in precalculus. They model real-life stuff like tax brackets, shipping costs, or the exact moment your mood switches from "I’m fine" to "don’t talk to me." If you’re a data nerd, you can even use them to create custom animations or visual filters.

One time, I used piecewise in Desmos to build a simple "traffic light" graph that turned red, yellow, and green based on a time slider. My friends thought I was a genius. I just knew how to type curly braces.
The main takeaway? Desmos treats piecewise functions as a single, chunky equation. You don’t need to define separate lines or use complicated logic. Just remember: {condition: expression, condition: expression}. It’s like talking to a very literal teenager.
Common Mistakes (That I Definitely Made)
First: forgetting to close all your curly braces. Desmos will highlight the error in red, but you’ll still panic. Second: using a regular equals sign = inside a condition instead of a double equals ==. Wait—actually, in Desmos, you can use a single = inside a condition for equality. Don’t overthink it.
Third: thinking you need to plot the pieces one at a time. No, no, no. Put it all in one expression line. Desmos is smart enough to hide the parts that don’t match the condition. You’re welcome.
Final side note: If you want to get fancy, you can use piecewise with parametric equations or even 3D graphs (Desmos 3D beta). But that’s a story for another day. For now, go forth and break your functions into pieces.
Now, go open Desmos. Type something weird. See what happens. You’ll either create math art or a complete disaster. Either way, you’ll learn something. And if you get stuck, blame the curly braces—I do.
