[Tutor] Complex roots
Tim Peters
tim.peters at gmail.com
Mon Dec 13 05:37:52 CET 2004
[Dick Moores]
>>> Actually, I'm trying to write a Python script that computes all 3
>>> roots of a cubic equation. Do you happen to have one tucked
>>> away in your store of wisdom and tricks? (One for real coefficients
>>> will do).
[Tim Peters]
>> I don't, no. You can code one for cubics from Cardano's formula, e.g.,
>>
>> http://mathworld.wolfram.com/CubicFormula.html
>>
>> but it's rarely worth the bother -- it's complicated and doesn't
>> generalize.
[Dick]
> I accept this challenge to write a complicated script of little value.
Cool! If it's just for fun, it's fun.
>> In practice, roots for polynomials beyond quadratics are
>> usually obtained by numerical approximation methods that don't care
>> much about the polynomial's degree.
> Are these "numerical approximation methods" pythonically possible?
Of course, but coding general-purpose root finders-- even if "general"
is limited to just polynomials --requires mathematical and numeric
expertise. If it interests you, there are book-length treatments of
the subject, and there's really no easy reliable approach. Good
online sources for numeric algorithms include:
http://www.netlib.org/
Just Googling on
polynomial roots Python
will point you to
http://www.scipy.org/
More information about the Tutor
mailing list