# Epicycle and deferent with Tikz - Function syntax

I want to build an epicyclic graph and found a useful trigonometric function on the web (URL is in comment in my MWE). My personal issue is that I can't write a complex function as a "plot" argument. I made several tries, mixing curved brackets, parenthesis and dollar, in various combinations (paying attention to pairs), it failed. The uncommented "plot" integrates sinus and cosinus and it works (indeed, it's just a small circle in the middle of the drawing). More complex - in comments - syntaxes fail and I don't understand why. I suspect that the function is handled by the PGF engine - not by TikZ - and that I'd mix the two syntaxes?

Any hint to have this working in a TikZ+LuaLaTeX environment? What are the parenthesis, curved brackets and dollar sign used for and in which combination?

\documentclass{article}
\usepackage{fontenc}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
% epicycle+deferent/epitrochoid - algorithm
% see http://www.malinc.se/math/trigonometry/spirographen.php
\draw [thick] (0,0) circle (\ri);
\foreach \a in {0,10,...,350} \draw (0,0)++(\a:\ri) circle (\re);
\draw[domain=0:360,smooth,samples=200,variable=\a] plot ({cos(\m*\a)},{sin(\m*\a)});
% \draw[domain=0:360,smooth,samples=200,variable=\a] plot ({$\ri*cos(\a)+\re*cos(\m*\a)$},{$\ri*sin(\a)+\re*sin(\m*\a)$});
% \draw[domain=0:360,smooth,samples=200,variable=\a] plot function {\ri*cos(\a)+\re*cos(\m*\a),\ri*sin(\a)+\re*sin(\m*\a)};
\end{tikzpicture}
\end{document}

• Very interesting :-) in Physics your question. – Sebastiano Feb 4 at 15:20

Remove the \$ pair and it should work

\documentclass{article}
\usepackage{fontenc}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
% epicycle+deferent/epitrochoid - algorithm
% see http://www.malinc.se/math/trigonometry/spirographen.php