- Mathematica: http://www.wolframalpha.com/input/?i=rank(%7B%7B1-sin(x)%5E2,+cos(x)%5E2%7D,+%7B1,+1%7D%7D)
- MATLAB:
Rank in Matlab shows different result than Mathematica
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I'm working on a Matlab script that replaces a Mathematica script. I noticed that Matlab's rank and nullspace on a symbolic matrix show a different result compared to Matematica. Unfortunately, I do not have a minimal example at this point. The symbolic matrix is of size 100x10 and contains trigonometric functions. Using the same input for the rank in Matlab and Mathematica shows that Mathematica can eliminate one block of trigonometric functions more than Matlab. The problem is, that I can't prove which version is wrong.
Are there any tips for the symbolic toolbox in Matlab to prevent wrong assumptions on symbols or to simplify row reduction? At the moment I assume all symbols to be real, which is the case.
Also, in both Programs, the reduced echelon form shows the same issue. There are more non-identity rows in Matlab.
Thanks in advance.
0 个评论
采纳的回答
Yuichi Tadokoro
2018-7-18
For example, we have rank=2 in MATLAB and rank=1 in WolframAlpha for a matrix shown below.
>> syms x
>> A = [1-sin(x)^2 cos(x)^2; 1 1]
A =
[ 1 - sin(x)^2, cos(x)^2]
[ 1, 1]
>> rank(A)
ans =
2
This issue is related to this topic: https://www.mathworks.com/help/symbolic/rank.html?s_tid=doc_ta#bupsf9u-1
The most general and practical workaround of this issue would be to use simplify or vpa before calling rank function.
In your case, the elements of the matrix are trigonometric functions, so rewrite function might help. https://www.mathworks.com/help/symbolic/rewrite.html
>> rewrite(A,'cos')
ans =
[ cos(x)^2, cos(x)^2]
[ 1, 1]
>> rank(rewrite(A,'cos'))
ans =
1
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!