Piecewise
y = ((x > 0) ?(x²) :(−x))
Open in the app The dials and keys named below are the app's.
What it draws
One function with two rules. To the right of the origin it is x², a parabola reaching 16 at the edge of the span. To the left it is −x, a straight line climbing away from the origin at 45 degrees, reaching 4 at the far edge. The two meet at x = 0, where both are zero.
The formula is stored the way it would be pasted from a book, as a cases environment. Each rule takes a row, the value first and the condition after an ampersand, and otherwise closes the last row in place of a second test. The plate above the plot shows what that became, a single conditional expression.
Continuous but not smooth
Both pieces arrive at the same height at the join, so the curve has no step in it and can be drawn without lifting the pen. The slopes do not match. Coming from the left the gradient is −1, and leaving to the right it is 2x, which is 0 at the origin. That mismatch is the kink, and it is the whole reason piecewise definitions are interesting: continuity and smoothness are separate properties, and a join can have the first without the second.
Try
- Break the continuity by changing the second row to 1 − x. The left piece now arrives at 1 while the right leaves from 0, and the curve jumps.
- Make it smooth instead, with −x replaced by 0. Both value and slope agree at the join, and the kink disappears.
- Add a third row before the others: 4 & x > 2 flattens the parabola into a plateau beyond x = 2, with a kink there too.
- Type the same thing as a ternary, x > 0 ? x² : −x. Identical plot, since that is what the cases rows became.