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

Johann Cohen-Tanugi cohen at slac.stanford.edu
Fri May 16 09:10:28 EDT 2008


yep.... but if you insist, scipy can propose the following among I am 
sure many other and even better solutions :
from scipy import optimize

def myCubicEq(r):
    return 1.2*r**3  + r - 20

results=optimize.fsolve(myCubicEq, 5) 
print results,myCubicEq(results)

I am too lazy/busy to check with the closed form solution. As a matter 
of fact, Alan, is the closed form algorithm implemented in scipy? I 
mean, why not.... :)

Johann

Alan G Isaac wrote:
> On Fri, 16 May 2008, zhang chi apparently wrote:
>   
>> I want to resolve a cubic equation 1.2r^3  + r - 20 = 0. 
>>     
>
> Cubics have a closed form solution:
> http://mathworld.wolfram.com/CubicFormula.html
>
> hth,
> Alan Isaac
>
>
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>   



More information about the SciPy-User mailing list