27
$\begingroup$

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.

$\endgroup$
3
  • 2
    $\begingroup$ Cinderella.$ $ $\endgroup$ Oct 15, 2010 at 11:44
  • 7
    $\begingroup$ [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] $\endgroup$
    – Fiktor
    Oct 15, 2010 at 12:29
  • 2
    $\begingroup$ If you have access to Mathematica and it produces the diagram you want, fine, but for more control use gnuplot+tikz. $\endgroup$
    – JS Milne
    Oct 18, 2010 at 13:36

10 Answers 10

18
$\begingroup$

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.

$\endgroup$
8
  • 9
    $\begingroup$ The bright side is that the real picture may be easy to draw: think of $x^2+y^2+1=0$ ... $\endgroup$ Oct 15, 2010 at 11:49
  • 2
    $\begingroup$ 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. $\endgroup$ Oct 15, 2010 at 13:11
  • 1
    $\begingroup$ Downvoted because there are free and open source alternatives which solve this problem. $\endgroup$ Oct 15, 2010 at 20:31
  • 5
    $\begingroup$ 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. $\endgroup$ Oct 15, 2010 at 22:24
  • 1
    $\begingroup$ 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. $\endgroup$ Oct 17, 2010 at 11:37
25
$\begingroup$

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

$\endgroup$
1
  • 17
    $\begingroup$ 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)) $\endgroup$ Oct 15, 2010 at 16:28
13
$\begingroup$

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.

$\endgroup$
6
$\begingroup$

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

$\endgroup$
2
  • $\begingroup$ GrafEq is awesome. It can even see if your algebraic curve has isolated points! $\endgroup$ Oct 18, 2010 at 15:11
  • $\begingroup$ Yes, GrafEq uses robust, interval methods. $\endgroup$
    – lhf
    Oct 18, 2010 at 15:13
5
$\begingroup$

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.

$\endgroup$
4
$\begingroup$

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

$\endgroup$
4
$\begingroup$

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
$\endgroup$
4
$\begingroup$

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

$\endgroup$
3
$\begingroup$

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.

$\endgroup$
0
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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