## Are there any good computer programs for drawing (algebraic) curves?

I realise that I lack some intuition into how a curve (or surface, or whatever) looks geometrically, from just looking at the equation. Thus, I sometimes resort to some computer program (such as Mathematica) to draw me a picture. The problem is, all these programs require input of the form $y=f(x)$, whereas my curve might be something like $y^3+x^3-6x^2 y=0$, and transforming this into the former form is not always easy, and always misses some information. So, my question:

Are there any programs that can take an equation ($p(x,y)=0$, say) as input and return a graph of its zero-set?

Update: So, lots of good answers, I wish I could accept them all. I'll accept Jack Huizenga's answer, for the reason of personal bias that I already have Mathematica available.

-
Cinderella. – Wadim Zudilin Oct 15 2010 at 11:44
[offtop] Your curve is a union of lines, because polynomial is homogeneous. You can just denote by $a_i$ solutions of $y^3+1-6y=0$ and write $y^3+x^3-6 x^2y=(y-a_1 x)(y-a_2 x)(y-a_3 x)$.[/offtop] – Fiktor Oct 15 2010 at 12:29
If you have access to Mathematica and it produces the diagram you want, fine, but for more control use gnuplot+tikz. – JS Milne Oct 18 2010 at 13:36

Mathematica does this just fine. You're looking for the command ContourPlot, as in

ContourPlot[y^3+x^3-6x^2y==0,{x,-5,5},{y,-5,5}].

A more serious issue is that if you're trying to do algebraic geometry over $\mathbb C$, the real picture isn't always terribly enlightening.

-
The bright side is that the real picture may be easy to draw: think of $x^2+y^2+1=0$ ... – Georges Elencwajg Oct 15 2010 at 11:49
And of course, in the example Ketil posted, the curve is just a union of three lines, all meeting at the origin. I agree real pictures are definitely worth something, especially when first cutting your teeth with the material. – Jack Huizenga Oct 15 2010 at 11:58
That's exactly what I am talking about. I would have no idea that this curve was a union of lines, just by looking at it. – Ketil Tveiten Oct 15 2010 at 12:11
Actually, with a bit more experience, its quite easy to see that. Any homogeneous polynomial in 2 variables factors as a product of linear forms over $\mathbb C$; it's also not hard to see that these complex lines intersect the real plane in real lines. – Jack Huizenga Oct 15 2010 at 13:11
Mathematica is "freely" available to most people who post on this site, and the original poster demonstrated he was already familiar with and had access to Mathematica. – Jack Huizenga Oct 15 2010 at 22:24

The mathematical visualization program 3D-XplorMath (which is freely available at http://3D-XplorMath.org) will do this easily. When the program starts up, first select the "Plane Curve" category, then select the "User Implicit" object, and then just enter your polynomial $p(x,y)$ in the "User-2D Curve" Dialog and click the Create button.

-

link textThe free open-source mathematical software SAGE can also do what you want.

-
Here's how to do this in Sage: var('x,y'); contour_plot(y^3+x^3-6*x^2*y==0, (x,-3,3), (y,-3,3)) – William Stein Oct 15 2010 at 16:28

I really like GrafEq. There's also Jep Implicit Plotter, which is interactive.

Wolfram Alpha understands Mathematica syntax and is free. The example given is http://www.wolframalpha.com/input/?i=ContourPlot%5By%5E3%2Bx%5E3-6x%5E2y%3D%3D0%2C%7Bx%2C-5%2C5%7D%2C%7By%2C-5%2C5%7D%5D

-
 GrafEq is awesome. It can even see if your algebraic curve has isolated points! – J. M. Oct 18 2010 at 15:11 Yes, GrafEq uses robust, interval methods. – lhf Oct 18 2010 at 15:13

The software packages Octave and scilab can also do this. An example for $y^3 + x^3 - 6x^2y=0$ would be as follows. Change the last line from contour(z) to surf(z) to get a surface plot; to surfl(z) to get a shaded and illuminated surface plot.

xmin=-5.0; xstep=0.1; xmax=5.0; // replace with your values
ymin=.... ;                     // replace with your values
// // generate x,y lattice points for plot
[x y]=meshgrid(xmin:xstep:xmax, ymin:ystep:ymax);
// // define z=f(x,y), replace with your desired function
z=y.^3 + x.^3 - 6 * x.^2 .* y;
// // now perform contour plot of function
contour(z);
// or surf(z), or surfl(z) for surface plots


and Octave and Scilab are free software and open-source software which can be freely downloaded and used on multiple operating system platforms.

If you've got a Macintosh with OS X, or System 9, you can use the built in Graphing Calculator program NuCalc to directly type in the equation, zoom in and out, and fly around the 3-d surface plot; Graphing Calculator can also do inequalitiies such as $x^2+y^2 \gt 5$.

-

In case anyone else is looking to this for advice, I'll add that Maple can also do this. The algcurves package has the command plot_real_curve(f,x,y,options) where f is your curve and x and y are the variables you use.

The benefit of this package is the default plot includes all 'interesting' points, and won't let you miss out.

http://www.maplesoft.com/support/help/Maple/view.aspx?path=algcurves/plot_real_curve

-

I can also recommend "surf" http://surf.sourceforge.net/ and the nice graphical user interface "surfex" http://www.surfex.algebraicsurface.net/ by Oliver Labs and Stephan Holzer.

This program produces really nice renders of algebraic surfaces (and curves). Check out http://www.algebraicsurface.net/ for examples. Some of you might also remember the old covers of the Suse Linux distribution. Those were made with this programs.

-

In Gnuplot, you can do this by (ab)using the 3D contour plot feature.

gnuplot> f(x,y) = x**2+y**2-1
gnuplot> set contour
gnuplot> set cntrparam levels discrete 0
gnuplot> set view 0,0
gnuplot> unset surface
gnuplot> splot f(x,y)


You can get a smoother curve by doing something like

gnuplot> set isosamples 500,500
gnuplot> replot

-

For high quality pictures of surfaces like these, Herwig Hauser apparently uses povray. It's not really what you're asking for and probably overkill, but I thought I'll add it for the record.

-