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.
Piecewise
. If none of the conditions above it evaluate toTrue
, then the last condition automatically evaluates toTrue
, 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 evaluatePiecewise[{{-1, True}, {1, x > 0}}]
. $\endgroup$x
be a complex number? It will default to0
in that case. $\endgroup$x
. There might also be something about the implementation ofPiecewise
that makes that sort of thing difficult. For possible hints of that, take yourf[x]
,Simplify
it, and look at the output. $\endgroup$