import matplotlib.pyplot as plt
import math


xtab = []
ytab = []

for i in range(0, 628):
    # Calculate polar coordinates for provided equation
    phi = float(i) / 100.0
    r = 4 * math.cos(2 * phi)
    # Convert to Cartesian and store in lists
    x = r * math.cos(phi)
    y = r * math.sin(phi)
    xtab.append(x)
    ytab.append(y)

plt.plot(xtab, ytab)
plt.show()
[((18, 0, 18, 20), 'matplotlib.pyplot.plot', 'plt.plot', ({(18, 9, 18, 13): 'xtab', (18, 15, 18, 19): 'ytab'}, {}), '(xtab, ytab)', True, 'import matplotlib.pyplot as plt\n'), ((19, 0, 19, 10), 'matplotlib.pyplot.show', 'plt.show', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((11, 12, 11, 29), 'math.cos', 'math.cos', ({(11, 21, 11, 28): '(2 * phi)'}, {}), '(2 * phi)', False, 'import math\n'), ((13, 12, 13, 25), 'math.cos', 'math.cos', ({(13, 21, 13, 24): 'phi'}, {}), '(phi)', False, 'import math\n'), ((14, 12, 14, 25), 'math.sin', 'math.sin', ({(14, 21, 14, 24): 'phi'}, {}), '(phi)', False, 'import math\n')]