Conjugate of Symbolic Root doesn't change anything

4 ビュー (過去 30 日間)
James Tursa 2024 年 2 月 21 日

Basically, the Symbolic Toolbox is making a simplification that, while it can be considered correct in the big picture, is nevertheless annoying. Take this code:
syms z
ex = z^5 + z^4 + z^3 + z^2 + z^1 + 1 == 0;
s = root(ex,z,1)
s =
c = conj(s)
c =
vpa(s)
ans =
vpa(c)
ans =
You can see that the conj( ) had no effect, and seems to have been ignored since both vpa values are the same.
In the big picture, it seems the Symbolic Toolbox knows that roots come in complex conjugate pairs when the coefficients of a polynomial are real. And since there is no published preferred order of returning the roots, it has apparently implicitly changed the order in the background as reasoning for doing away with the conjugate. It is as if root(ex,z,1) is interpreted as "one of the roots of ex given a changeable background ordering depending on how you use it", and not "the first root of ex given some fixed order in the background". At least that is my take on what is happening.
If you ask for all the roots and convert them you get this:
vpa(root(ex,z))
ans =
which of course gives you all the roots. Taking the conj( ) of this gives the expected results. It seems to me a description of this type of behavior in the doc is in order, but I see no mention of it in either the root( ) or conj( ) doc. Is there a mention of this somewhere that I missed? Is there a way to have conj( ) treat symbolic root( ) (and maybe other related functions) differently?
2 件のコメントなしを表示なしを非表示
Walter Roberson 2024 年 2 月 21 日
Interesting.
I could see conj(root(ex,z)) (without the root selector) being silently dropped, but it does seem wrong to drop it when there is a root selector.
James Tursa 2024 年 2 月 22 日
It can also lead to strange results such as this:
syms z
ex = z^5 + z^4 + z^3 + z^2 + z^1 + 1 == 0;
s = root(ex,z,1)
s =
vpa(s*conj(s))
ans =
You would expect the result to be real (within numerical effects), but it isn't. Forces you to do the vpa( ) first:
vpa(s)*conj(vpa(s))
ans =
1.0

サインインしてコメントする。

回答 (1 件)

Sufiyan 2024 年 2 月 26 日
root() is used to represent roots of the polynomial. If you refer to this link root documentation, you can see that solve() is recommended to find the roots.
syms z
ex = z^5 + z^4 + z^3 + z^2 + z + 1;
s = (solve(ex, z));
% consider the second root
sroot = s(2);
product = vpa(sroot * conj(sroot))
product =
1.0
I believe this would resolve your query.
1 件のコメント-1 件の古いコメントを表示-1 件の古いコメントを非表示
James Tursa 2024 年 2 月 26 日

Except when it doesn't. E.g., when solve() can't find explicit roots, it punts to root():
syms z
ex = 3*z^5 + z^4 + z^3 + z^2 + z + 1;
s = (solve(ex, z))
s =
vpa(s(2)*conj(s(2)))
ans =
So, same problem.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeConversion Between Symbolic and Numeric についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by