Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math;
- # Complex Roots
- def croots(z, p):
- l = math.sqrt(z.real**2 + z.imag**2);
- s = l**(1.0 / p);
- a = math.atan2(z.imag, z.real) / p;
- n = math.ceil(math.fabs(p));
- astep = (math.pi * 2.0) / p;
- result = [];
- for i in range(n):
- r = complex(math.cos(a + astep * i) * s,
- math.sin(a + astep * i) * s);
- # print(r);
- result.append(r);
- return result;
- # The secret key (c), and origin point (z)
- c = (-.75+.09j);
- z = (0+0j);
- p = 7.628;
- print("c = " + str(c));
- print("z = " + str(z));
- print("p = " + str(p));
- # display the complex roots
- print("complex roots for z^" + str(p) + " + c");
- print("_____________________________________");
- cr = croots(z - c, p);
- for b in cr:
- print(b);
- print("_____________________________________");
Advertisement
Add Comment
Please, Sign In to add comment