# [Tutor] Complex roots

Dick Moores rdm at rcblue.com
Fri Dec 17 02:01:42 CET 2004

```Thanks. Tim Peters helped me out with his answer of 12/9.
<http://mail.python.org/pipermail/tutor/2004-December/033967.html>

Dick Moores

Jacob S. wrote at 19:27 12/15/2004:
>Finding the all the roots of a complex number shouldn't be too difficult. I
>tend to do it on paper sometimes. Maybe I can write a script to do it for me
>instead.  I stongly caution you though. The methods that I show below are
>unstable and should be verified by a math web site as it has been quite a
>few months since I last used the equations. In fact, I'll almost bet they're
>wrong. If you want me to check them, I'll gladly google for the right
>equations if you want.
>
>where i == sqrt(-1)
>
>[pseudo-code]
>p = (a+bi)**n
>n = polar(p)  ## polar is a function that converts rectangular coordinates
>to polar coordinates.
>angle = n[1]
>
>1st root        radius**n cis (angle/(180*n))  ## Where cis is short for
>(cos(angle) + i*sin(angle))
>...
>[/pseudo-code]
>
>So saying, I would set a for i in range loop for n times to run these root
>finders through. Note unless you call some sort of polar to rectangular
>function on the roots, they will still be in polar.
>
>HTH as always,
>Jacob Schmidt
>
>_______________________________________________
>Tutor maillist  -  Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor

```