Welcome to Fractal Forums

Fractal Math, Chaos Theory & Research => Mathematics => Topic started by: cKleinhuis on February 06, 2010, 08:15:13 PM




Title: help: how was polar exponentiation exactly ?!
Post by: cKleinhuis on February 06, 2010, 08:15:13 PM
i am right now sitting on implementing some function in glsl, but as always, i have problems getting the complex exponentiation ( complex number with complex numbers )
running, i use the following function, but it is only working correctly for positive real exponents, as soon as the exponent gets negative, or an imaginary parts comes into
play, the function returns invalid values, can someone look at it, and tell me what i am doing wrong ??!


Code:
vec2 complexPot(vec2 x,vec2 y){

float a=x.x;
float b=x.y;
float c=y.x;
float d=y.y;


vec2 p1=cartesianToPolar(x);
float r=p1.y;
float t=p1.x;

float re = pow(r,c)*exp(-d*t)*cos(c*t + d*log(r));
float im = pow(r,c)*exp(-d*t)*sin(c*t + d*log(r));

return vec2(re,im);

}


Title: Re: help: how was polar exponentiation exactly ?!
Post by: jehovajah on February 09, 2010, 03:23:59 AM
A point in the [[polynomial plane]] can be represented by a polynomial number written in
[[Coordinates (elementary_mathematics)#Cartesian coordinates|cartesian coordinates]].  Euler's formula provides a means of conversion between cartesian coordinates and [[coordinates (elementary mathematics)#Polar coordinates|polar coordinates]].  The polar form reduces the number of [[Term (mathematics)|term]]s from two to one, which simplifies the mathematics when used in multiplication or powers of polynomial numbers.  Any p0lynomial number z= x + iy can be written as

z = x + iy = |z| (\cos \phi + i\sin \phi ) = |z| e^{i \phi} \,
 \bar{z} = x - iy = |z| (\cos \phi - i\sin \phi ) = |z| e^{-i \phi} \,

where
 x = \mathrm{Re}\{z\} \, the real part
 y = \mathrm{Im}\{z\} \, the imaginary part
|z| = \sqrt{x^2+y^2} the [[magnitude (mathematics)|magnitude]] of ''z''
\phi = \, [[atan2]](''y'', ''x'').

\phi \, is the ''[[arg (mathematics)|argument]]'' of 'z'-i.e., the angle between the ''x'' axis and the vector ''z'' measured counterclockwise and in [[radian]]s-which is defined [[up to]] addition of 2π.
                  
Now, taking this derived formula, we can use Euler's formula to define the [[logarithm]] of a polynomial number. To do this, we also use the definition of the logarithm (as the inverse operator of exponentiation) that

a = e^{\ln (a)}\,

and that

e^a* e^b = e^{a + b}\,

both valid for any polynomial numbers ''a'' and ''b''.

Therefore, one can write:

 z = |z| e^{i \phi} = e^{\ln |z|} e^{i \phi} = e^{\ln |z| + i \phi}\,


for any ''z''≠0. Taking the logarithm of both sides shows that:

ln z= \ln |z| + i \phi.\,

and in fact this can be used as the definition for the [[polynomial logarithm]]. The logarithm of a polynomial number is thus a [[multi-valued function]], because \phi is multi-valued.

Finally, the other exponential law

(e^a)^k = e^{a k}, \,

which can be seen to hold for  all integers ''k'', together with Euler's formula, implies several [[trigonometric identity|trigonometric identities]] as well as [[de Moivre's formula]].

Based on wikipedia.