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)

 채택된 답변

Massimo Zanetti
Massimo Zanetti 2016년 9월 29일
편집: Massimo Zanetti 2016년 9월 29일

3 개 추천

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

Corey Richardson
Corey Richardson 2016년 9월 29일
OK, that makes sense. Is there a way to rewrite them away?
Massimo Zanetti
Massimo Zanetti 2016년 9월 29일
Actually the point is, why you need to rewrite something that is correct?
Corey Richardson
Corey Richardson 2016년 9월 29일
For display purposes in live scripts, it muddies the expressions.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by