uw-python/2014_Astr599_HW — pull request #149 by ffCrack (2014-11-25 03:54:10+00:00)
Title: Fangfang Wang HW8

Approaches to debug:
There are 3 functions defined in the code, I checked the functions one
by one, and validated by plugging in trial parameters.
Firstly, I checked the syntax errors.
At the apply_optimizer() function, I deleted the "," following
"function_calls".
Currently, I didn't notice any runtime error. Then I checked the
semantic errors.
In the code of compare_optimizers(optimizers), I noticed that in the
for loop, "for optimizer in OPTIMIZERS:", since the parameter taken is
"optimizers", I changed it to "for optimizer in optimizers:"
After correcting the above error, I noticed that the total calls of
brentq, ridder, bisect algorithms were all 0, only the first
algorithm's number of calls output is around 602000. Actually, I'm
still not quite confident in explaining this. But this could possibly
be because the 2nd to 4th algorithms took the optimizer calculated from
the first algorithm as the initial value, so it reached the desired
value at the 1st iteration. I also tested this assumption by running
the two algorithms consecutively using some test numbers. This won't
compare the efficiency of the 4 algorithms, so I move the code of
creating random arrays random_a and random_b into the loop, so this
will let each algorithm's initial value to be different of the
optimizer.
In addition,I notice that the above code will throw valueError
excepetion when the interval [a,b] does not contain 0.