tikz add tag
Laurenso
I am trying to draw this figure 

![image.png](/image?hash=310103ee5175795c28616a8ced80bdf1810018dcc13d1f74a913c11206498db7)

I tried

```
\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepackage{calc}
\begin{document}
			\begin{tikzpicture}[>=stealth,declare function={mye=1.5;a=1.5;b=a*sqrt((mye)^2-1);c=sqrt(a^2+b^2);xmin=-a-2;xmax=a+2;}]
		\path 
		(-c,0) coordinate (F1)
		(c,0) coordinate (F2)
		(0,0) coordinate (O)
		(-a,0) coordinate (A')
		(a,0) coordinate (A)
		({a*sec(60)},{b*tan(60)}) coordinate (M) 
		;
		\draw[thick, ->] (xmin,0) -- (xmax,0) node[right]{$x$};
		\draw[thick, ->] (0,b/a*xmin) -- (0,b/a*xmax) node[above]{$y$};
		\draw[dashed, domain=xmin:xmax] plot(\x,{b/a*\x});
		\draw[dashed, domain=xmin:xmax] plot(\x,{-b/a*\x});
		\draw[red,smooth,samples=100, domain=a:xmax] plot(\x,{b/a*sqrt(\x^2-a^2)});
		\draw[red,smooth,samples=400, domain=a:xmax] plot(\x,{-b/a*sqrt(\x^2-a^2)});
		\draw[red,smooth,samples=400, domain=a:xmax] plot(\x,{-b/a*sqrt(\x^2-a^2)});
		\draw[red,smooth,samples=400, domain=xmin:-a] plot(\x,{-b/a*sqrt(\x^2-a^2)});
		\draw[thick, blue] (a/mye,b/a*xmin) -- (a/mye,b/a*xmax);
		\draw[thick, blue] (-a/mye,b/a*xmin) -- (-a/mye,b/a*xmax);
		\foreach \p in {A,A',O,F1,F2,M}
		\draw[fill=black] (\p) circle (1.5pt);
		\foreach \p/\g in {A/45,A'/-135,O/-40,F1/-90,F2/-90,M/0}
		\path (\p)+(\g:3.5mm) node{$\p$};	
		\draw (F1) -- (M) node[midway,left]{$ r_1 $};
		\draw (F2) -- (M) node[midway, right]{$ r_2 $};
	\end{tikzpicture}
	\end{document}


```
![image.png](/image?hash=cad07c1144c5036bc0c0c6fb6d527e060b8818009363bfeb43de3b6c674614e8)

I have a problem at
```
\draw[red,smooth,samples=400, domain=xmin:-a] plot(\x,{-b/a*sqrt(\x^2-a^2)});
```

How can I repair it?
Top Answer
samcarter
As a general strategy for debugging most problems involving squares: try with `\x*\x` instead

```
\documentclass[tikz,border=3mm]{standalone}
\usepackage{calc}
\begin{document}
\begin{tikzpicture}[>=stealth,declare function={mye=1.5;a=1.5;b=a*sqrt((mye)^2-1);c=sqrt(a^2+b^2);xmin=-a-2;xmax=a+2;},samples=2000]
	\path 
	(-c,0) coordinate (F1)
	(c,0) coordinate (F2)
	(0,0) coordinate (O)
	(-a,0) coordinate (A')
	(a,0) coordinate (A)
	({a*sec(60)},{b*tan(60)}) coordinate (M) 
	;
	\draw[thick, ->] (xmin,0) -- (xmax,0) node[right]{$x$};
	\draw[thick, ->] (0,b/a*xmin) -- (0,b/a*xmax) node[above]{$y$};
	\draw[dashed, domain=xmin:xmax] plot(\x,{b/a*\x});
	\draw[dashed, domain=xmin:xmax] plot(\x,{-b/a*\x});
	\draw[red,smooth, domain=a:xmax] plot(\x,{b/a*sqrt(\x*\x-a*a)});
	\draw[red,smooth, domain=a:xmax] plot(\x,{-b/a*sqrt(\x*\x-a*a)});
	\draw[red,smooth, domain=xmin:-a] plot(\x,{b/a*sqrt(\x*\x-a*a)});
	\draw[red,smooth, domain=xmin:-a] plot(\x,{-b/a*sqrt(\x*\x-a*a)});
	\draw[thick, blue] (a/mye,b/a*xmin) -- (a/mye,b/a*xmax);
	\draw[thick, blue] (-a/mye,b/a*xmin) -- (-a/mye,b/a*xmax);
	\foreach \p in {A,A',O,F1,F2,M}
	\draw[fill=black] (\p) circle (1pt);
	\foreach \p/\g in {A/45,A'/-135,O/-40,F1/-90,F2/-90,M/0}
	\path (\p)+(\g:3.5mm) node{$\p$};	
	\draw (F1) -- (M) node[midway,left]{$ r_1 $};
	\draw (F2) -- (M) node[midway, right]{$ r_2 $};
\end{tikzpicture}
\end{document}
```
![document-1.png](/image?hash=4c5805a8b7bc394c66d2b039311b34379a2af876c18cedeaa4659524bf4dd523)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.