Re: [GiNaC-devel] [GiNaC-list] Issue with derivative of "abs"
Dear Developers, To support Pierangelo's suggestion from here: https://www.ginac.de/pipermail/ginac-list/2020-June/002301.html I am forwarding it to this list as a Git patch attached to this email. 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
Hello! 17.06.2020, 00:30, "Vladimir V. Kisil" <v.kisil@leeds.ac.uk>:
Dear Developers,
To support Pierangelo's suggestion from here:
https://www.ginac.de/pipermail/ginac-list/2020-June/002301.html
I'm afraid the patch is wrong. abs(x) is not differentiable at x = 0, and there's no way to "fix" that. x*abs(x) is differentiable at x = 0 (with derivative being zero). Unfortunately GiNaC can't automatically compute that. For now one can manually substitute x^2 -> abs(x)^2 which will reduce x^2/abs(x) + abs(x) to 2*abs(x) Best regards, Alexey
Dear Alexey,
On Wed, 17 Jun 2020 02:21:37 +0400, Alexey Sheplyakov <asheplyakov@yandex.ru> said: ASh> 17.06.2020, 00:30, "Vladimir V. Kisil" <v.kisil@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
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
participants (2)
-
Alexey Sheplyakov
-
Vladimir V. Kisil