Hacker Newsnew | comments | show | ask | jobs | submitlogin
carterschonwald 467 days ago | link | parent

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/

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/Differenti...



antonvs8 466 days ago | link

Good 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 466 days ago | link

neat code golf reason! :)

btw, I've been to some of the recent LispNYC events, have you been to recent ones?

-----

antonvs8 466 days ago | link

I 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 466 days ago | link

Let 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)

-----

carterschonwald 466 days ago | link

Zippers are really awesome data structures indeed. More people should use them. (But not for numerical computation)

-----

Paradigma11 466 days ago | link

I just implemented a tree library using zippers without knowing this. Thanks for pointing this out.... .... .... shutdown initiated.

-----




Guidelines | FAQ | Lists | RSS | Bookmarklet | DMCA | News News | Bugs and Feature Requests | Y Combinator | Apply | Library | Contact

Search: