Skip to content
0:00 / 0:00

#automaticdifferentiation#calculus#dualnumbers

Daniel Brice - Automatic Differentiation in Haskell

Brainium

13K subscribers • 3 videos on Hallway

YouTube
  • Recommended by 1 person: 1 in engineering communities.
  • Presented by Daniel Brice
  • Linked in the descriptionfriedbrice/AutoDiff

Intermediate. Assumes working knowledge.

3.4K views9 years ago1 recommendation

Programming languagesComputer scienceHaskellMath for programmersFunctional programming

Daniel Brice explains how to implement automatic differentiation in Haskell using algebraic abstractions.

A case study in the power of abstraction. Differentiation of a function `f: ℝ → ℝ` is inherently a numerical process, and as such is subject to all of the limitations associated with implementing numerical algorithms, e.g. potentially slow convergence and round-off error. Engineers and Mathematicians have known since the seventeenth century that abstracting the notion of a function `f: ℝ → ℝ` via algebraic expressions exposes an "algebra of differentiation," i.e. rules that can be applied to replace the costly and inaccurate process of numerical differentiation with simple symbol replacement that can be done by hand, the difficult of which is bounded by the complexity of the initial algebraic expression for `f` and the result of which is exact. So is the computer useless? Automatic Differentiation leverages the algebraic abstraction in order to overcome the limitations of numerical algorithms. We encode, in a mere 42 lines of Haskell, the algebra of differentiation, resulting in a library that produces exact numerical results (up to machine precision) in CPU time that is bounded by the complexity of `f`. We discuss extending the library to include symbolic results as well (and I'll implement it, if I have time before the talk). As a pièce de résistance, we lift the abstraction of differentiation as an algebraic system (rather than a numerical process) to the Haskell type system, definitively putting the "Algebraic" in "Algebraic Data Types". We learn how to find the derivatives of Haskell data types, and we discuss reasons why this unholy mess might actually be a useful concept. Inspired by and incorporating material from Justin Domke's, Benjamin Kovach's, and Chris Taylor's blogs. github: github.com/friedbrice/AutoDiff/blob/master/README.md blog posts: danielbrice.net/blog/10/ danielbrice.net/blog/15/ I neglected to readjust the camera for parts of the presentation, sorry. This was recorded at Brainium in Santa Monica during a Santa Monica Haskell meetup: meetup.com/santa-monica-haskell/events/233976257/

Why it's here

1 person recommends this

What people say. Recommended as a great explanation of how automatic differentiation works and how to implement it in Haskell.

Moments people linked to

u/m0d2in r/haskell • Recommends

On “What was the topmost thing you learned about Haskell in 2016?”

I eventually learned how Automatic Differentiation works, thanks to Daniel Brice great talk about implementing AD in Haskell.

u/friedbricein r/haskell • Mentions

On “Daniel Brice - Automatic Differentiation in Haskell”

The first twenty or so minutes is an intro to Calculus. If you've already taken lots of Calculus, you might want to start the video at 19:12. (link to this video
6View on Reddit

u/friedbricein r/haskell • Mentions

On “How exactly do I get a Haskell job in the US?”

Present your library at various Haskell meetup around the country. That should be easy in this post-covid world b/c meets have either moved 100% to zoom or are at least familiar with hosting speakers via zoom. Make sure to stick around and answer questions and just basically talk shop at the end. That way, running the meetup circuit will cultivate a stable of friends. Some of those friends work at Haskell companies. Some of those friends help make the hiring decisions at Haskell companies. Here's (shameless self plug) an example of a meetup talk I gave on my Calculus "library" (scare quotes b/c i never put it on hackage). link to this video