1

I need to plot this algebraic curve in tikz

enter image description here

but I don't understand how to deal with these curves in tikz since it's not a function. Desmos tells that it should look something like this

enter image description here

I only need a curve without axis or whatever and only in tikz.

  • 1
    Try pgfplots, not tikz. – tush Jun 08 '23 at 11:07
  • 1
    Either look it up, or: a) multiply with both roots, b) square it, c) sort terms, d) regroup for either x or y ... and there you go. // OR: introduce a parameter, e.g. a polar plot around (1.5,0). Express x and y by said parameters ... and there you go. // And so on. – MS-SPO Jun 08 '23 at 11:16
  • Q663247: Somebody has a very similar curve already in y (x) form. – Qrrbrbirlbel Jun 22 '23 at 13:53

1 Answers1

2

1

Considering the equation, an answer to your question should be composed of two steps in my opinion.

  1. Find a parametrisation of the curve defined by the equation.
  2. Use plot of TikZ to draw the curve.

The difficult part is 1) here. The code below is the explicit development of 2). As for 1), I won't give all the mathematical details. In case you need them, I could add them later. I try only to justify the constants and functions appearing in the code.

The equation must be put in a symmetrical form first. For example changing the x coordinate: s = x -3/2. At the end, we come back to the initial x coordinate. So, in what follows I consider the equation

1/sqrt((x+a)^2 +y^2) + 1/sqrt((x-a)^2 +y^2) = 2/a

We are looking for the points P at distance r_m from (-a, 0) and r_p from (a, 0) such that 1/r_m +1/r_p = 2/a. It is this geometrical problem that yields the parametrisation. The parameter is d, with r_m = a/2 +d. (The geometrical situation for a fixed value of d is represented in the next figure. The points (-a, 0) and (a, 0) appear as blue dots.)

enter image description here

The formulae for x and y appear in the functions eForX and eForY. The domain folows form compatibility conditions.

The code

\documentclass[11pt, margin=.5cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{math, calc}

\begin{document} % https://tex.stackexchange.com/questions/688042/algebraic-curve-plot-tikz

\tikzmath{ real \a, \dmin, \dmax; \a = 3/2; \dmin = (-1 +sqrt(5)/2)\a; \dmax = (1 +sqrt(5)/2)\a; \dFixed = .27\a; \rMFixed = \a/2 +\dFixed; \rPFixed = \a/2(\a/(2\dFixed) +1); function eForX(\t) {% \s = \t/\a; \res = \s\s +\s -1/(4\s) -1/(16\s\s); return \a/4\res; }; function eForY(\t) {% \res = (\a/2 +\t)(\a/2 +\t) -(eForX(\t) +\a)(eForX(\t) +\a); return sqrt(\res); }; }

\begin{tikzpicture}[every node/.style={scale=.5}] % translated coordinate system \draw[very thin, ->] (-2\a, 0) -- ++(4\a, 0) node[right] {$x$}; \foreach \i in {-1, 0, ..., 4}{% \draw (\i -\a, 0) -- ++(0, -2pt) node[below] {\i}; } \draw[very thin, ->] (-\a, -\a) -- ++(0, 2* \a) node[above] {$y$}; \draw[very thin, gray!50, xshift=-\a cm] (-\a, -\a) grid ++(4\a , 2 \a);

\draw[red, thick, variable=\t, domain=\a/2:\dmax, samples=100] plot ({eForX(\t)}, {eForY(\t)}); \draw[red, thick, variable=\t, domain=\a/2:\dmax, samples=100] plot ({-eForX(\t)}, {eForY(\t)});

\draw[red, thick, variable=\t, domain=\a/2:\dmax, samples=100] plot ({eForX(\t)}, {-eForY(\t)}); \draw[red, thick, variable=\t, domain=\a/2:\dmax, samples=100] plot ({-eForX(\t)}, {-eForY(\t)});

\filldraw[blue] (-\a, 0) circle (1pt) (\a, 0) circle (1pt); % \draw[blue] (-\a, 0) circle (\a/2 +\dmin); % \draw[blue] (\a, 0) circle (\a/2 +\dmax); \end{tikzpicture} \end{document}

Daniel N
  • 5,687