# Drawing the limaçon, r=0.5+2cos(theta) in TeX [duplicate]

Could anyone tell me what I am doing wrong please. I am trying to only use the tikz package. My thought process is that; r^2=x^2+y^2 and r=sqrt(x^2+y^2) so using x=(a/2)+bcos(theta)+(a/2)cos(2theta) and y=bsin(theta)+(a/2)sin(2theta) when r=a+bcos(theta), we get r=sqrt(((0.25)+2cos(theta)+(0.25)cos(2theta))^2+((2sin(theta)+0.25sin(sin(2theta))^2). So rearranging for theta we get theta=acos(r-0.5)*0.5. My code reads:

\documentclass{article}
\usepackage{tikz}
\begin{document}

\begin{figure}[h!]
\centering
\begin{tikzpicture}[xscale=1.3, yscale=5, domain=-2*pi:2*pi]
\draw[->] (-0.2,0) -- (1.7,0)
node[below]{$x$};
\draw[->] (0,-1) -- (0,1)
node[left]{$F(x)$};
\draw[color=blue,smooth]
plot(\x,{0.5*acos({{sqrt((0.25+2*cos(\x r) + 0.25*cos(2*\x r))^2+(2*sin(\x r) +0.25*sin(2*\x r))^2)-0.5}})})
node[below]{$\cos$};

\end{tikzpicture}
\caption{Lim}
\label{fig:Lim}
\end{figure}
\end{document}


But it keeps on going wrong. I dont want to use cspolar or any other package.

• It is certainly possible to plot the curve directly from its polar form, using tikz only. tex.stackexchange.com/questions/65446/… – Franck Pastor May 30 '15 at 22:21
• Does this answer your question? tex.stackexchange.com/questions/247462/tikz-picture-of-limaçon – Alenanno May 30 '15 at 22:47
• I think one of the problems is the domain. You can only take the arc cosine of numbers between -1 and 1. If x=0 it's easy to see you're evaluating acos(sqrt((2.5)^2+0^2)-.5)=acos(2) which isn't defined. – DJP May 31 '15 at 2:18

By trying to convert to rectangular, you're going to run into domain errors. You can use the handy pgfplots in conjunction with tikz to get what you want quite easily:

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{polar}

\begin{document}

\begin{tikzpicture}
\begin{polaraxis}
\addplot+[black, very thick, mark=none, domain=0:720, samples=600 ] {0.5+2*cos(x)};
\end{polaraxis}
\draw (3.43cm,-.45cm) node [below] {$\frac12+2\cos(\theta)$};
\end{tikzpicture}

\end{document} Just for fun: a short code with pst-plot:

\documentclass[11pt, a4paper, pdf, svgnames]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fourier}

\usepackage{pst-plot}

\begin{document}

\psset{unit=2.5cm, arrowinset=0.15, ticksize=2.5pt -2.5pt, labelFontSize=\footnotesize, tickwidth =0.6pt}

\begin{pspicture}(-1.5,-1.9)(3.9,1.9)
\psaxes[arrows=->, linecolor=LightSteelBlue, tickcolor=LightSteelBlue](0,0)(-1.6,-1.9)(3.6,1.9)[$x$,-110][$y$,-140]
\psset{linewidth=1.2pt, plotpoints=200, plotstyle=curve, polarplot, algebraic, labelsep=0.5em}
\psplot[linecolor =IndianRed ]{0}{TwoPi}{0.5 + 2*cos(x)}
\end{pspicture}

\end{document} 