#! /usr/bin/env python """ This program creates a polar plot of Fay's function, which is also know as a butterfly curve: r = e^sin(theta) - 2cos(4theta) + sin(theta/12)^5 Paul Eugenio Florida State University PHZ4151C 29 Jan 2019 """ from __future__ import division, print_function import matplotlib.pyplot as plt import numpy as np # use latex rendering in lables plt.rc('text', usetex=True) # define parameters thetaMin, thetaMax = 0, 24*np.pi steps = 10000 # Using the numpy vectorization # to generate plot data theta = np.linspace(thetaMin, thetaMax, steps) r = np.exp(np.sin(theta)) - 2*np.cos(4*theta)+ np.sin(theta/12)**5 x = r*np.cos(theta) y = r*np.sin(theta) # plot curve and decorate with latex equation plt.plot(x,y) plt.xlabel(r"$r cos(\theta)$") plt.ylabel(r"$r sin(\theta)$") plt.legend([r"$r = e^{sin(\theta)} - 2 cos(4\theta) + sin^5(\theta / {12})$"]) plt.title("Fay's function") plt.savefig("fay.png") plt.show()