0

I want to plot an equation, not a function, with TikZ. Is there any general way to realize it without calculation?

For example to plot the equation: 2x²-2xy+2y²=1 as follows

enter image description here

Ingmar
  • 6,690
  • 5
  • 26
  • 47
Ben
  • 105
  • 7
  • Place a \node, e.g. at (1.5, 0.4), and enter text in math mode, like \node at (1.5, 0.4) {$2 x^2 ...$}; . That should do the job. – MS-SPO Jun 12 '22 at 10:52
  • 1
    The pedestrian way: find the corresponding function, e.g. in wolframalpha.com 2x^2 - 2xy + 2y^2 = 1; solve (y): y = 1/2 (x - sqrt(2 - 3 x^2)), y = 1/2 (x + sqrt(2 - 3 x^2)) – Alexander Wittmann Jun 12 '22 at 11:09
  • 1
    ...or you can use the plotting of implicit function through gnuplot: https://tex.stackexchange.com/questions/18359/plotting-an-implicit-function-using-pgfplots – Rmano Jun 12 '22 at 11:18

1 Answers1

0

This (standing on the shoulder of giants) works. There is a warning Missing character: There is no ` in font nullfont! which I do not like at all, but I am not sure where it comes from.

You must compile with -shell-escape and have a recent gnuplot installed and reachable in your standard PATH.

\documentclass{standalone}
\usepackage{pgfplots}

\pgfplotsset{compat=1.18}

\begin{document}

\begin{tikzpicture} \begin{axis}[ grid, xmin = -1, xmax=3, ymin=-1, ymax=1, ] \addplot +[no markers, raw gnuplot, thick, empty line = jump % ] gnuplot { set xrange[-1:3]; set contour base; set cntrparam levels discrete 0.0; unset surface; set view map; set isosamples 500; splot 2xx-2xy+2yy-1; }; \path (1,0.5) node[right, fill=white]{$2x^2-2xy+2y^2=1$}; \end{axis} \end{tikzpicture} \end{document}

implicit function plot through gnuplot

Rmano
  • 40,848
  • 3
  • 64
  • 125