MatLAB do not simplify (a^2)^(1/2) in symbolic ToolBox?
24 次查看(过去 30 天)
显示 更早的评论
>> simplify((cos(phymi)^2)^(1/2), 3000)
ans =
(cos(phymi)^2)^(1/2)
>> rewrite (((cos(phymi))^2)^(1/2), 'exp')
ans =
((exp(-phymi*1i)/2 + exp(phymi*1i)/2)^2)^(1/2)
>> simplify((phymi^2)^(1/2), 5000)
ans =
(phymi^2)^(1/2)
0 个评论
采纳的回答
Walter Roberson
2018-8-3
编辑:Walter Roberson
2018-8-3
MATLAB assumes that symbols might have complex values unless you tell it they are not complex. For complex values, sqrt(x^2) is not the same as x. For that matter, sqrt(x^2) is not the same as x even just for negative real values.
If you know for sure that your values are nonnegative, then add an assumption about that, such as
syms phymi
assume(phymi >= 0)
1 个评论
Nathan Hardenberg
2023-7-27
You can also assume directly:
syms a
syms b real
syms c positive
syms d real positive
A = simplify( sqrt(a^2) )
B = simplify( sqrt(b^2) )
C = simplify( sqrt(c^2) )
D = simplify( sqrt(d^2) )
更多回答(1 个)
Star Strider
2018-8-3
It does:
syms phymi
a = simplify((cos(phymi)^2)^(1/2), 'Steps',3000, 'IgnoreAnalyticConstraints',1)
a =
cos(phymi)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!