Logo by Fiery - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Check out the originating "3d Mandelbulb" thread here
 
*
Welcome, Guest. Please login or register. December 02, 2025, 04:24:23 PM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: [1]   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: Z = Z^1.5 - 0.2  (Read 2087 times)
Description: Math question
0 Members and 1 Guest are viewing this topic.
mistabell
Forums Newbie
*
Posts: 7


« on: July 13, 2010, 04:16:26 AM »

I'm trying to draw a Glynn fractal.

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?
Logged
David Makin
Global Moderator
Fractal Senior
******
Posts: 2286



Makin' Magic Fractals
WWW
« Reply #1 on: July 13, 2010, 11:38:03 PM »

See:

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.

« Last Edit: July 14, 2010, 12:04:36 AM by David Makin » Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
Schlega
Navigator
*****
Posts: 63


« Reply #2 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.
Logged
mistabell
Forums Newbie
*
Posts: 7


« Reply #3 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.)


Logged
yv3
Conqueror
*******
Posts: 149



WWW
« Reply #4 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) 
{
temp = pow(real*real + imag*imag, l/2.0);
temp2 = l*atan2(imag, real); //*-1.0?

real = temp*cos(temp2);
imag = temp*sin(temp2);
}
« Last Edit: December 20, 2010, 08:59:03 PM by yv3 » Logged

Creator of yFract
Pages: [1]   Go Down
  Print  
 
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.403 seconds with 23 queries. (Pretty URLs adds 0.012s, 2q)