MatLAB do not simplify (a^2)^(1/2) in symbolic ToolBox?

24 Ansichten (letzte 30 Tage)
Alaa Altimimy
Alaa Altimimy am 3 Aug. 2018
>> 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)

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 3 Aug. 2018
Bearbeitet: Walter Roberson am 3 Aug. 2018
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 Kommentar
Nathan Hardenberg
Nathan Hardenberg am 27 Jul. 2023
You can also assume directly:
syms a
syms b real
syms c positive
syms d real positive
A = simplify( sqrt(a^2) )
A = 
B = simplify( sqrt(b^2) )
B = 
C = simplify( sqrt(c^2) )
C = 
c
D = simplify( sqrt(d^2) )
D = 
d

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Star Strider
Star Strider am 3 Aug. 2018
It does:
syms phymi
a = simplify((cos(phymi)^2)^(1/2), 'Steps',3000, 'IgnoreAnalyticConstraints',1)
a =
cos(phymi)

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by