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.
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 <mailto: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
<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.