How can I determine which roots are closest to the unit circle?

4 views (last 30 days)
Hi all!
I have a problem that I'm currently facing. Lets say I have a column vector (6x1) in which all elements provides me the roots of a polynomial.
For example,
root_out = 6×1 complex
-2.446362435057714 - 0.000000000000002i
-0.408770174717145 - 0.000000000000000i
0.862312857431274 - 0.529586047198464i
0.842065522070228 - 0.517151225883085i
0.862312857431279 + 0.529586047198471i
0.842065522070224 + 0.517151225883078i
Out of this list (Which may vary in size for its rows), how do I determine which root_out elements (could be more than 1) are closest to the unit circle efficiently? (Maybe in something like a search/range function?)

Accepted Answer

Jan
Jan on 11 Jan 2019
Edited: Jan on 11 Jan 2019
x = [ -2.446362435057714 - 0.000000000000002i, ...
-0.408770174717145 - 0.000000000000000i, ...
0.862312857431274 - 0.529586047198464i, ...
0.842065522070228 - 0.517151225883085i, ...
0.862312857431279 + 0.529586047198471i, ...
0.842065522070224 + 0.517151225883078i, ...
0.842065522070228 - 0.517151225883085i]; % Repeated 4th line
r = abs(x);
d = abs(r - 1);
index = (d == min(d));
result = x(index)
Now result contains the value(s), which are nearest to the unit circle. I've repeated the 4th value to test the output of multiple minimal values.
  3 Comments
Jan
Jan on 13 Jan 2019
Edited: Jan on 13 Jan 2019
Find n=3 points with smallest distance to unit circle:
n = 3;
radius = abs(x);
dist = abs(r - 1);
[~, index] = sort(dist);
x(index(1:n))
With Matlab >= R2017b:
n = 3;
radius = abs(x);
dist = abs(r - 1);
[~, index] = mink(dist, n);
x(index)

Sign in to comment.

More Answers (1)

Torsten
Torsten on 11 Jan 2019
[~,ix] = min(abs(real(root_out).^2+imag(real_out).^2-1)./sqrt(real(root_out).^2+imag(real_out).^2));
root_out(ix)

Categories

Find more on Historical Contests in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!