[SciPy-user] how to resolve a cubic equation in scipy?

Anne Archibald peridot.faceted@gmail....
Fri May 16 10:04:05 CDT 2008


2008/5/16 Pauli Virtanen <pav@iki.fi>:
> Fri, 16 May 2008 21:03:22 +0800, zhang chi wrote:
>>    I want to resolve a cubic equation 1.2r^3  + r - 20 = 0.
>
>>>> scipy.roots([1.2, 0, 1, -20])
> array([-1.22284347+2.30637633j, -1.22284347-2.30637633j,
>       2.44568694+0.j        ])

Given that the equation has just one real root, scipy's root-finders
(e.g. brentq) should be reliable and fast.

Of course, if the OP really only has the one equation to solve, it's
done. But presumably they're working with a family of related
cubics...

Anne


More information about the SciPy-user mailing list