3 ms·
The post mentions motivation being symbolic differentiation. Let me instead advocate auto differentiaton. It enables writing mathematical expressions as norma
by carterschonwald 14y ago
The post mentions motivation being symbolic differentiation.
Let me instead advocate auto differentiaton. It enables writing mathematical expressions as normal programs, is less error prone for the programmer, is well defined at every valid point in the derivative, and is better at using sharing when computing higher order derivatives. An excellent library for this is, called ad, is available in Haskell.
edit: link to package is http://hackage.haskell.org/package/ad/ http://hackage.haskell.org/package/ad/
edit2: I should also add that MOST auto differentiation libraries also have a problem of not being able to distinguish the differential/ epsilon used in two independent derivative calculations, and this can lead to subtle / large numerical errors.
The AD library uses some haskell type system cleverness to prevent users from making that mistake!
a nice exposition of this problem can be found in this excellent blog post http://conway.rutgers.edu/~ccshan/wiki/blog/posts/Differentiation/ http://conway.rutgers.edu/~ccshan/wiki/blog/posts/Differenti...
- antonvs8 14y agoGood tip in general. Symbolic differentiation was McCarthy's motivation in 1960. My own motivation was nothing more sophisticated than "I wonder how much Haskell can look like M-expressions, without resorting to Template Haskell?"
- carterschonwald 14y agoneat code golf reason! :) btw, I've been to some of the recent LispNYC events, have you been to recent ones?
- antonvs8 14y agoI live about two hours away, more by public transport, and don't get in to the city much. I'll try to make a meeting in 2013...
- lelf 14y agoLet me advocate something even more interesting. Take Haskell type, formally find its derivative, notice this new type is useful for traversing the original one and (optionally) explode your head. (They call it zipper)
- Paradigma11 14y agoI just implemented a tree library using zippers without knowing this. Thanks for pointing this out.... .... .... shutdown initiated.
- carterschonwald 14y agoZippers are really awesome data structures indeed. More people should use them. (But not for numerical computation)