any Python equivalent of Math::Polynomial::Solve?
konrad.hinsen at laposte.net
konrad.hinsen at laposte.net
Wed Mar 2 11:46:08 EST 2005
Carl Banks wrote:
> If you don't have a great need for speed, you can accomplish this
> easily with the linear algebra module of Numeric/numarray. Suppose
> your quintic polynomial's in the form
>
> a + b*x + c*x**2 + d*x**3 + e*x**4 + x**5
>
> The roots of it are equal to the eigenvalues of the companion matrix:
>
> 0 1 0 0 0
> 0 0 1 0 0
> 0 0 0 1 0
> 0 0 0 0 1
> -a -b -c -d -e
The method "zeros()" in Scientific.Functions.Polynomial uses exactly
that trick for finding the zeros of a general polynomial. If you need
to do more with polynomials than just finding the zeros, the Polynomial
class is probably better than an on-the-spot solution.
Root finding through eigenvalues is not the fastest method, but it's
simple and stable, and not terribly bad either.
Sorry for not making that comment earlier, I don't have the time to
follow this list at the moment (to my great regret), but I was made
aware of this thread through PythonURL.
Konrad.
More information about the Python-list
mailing list