Ask Your Question

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

asked 2012-06-22 06:40:52 -0500

dasmith88 gravatar image

updated 2012-06-22 06:56:51 -0500

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 flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2012-06-22 08:06:47 -0500

benjaminfjones gravatar image

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.

edit flag offensive delete link 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.

dasmith88 gravatar imagedasmith88 ( 2012-06-22 10:08:39 -0500 )edit

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

dasmith88 gravatar imagedasmith88 ( 2012-06-22 10:12:12 -0500 )edit

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

Jason Grout gravatar imageJason Grout ( 2012-06-22 10:47:38 -0500 )edit

I've made this - 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).

kcrisman gravatar imagekcrisman ( 2012-07-12 15:04:54 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-06-22 06:40:52 -0500

Seen: 502 times

Last updated: Jun 22 '12