2

Problem: I want to graph the curve defined by the equation $\left(x^2+y^2\right)^2=x^2-y^2$ in the $xy$-plane. I want to use pgfplots.

My attempt: I tried \addplot {(x^2+y^2)^2=x^2-y^2} but I am getting several errors about using $y$ in this context or using $=x$.

Question: Is there a workaround for plotting implicit equations? Should I switch it to polar? If so, can I graph a polar equation on the $xy$-plane?

EDITED: My solution was to use \addplot [data cs=polar,domain=0:180,samples=361] (\x,{sqrt(cos(2*x))}). I found this idea in the manual in Section 4.23 on Transforming Coordinate Systems. I also added a plot for the negative square root to plot the lower half of the curve.

Stefan Pinnow
  • 29,535

1 Answers1

3

As I know, to draw implicit plots, we can try hard with TikZ/GNUplot/pgfplots (see this, for example). With Asymptote, it is straightforward.

enter image description here

// Run on http://asymptote.ualberta.ca/
size(5cm);       // size of figure   
import graph;    // module for xaxis, y axis, etc
import contour;  // module for contour

// define implicit function of the Lemnisace real f(real x, real y) {return (x^2 + y^2)^2 -(x^2-y^2);}
// the contour for f(x,y)=0 guide[][] pf = contour(f,(-1,-1),(1,1),new real[] {0});

// draw the first branch (here is the only branch) draw(pf[0],blue+1pt);

xaxis("$x$",-1.2,1.4,Arrow(TeXHead)); yaxis("$y$",-.5,.6,Arrow(TeXHead));

Black Mild
  • 17,569