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 it must be purely real. It seems the
notation of i in exp( i x ) is used to indicate the complex mapping
of the real x into the complex plane.

Thus my error in passing a complex argument to exp.

Rather I should stick with:

expi(x) = complex( cos(x), sin(x) )

when working with phasors based on Euler's formula.

Just as a note:
I don't think this is an expression of Euler's formula:

exp(x + iy) = exp(x)*(cos(y) + i sin(y))

The argument is complex and will in general not map onto the unit circle.


On 01/30/2012 02:13 PM, R. Michael Weylandt wrote:
> 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
> imaginary) numbers looks like this:
>
> exp(x + iy) = exp(x)*(cos(y) + i sin(y))
>
> That is, the real part gives the modulus and the imaginary part goes
> solely to the argument. What's often surprising about this is that
>
> exp(2 + 2*pi*i) = exp(2) = exp(2+4*pi*i) = exp(2 - 2*pi*i)
>
> because the trig functions which get applied to the imaginary part are
> periodic.
>
> Take a closer look at what you wrote:
>
> complex( real = cos(2*pi), imaginary = sin(2*pi) )
> exp( (complex( real = 2*pi, imaginary = 2*pi) ) )
>
> The number in the first line is not what gets exponentialed in the
> second! You'll get the expected (by you) behavior if you actually use
> the same number for both calculations:
>
> complex( real = cos(2*pi), imaginary = sin(2*pi) )
> exp(complex( real = cos(2*pi), imaginary = sin(2*pi) ))
>
> or
>
> complex(real = 2*pi, imaginary = 2*pi)
> exp(complex(real = 2*pi, imaginary = 2*pi))
>
> If you work out the second like I did for exp(pi + 2*pi*i) in my first
> email, you'll get the correct answer.
>
> All in all, R is definitely correct in it's "interpretation" of
> Euler's formula. There's only one way to parse this relationship that
> gives mathematical consistency and it's what Peter and I have set out
> for you.
>
> Michael
>
> ** Not actually true, if x is complex, it of course works out
> correctly as well, but you wind up having to use the more general
> expression I give to get there.
>
> On Mon, Jan 30, 2012 at 2:43 PM, 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
>>
>> Not this:
>>> exp(a)
>> [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
>>
>> That would not work in Michaels expansion, the answer must
>> be 1 + 0i.
>>
>> Which seems to suggest that exp( ix ) and cos x + i sin x (as
>> written above) are different interpretations.
>>
>>
>> On 01/30/2012 12:47 PM, Peter Langfelder wrote:
>>
>> 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 ignorance of possible signs) cos(x) = cosh(y), and
>> sin(x) = -sinh(y) simply by expressing (from the formula you wrote)
>> cos(x) and sin(x) as
>>
>> cos(x) = ( exp(ix) + exp(-ix) )/2
>> and sin(x) = ( exp(ix) - exp(-ix) )/2
>>
>> In any case, plug any complex number into
>> exp( ix )
>> and
>> cos x + i sin x
>>
>> in R and you will get the exact same answers.
>>
>> HTH,
>>
>> Peter
>>
>> On Mon, Jan 30, 2012 at 7:37 AM, Joseph Park<josephp...@ieee.org>  wrote:
>>
>> 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] 23.14069-0i
>>   >  exp( complex(real = pi/2, imag = 0) )
>> [1] 4.810477+0i
>>
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> 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.

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to