[Freeman Dyson](https://en.wikipedia.org/wiki/Freeman_Dyson) was wo...

***How to use Epicycles to draw any image***
To understand how w...

Apparently a spelling error -- obviously should be "trunkation." A...

Taking these parameters and writing a Python script to implement th...

References 5 and 6 are both dead links to java applets, no obvious ...

Drawing an elephant with four complex parameters

Jürgen Mayer

Max Planck Institute of Molecular Cell Biology and Genetics, Pfotenhauerstr. 108, 01307 Dresden,

Germany

Khaled Khairy

European Molecular Biology Laboratory, Meyerhofstraße. 1, 69117 Heidelberg, Germany

Jonathon Howard

Max Planck Institute of Molecular Cell Biology and Genetics, Pfotenhauerstr. 108, 01307 Dresden,

Germany

!Received 20 August 2008; accepted 5 October 2009"

We deﬁne four complex numbers representing the parameters needed to specify an elephantine

shape. The real and imaginary parts of these complex numbers are the coefﬁcients of a Fourier

coordinate expansion, a powerful tool for reducing the data required to deﬁne shapes. ©

2010

American Association of Physics Teachers.

#DOI: 10.1119/1.3254017$

A turning point in Freeman Dyson’s life occurred during a

meeting in the Spring of 1953 when Enrico Fermi criticized

the complexity of Dyson’s model by quoting Johnny von

Neumann:

1

“With four parameters I can ﬁt an elephant, and

with ﬁve I can make him wiggle his trunk.” Since then it has

become a well-known saying among physicists, but nobody

has successfully implemented it.

To parametrize an elephant, we note that its perimeter can

be described as a set of points !x!t",y!t"", where t is a pa-

rameter that can be interpreted as the elapsed time while

going along the path of the contour. If the speed is uniform,

t becomes the arc length. We expand x and y separately

2

as a

Fourier series

x!t" =

%

k=0

!

!A

k

x

cos!kt" + B

k

x

sin!kt"", !1"

y!t" =

%

k=0

!

!A

k

y

cos!kt" + B

k

y

sin!kt"", !2"

where A

k

x

, B

k

x

, A

k

y

, and B

k

y

are the expansion coefﬁcients. The

lower indices k apply to the kth term in the expansion, and

the upper indices denote the x or y expansion, respectively.

Using this expansion of the x and y coordinates, we can

analyze shapes by tracing the boundary and calculating the

coefﬁcients in the expansions !using standard methods from

Fourier analysis". By truncating the expansion, the shape is

smoothed. Truncation leads to a huge reduction in the infor-

mation necessary to express a certain shape compared to a

pixelated image, for example. Székely et al.

3

used this ap-

proach to segment magnetic resonance imaging data. A simi-

lar approach was used to analyze the shapes of red blood

cells,

4

with a spherical harmonics expansion serving as a 3D

generalization of the Fourier coordinate expansion.

The coefﬁcients represent the best ﬁt to the given shape in

the following sense. The k =0 component corresponds to the

center of mass of the perimeter. The k=1 component corre-

sponds to the best ﬁt ellipse. The higher order components

trace out elliptical corrections analogous to Ptolemy’s

epicycles.

5

Visualization of the corresponding ellipses can be

found at Ref. 6.

We now use this tool to ﬁt an elephant with four param-

eters. Wei

7

tried this task in 1975 using a least-squares Fou-

rier sine series but required about 30 terms. By analyzing the

picture in Fig. 1!a" and eliminating components with ampli-

tudes less than 10% of the maximum amplitude, we obtained

an approximate spectrum. The remaining amplitudes were

Fig. 1. !a" Outline of an elephant. !b" Three snapshots of the wiggling trunk.

648 648Am. J. Phys. 78 !6", June 2010 http://aapt.org/ajp © 2010 American Association of Physics Teachers

Downloaded 25 Sep 2013 to 131.211.208.19. Redistribution subject to AAPT license or copyright; see http://ajp.aapt.org/authors/copyright_permission

slightly modiﬁed to improve the aesthetics of the ﬁnal image.

By incorporating these coefﬁcients into complex numbers,

we have the equivalent of an elephant contour coded in a set

of four complex parameters !see Fig. 1!b"".

The real part of the ﬁfth parameter is the “wiggle param-

eter,” which determines the x-value where the trunk is at-

tached to the body !see the video in Ref. 8". Its imaginary

part is used to make the shape more animal-like by ﬁxing the

coordinates for the elephant’s eye. All the parameters are

speciﬁed in Table I.

The resulting shape is schematic and cartoonlike but is

still recognizable as an elephant. Although the use of the

Fourier coordinate expansion is not new,

2,3

our approach

clearly demonstrates its usefulness in reducing the number of

parameters needed to describe a two-dimensional contour. In

the special case of ﬁtting an elephant, it is even possible to

lower it to four complex parameters and therein implement a

well-known saying.

ACKNOWLEDGMENTS

Many thanks to Jean-Yves Tinevez and Marija Žanić, as

well as the anonymous reviewers, for revising and improving

this article.

1

F. Dyson, “A meeting with Enrico Fermi,” Nature !London" 427!6972",

297 !2004".

2

F. P. Kuhl and C. R. Giardina, “Elliptic Fourier features of a closed

contour,” Comput. Graph. Image Process. 18, 236–258 !1982".

3

G. Székely, A. Kelemen, C. Brechbühler, and G. Gerig, “Segmentation of

2D and 3D objects from MRI volume data using constrained elastic de-

formations of ﬂexible Fourier contour and surface models,” Med. Image

Anal. 1!1", 19–34 !1996".

4

K. Khairy and J. Howard, “Spherical harmonics-based parametric decon-

volution of 3D surface images using bending energy minimization,” Med.

Image Anal. 12!2", 217–227 !2008".

5

The interactive Java applet written by Rosemary Kennett,

&physics.syr.edu/courses/java/demos/kennett/Epicycle/Epicycle.html'.

6

Interactive Java applet of elliptic descriptors by F. Puente León,

&www.vms.ei.tum.de/lehre/vms/fourier/'.

7

J. Wei, “Least square ﬁtting of an elephant,” CHEMTECH 5, 128–129

!1975".

8

See supplementary material at http://dx.doi.org/10.1119/1.3254017 for

the movie showing the wiggling trunk.

Table I. The ﬁve complex parameters p

1

,...,p

5

that encode the elephant

including its wiggling trunk.

Parameter Real part Imaginary part

p

1

=50−30iB

1

x

=50 B

1

y

=−30

p

2

=18+8iB

2

x

=18 B

2

y

=8

p

3

=12−10iA

3

x

=12 B

3

y

=−10

p

4

=−14−60iA

5

x

=−14 A

1

y

=−60

p

5

=40+20i Wiggle coeff.=40 x

eye

=y

eye

=20

649 649Am. J. Phys., Vol. 78, No. 6, June 2010 Notes and Discussions

Downloaded 25 Sep 2013 to 131.211.208.19. Redistribution subject to AAPT license or copyright; see http://ajp.aapt.org/authors/copyright_permission

References 5 and 6 are both dead links to java applets, no obvious backups exist... The fate of all URL references?
Great paper, didn't know about this lovely story
Apparently a spelling error -- obviously should be "trunkation." Also, for drawing with epicycles, check Engare on Steam.
At least in American English, *truncate* (with a letter *'c'*) is the correct spelling. [ref](http://www.dictionary.com/browse/truncate)
I think he's joking because the article talks about the elephant's *trunk*
Taking these parameters and writing a Python script to implement them we end up with:
```python
"""
Author: Piotr A. Zolnierczuk (zolnierczukp at ornl dot gov)
Based on a paper by:
Drawing an elephant with four complex parameters
Jurgen Mayer, Khaled Khairy, and Jonathon Howard,
Am. J. Phys. 78, 648 (2010), DOI:10.1119/1.3254017
"""
import numpy as np
import pylab
# elephant parameters
p1, p2, p3, p4 = (50 - 30j, 18 + 8j, 12 - 10j, -14 - 60j )
p5 = 40 + 20j # eyepiece
def fourier(t, C):
f = np.zeros(t.shape)
A, B = C.real, C.imag
for k in range(len(C)):
f = f + A[k]*np.cos(k*t) + B[k]*np.sin(k*t)
return f
def elephant(t, p1, p2, p3, p4, p5):
npar = 6
Cx = np.zeros((npar,), dtype='complex')
Cy = np.zeros((npar,), dtype='complex')
Cx[1] = p1.real*1j
Cx[2] = p2.real*1j
Cx[3] = p3.real
Cx[5] = p4.real
Cy[1] = p4.imag + p1.imag*1j
Cy[2] = p2.imag*1j
Cy[3] = p3.imag*1j
x = np.append(fourier(t,Cx), [-p5.imag])
y = np.append(fourier(t,Cy), [p5.imag])
return x,y
x, y = elephant(np.linspace(0,2*np.pi,1000), p1, p2, p3, p4, p5)
pylab.plot(y,-x,'.')
pylab.show()
```
Finally we get the elephant wiggling his trunk
![](https://i.imgur.com/XnYFboV.gif)
***How to use Epicycles to draw any image***
To understand how we can use the Fourier series to draw any arbitrary shape let's start with a simple example: the circle.
![](https://i.imgur.com/1UmWjkj.gif)
A way to express the coordinates (x,y) of the green dot as a function of time is:
$$
x(t) = R \cos(w t)\\
y(t) = R \sin(w t)\\
$$
By adding additional circles and varying their speeds and sizes, it is possible to draw increasingly complex curves called epicycles.
More generally epicycles are curves governed by the equations:
$$
x(t) = \sum_i R_i \cos(w_i t + \phi_i)\\
y(t) = \sum_i R_i \sin(w_i t + \phi_i)\\
$$
where $\phi_i$ is just a phase corresponding to how much the disk is rotated at $t=0$.
With epicycles you can draw very complex images such as this one:
![](https://media.giphy.com/media/5sYuAhjih2LvHRq7nl/giphy.gif)
The way to make an epicycle draw a specific image is by sampling a few points from the image and then force the functions $x(t)$ and $y(t)$ to pass as close as possible to the sampled points - for instance, minimizing the mean square error by varying the $R_i, w_i$ and $\phi_i$.
To do this, it's convenient to work in the complex plane so that:
$$
p_j = x_j + iy_j \\
p(t) = x(t) + iy(t)= \sum_j^{N} R_j( \cos(w_i t + \phi_i) + i\sin(w_i t + \phi_i))=\sum_j^{N} R_j e^{iw_jt+\phi_j}
$$
where N is just the total number of circles. A final assumption that we can do to further simplify things: instead of choosing N arbitrary speeds w, we'll make the speeds be 0 (stationary), 1x, -1x, 2x, -2x, 3x, -3x, ... N/2x, -N/2x.
$$
p(t) = \sum_{j=0}^{N} \underbrace{X_j}_{R_je^{\phi_j}} e^{\frac{2\pi i j}{N}t}
$$
This expression is just a Discrete Fourier Transform, which means we can use it on the points $p_j$ and get the coefficients $X_j$!
[Freeman Dyson](https://en.wikipedia.org/wiki/Freeman_Dyson) was working at the time with a team of graduate students and postdocs from Cornell to calculate the effects of the strong force in the scattering of mesons by protons. He was inspired by the calculations that had been previously done for Quantum Electrodynamics which showed a tremendous agreement between experiment and theory. He wanted to do the same for the strong force and compare it with [Fermi's](https://en.wikipedia.org/wiki/Enrico_Fermi) measurements of the scattering of mesons by protons.
To calculate the meson-proton scattering, he used a theory of the strong forces known as pseudoscalar meson theory. The problem was that electromagnetic forces are weak and in the pseudoscalar theory the forces are so strong that in order to calculate anything you'd need to introduce artificial parameters (cut-offs) in the integrals to avoid divergences.
When Dyson showed Fermi the scattering calculations, Fermi pointed that the arbitrary cut-offs are "are not based either on solid physics or on solid mathematics", challenging the validity of the calculations. Finally after knowing that Dyson used 4 parameters (cut-offs) for the calculations he quoted his friend John Von Neumann saying that "with 4 parameters I can fit an elephant, and with 5 I can make him wiggle his trunk"
Fermi was in the end absolutely right. A few years after Fermi died, Murray Gell-Mann discovered quarks, the missing link to make sense of strong interactions (mesons and protons are simply little bags made of quarks).
Dyson describes the episode in more detail in this charming interview with Web of Stories.
[!['aw'](https://i.ytimg.com/vi/kEAy6ClrDLA/hqdefault.jpg)](https://www.youtube.com/watch?v=hV41QEKiMlM)