First time here? Check out the FAQ!

Ask Your Question
0

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

asked 12 years ago

dasmith88 gravatar image

updated 12 years ago

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?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
0

answered 12 years ago

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.

Preview: (hide)
link

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 ( 12 years ago )

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 ( 12 years ago )
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 ( 12 years ago )

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 ( 12 years ago )

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: 12 years ago

Seen: 802 times

Last updated: Jun 22 '12