Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: problem with complex numbers

Subject: problem with complex numbers

From: Yuriy

Date: 08 Jan, 2008 23:30:10

Message: 1 of 4

can anybody explain me why this code gives different results
for F1 and F2

clear all
A=5*rand(5,5);

z=2.5;

F1=exp(-j*A).^z;
F2=exp(-j*A*z);

Subject: Re: problem with complex numbers

From: James Tursa

Date: 09 Jan, 2008 01:26:02

Message: 2 of 4

"Yuriy " <aaa@yahoo.com> wrote in message <fm1121
$9dg$1@fred.mathworks.com>...
> can anybody explain me why this code gives different
results
> for F1 and F2
>
> clear all
> A=5*rand(5,5);
>
> z=2.5;
>
> F1=exp(-j*A).^z;
> F2=exp(-j*A*z);

Raising complex numbers to powers is a multi-valued
operation. Depending on how you formulate the calculation
you can get different results, all valid. For example,
consider the very simple calculation of the square root
of -1. MATLAB will give you one answer, i, by default when
you do sqrt(-1), but an equally valid answer is -i.
Depending on how you do the calculation you can get MATLAB
to give you the other answer as well. Anytime you raise
complex numbers to powers you need to be careful. Other
functions are multi-valued for complex arguments also.

James Tursa

Subject: Re: problem with complex numbers

From: Roger Stafford

Date: 09 Jan, 2008 02:08:02

Message: 3 of 4

"Yuriy " <aaa@yahoo.com> wrote in message <fm1121$9dg
$1@fred.mathworks.com>...
> can anybody explain me why this code gives different results
> for F1 and F2
>
> clear all
> A=5*rand(5,5);
>
> z=2.5;
>
> F1=exp(-j*A).^z;
> F2=exp(-j*A*z);
-------
 In the mathematics of complex numbers it is understood that the quantity
w^z, where w is complex-valued, must satisfy the identity

 w^z = exp(z*log(w)).

It is this logarithm function that gives rise to the ambiguity of possible values
for w^z.

  If one travels around the zero value of w in a counterclockwise circular
direction, keeping log(w) a continuous function, it will be increased by 2*pi*j
after each complete revolution. Thus the logarithm function is regarded as
an analytic function but with infinitely many branches, and it has a
discontinuity at w = 0.

  The effect on w^2.5 is to reverse sign after each revolution. This is the
cause of the sign reversals you see between F1 and F2. Matlab follows the
convention that the imaginary part of the logarithm is restricted to the
interval from -pi*j to +pi*j, and this leads to the difference between F1 and
F2. If you had selected z = 2.75, you would see four different kinds of
inequalities occurring between F1 and F2. They would differ by various
multiples of a pi/2 rotation.

  This is an inevitable ambiguity in the mathematics of complex numbers and
not a fault of matlab's convention. It is the same problem that prevails when
taking square roots or higher roots. The square root of 9 can be +3 or -3.
The fourth root of 16 can be any one of the quantities 2, 2*j, -2, or -2*j. All
are equally valid from the point of view of complex numbers.

Roger Stafford

Subject: Re: problem with complex numbers

From: Vasia

Date: 09 Jan, 2008 16:26:02

Message: 4 of 4

Thanks for the answer.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
power Vasia 08 Jan, 2008 18:35:04
complex Vasia 08 Jan, 2008 18:35:04
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics