Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matlab absolute value squared

I can't find a way in matlab to simplify this symbolic expression. x will be evaluated in a real number.

syms x
expr = abs(x)^2

I expect the result to be

 expr = x^2

Matlab gives

expr = abs(x)^2
like image 467
T. Meunier Avatar asked Jan 16 '26 22:01

T. Meunier


1 Answers

Your desired solution is only valid if x is real, thus you need to tell MATLAB that.

 assume(x, 'real')
 simplify(expr)
like image 52
Ander Biguri Avatar answered Jan 19 '26 15:01

Ander Biguri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!