More conceptually, one can use, with care, Sage's substitution facilities:
sage: var('u v x y t');
sage: f=y^2-x^3+x
sage: fs=(f.subs(x=u*3*t^(-1/2),y=v*3*t^(-1/2))*t^(3/2)).expand() #
only works with extra variable t
sage: implicit_plot(fs.subs(t=1-u^2-v^2),(u,-1,1),(v,-1,1))

On Thu, Mar 5, 2020 at 5:13 PM Dima Pasechnik <dimp...@gmail.com> wrote:
>
> In fact, substituting x and y directly into the equation of the curve
> to plot, and clearing denominators,
> produces something pretty good,IMHO:
>
> implicit_plot(v^2*3*sqrt(1-u^2-v^2)-u^3*9+u*(1-u^2-v^2),(u,-1,1),(v,-1,1))
>
>
> On Thu, Mar 5, 2020 at 4:51 PM Dima Pasechnik <dimp...@gmail.com> wrote:
> >
> > On Thu, Mar 5, 2020 at 2:32 PM Fernando Gouvea <fqgou...@colby.edu> wrote:
> > >
> > > This works, in the sense that there's no error. One does get a bunch of 
> > > extraneous points near the boundary of the disk. It's as if plot_points 
> > > were trying to connect the point at (0,1) and the point at (0,-1) along 
> > > the circle, even though f_uv is 1 on the circle.
> > >
> > > Strangely, they occur only on the right hand side (i.e., positive u, not 
> > > negative u). I tried setting plot_points to be 500, but the bad points 
> > > don't go away. Changing the curve to y^2-x^3+x-1=0 doesn't make them go 
> > > away either.
> > >
> >
> > the reason is that implicit_plot attempts to approximate the function
> > it assumes continuous, so if it's negative inside, but near, the
> > boundary, and positive nearby, but outside, then a fake zero is being
> > drawn very close to the boundary.
> >
> > That's why it should be better to create a plot in polar coordinates
> > and then transform it.
> >
> >
> >
> > > Fernando
> > >
> > > On 3/5/2020 8:22 AM, Dima Pasechnik wrote:
> > >
> > > The easiest way is to use Python functions rather than symbolic ones;
> > > define a function that is 1 outside the unit disk, and implicitly plot it.
> > >
> > > sage: def f_uv(u,v):
> > > ....:     if u^2+v^2>=1:
> > > ....:         return 1
> > > ....:     else:
> > > ....:         x=u*sqrt(9/(1-u^2-v^2))
> > > ....:         y=v*sqrt(9/(1-u^2-v^2))
> > > ....:         return y^2-x^3+x
> > > ....: implicit_plot(f_uv,(u,-1,1),(v,-1,1))
> > > >
> > >>
> > >> > On Tue, Mar 3, 2020 at 8:20 PM Fernando Gouvea <fqgou...@colby.edu> 
> > >> > wrote:
> > >> >
> > >> > Here's what I ended up trying, with r=3:
> > >> >
> > >> > var('x y u v')
> > >> > x=u*sqrt(9/(1-u^2-v^2))
> > >> > y=v*sqrt(9/(1-u^2-v^2))
> > >> > implicit_plot(y^2-x^3+x==0,(u,-1,1),(v,-1,1))
> > >> >
> > >> > That gives an error:
> > >> >
> > >> > /opt/sagemath-8.9/local/lib/python2.7/site-packages/sage/ext/interpreters/wrapper_rdf.pyx
> > >> >  in sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ 
> > >> > (build/cythonized/sage/ext/interpreters/wrapper_rdf.c:2237)()
> > >> >      74         for i from 0 <= i < len(args):
> > >> >      75             self._args[i] = args[i]
> > >> > ---> 76         return self._domain(interp_rdf(c_args
> > >> >      77             , self._constants
> > >> >      78             , self._py_constants
> > >> >
> > >> > ValueError: negative number to a fractional power not real
> > >> >
> > >> > Is there some way to tell implicit_plot to stay inside u^2+v^2\leq 1? 
> > >> > Or to ignore complex values?
> > >> >
> > >> > I'd just change the limits of u and v to make the rectangle of the
> > >> > values you plot in, anyway,
> > >> > to well stay inside the unit circle.
> > >> >
> > >> > The equivalent code seems to give the correct graph in Mathematica.
> > >> >
> > >> > Fernando
> > >> >
> > >> > On 2/29/2020 5:29 PM, Fernando Gouvea wrote:
> > >> >
> > >> > Some years ago in a book review, David Roberts had the idea of 
> > >> > plotting an algebraic curve using the transformation  (u,v) = 
> > >> > (x,y)/(r2 + x2 + y2)1/2, which transforms the plane into a circle and 
> > >> > makes it easy to visualize the projective completion of the curve. You 
> > >> > can see some of his plots at 
> > >> > https://www.maa.org/press/maa-reviews/rational-algebraic-curves-a-computer-algebra-approach
> > >> >
> > >> > I’d love to do this kind of plot for my students. Can anyone offer 
> > >> > help on how to do it with Sage? (Of course the dream scenario would be 
> > >> > to add this option to the plot method for curves...)
> > >> >
> > >> > I’ve been using implicit_plot for most of my examples, which seems to 
> > >> > be equivalent of using C.plot() when C is a curve.
> > >> >
> > >> > Thanks,
> > >> >
> > >> > Fernando
> > >
> > > --
> > > =============================================================
> > > Fernando Q. Gouvea         http://www.colby.edu/~fqgouvea
> > > Carter Professor of Mathematics
> > > Dept. of Mathematics and Statistics
> > > Colby College
> > > 5836 Mayflower Hill
> > > Waterville, ME 04901
> > >
> > > We now face a choice between Christ and nothing, because Christ has
> > > claimed everything so that renouncing him can only be nihilism.
> > >   -- Peter Leithart
> > >
> > > --
> > > You received this message because you are subscribed to the Google Groups 
> > > "sage-support" group.
> > > To unsubscribe from this group and stop receiving emails from it, send an 
> > > email to sage-support+unsubscr...@googlegroups.com.
> > > To view this discussion on the web visit 
> > > https://groups.google.com/d/msgid/sage-support/bc81b0c4-62ff-65b9-a7f2-e995f26f9234%40colby.edu.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/CAAWYfq1_oFX58Zu6jLwGk%2Bk6Qr8qELOKJedNXXVT82JDh4ZZ%2BQ%40mail.gmail.com.

Reply via email to