Title: Z = Z^1.5 - 0.2 Post by: mistabell on July 13, 2010, 04:16:26 AM I'm trying to draw a Glynn fractal (http://eldar.mathstat.uoguelph.ca/dashlock/ftax/Glynn.html).
I've successfully rendered the mandelbrot and various julia sets. But how the heck do you raise a complex number to the 1.5 power? I have this so far: function glynnPow(a,b) { var tempa = a*a-b*b; // Z^2 = (ac - bd, bc + ad) var tempb = b*a+a*b; var tempaB = tempa*a-tempb*b; var tempbB = tempb*a+tempa*b; a = tempaB; // Z^3 b = tempbB; var r = Math.sqrt(a*a + b*b); // Rectangular to Polar form var q = Math.atan(b/a); a = Math.sqrt(r)*Math.cos(q/2); // De Moivre's Formula b = Math.sqrt(r)*Math.sin(q/2); return a + "," + b; } However, sometimes the signs are flipped or the real and imaginary parts are flipped when I compare the answers with wolframalpha. How do you compute these? Title: Re: Z = Z^1.5 - 0.2 Post by: David Makin on July 13, 2010, 11:38:03 PM See:
http://spanky.triumf.ca/www/fractint/append_a_misc.html (http://spanky.triumf.ca/www/fractint/append_a_misc.html) Just find the section on trig identities. To calculate a fractional or fully complex power e.g. a^b then use exp(b*log(a)). This method is clear and straightforward for complex numbers and standard hypercomplex (bicomplex) numbers but is a little woolly when it comes to quaternions or other number forms that are not commutative since then: exp(b*log(a)) is not necessarily the same as exp(log(a)*b). (Of course here I'm using "exp" so "log" here is the natural log) Edit: Of course the above is the complete general method, in fact for a real power for (x+i*y)^p I think one can use: m = (x*x + y*y)^(p/2) a = p*atan(y/x) x = m*cos(a) y = m*sin(a) which is essentially just a simplification of the method you posted. Title: Re: Z = Z^1.5 - 0.2 Post by: Schlega on July 14, 2010, 10:04:11 AM I think atan(y/x) does not always give the correct angle. You should use atan2(y,x) instead.
Title: Re: Z = Z^1.5 - 0.2 Post by: mistabell on July 14, 2010, 11:52:20 AM Awesome. I had to switch the atan function out with atan2, and multiply by -1 (not sure why.)
(http://imgur.com/jJ0fk.png) Title: Re: Z = Z^1.5 - 0.2 Post by: yv3 on December 20, 2010, 08:48:52 AM Thx to David and Schlega! Now my glynn fractal is rendered 4,5 x faster! I found out that the complex class of Microsoft is very slow, i was searching a long time to make my own pow function. In most descriptions i was missing how to calculate the real and imaginery part directly. I like this forum. Happy X-Mas. Code: void yComplex::powr(double l) |