ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 12 Jul 2012 15:04:54 -0500Is there a reasonable way to plot arcsec (real) without having a line connecting the branches?http://ask.sagemath.org/question/9104/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?Fri, 22 Jun 2012 06:40:52 -0500http://ask.sagemath.org/question/9104/is-there-a-reasonable-way-to-plot-arcsec-real-without-having-a-line-connecting-the-branches/Answer by benjaminfjones for <p>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?</p>
http://ask.sagemath.org/question/9104/is-there-a-reasonable-way-to-plot-arcsec-real-without-having-a-line-connecting-the-branches/?answer=13739#post-id-13739Try 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.Fri, 22 Jun 2012 08:06:47 -0500http://ask.sagemath.org/question/9104/is-there-a-reasonable-way-to-plot-arcsec-real-without-having-a-line-connecting-the-branches/?answer=13739#post-id-13739Comment by dasmith88 for <p>Try the <code>exclude</code> optional argument to plot to tell sage to ignore specific points not in the domain of the function, e.g.</p>
<pre><code>plot(arcsec(x), (x,-8,8), exclude=[-1,1])
</code></pre>
<p>Note that this option technically just excludes the poles at <code>x=-1</code> and <code>x=1</code> but Sage gracefully ignores the points in between which are not in the domain.</p>
http://ask.sagemath.org/question/9104/is-there-a-reasonable-way-to-plot-arcsec-real-without-having-a-line-connecting-the-branches/?comment=19529#post-id-19529That 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.Fri, 22 Jun 2012 10:08:39 -0500http://ask.sagemath.org/question/9104/is-there-a-reasonable-way-to-plot-arcsec-real-without-having-a-line-connecting-the-branches/?comment=19529#post-id-19529Comment by kcrisman for <p>Try the <code>exclude</code> optional argument to plot to tell sage to ignore specific points not in the domain of the function, e.g.</p>
<pre><code>plot(arcsec(x), (x,-8,8), exclude=[-1,1])
</code></pre>
<p>Note that this option technically just excludes the poles at <code>x=-1</code> and <code>x=1</code> but Sage gracefully ignores the points in between which are not in the domain.</p>
http://ask.sagemath.org/question/9104/is-there-a-reasonable-way-to-plot-arcsec-real-without-having-a-line-connecting-the-branches/?comment=19413#post-id-19413I'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).Thu, 12 Jul 2012 15:04:54 -0500http://ask.sagemath.org/question/9104/is-there-a-reasonable-way-to-plot-arcsec-real-without-having-a-line-connecting-the-branches/?comment=19413#post-id-19413Comment by dasmith88 for <p>Try the <code>exclude</code> optional argument to plot to tell sage to ignore specific points not in the domain of the function, e.g.</p>
<pre><code>plot(arcsec(x), (x,-8,8), exclude=[-1,1])
</code></pre>
<p>Note that this option technically just excludes the poles at <code>x=-1</code> and <code>x=1</code> but Sage gracefully ignores the points in between which are not in the domain.</p>
http://ask.sagemath.org/question/9104/is-there-a-reasonable-way-to-plot-arcsec-real-without-having-a-line-connecting-the-branches/?comment=19528#post-id-19528Maybe the right question is whether plot can test for and plot only points that are real -- instead of plotting real parts?Fri, 22 Jun 2012 10:12:12 -0500http://ask.sagemath.org/question/9104/is-there-a-reasonable-way-to-plot-arcsec-real-without-having-a-line-connecting-the-branches/?comment=19528#post-id-19528Comment by Jason Grout for <p>Try the <code>exclude</code> optional argument to plot to tell sage to ignore specific points not in the domain of the function, e.g.</p>
<pre><code>plot(arcsec(x), (x,-8,8), exclude=[-1,1])
</code></pre>
<p>Note that this option technically just excludes the poles at <code>x=-1</code> and <code>x=1</code> but Sage gracefully ignores the points in between which are not in the domain.</p>
http://ask.sagemath.org/question/9104/is-there-a-reasonable-way-to-plot-arcsec-real-without-having-a-line-connecting-the-branches/?comment=19527#post-id-19527That's a good point. Sage should break the graph when it gets a math domain error, instead of ignoring the point.Fri, 22 Jun 2012 10:47:38 -0500http://ask.sagemath.org/question/9104/is-there-a-reasonable-way-to-plot-arcsec-real-without-having-a-line-connecting-the-branches/?comment=19527#post-id-19527