Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I am trying to plot a piecewise function in Maple and have the endpoints of each piece be an open circle or closed circle accordingly. To define the function, I did:

f := proc (x) options operator, arrow; piecewise(x <= -1, -2-x, -1 < x and x <= 1, 4-4*x^2, 1 < x, x^2-4*x+3);

The to get a picture I did:

plot(f(x), x = -4 .. 4, discont = true)

I'd like to have the point $(-1,0)$, coming from the parabola, to have an open dot. I can't figure out how to make that work. I am brand new to Maple.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

For this particular case use:

with(plottools):with(plots):
display(circle([-1, 0], 0.05, color = red), plot(f(x), x = -4 .. 4, discont = true));

share|improve this answer

One potential issue with using plottools:-circle is that the shape can appear as an ellipse if, say, the displayed x- and y-views are not equal and the scaling is not constrained. (Eg. change the x-range to x=-1.4 .. -0.9 to see this effect.)

Also, such a circle can get rendered a little roughly.

An alternative is to use plottools:-point and set the symbol to circle or solidcircle, which should render as circles regardless of the view or scaling.

You can even program it to compute the limits and value, etc.

restart:
with(plottools):with(plots):

f := x -> piecewise(x <= -1, -2-x,
                    -1 < x and x <= 1, 4-4*x^2,
                    1 < x, x^2-4*x+3):

setoptions(color="DarkRed", symbolsize=16, symbol=circle);

display(point([-1, limit(f(x),x=-1,right)]),
        point([-1, limit(f(x),x=-1,left)]),
        point([-1, f(-1)],  symbol=solidcircle),
        plot(f(x), x = -4 .. 4, discont = true));

In the above code a few plot options are set as new defaults, which can get overridden with optional arguments to the plotting commands. (Eg. symbol=solidcircle, when passed as an option, overrides the new default of symbol=circle.)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.