Coder Social home page Coder Social logo

Comments (7)

dsyme avatar dsyme commented on May 18, 2024

@barak @gbaydin The generalized power rule only applies when the x is non-zero. What's the right way to treat this in the variant of symbolic differentiation you're using? thx

from diffsharp.

dsyme avatar dsyme commented on May 18, 2024

@gbaydin @barak I took a look at fixing this more out of curiosity than anything else. Is adding the conditional check the right fix? https://github.com/DiffSharp/DiffSharp/pull/31/files#diff-419be3dee4710aa72c56268abcf97b05L63

from diffsharp.

barak avatar barak commented on May 18, 2024

The issue is the x**y is continuous and differentiable except at (x,y)=(0,0). But the equation needs to be special-cased for some of the cases x=0 or y=0. Depending on which is "active", to save unnecessary computation.

This is done reasonably carefully in the "FAD" package for Haskell, as I recall.

from diffsharp.

barak avatar barak commented on May 18, 2024

See lines 382 and following in https://github.com/NUIM-BCL/fad/blob/master/Numeric/FAD.hs

from diffsharp.

dsyme avatar dsyme commented on May 18, 2024

OK, thx

from diffsharp.

barak avatar barak commented on May 18, 2024

Actually looking at that Haskell FAD code again, the division by x on line 391 is wrong when x==0. Needs special cases for that as well, basically x^(n-1) cannot be calculated as (x^n)/x when x==0, so even when x^n is in hand one needs to calculate x^(n-1) from scratch. In the FAD context, this is a particular issue when x is not just a dual number, but an infinite power series, as is often the case there. I suppose the right thing in that context is to first calculate x^(n-1) and then multiply it by x to get x^n.

This is the kind of fiddly numerics that makes me avoid numeric analysis...

from diffsharp.

dsyme avatar dsyme commented on May 18, 2024

Closing because this is out of date for DiffSHarp 1.x, which is currently planned to be AD only

from diffsharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.