[Tutor] Complex roots
tim.peters at gmail.com
Mon Dec 13 05:37:52 CET 2004
>>> 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).
>> I don't, no. You can code one for cubics from Cardano's formula, e.g.,
>> but it's rarely worth the bother -- it's complicated and doesn't
> 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:
Just Googling on
polynomial roots Python
will point you to
More information about the Tutor