this is the code i have written for ps2 http://pastebin.com/GawtDFrL there is a error in the last part i.e to calculate the root of the polynomial.please could you let me know my mistake. (about newton's method)
I found a few bugs. http://pastebin.com/U8KcLmuQ has the corrections Line 4 should be valpoly = valpoly + (poly[i]*x**i) instead of valpoly = sumpoly + (poly[i]*x**i) also, you need to have your functions return values so add return valpoly as line 5 of your evaluate_poly function and return deriv should be added at the end of compute_deriv lastly, you need to add some harness code to run the functions. polyMy = (-13.39, 0.0, 17.5, 3.0, 1.0) print compute_root(polyMy, .01, .0001)
thanks a lot...was the main mistake that i didn`t return the value in the function?
yes, both evaluate_poly and compute_deriv needed to return a value
Join our real-time social learning platform and learn together with your friends!