Improve diff(abs(x)) for real x.
authorPierangelo Masarati <pierangelo.masarati@polimi.it>
Wed, 17 Jun 2020 17:52:49 +0000 (19:52 +0200)
committerRichard Kreckel <kreckel@ginac.de>
Wed, 17 Jun 2020 17:52:49 +0000 (19:52 +0200)
ginac/inifcns.cpp

index d68afbb50df6d6f965e8d6bbbd4573cd9bdf5115..ec74a435de0774290f6d95baa221690b87420de7 100644 (file)
@@ -321,6 +321,8 @@ static ex abs_expand(const ex & arg, unsigned options)
 static ex abs_expl_derivative(const ex & arg, const symbol & s)
 {
        ex diff_arg = arg.diff(s);
+       if (arg.info(info_flags::real))
+               return diff_arg*(2*step(arg) - 1);
        return (diff_arg*arg.conjugate()+arg*diff_arg.conjugate())/2/abs(arg);
 }