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: Follow us on Twitter
 
*
Welcome, Guest. Please login or register. November 20, 2025, 02:36:39 AM


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: Quaternion Exponentiation  (Read 6795 times)
Description: Raising quaternions to an exponent.
0 Members and 1 Guest are viewing this topic.
JVillella
Guest
« on: December 31, 2011, 10:03:37 PM »

Hi everyone. I have been learning about the Mandelbulb for quite some time now using hypercomplex triplex numbers. I wanted to try something new though and switched to quaternions. I have implemented them into my fractal explorer buts I only know how to do quaternion multiplication. I have been stuck rendering "z -> z^n + c" with "n" always being 2. Is there a way to do quaternion exponentiation so I can set "n" to something like 8?

I would really appreciate some guidance on this.

Thank you smiley
Julian
Logged
David Makin
Global Moderator
Fractal Senior
******
Posts: 2286



Makin' Magic Fractals
WWW
« Reply #1 on: December 31, 2011, 10:16:41 PM »

Is there a way to do quaternion exponentiation so I can set "n" to something like 8?

Yes, though the exact method isn't to hand for me at the moment - in fact the really weird thing is that getting powers of quaternions using the log/exp method actually has 2 possible values *if* the power and the log of the value are both more than plain complex (i.e. both have a non-zero 3rd or 4th term) this is because quaternions are not commutative so when getting the power using:

exp(power*log(value))

the result is not the same as:

exp(log(value)*power)

*if* both log(value) and power are not plain complex.

After a quick Google, I think this pdf is correct (though I only scanned it *very* briefly) in so far as it shows how they're normally treated:

http://www.google.co.uk/url?sa=t&rct=j&q=quaternion+log+exp&source=web&cd=5&ved=0CE0QFjAE&url=http%3A%2F%2Fwww.lce.hut.fi%2F~ssarkka%2Fpub%2Fquat.pdf&ei=53r_TszDM4Pp8QPvlPz6Dg&usg=AFQjCNFXWWscHijx2qr5M1z93rhCPYKN7w



Also I don't think I've ever tried it myself, but surely the same method as is used for the triplexes can be applied to quaternions i.e. raising the power of the magnitude by the power value and scaling the relevant angles by the power value, then recombining ?
« Last Edit: December 31, 2011, 10:21:17 PM 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
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #2 on: December 31, 2011, 10:43:33 PM »

It is not necessary to "exponentiate" to get power 8! Just repeat 8 times a 2 term product
a b c d ... initially set em to the same values to x y z w
then do
for i 0 to 7
newa = x*a ... etc ...
newb ...
until newd.
then copy newa in a, newb in b ...
and finally next i.
after that x = a+cx, y = b+cy ...
done wink

use exponentiation only for do some weird power experiments cheesy
Logged

No sweat, guardian of wisdom!
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #3 on: December 31, 2011, 10:47:12 PM »

Ah ... there is a quatpow formula for mandelbulb but nobody uses it (too slow) so ... cheesy
Logged

No sweat, guardian of wisdom!
JVillella
Guest
« Reply #4 on: January 01, 2012, 03:48:19 PM »

Hi everyone. Thank you for your quick replies.

Quote
Yes, though the exact method isn't to hand for me at the moment - in fact the really weird thing is that getting powers of quaternions using the log/exp method actually has 2 possible values *if* the power and the log of the value are both more than plain complex (i.e. both have a non-zero 3rd or 4th term) this is because quaternions are not commutative so when getting the power using:

exp(power*log(value))

the result is not the same as:

exp(log(value)*power)

*if* both log(value) and power are not plain complex.

I will give this a shot right away! Thanks for the link and the little caveat.

Quote
It is not necessary to "exponentiate" to get power 8! Just repeat 8 times a 2 term product

This is what I have essentially been doing. Do you think I would get different results in any way if I did it using exponentiation?



Logged
fractower
Iterator
*
Posts: 173


« Reply #5 on: January 01, 2012, 04:26:00 PM »

As long as the exponent is a non-negative integer there is a method goes as log2 the exponent.

quad exp_int(quad q, exp e){
    int tmp_e = e;
    quad result = (1,0,0,0);
    quad q2 = q;

    while(tmp_e){
        if(tmp_e&1){
            result = result * q2;
        }
        q2 = q2 * q2;
        tmp_e>>1;
    }
    return(result);
}

The trick is that each bit position in e "adds" a unique power of 2 factor of q to the final product. If you know the exponent in advance it is better to unroll the loop and avoid the mispredicted branches. For example a power of 8 would be:

q2 = q *q
q4 = q2*q2
q8 = q4 * q4




Logged
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #6 on: January 01, 2012, 04:28:25 PM »

Quote
It is not necessary to "exponentiate" to get power 8! Just repeat 8 times a 2 term product

This is what I have essentially been doing. Do you think I would get different results in any way if I did it using exponentiation?

