On Mon, Jan 30, 2012 at 11:43 AM, Joseph Park <josephp...@ieee.org> wrote: > Thanks Michael & Peter. > > Michael's expansion makes sense. > > This is what I expected: > >> a = pi + 0i >> complex( real = cos(Re(a)), imaginary = sin(Im(a)) ) > [1] -1+0i
As they say, the error is between the keyboard and the chair. You cannot drop parts of a - in your formula above you dropped the imaginary part of a in cos and the real part of a in sin. In this case it doesn't make a difference but in general it will. > > Not this: >> exp(a) you need exp(ia), not exp(a): i = complex(real = 0, imaginary = 1) exp(i*a) [1] -1+0i > [1] 23.14069+0i > > Is this not an implementation of Euler's formula: >> complex( real = cos(2*pi), imaginary = sin(2*pi) ) > [1] 1-0i > > And that is a result Michael depends on in his > expansion, yet if we pass this argument to exp: >> exp( (complex( real = 2*pi, imaginary = 2*pi) ) ) > [1] 535.4917-0i Again, you are not using the formula correctly. Remember x = 2*pi, so you need exp( i * 2 * pi) and you get the same result as complex( real = cos(2*pi), imaginary = sin(2*pi) ) Peter ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.