When I take the integer root of a complex number, which root will MATLAB return?
3 views (last 30 days)
Show older comments
When I take the integer root of a complex number, which root will MATLAB return?
There are "n" roots that are a solution to "r = z^(1/n)". How can I anticipate which root will be returned?
Accepted Answer
MathWorks Support Team
on 27 Jun 2009
MATLAB returns the root closest to the positive x-axis. This corresponds to the root with smallest absolute phase angle as returned by the ANGLE function.
When there are two roots symmetric about the x-axis (as is the case for a negative real number or a pure imaginary number), MATLAB returns the root with a positive imaginary part.
To obtain all "n" roots of the complex number "z", use the commands:
P = -1;P(n+1) = z;
r = roots(P)
or
k=1:n;
y = abs(z)^(1/n)*exp(i/n*(angle(z)+2*k*pi))
or
y2 = z^(1/n);
y2 = abs(y2)*exp(i*(angle(y2)+2*[1:n]*pi/n))
The results "y" and "y2" will be identical.
When "z" is a matrix of complex values, use the commands:
[z k] = meshgrid(z,1:n);
y = abs(z).^(1/n).*exp(i/n*(angle(z)+2*k*pi))
or
[z k] = meshgrid(z,1:n);
y2 = z.^(1/n);
y2 = abs(y2).*exp(i*(angle(y2)+2*k*pi/n))
Again, the results "y" and "y2" will be identical.
0 Comments
More Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!