Assumption on another symbolic Variable affecting a previous assumption

1 次查看(过去 30 天)
Why is the assumption I made being changed by the next assumption I do on another variable ?
The assumpitons on Phi_geod and Phi_dot_geod are being changed by the assumptions on the variables lambda_geod and lambda_dot_geod.
Code:
syms Phi_geod(t) lambda_geod(t)
syms Phi_dot_geod(t) lambda_dot_geod(t)
assumptions(Phi_geod)
ans = Empty sym: 1-by-0
assume(Phi_geod(t),"real");
assumptions(Phi_geod)
ans = 
assume(lambda_geod(t),"real");
assumptions(Phi_geod)
ans = 
assume(Phi_dot_geod(t),"real");
assume(lambda_dot_geod(t),"real");
assumptions(Phi_geod)
ans = 

采纳的回答

Dyuman Joshi
Dyuman Joshi 2024-4-4
Because assume over-writes assumptions.
From the Tips section in the documentation page -
"assume removes any assumptions previously set on the symbolic variables. To retain previous assumptions while adding an assumption, use assumeAlso."
As mentioned in the note above, you need to use assumeAlso, after using assume() the first time.
syms Phi_geod(t) lambda_geod(t)
syms Phi_dot_geod(t) lambda_dot_geod(t)
assumptions(Phi_geod)
ans = Empty sym: 1-by-0
assume(Phi_geod(t),"real");
assumptions(Phi_geod)
ans = 
assumeAlso(lambda_geod(t),"real");
assumptions(Phi_geod)
ans = 
assumeAlso(Phi_dot_geod(t),"real");
assumeAlso(lambda_dot_geod(t),"real");
ans = 
assumptions(Phi_geod)
ans = 
  5 个评论
Dyuman Joshi
Dyuman Joshi 2024-4-5
编辑:Dyuman Joshi 2024-4-5
Yes, the class of y is symfun and the class of y(t) is not symfun.
And yes, the statement should be more precise as you have stated.
syms y(t)
class(y)
ans = 'symfun'
class(y(t))
ans = 'sym'
try
assume(y(t),'real')
catch ME
ME.message
end
assumptions
ans = 
try
assume(y,'real')
catch ME
ME.message
end
ans = 'Assumptions on symbolic functions not supported. Make assumptions on symbolic variables and expressions instead.'
y(t) = t^2;
%returns the function definition
y
y(t) = 
%returns the expression
y(t)
ans = 
Christian Luciano Maendle
Thank you very much! This constructive discussion has made it very clear to me. Thank you for your help! :)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Assumptions 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by