5

I want to draw an infinite earring, i.e., each circle centerd at $(\frac{1}{n},0)$ with radius $\frac{1}{n}$ for each $n\in \mathbf{N}$. The figure will be the following:

wanted

I have used the following code to do the diagram:

\documentclass[10pt]{article}
\usepackage{pgf,tikz}
\begin{document}

\begin{tikzpicture} 
  \foreach \n in {1,2,3,4,5,6,7,...................} 
    \draw (1/\n,0) circle (1/\n);
  \foreach \n in {1,2,3,4,5,6,7,...................}  
    \draw[fill] (1\n,0) circle (0.5pt);
\end{tikzpictute}
\end{document}  

But it shows an error.

  • 6
    You don't need pgf and it is \end{tikzpicture} – touhami Feb 28 '15 at 8:35
12

May be better than infinity you fix a large number

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

 \begin{tikzpicture} 
  \foreach \n in {1,2,...,2000} 
   \draw (1/\n,0) circle (1/\n);
 \end{tikzpicture}
 \end{document}

Edit: we can replace

  \foreach \n in {1,2,...,2000}

by

  \foreach \n in {1,...,2000}

since the step is 1

| improve this answer | |
  • {1,...,140} is enough and it makes it much quicker. – LaRiFaRi Jul 8 '15 at 13:34
7

Couldn't resist to add a MetaPost version of this.

\documentclass{standalone}
\usepackage{luamplib}
\begin{document}
\begin{mplibcode}
r = 10cm; % Unit
d = 2r;
beginfig(1);
    for n = 1 upto 1000: draw fullcircle scaled (d/n) shifted (r/n, 0) ; endfor
endfig;
\end{mplibcode}
\end{document}

To be run with LuaLaTeX.

enter image description here

| improve this answer | |
  • Surely you meant to write for n=1 upto infinity: (since you can in MP)! – Thruston Feb 28 '15 at 11:45
  • 3
    @Thruston What's the limiting factor in that case? Don't want to keep compiling until off to the nursing home I go! – 1010011010 Feb 28 '15 at 11:54
  • @Thruston I usually use MetaPost with the double numbersystem, and I lose the habit to use the infinity constant, since I thought that infinity would have a much bigger value than 2^12-1. But I must correct myself: infinity is still equal to 2^12-1=4095,99998… in double mode, despite the fact that MetaPost can handle much bigger numerics then; I've just checked it. It looks like an oversight from MetaPost's developers. – Franck Pastor Feb 28 '15 at 12:49
  • 1
    @1010011010 I was just making an in-joke: one of the amusing features of Metafont/Metapost is that it actually defines a constant infinity. An example of Knuth's humour I think, but occasionally it is useful; for example if you have a path p then point infinity of p is always at the far end of p. – Thruston Feb 28 '15 at 13:41
  • If you wonder why I've drawn up to 1000 circles, it is because I wanted to make the white point (the last circle), which is left at the origin in most of the other pictures, completely disappear (in appearance I mean). I first try with n = 100, and it was still here. So I went for n = 1000… I confess, I was too lazy to search a more optimal value for n :-) – Franck Pastor Feb 28 '15 at 16:07
6

Another solution leveraging nodes' alignment property:

\documentclass[tikz,border=10pt]{standalone}

\pgfkeys{tikz/.cd,
  num of circles/.store in=\numcirc,
  num of circles=100,
  circle initial size/.store in=\circlesize,
  circle initial size=3cm,
}
\begin{document}
\begin{tikzpicture}
\foreach \n in {1,...,\numcirc}{
\pgfmathsetmacro\actualsize{\circlesize/\n}
\node[anchor=west,circle,draw,inner sep=\actualsize pt] at (0,0){};
}
\end{tikzpicture}
\end{document}

The result:

enter image description here

| improve this answer | |
  • Watch out for the tiny white dot just to the right of the centers of the circles. – Benjamin McKay Mar 1 '15 at 13:45
  • @BenjaminMcKay: That's due to the low number of samples used. Just add \begin{tikzpicture}[num of circles=2000] and it will disappear. – Claudio Fiandrino Mar 1 '15 at 13:57
4

A PSTricks solution:

\documentclass{article}

\usepackage{multido}
\usepackage{pstricks}
\usepackage{xfp}

% parameters
\def\circles{100}
\def\radius{3}

\begin{document}

\begin{pspicture}(\fpeval{2*\radius},\fpeval{2*\radius})
  \multido{\i = 1+1}{\circles}{\pscircle(\fpeval{\radius/\i},\radius){\fpeval{\radius/\i}}}
\end{pspicture}

\end{document}

output

...and in case the drawing of the circle perimeters are done with a too thick pen:

\documentclass{article}

\usepackage{multido}
\usepackage{pstricks}
\usepackage{xfp}

% parameters
\def\circles{100}
\def\radius{3}

\begin{document}

\begin{pspicture}(\fpeval{2*\radius},\fpeval{2*\radius})
  \multido{\i = 1+1}{\circles}{\pscircle[linewidth = 0.5\pslinewidth](\fpeval{\radius/\i},\radius){\fpeval{\radius/\i}}}
\end{pspicture}

\end{document}

output2

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.