Home page 

IntroductionThe "NewtonRaphson" method is an algorithm for finding the roots of differentiable equations. See Wolfram or Wikipedia This page allows you to download a python script that will find the roots of a polynomial with real coefficients.
UsageThe NewtonRaphson method can be applied to any differentiable equation y = f(x), but the python code presented here is designed to work with polynomials: y = P_{0}x^{n} + P_{1}x^{n1} + ... + P_{n} which in the Python code are represented as vectors [P_{0}, P_{1}, ..., P_{n}]. The derivative of a single polynomial term, Px^{n} is nPx^{n1}, and the derivative of the whole polynomial is [nP_{0}, (n1)P_{1}, ..., P_{n1}]. Derivative (x^{3} + x^{2} + x + 1) = 3x^{2} + 2x + 1 becomes Derivative ([1,1,1,1]) = [3,2,1] Note: the derivative has one fewer terms than the original polynomial. So, to solve a polynomial, say x^{6} + 2x^{5} + 3x^{4} + 4x^{3} + 5x^{2} + 6x + 7 = 0, you first have to convert it to a vector, in this case [1,2,3,4,5,6,7]. Now you can load the python script and call the "FindRoots" method. >>> import Polynomial >>> Polynomial.FindRoots ([1,2,3,4,5,6,7]) [(1.3078697439524358+0.59329470741458734j), (1.30786974395243580.59329470741458734j), (0.40250912536027966+1.3416668277593837j), (0.402509125360279661.3416668277593837j), (0.71037886931271566+1.1068452983838484j), (0.710378869312715661.1068452983838484j)] >>> All six roots of this polynomial are complex and come in three conjugate pairs: (1.308 ± 0.593i), (0.403 ± 1.342i) and (0.710 ± 1.107i). 

(c) John Whitehouse 2010
