The "Mystery Curve"

(2 comments)

A family of curves in the complex plane may be generated by the formula:

$$ f(t) = e^{it}\left[ 1 - \frac{1}{2}e^{ikt} + \frac{i}{3}e^{-3ikt} \right] $$

for $k=1,2,3,\cdots$. The plotted curve displays $k-$fold rotational symmetry.

Here's the Python code to generate the curve (run as python mystery_curve.pyk).

This code is also available on my github page.

import sys
import matplotlib.pyplot as plt
import numpy as np

def f(t, k):
    """Return the "Mystery Curve" for parameter k on a grid of t values."""

    def P(z):
        return 1 - z / 2 - 1 / z**3 / 3j
    return np.exp(1j*t) * P(np.exp(k*1j*t))

# k is supplied as a command line argument.
k = int(sys.argv[1])

# Choose a grid of t values at a suitable resolution so that the curve.
# is well-represented.
t = np.linspace(0, 2*np.pi, 200*k+1);

u = f(t, k)

# Plot the Mystery Curve in a pleasing colour, removing the axis clutter.
fig, ax = plt.subplots(facecolor='w')
ax.plot(np.real(u), np.imag(u), lw=2, color='m', alpha=0.5)
ax.set_aspect('equal')
plt.axis('off')

plt.savefig('mystery_curve_{}.png'.format(k))
plt.show()

For example, the curves for $k=3, 6$ and $20$ are plotted below.

The Mystery Curve for k = 3 The Mystery Curve for k = 6 The Mystery Curve for k = 20

Current rating: 4.2

Comments

Comments are pre-moderated. Please be patient and your comment will appear soon.

Para 1 year, 4 months ago

Thanks for sharing your knowledge. I see the equation, but I am not able to see how the python code corresponds to it esp the z**3 part of it.

Link | Reply
Currently unrated

christian 1 year, 2 months ago

Hmm – it's been a while since I wrote this. I think the equation given is just one of a family of curves with different exponent integers: you can experiment. I've made the equation match the code to avoid confusion!

Link | Reply
Currently unrated

New Comment

required

required (not published)

optional

required