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

Vladimir V. Kisil V.Kisil at leeds.ac.uk
Wed Jun 17 09:39:37 CEST 2020


	Dear Alexey,
>>>>> On Wed, 17 Jun 2020 02:21:37 +0400, Alexey Sheplyakov <asheplyakov at yandex.ru> said:
    ASh> 17.06.2020, 00:30, "Vladimir V. Kisil" <v.kisil at leeds.ac.uk>:
    >>        Dear Developers,
    >>         To support Pierangelo's suggestion from here:
    >> https://www.ginac.de/pipermail/ginac-list/2020-June/002301.html

    ASh> I'm afraid the patch is wrong. abs(x) is not differentiable at
    ASh> x = 0, and there's no way to "fix" that.

    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. How does it speak against the patch? With this patch I have
  (in PyGyNac, sorry):
    
In [1]: x=realsymbol("x")

In [2]: e=x*abs(x)

In [3]: print(e.diff(x))
{|x|}+ {(-1+2 \mbox{step}(x))} x

In [4]: print(e.diff(x).subs(x==0))
0

  So we got exactly the value you have pointed out!

  Best wishes,
  Vladimir
-- 
Vladimir V. Kisil                 http://www.maths.leeds.ac.uk/~kisilv/
  Book:     Geometry of Mobius Transformations     http://goo.gl/EaG2Vu
  Software: Geometry of cycles          http://moebinv.sourceforge.net/
  Jupyter: https://github.com/vvkisil/MoebInv-notebooks



More information about the GiNaC-devel mailing list