a thoughtful web.
Good ideas and conversation. No ads, no tracking.   Login or Take a Tour!
comment by am_Unition
am_Unition  ·  3179 days ago  ·  link  ·    ·  parent  ·  post: Roots, Roots!

So I finally finished my little program, it's worth about 25% of one homework assignment (the prof keeps us busy). Written in Python.

I was tasked with calculating the complex roots of the function z^n - 1 = 0, with z of the form z = a*x + i*b*y. Here, a and b are coefficients, both of which I varied from -1 to +1 divided into 1001 grid points. In other words, the coordinates of a point on the complex plane from x=-1 to +1 and y=-i to +i were inputted for z. We were only required to map to degree n=3 and n=4, but I can go as high as n=9 before my computer starts protesting. The current hang-up seems to be Python's unwillingness to use scientific notation for the imaginary component. Anything bigger than about 10^16*i gives me errors.

The Newton Method was my prescribed workhorse for root solving. So I set up some reasonable constraints for "converging" on a solution, and plotted two things for each value of n: number of iterations it took to converge, and the final solution (converted to a color). As mentioned, both are a function of starting position on the complex plane.

Each pair of 1001x1001 plots took about 20 minutes to generate. You must be a wizard to do n=24 for 20,000x20,000 on any timescale less than several days!