Evan Martin (evan) wrote in evan_tech,
Evan Martin
evan
evan_tech

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
Subscribe

  • blog moved

    As described elsewhere, I've quit LiveJournal. If you're interested in my continuing posts, you should look at one of these (each contains feed…

  • dremel

    They published a paper on Dremel, my favorite previously-unpublished tool from the Google toolchest. Greg Linden discusses it: "[...] it is capable…

  • treemaps

    I finally wrote up my recent adventures in treemapping, complete with nifty clickable visualizations.

  • Post a new comment

    Error

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