Homework 1.1: Plotting an elephant (35 pts)

In this problem, we will practice skills with manipulating Numpy arrays and making plots with a fun example.

a) Read this little gem of an article. It has a good lesson, but it is important to note, as you will learn if you take part (b) of this course, a model is not automatically invalid because it has a lot of parameters. More important is what the parameters are and to what physical quantities they relate. Nonetheless, it is often desirable to have simpler models for many reasons, including interpretability.

b) Based on the anecdote about John von Neumann, Mayer, Khairy, and Howard worked out a scheme to draw an elephant with four complex parameters. The complex parameters are

\begin{align} &p_1 = -60 - 12 i,\\[1em] &p_2 = -30 + 14 i,\\[1em] &p_3 = 8 - 50 i,\\[1em] &p_4 = -10 - 18 i. \end{align}

For notational ease, let \(r_j\) be the real part of parameter \(j\) and \(i_j\) by the imaginary part of parameter \(j\). For example, \(r_1 = -60\) and \(i_3 = -50\).

Using these parameters, Mayer, Khairy, and Howard worked out a parametric curve for the shape of an elephant based on a truncated Fourier series. You can write the \(x\) and \(y\) values of a smooth parametric curve as a Fourier series as

\begin{align} x(t) = A_{0,x} + \sum_{k = 1}^\infty A_{k,x} \cos kt + \sum_{k = 1}^\infty B_{k,x} \sin kt, \\[1em] y(t) = A_{0,y} + \sum_{k = 1}^\infty A_{k,y} \cos kt + \sum_{k = 1}^\infty B_{k,y} \sin kt, \end{align}

where \(t\) ranges from zero to \(2\pi\). The Mayer, Khairy, and Howard worked out that you can get an elephant using

\begin{align} &A_{1,x} = r_1,\;B_{1,x} = r_2, \; B_{2,x} = r_3, \; B_{3,x} = r_4,\\[1em] &A_{3,y} = i_1,\;A_{5,y} = i_2, \; B_{1,y} = i_3, \; B_{2,y} = i_4, \end{align}

with all other Fourier coefficients being zero.

Compute a smooth curve for an elephant using this formula and plot it. (This problem is not meant to teach you about Fourier series, but rather to practice creating and manipulating Numpy arrays and making plots.)

c) For fun, you can make a little scene for your elephant by adding other glyphs to the plot. You can read Bokeh’s documentation to learn about what you can do. You may wish to investigate patches and box annotations, among others. (This part of the problem is not graded.)