Ask Your Question
0

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

asked 2012-06-22 13:40:52 +0200

dasmith88 gravatar image

updated 2012-06-22 13:56:51 +0200

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
0

answered 2012-06-22 15:06:47 +0200

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

Comments

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 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?

dasmith88 gravatar imagedasmith88 ( 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.

Jason Grout gravatar imageJason Grout ( 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).

kcrisman gravatar imagekcrisman ( 2012-07-12 22:04:54 +0200 )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

Stats

Asked: 2012-06-22 13:40:52 +0200

Seen: 706 times

Last updated: Jun 22 '12