1

I want to draw this equation in LaTeX using tikz (maybe with pgfplots):

(x^2+y^2) + \frac{0.7}{\sqrt((x-0.3)^2+y^2)} + \frac{0.3}{\sqrt((x+0.7)^2+y^2)} = 2.5

enter image description here

This is from geogebra: enter image description here


I tried gnuplot:

\begin{tikzpicture}
        \draw plot[raw gnuplot] function{
        f(x,y) = (x**2+y**2) + 0.7/(sqrt((x-0.3)**2+y**2)) + 0.3/(sqrt((x+0.7)**2+y**2)) - 1.5;
        set xrange [-4:4];
        set yrange [-4:4];
        set view 0,0;
        set isosample 1000, 1000;
        set sample 1000, 1000;
        set size square;
        set contour base;
        set cntrparam levels incre 0,0.1,0;
        unset surface;
        splot f(x,y);
    };
\end{tikzpicture}

I need to turn on -shell-escape:

How to enable `shell escape' (or `write18') - Visual Studio Code (Latex Workshop extension)

On the other hand, I tried pst-func but it failed to plot my function.

I am also willing to find any solution without gnuplot as I do not want to install a new software for one chart

F. Pantigny
  • 40,250

1 Answers1

0

a lualatex answer

\begin{figure}[ht!]
    \centering
    \begin{tikzpicture}
        \begin{axis}[
        view={0}{90},
        samples=40,
        domain=-3:3,
        axis equal=true,
        axis lines=middle,
        xtick=\empty,ytick=\empty,
        max=3,min=-3,
        xlabel={$x$},ylabel={$y$},
        width=7.5cm, height=7.5cm,
        ]
        \addplot3 [black, contour lua={levels={1.397, 1.42, 1.5, 1.6456751, 1.7782065, 1.9600748, 2.5, 3.5},labels=false}] {0.5*(x^2+y^2) + 0.7/(sqrt((x-0.3)^2+y^2)) + 0.3/(sqrt((x+0.7)^2+y^2))};
        \addplot3[only marks, mark size=3.5pt] coordinates {(0.3,0,0)};
        \addplot3[only marks, mark size=1.5pt] coordinates {(-0.7,0,0)};
        \addplot[only marks, mark size=0.5pt] coordinates {(-0.28613,0) (-1.25673,0) (1.12321,0) (-0.2,-0.8660254) (-0.2,0.8660254)};
        \end{axis}
    \end{tikzpicture}
    \caption{lagrange points}
\end{figure}