-1

How do I graph this equation in PGF-TikZ:

x^2+((96*y/69)-(sqrt(abs(x))))^2=1

using \usepackage{pgf,tikz}?

EDIT: What about this one:

-2(x^2)-2(y^4)+3(y^3)+2(y^2)-(2*(x^2)*(y^2))+(x/3)=0

teed
  • 241

1 Answers1

6

The first one is a simple quadratic equation which can be solved on paper easily with the two solutions

enter image description here

This can then be graphed using pgfplots.

\documentclass{article}
\pagestyle{empty}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[
    domain=-1:1,
    samples=101,
    smooth,
    no markers,
    ]
    \addplot {23/32*(sqrt(abs(x)) - sqrt(1-x^2))};
    \addplot {23/32*(sqrt(abs(x)) + sqrt(1-x^2))};
  \end{axis}
\end{tikzpicture}
\end{document}

enter image description here


For equations like the one in the comments the approach is the following:

  1. Rewrite the equation to isolate zero on the left-hand side.
  2. Plug the resulting right-hand side into a contour plot.
  3. To solve the equation, instruct gnuplot to plot the contour at level 0.

Also set labels=false, otherwise the resulting line will be annotated with 0 everywhere. Since you are calling an external program (gnuplot) you have to use pdflatex -shell-escape.

% arara: pdflatex: { shell: yes }
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[
      view={0}{90},
      samples=101,
      no markers,
    ]

    \addplot3+[
      contour gnuplot={
        levels=0,
        labels=false,
      }
    ]
    {-2*(x^2)-2*(y^4)+3*(y^3)+2*(y^2)-(2*(x^2)*(y^2))+(x/3)};

  \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

Henri Menke
  • 109,596