Title: Quaternion Exponentiation Post by: JVillella 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 :) Julian Title: Re: Quaternion Exponentiation Post by: David Makin 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 (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 ? Title: Re: Quaternion Exponentiation Post by: DarkBeam 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 ;) use exponentiation only for do some weird power experiments :D Title: Re: Quaternion Exponentiation Post by: DarkBeam on December 31, 2011, 10:47:12 PM Ah ... there is a quatpow formula for mandelbulb but nobody uses it (too slow) so ... :D
Title: Re: Quaternion Exponentiation Post by: JVillella 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? Title: Re: Quaternion Exponentiation Post by: fractower 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 Title: Re: Quaternion Exponentiation Post by: DarkBeam 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! ... :sad1: That's what I do all the times Title: Re: Quaternion Exponentiation Post by: David Makin 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. Title: Re: Quaternion Exponentiation Post by: JVillella 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 :) Title: Re: Quaternion Exponentiation Post by: David Makin 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 :) Now I don't follow, AFAIK no-one is mixing quaternions and the Mandelbulb triplex math, except in hybrids. Title: Re: Quaternion Exponentiation Post by: Syntopia 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 :) 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) {Here is an image - it looks even more whipped than the standard power-2 :-) Title: Re: Quaternion Exponentiation Post by: DarkBeam on January 03, 2012, 11:55:49 PM What a waste, to calculate separately pow7 and pow8! :D |