# Creating a Fermat Spiral

I have been trying to create a picture of a Fermat's (or parabolic) spiral, with a couple of labels on it.

I have tried to use some of the responses in TikZ — involute of a circle, as well as the rooty helix, bBut can't seem to get it working.

Basically what I am after, are two intersecting fermat spirals each with a different background colour:

I also want labels that signify the components of growth as it expands. If the colour can get darker as it grows, as the rooty helix does, that would be an added bonus.

My answer to spiral spring in tikz provides a way to that with a command:

\newcommand\spiral{} % just for safety
\def\spiral[#1](#2)(#3:#4)(#5:#6)[#7]{%
\pgfmathsetmacro{\domain}{#4+#7*360}
\pgfmathsetmacro{\growth}{180*(#6-#5)/(pi*(\domain-#3))}
\draw [#1,
shift={(#2)},
domain=#3*pi/180:\domain*pi/180,
variable=\t,
smooth,
samples=int(\domain/5)] plot ({\t r}: {#5+\growth*\t-\growth*#3*pi/180})
}


But in this way the spiral growth is linear and the Fermat's spiral has a function of another kind: r(θ)=θ^(1/2), so we just need to adapt the command:

\newcommand\fermatspiral{} % just for safety
\def\fermatspiral[#1](#2)(#3:#4)[#5]{%
% \fermatspiral[options](placement)(start angle:final angle)[revolutions]
\pgfmathsetmacro{\domain}{#4+#5*360}
\draw [#1,
shift={(#2)},
domain=#3*pi/180:\domain*pi/180,
variable=\t,
smooth,
samples=int(\domain/5)] plot ({\t r} : {sqrt(\t)})
}


The only Problem is getting the - part, so we can just rotate=180 and we can get both spirals.

# MWE

\documentclass{standalone}
\usepackage{tikz}
\newcommand\fermatspiral{} % just for safety
\def\fermatspiral[#1](#2)(#3:#4)[#5]{%
% \fermatspiral[options](placement)(start angle:final angle)[revolutions]
\pgfmathsetmacro{\domain}{#4+#5*360}
\draw [#1,
shift={(#2)},
domain=#3*pi/180:\domain*pi/180,
variable=\t,
smooth,
samples=int(\domain/5)] plot ({\t r} : {sqrt(\t)})
}
\begin{document}
\begin{tikzpicture}
\fermatspiral[red](0,0)(0:2)[3]; % Positive part
\fermatspiral[blue, rotate=180](0,0)(0:2)[3]; % Negative part
\end{tikzpicture}
\end{document}


# EDIT:

There are three separate questions here, I answered the first and only which hadn't been answered on the website yet. The following answers the other questions, which are: (i) how to fade the path from light color to dark color and (ii) how to place labels on an arbitrary path generated by a function.

To get the path fading from red to dark red it's not that straightfoward as inner color=red, outer color=red!20!black, one has to use path fading like on this wonderful answer by percusse but then you detach the path specification from the filling and some weird things can happen:

\begin{tikzfadingfrompicture}[name=fermat]%
\fermatspiral[transparent!20](0,0)(0:360)[3];


To get a label somewhere on the path one could use decorations with markings (like in this answer by Jesse), but then again, by using path fading now our path is specified inside the fading option and we can no longer decorate it. Nevertheless, not all is lost, since our path is a well known function we can use \node at (x,f(x)) {}; to specify our label position. So, in summary we can either use path fading and label manually with \node at notation, or we can forget about fading and use decorations to label our path. Since the OP wants to have faded and labeled path the below MWE presents such solution:

## Complete MWE

\documentclass{standalone}
\usepackage{tikz}
\newcommand\fermatspiral{} % just for safety
\def\fermatspiral[#1](#2)(#3:#4)[#5]{%
\pgfmathsetmacro{\domain}{#4+#5*360}
\draw [#1,
shift={(#2)},
domain=#3*pi/180:\domain*pi/180,
variable=\t,
smooth,
samples=int(\domain/2)] plot ({\t r} : {sqrt(\t)})
}
\fermatspiral[transparent!20](0,0)(0:360)[3];
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\domain}{4*360}
\end{tikzpicture}
\end{document}


Here's a simple version in Metapost wrapped up in luamplib. Compile with lualatex. (Or strip off the LaTeX header/footer and use plain mpost).

\RequirePackage{luatex85}
\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);

turns = 5;

path s;     % MP deals in degrees, so \pi/180 \simeq 0.0174533
s = origin for t=1 upto 360*turns: -- (radius * sqrt(0.0174533t),0) rotated t endfor;

path xx, yy;
xx = (left--right) scaled radius scaled sqrt( 2 * 3.1415926 turns );
yy = xx rotated 90;

draw xx withcolor .7 white;
draw yy withcolor .7 white;

drawarrow s withcolor 2/3 red;
drawarrow s rotated 180 withcolor 1/2 blue;

endfig;
\end{mplibcode}
\end{document}