abs and sign simplification

2 views (last 30 days)
In some symbolic manipulations, I get a result which has something like abs(e)*sign(e). Why is this not simplified away, even by simplify? It's surely an identity that e = abs(e)*sign(e). For example, with this code:
syms x
diff(norm(diff(cos(x))))
% ans = (abs(sin(t))*sign(sin(t))*cos(t))/(abs(sin(t))^2)^(1/2)

Accepted Answer

Massimo Zanetti
Massimo Zanetti on 29 Sep 2016
Edited: Massimo Zanetti on 29 Sep 2016
It happens because for the scalar case norm(y)=|y| (here y=y(x) is any function), therefore Matlab computes derivative by splitting the two cases in the derivative of|y|: y>=0 and y<0. Then it combines the results in a signle function by the sign*|.| trick.
  3 Comments
Massimo Zanetti
Massimo Zanetti on 29 Sep 2016
Actually the point is, why you need to rewrite something that is correct?
Corey Richardson
Corey Richardson on 29 Sep 2016
For display purposes in live scripts, it muddies the expressions.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!