# Is there a reasonable way to plot arcsec (real) without having a line connecting the branches?

I'm working on a student exploration of inverse trig functions (interact), and I'd like to plot y=arcsec(x), say from -8 to 8, without having to specify the domain. How do I turn off the spurious line that Sage draws?

edit retag close merge delete

Sort by ยป oldest newest most voted

Try the exclude optional argument to plot to tell sage to ignore specific points not in the domain of the function, e.g.

plot(arcsec(x), (x,-8,8), exclude=[-1,1])


Note that this option technically just excludes the poles at x=-1 and x=1 but Sage gracefully ignores the points in between which are not in the domain.

more

That works to draw the correct graph, but I don't see how to put it in an interact -- where the student enters the function -- without excluding [-1,1] for every function the student might choose. It's basically a graphing calculator with student control of functions and ranges. And I'm trying not to give too much away. Thanks for pointing out the exclude -- I was missing that one.

( 2012-06-22 17:08:39 +0200 )edit

Maybe the right question is whether plot can test for and plot only points that are real -- instead of plotting real parts?

( 2012-06-22 17:12:12 +0200 )edit
1

That's a good point. Sage should break the graph when it gets a math domain error, instead of ignoring the point.

( 2012-06-22 17:47:38 +0200 )edit

I've made this http://trac.sagemath.org/sage_trac/ticket/13246 - it's actually relatively tricky, because we throw away those points in generate_plot_points and returning them along with it to pass to exclude would require changing that somewhat (or something equivalent), not to mention efficiency concerns. But it's doable for this kind of function (not for things like 1/x, of course, where it's nearly impossible to actually hit the singularity).

( 2012-07-12 22:04:54 +0200 )edit