Honors 270 Assignment 5

Due October 13


Please turn in this assignment (and all future assignments for this course) by emailing them to me . Please use the subject of "Honors 270 HW5" (note that the spacing matters) for this assignment (if you use the link above, the subject will be added automatically). Please attach separately the source code to all the programs that you write for this assignment. Each program should be attached as separate file to make it easier for me to read them. When answering the questions themselves feel free to answer directly in the body of your message or attach your answers as a separate file. You may want to copy and paste the questions into your message.

You will also need to install Numpy and PyPlot. Run the following commands in a terminal window on Linux. Copy and paste them one by one and let me know if you have any problems. Feel free to do this at the beginning of class, or right before we start, if you get there early. If you want to follow along with the exercises in the tutorials, you will need to do these commands first.

 python -m pip install --upgrade --user pip
 ~/.local/bin/pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose
 echo 'set path = ( $path ${HOME}/.local/bin)' >> ~/.cshrc

Fibonacci's Sunflower

Write a program that will ask the user to input a number of terms to calculate of the Fibonacci's sequence. The program will then create a plot of Fibonacci's sunflower for that many terms.

The Fibonacci series goes: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 ... where each term is the sum of the previous two terms. The ratio of any two terms of the Fibonacci sequence approaches the golden ratio, φ = (1. + sqrt(5.))/2. The golden angle is the related to the Golden ratio and it is the rotation a plant should go through before putting the next petal, leaf, or seed in order to tightly pack them. The golden angle = 2 π - 2π/ φ.

To create this plot, create a function that will return coordinates for each seed in your sunflower. You should pass into this function n, the number of terms (seeds) that you want in your sequence. In this function, you should calculate φ and the golden angle. The program should also create a Numpy array that starts at 1 and goes up to n. That array is the index of the term in the Fibonacci sequence. The polar coordinate of your seeds for your plot will be r = sqrt(j), where j is the term in the index array. The angle θ = (index -1) * golden_angle. The polar coordinates should also be in arrays.

Cartesian coordinates are easier to deal with for plotting, so you the regular conversion for polar to Cartesian coordinates to create arrays for the x and y coordinates of the seeds. Your function should pass these values back.

Your program should then plot your Fibonacci sunflower. You should play with different point markers and scale options to get nice looking plots. You also should label the axes and put a title on your plot.

Run your program for n =200 and n =2000, and attach the output of your program for those cases, as well as png copies of the plots that you made for those cases. Also attach your Python code.

Briefly explain the choices that you made for plot options for your final version of your program.