Scientific Computing Using Python - PHYS:4905
Homework #11
Due 10/17/2019


The homework must be turned in electronically.  You will need to upload one file for each problem containing your Python code as a text file.  Please have the file name start with your last name, e.g. smith_hw11.py. 

(10) Hand in your modified version of plot_image.py from lecture #12 that scales the data by adjusting the lower and upper bound on the scale so that some percentage of the pixel values lie below the lower bound and some percentage lie below the upper bound.  You code must have two parameters, vmin_frac and vmax_frac, that are adjustable.  Hand in the code with your favorite choice for those two variables.

(30) Using the functions bisection_method and false_position_method that you wrote in class, write a function, find_roots, that takes a function, an interval [a, b], and an array of values of xtol as input.  find_roots should make two plots similar to those that you made in class.  One plot is the the number of iterations versus the values of xtol, the results for both methods must go on one plot.  For the false_position_method set ytol equal to the value of xtol that you use for the bisection_method.  The second plot is the absolute value of the difference between the your best guess of the root and the estimates of the root for the two methods for the different values of xtol = ytol.  Note that this means you will need to use the same best guess as the reference for both methods.  Again, the results for both methods must go on one plot.  Also, you should think about whether you want linear or log scales on each axis.

Add code blocks, as defined in Spyder (#%%), to run find_roots  with values for xtol of 10n where n = -2, -3, ..., -10 and the function g as defined in class for each of the intervals [-2,2], [2, 6], [6,10].  The point of the this is that I want to be able to load your code into Spyder and then run different code blocks that make the three plots for different intervals without having to do any typing myself.