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

  • fonts on linux

    I wrote a document on how to diagnose font problems on Linux. I would appreciate feedback, corrections, other common misconfigurations, etc.

  • socks5 proxying flash via ssh

    Suppose you're in Germany and want to watch some Flash-based videos that are IP-limited to the US for whatever reason. At first you'd think you could…

  • chromium.el

    This weekend I wrote some Emacs Lisp to write some utility functions I find useful for hacking on Chromium. It's fun to have a reason to use Lisp!…

  • 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.