Take the 2-minute tour ×
MathOverflow is a question and answer site for professional mathematicians. It's 100% free, no registration required.

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.

share|improve this question
Cinderella.$ $ –  Wadim Zudilin Oct 15 '10 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 '10 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 '10 at 13:36

9 Answers 9

up vote 15 down vote accepted

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


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.

share|improve this answer
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 '10 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 '10 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 '10 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 '10 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 '10 at 22:24

SAGE: The free open-source mathematical software SAGE can also do what you want.

share|improve this answer
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 '10 at 16:28

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.

share|improve this answer

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.

share|improve this answer

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

share|improve this answer
GrafEq is awesome. It can even see if your algebraic curve has isolated points! –  J. M. Oct 18 '10 at 15:11
Yes, GrafEq uses robust, interval methods. –  lhf Oct 18 '10 at 15:13

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.


share|improve this answer

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
share|improve this answer

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
// 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$.

share|improve this answer

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.