[R] Euler identity with complex exp

2012-01-30 Thread Joseph Park
Hi, Am i doing something silly here in expecting Euler's formula to be handled by exp? exp( ix ) = cos x + i sin x. The first example below follows this, the others not. Thanks for the education! exp( complex(real = 0, imag = 2*pi) ) [1] 1-0i exp( complex(real = pi, imag = 2*pi) ) [1]

Re: [R] Euler identity with complex exp

2012-01-30 Thread R. Michael Weylandt
Seems fine to me: exp(pi + i*2pi) = exp(pi) * exp(i *2pi) = exp(pi) * (cos(2pi) + i*sin(2*pi)) = exp(pi) *(1+ 0i) = exp(pi) ~ 23.14 exp(pi/2) ~ 4.81 What would you expect? Michael On Mon, Jan 30, 2012 at 10:37 AM, Joseph Park josephp...@ieee.org wrote: Hi, Am i doing something silly here in

Re: [R] Euler identity with complex exp

2012-01-30 Thread Peter Langfelder
Not sure why you think the formula does not hold... but am guessing you think that sin(x) and cos(x) are have values in [-1, 1]? Well that only holds for real x. If you have a complex x, sin(x) and cos(x) are unbounded - indeed, if you can write x=iy and y is real, you can show (up to my own

Re: [R] Euler identity with complex exp

2012-01-30 Thread Peter Langfelder
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

Re: [R] Euler identity with complex exp

2012-01-30 Thread R. Michael Weylandt
This is off-topic for R-help, but we might as well finish what's been started: Take a closer look at exp(i*x). If x is real, i*x is a pure imaginary number, not a complex number so the formula you are using doesn't hold in general.** The general Euler result for complex (= mixed real and

Re: [R] Euler identity with complex exp

2012-01-30 Thread Joseph Park
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 Not this: exp(a) [1] 23.14069+0i Is this not an implementation of Euler's formula: complex( real = cos(2*pi), imaginary =

Re: [R] Euler identity with complex exp

2012-01-30 Thread Joseph Park
Thanks Gentlemen. Now I see the disconnect. I was misusing exp( i x ) and expecting to get exp( i x ) = cos x + i sin x, which is Euler's formula. Since it is a mapping of a real number onto the unit circle in the complex plane, any answer it gives must have a magnitude of 1 and the argument to