Evan Martin (evan) wrote in evan_tech,
Evan Martin

differentiation of compiled functions

Typeful symbolic differentiation of compiled functions:
In this message, we develop the `symbolic' differentiator for a subset of Haskell functions (which covers arithmetics and a bit of trigonometry). We can write

test1f x = x * x + fromInteger 1
test1 = test1f (2.0::Float)
test2f = diff_fn test1f
test2 = test2f (3.0::Float)

We can evaluate our functions _numerically_ -- and differentiate them _symbolically_.


We must point out that we specifically do _not_ represent our terms as algebraic datatypes. Our terms are regular Haskell terms, and can be compiled!
The key here (as in most creative Haskell hacks) is the clever use of type classes, which may be the subject of my next post.

(The mail is from Oleg, who is the Haskell community's equivalent of _why: every few weeks or so he comes out with an absurd hack. The hackers mirrors the languages, as well: as _why's hacks are fast-and-loose and impenetrably obfuscated, Oleg's are often theory-heavy and impenetrably complicated.)
Tags: haskell

  • your vcs sucks

    I've been hacking on some Haskell stuff lately that's all managed in darcs and it's reminded me of an observation I made over two years ago now (see…

  • ghc llvm

    I read this thesis on an LLVM backend for GHC, primarily because I was curious to learn more about GHC internals. The thesis serves well as an…

  • found my bug!

    Not too interesting, but this has been bugging me for a week. Been working on a toy program that proxies a TCP connection. It was working fine for…

  • Post a new comment


    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.