MathOverflow is a question and answer site for professional mathematicians. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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|cite|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

10 Answers 10

up vote 16 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|cite|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
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
Downvoted because there are free and open source alternatives which solve this problem. – Quadrescence Oct 15 '10 at 20:31
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
If I could accept multiple answers, I would have. This answer got the nod because it solved my immediate problem, but it might as well have been Julián Aguirre's answer, as SAGE is on my list of things I should get around to looking at, but haven't yet. Mathematica is 'free' in the sense that my university has it installed on its systems, but I agree that open-source alternatives should be encouraged. – Ketil Tveiten Oct 17 '10 at 11:37

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

share|cite|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" and the nice graphical user interface "surfex" by Oliver Labs and Stephan Holzer.

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

share|cite|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

share|cite|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

The mathematical visualization program 3D-XplorMath (which is freely available at 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|cite|improve this answer

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

DMelt has good plotting capabilities, with possibility to export math drawings in the vector graphics format (SVG, EPS, PDF). I would recommend to look at jhplot.HPlot3D JAVA class to draw jhplot.F2D functions

share|cite|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.