Rank of symbolic matrix is wrong (but too small, not too large)

3 ビュー (過去 30 日間)
creepydog
creepydog 2021 年 8 月 4 日
コメント済み: Walter Roberson 2022 年 3 月 21 日
I get a wrong result using the sym/rank command. I'm aware of the limitations of this command as it does not simplify expressions (see: doc sym/rank). So it might fail to recognize linear dependencies and therefore overestimate the rank.
But in my example it computes a too low rank. sym/rank finds a singularity where there is none.
Consider this symbolic 3x3 matrix S:
clear
pi = sym(pi);
syms phi real
S = [cos(phi) cos(phi - 2*pi/3) cos(phi - 4*pi/3)
sin(phi) sin(phi - 2*pi/3) sin(phi - 4*pi/3)
1 1 1];
At the command line:
>> S
S =
[cos(phi), cos(phi - (2*pi)/3), cos(phi - (4*pi)/3)]
[sin(phi), sin(phi - (2*pi)/3), sin(phi - (4*pi)/3)]
[ 1, 1, 1]
This matrix is always regular (i.e. for any value of phi). This can be shown by computing the determinant of S, which is non-zero (and independent of phi).
>> simplify(det(S))
ans =
-(3*3^(1/2))/2
But the rank command returns 2 (should be 3):
>> rank(S)
ans =
2
inv(S) computes the correct inverse of S without any problem. Also try simplify(inv(S)*S), which returns the identity matrix as expected.
I've tested this on R2016b, R2018b, R2020b and R2021a.
In my opinion this behavior cannot be explained by the documented limitations and should be considered a bug.

採用された回答

Prahlad Gowtham Katte
Prahlad Gowtham Katte 2022 年 2 月 15 日
Hello,
This is a known issue and has been communicated with the internal staff and it would be considered for a fix in the future.
  2 件のコメント
Scott Phillips
Scott Phillips 2022 年 3 月 21 日
Has this bug been resolved yet? I'm getting similar errors
Walter Roberson
Walter Roberson 2022 年 3 月 21 日
Still a problem in R2022a unfortunately.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear Algebra についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by