[GiNaC-devel] [GiNaC-list] Issue with derivative of "abs"

Alexey Sheplyakov asheplyakov at yandex.ru
Wed Jun 17 10:34:14 CEST 2020


Hi!

>     ASh> x*abs(x) is differentiable at x = 0 (with derivative being
>     ASh> zero). Unfortunately GiNaC can't automatically compute
>     ASh> that. For now one can manually substitute x^2 -> abs(x)^2 which
>     ASh> will reduce x^2/abs(x) + abs(x) to 2*abs(x)
>
>   Without arguing on can we regularise the derivative abs(x) at x=0 by
>   _declaring_ it being 0 or we cannot, I am missing you next
>   argument.

The point is that

1) giving correct result in some cases does not make the patch correct
2) Unfortunately GiNaC can't compute limits, so one should do that manually
3) Transforming x^2/abs(x) into abs(x) makes it better suited for a numerical computation

> How does it speak against the patch?

It does not. I was trying to explain why the patch gives a correct result for the function
in question (x*abs(x)) despite being incorrect in general.

Best regards,
      Alexey



More information about the GiNaC-devel mailing list