# How can I draw a spiral that gets arbitrary close to a unit circle?

I would like to draw something like this:

The circle in the center is not connected to the spiral, but the spiral gets arbitrary close to the circle.

A problem why I can't draw this is that I don't know how to describe this mathematically / formally.

I have found this one:

\documentclass[varwidth=true, border=2pt]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw [domain=0:30,variable=\t,smooth,samples=100]
plot ({\t r}: {0.005*\t*\t});
\end{tikzpicture}
\end{document}


but it seems not to get closer to a fixed size circle in the center.

This image looks similar to what I'm looking for, but I only need one spiral.

## Background of my question

I'm currently studying geometry and topology. Sadly the professor does not provide a script, so I write one by my own to make studying easier for other students (see repository with source files and compiled pdf). The space that is described by the spiral and the circle is connected when you have a definition that makes use of $\varepsilon$-environments, but not connected when you make use of a definition that demands the existance of a path.

-
a classical other example of this type is the union of the graph of sin(1/x) with the vertical unit interval at x=0. – jfbu Nov 7 '13 at 16:32

You need a function for the radius that approaches 1. For example, you could use 1+2*exp(-0.1*\t):

\documentclass[border=5pt]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw [domain=0:50,variable=\t,smooth,samples=500]
plot ({\t r}: {1+2*exp(-0.1*\t)});
\end{tikzpicture}
\end{document}

-
I've restricted the domain to 1:18.8 and added an arrow head ->,>=stealth' to indicate that the spiral continues. Do you think there is a simple solution to make fix the arrow head orientation when sampling to 1:22? – Martin Thoma Nov 7 '13 at 15:55
That happens because of the issue described at tex.stackexchange.com/questions/19642/… (and the solution is there, too) – Jake Nov 7 '13 at 16:06

My spiral starts from the correct point, does not it?

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}

\begin{document}
\begin{pspicture}(-5,-5)(5,5)
\psplot[algebraic,polarplot,plotpoints=2000]{0}{TwoPi 8 mul}{1+4*3^(-0.1*x)}
\end{pspicture}
\end{document}


## Animated version

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}

\begin{document}
\multido{\n=0.0+0.2}{41}{
\begin{pspicture}(-5,-5)(5,5)
\psplot[algebraic,polarplot,plotpoints=2000]{0}{TwoPi \n\space mul}{1+4*3^(-0.1*x)}
\end{pspicture}}
\end{document}


With an attenuated sinusoidal multiplier.

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}

\begin{document}
\multido{\n=0.0+0.2}{41}{%
\begin{pspicture}(-5,-5)(5,5)
\pscircle[linecolor=red,dimen=m]{1}
\psplot[algebraic,polarplot,plotpoints=2000]{0}{TwoPi \n\space mul}{1+4*(1-sin(3*Pi*x)/8*2^(-x/10))*3^(-x/10)}
\end{pspicture}}
\end{document}


The last edit (I promise). The following might be difficult in TikZ.

\documentclass[pstricks,border=12pt]{standalone}
\psset{unit=8}
\begin{document}
\multido{\n=-6.0+.2}{61}{%
\begin{pspicture}(-.5,-.5)(1.5,1.5)
\psplotDiffEqn[whichabs=0,whichord=1,linecolor=red,method=rk4,algebraic,plotpoints=1000]{-6}{\n}{0 0}{cos(Pi*x^2/2)|sin(Pi*x^2/2)}
\end{pspicture}}
\end{document}


-
The starting point does not matter. It also does not matter if it approaches a unit circle (as long as it does approach a circle). – Martin Thoma Nov 7 '13 at 15:50
ok, the problem with my suggested functions is that the approach is so slow one never gets to the unit circle. Became obvious once I started actually using your code rather than phantasizing. Will delete my comments. – jfbu Nov 7 '13 at 16:44

This doesn't have, for health reasons, the animated effect... but it allows through another approach to more easily construct denser spirals (it is not essentially different though and belong to the same family of "exponential" spirals).

The number of complete turns done is on purpose a bit too much.

\documentclass[border=2pt,tikz]{standalone}
%\usepackage{tikz}
\usepackage{xintfrac}

% \ratio will get defined inside each tikzpicture

% The floating point macros of xintfrac are used, not the exact ones as we don't
% need the *exact* values with all digits!
\xintDigits := 4;
\def\Rescale #1#2{\xintTrunc {3}
{\xintFloatMul {\xintFloatPow {\ratio}{#1}}{#2}}}
% \Rescale multiplies its second argument #2 by \ratio to the power #1

\newcount\cnta

\begin{document}
\begin{tikzpicture}
\cnta 0
\def\ratio     {0.9}
\def\quarters  {120}
\def\couleur   {red}
\loop
\def\Quarter {(1+\Rescale{\cnta}{2},0) arc
(0:90:1+\Rescale{\cnta}{2} and 1+\Rescale{\cnta+1}{2})}

\draw [color=\couleur!\the\numexpr 100-100*\the\cnta/\quarters\relax]
\Quarter;

\draw [rotate=90,
color=\couleur!\the\numexpr 100-100*\the\cnta/\quarters\relax]
\Quarter;

\draw [rotate=180,
color=\couleur!\the\numexpr 100-100*\the\cnta/\quarters\relax]
\Quarter;

\draw [rotate=270,
color=\couleur!\the\numexpr 100-100*\the\cnta/\quarters\relax]
\Quarter;

\ifnum \cnta < \quarters
\repeat
\draw [thick,color=\couleur] (0,0) circle (1);
\end{tikzpicture}

\begin{tikzpicture}
\cnta 0
\def\ratio     {0.95}
\def\quarters  {180}
\def\couleur   {blue}
\loop
\def\Quarter {(1+\Rescale{\cnta}{2},0) arc
(0:90:1+\Rescale{\cnta}{2} and 1+\Rescale{\cnta+1}{2})}

\draw [color=\couleur!\the\numexpr 100-100*\the\cnta/\quarters\relax]
\Quarter;

\draw [rotate=90,
color=\couleur!\the\numexpr 100-100*\the\cnta/\quarters\relax]
\Quarter;

\draw [rotate=180,
color=\couleur!\the\numexpr 100-100*\the\cnta/\quarters\relax]
\Quarter;

\draw [rotate=270,
color=\couleur!\the\numexpr 100-100*\the\cnta/\quarters\relax]
\Quarter;

\ifnum \cnta < \quarters
\repeat
\draw [thick,color=\couleur] (0,0) circle (1);
\end{tikzpicture}

\begin{tikzpicture}
\cnta 0
\def\ratio     {0.97}
\def\quarters  {240}
\def\couleur   {green}
\loop
\def\Quarter {(1+\Rescale{\cnta}{2},0) arc
(0:90:1+\Rescale{\cnta}{2} and 1+\Rescale{\cnta+1}{2})}

\draw [color=\couleur!\the\numexpr 100-100*\cnta/\quarters\relax]
\Quarter;

\draw [rotate=90,
color=\couleur!\the\numexpr 100-100*\the\cnta/\quarters\relax]
\Quarter;

\draw [rotate=180,
color=\couleur!\the\numexpr 100-100*\the\cnta/\quarters\relax]
\Quarter;

\draw [rotate=270,
color=\couleur!\the\numexpr 100-100*\the\cnta/\quarters\relax]
\Quarter;

\ifnum \cnta < \quarters
\repeat
\draw [thick,color=\couleur] (0,0) circle (1);
\end{tikzpicture}

\end{document}


-