Impossible, unless you do mistakes in coding. So check all accurately again and again! ... sad That's what I do all the times
Logged

No sweat, guardian of wisdom!
David Makin
Global Moderator
Fractal Senior
******
Posts: 2286



Makin' Magic Fractals
WWW
« Reply #7 on: January 02, 2012, 12:37:55 AM »


This is what I have essentially been doing. Do you think I would get different results in any way if I did it using exponentiation?


Essentially I think all bets are off *if* both the power and the value are truly quaternionic i.e. both have non-zero 3rd and 4th components, but I think if the value is truly quaternionic but the power is plain real or complex then there's no issue - I'm not so sure if the power is quaternionic but the value is plain real or complex.
Logged

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

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
JVillella
Guest
« Reply #8 on: January 02, 2012, 03:42:44 AM »

I have been experimenting with different exponents and I notice that a power-8 mandelbulb is not visible whilst using a quaternion number system. On your mandelbulb implementations have you noticed this? It is possible I am doing things wrong. I just want to make sure it isn't "normal" before I begin debugging.

Thanks,
Julian smiley
Logged
David Makin
Global Moderator
Fractal Senior
******
Posts: 2286



Makin' Magic Fractals
WWW
« Reply #9 on: January 03, 2012, 10:30:39 AM »

I have been experimenting with different exponents and I notice that a power-8 mandelbulb is not visible whilst using a quaternion number system. On your mandelbulb implementations have you noticed this? It is possible I am doing things wrong. I just want to make sure it isn't "normal" before I begin debugging.

Thanks,
Julian smiley

Now I don't follow, AFAIK no-one is mixing quaternions and the Mandelbulb triplex math, except in hybrids.
Logged

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

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
Syntopia
Fractal Molossus
**
Posts: 681



syntopiadk
WWW
« Reply #10 on: January 03, 2012, 10:50:26 PM »

I have been experimenting with different exponents and I notice that a power-8 mandelbulb is not visible whilst using a quaternion number system. On your mandelbulb implementations have you noticed this? It is possible I am doing things wrong. I just want to make sure it isn't "normal" before I begin debugging.

Thanks,
Julian smiley

Now I don't follow, AFAIK no-one is mixing quaternions and the Mandelbulb triplex math, except in hybrids.

If you mean to create a power-8 Quaternion Julia set, it is possible. It is not related to the Mandelbulb, though.

How do you draw your Quaternion systems?
Here is an example distance estimator for a power-8 quaternion system, sliced through w=0:

Code:
vec4 qMul(vec4 a, vec4 b) {
return vec4(
a.x*b.x  - a.y*b.y - a.z*b.z  - a.w*b.w,
a.x*b.y + a.y*b.x + a.z*b.w - a.w*b.z,
a.x*b.z - a.y*b.w +a.z*b.x + a.w*b.y,
a.x*b.w  + a.y*b.z  - a.z*b.y + a.w*b.x
);
}

// power 8
vec4 q8(vec4 a) {
a = qMul(a,a);
a = qMul(a,a);
a = qMul(a,a);
return a;
}

// power 7
vec4 q7(vec4 a) {
vec4 a2 = qMul(a,a);
vec4 a4 = qMul(a2,a2);
return qMul(qMul(a2,a4),a);
}

float DE(vec3 pos) {
vec4 p = vec4(pos, 0.0);
vec4 dp = vec4(1.0, 0.0,0.0,0.0);
for (int i = 0; i < Iterations; i++) {
dp = 8.0*qMul(q7(p),dp);
p = q8(p) + C;
float p2 = dot(p,p);
if (p2 > Threshold) break;
}
float r = length(p);
return  0.5 * r * log(r) / length(dp);
}

Here is an image - it looks even more whipped than the standard power-2 :-)


* quat8.jpg (48.4 KB, 570x375 - viewed 385 times.)
Logged
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #11 on: January 03, 2012, 11:55:49 PM »

What a waste, to calculate separately pow7 and pow8! cheesy
Logged

No sweat, guardian of wisdom!
Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
help: how was polar exponentiation exactly ?! Mathematics cKleinhuis 1 1524 Last post February 09, 2010, 03:23:59 AM
by jehovajah
Generalizations of Complex Numbers by Circular Functions and Exponentiation (new) Theories & Research scientiaesthete 1 789 Last post December 01, 2011, 04:41:50 AM
by s31415
giant leaps? fast exponentiation for iteration Mandelbrot & Julia Set claude 0 1802 Last post September 26, 2013, 01:09:36 AM
by claude
Quaternion Quest IV Mandelbulber Gallery mclarekin 0 659 Last post November 04, 2014, 07:05:36 AM
by mclarekin
Quaternion Mandelbulb3D Gallery MichaelWGioffredi 0 822 Last post April 02, 2015, 03:16:12 PM
by MichaelWGioffredi

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.221 seconds with 27 queries. (Pretty URLs adds 0.01s, 2q)