# Plot Algebraic Curves with TikZ/PGFPlots

Is there a way to plot this curve

    x^2y^2-x^2-3xy+2=0


using TikZ or PGFPlots using exaclty the equation given in order to have something like that?

• Shouldn't tikz or pgfplots support that kind of equation, you can tell tikz to compute the points with gnuplot and then plot the result. – gigabytes Jan 5 '17 at 8:51
• You already asked that kind of question tex.stackexchange.com/q/312675/95441. Where is the difference to your old question? – Stefan Pinnow Jan 5 '17 at 8:53
• There is no the answere that I need today. I need to plot the curve with 1 equation. – Andrea Leo Jan 5 '17 at 9:02
• why can't you separate as two equations for y and plot the two curves on the same axis, I don't know whether pgfplots can do that but why does it matter if it can't you can do it by hand or with other software before plotting. – David Carlisle Jan 5 '17 at 9:33
• Is tex.stackexchange.com/questions/18359/… helpful? – Torbjørn T. Jan 5 '17 at 10:02

As I already mentioned in the comment below the question I don't see anything new here compared to your other question. And as David already mentioned in his comment below the question what should be so bad to just draw two \addplots? If this would be an option, you could do the following. (I think adding the shaded areas should not be a problem for you.)

Please have a look at the comments in the code for more details.

\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
% set some appropriate y min and max values
ymin=-5,
ymax=5,
% increase the number of samples so the corresponding calculated y values
% are at minimum in the given y range AND the value at x = 0 is calculated
samples=101,
% just to be sure, plot the lines smoothly
smooth,
axis lines=middle,
% we don't need any x ticks
xtick=\empty,
% draw horizontal lines for asymptotes ...
% https://www.wolframalpha.com/input/?i=asymptotes+x%5E2y%5E2-x%5E2-3xy%2B2%3D0
ytick={-1,1},
grid=major,
% ... but we don't need any labels at them
yticklabels={,},
% print x and y labels
xlabel=$x$,
ylabel=$y$,
% move the y label to "the other side" so it is not overlapping
% with the plots
ylabel style={
anchor=north east,
},
% to filter away the zero values
unbounded coords=jump,
x filter/.expression={x==0 ? NaN : x},
]
% solve the equation x^2y^2-x^2-3xy+2=0 with Wolfram Alpha ...
% https://www.wolframalpha.com/input/?i=Solve%5Bx%5E2y%5E2-x%5E2-3xy%2B2%3D0,+y%5D
% ... and draw them in the same style
\addplot [red] {(3*x - sqrt(4*x^4 + x^2))/(2*x^2)};
\addplot [red] {(3*x + sqrt(4*x^4 + x^2))/(2*x^2)};

% find the values for y = 0 and add some nodes
% https://www.wolframalpha.com/input/?i=Solve%5Bx%5E2y%5E2-x%5E2-3xy%2B2%3D0,+y%3D0%5D
\addplot [only marks] coordinates {(-sqrt(2),0) (sqrt(2),0)}
node [at start,above right] {$A_1$}
node [at end,below left]    {$A_2$}
;
\end{axis}
\end{tikzpicture}
\end{document}