Possibly a bug in the ASSUME function (Symbolic Math Toolbox)
13 ビュー (過去 30 日間)
古いコメントを表示
I am afraid I have bumped across a bug, or at least a confusing feature. It deals with imposing an assumption on a symbolic function. Consider the following code
clear all
syms theta1(t)
assume(theta1(t),'real')
theta1' % checking if conjugate transpose correctly reduces to transpose for a real function
assumptions % gives a list of all assumptions
The outputs are
ans(t) =
theta1(t)
ans =
in(theta1(t), 'real')
Perfect. That is what we expect. But now consider a minor extension – we add one more symbolic function
clear all
syms theta1(t)
syms theta2(t)
assume(theta1(t),'real')
assume(theta2(t),'real')
theta1'
theta2'
assumptions
The outputs are incorrect:
ans(t) =
conj(theta1(t))
ans(t) =
theta2(t)
ans =
in(theta2(t), 'real')
It appears that upon imposing the second assumption, the first assumption is reset/removed.
Note that here the assumptions are imposed on two different/distinct objects; this is not the same case as the one with multiple assumptions mentioned in the manual.
But let's now check that the outcomes are correct if instead of symbolic functions we impose the assumptions on symbolic variables/expressions
clear all
syms theta1
syms theta2
assume(theta1,'real')
assume(theta2,'real')
theta1'
theta2'
assumptions
The outputs are
ans =
theta1
ans =
theta2
ans =
[in(theta1, 'real'), in(theta2, 'real')]
Correct. That is why I am tempted to conclude that the behaviour for functions exhibits a bug.
0 件のコメント
採用された回答
Ameer Hamza
2020 年 11 月 26 日
編集済み: Ameer Hamza
2020 年 11 月 26 日
This is documented in the Tips section of assume() function: https://www.mathworks.com/help/releases/R2020b/symbolic/assume.html#bt07ws4-4
The toolbox does not support assumptions on symbolic functions. Make assumptions on symbolic variables and expressions instead.
Therefore, the results you are getting for second code can be considered undocumented behaviour.
8 件のコメント
Ameer Hamza
2020 年 11 月 27 日
This works fine because theta1 and theta2 are two independent variables. In the case of theta1(t) and theta2(t). They are not independent. Rather they are both dependent on 't'. assume(theta1(t),'real') applies assumption on both theta1, and t. Since applying assume() again on a variable remove its previous assumptions, therefore, assume(theta2(t),'real') applies assumption about 't' which force MATLAB to remove the previous assumption on 't'. Since theta1 is dependent on 't', so its assumption is also gone. For example, consider the following
>> syms x
>> assume(x > 0)
>> assumptions
ans =
0 < x
>> assume(x < 2)
>> assumptions
ans =
x < 2
As you can see, it deleted the assumption that x > 0. The workaround is to use assumeAlso().
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Assumptions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!