I would like to create a graph of the piecewise function
$f(x) = \begin{cases} x + 2, & x < -1 \\ x^2, & -1 \leq x \leq 2 \\ 3, & x > 2\end{cases}$
where the changes in the definition of $f(x)$ are clearly demonstrated. Specifically, I would like to:
a) have each part of the definition graphed in a different colour;
b) have the appropriate open/closed disks (any simpler method than my tedious solution of plotting each disk?)
Here is what I have so far:
Plot[Piecewise[{{2+x,x<-1},{x^2,-1<x&&x<=2},{3,x>2}},0],{x,-5,6}, PlotStyle ->Thick, Epilog->{PointSize[0.03],Blue,Point[{-1,1}],PointSize[0.03],Blue,Point[{2,3}],PointSize[0.02],White,Point[{2,3}]}] Which yields this:
Again, although this has the dots, it's a very tedious solution, and I would like to be able to set the colour of the three parts, separately (ideally have Mathematica do it automatically).
I am looking for a solution that students using a sandboxed version of Mathematica (provided through WolframAlpha Pro) could implement.


