# Piecewise Function, Explanation of Extra Case

Consider: Can someone explain why the 0, True occurs?

As a second question, I like to fill the endpoints as follows:

Plot[f[x], {x, -2, 2},
Epilog -> {Blue, PointSize[Large],
Point[{{-1, 3}, {-1, -1}, {1, 1}, {1, 0}}],
White, PointSize[Medium],
Point[{{-1, 3}, {1, 1}}]
}] Does anyone use an easier method for filled and unfilled endpoints?

Update: A lot of folks mentioned the possibility that x could be a complex number. I gave that a try. Watch what happened. So I still am not sure how to explain this 0, True situation to my students.

• It's a default added automatically to the end of Piecewise. If none of the conditions above it evaluate to True, then the last condition automatically evaluates to True, and the function spits out a 0. You can change that default by explicitly putting in, say {-1, True}. Piecewise tests its arguments in order: for example, ponder on the output when you evaluate Piecewise[{{-1, True}, {1, x > 0}}]. – march Dec 17 '15 at 4:20
• As for your update, see this post. – march Dec 17 '15 at 5:09
• What happens when you let x be a complex number? It will default to 0 in that case. – Chip Hurst Dec 17 '15 at 5:11
• I can only speculate, but I imagine it's because there might be some problems with checking to see if all the conditions cover every possible value of x. There might also be something about the implementation of Piecewise that makes that sort of thing difficult. For possible hints of that, take your f[x], Simplify it, and look at the output. – march Dec 17 '15 at 6:09
• "every possible value of $x$" - I don't see your construction covering complex arguments; recall that Mathematica assumes everything is complex unless told otherwise. – J. M. is in limbo Dec 17 '15 at 6:43

Piecewise[conds] automatically evaluates to Piecewise[conds,0].
This implies that the default {0, True} item is added to the Piecewise. It is the same as if you wrote
f[x_] = Piecewise[{{2 - x, x < -1}, {x, -1 <= x < 1}, {(x - 1)^2, x >= 1}, {0, True}}]