hn.today

Derivative Flipping

blog.sigfpe.com65 points6 comments
Screenshot of Derivative Flipping

The central idea is to rethink automatic differentiation through an analogy with Brzozowski derivatives for regular expressions. In regex matching, repeatedly differentiating an expression by the next input symbol creates a residual expression, and matching reduces to checking whether the final residual accepts the empty string. For polynomials, the corresponding pairing takes a polynomial p as a differential operator, applies it to another polynomial q, and evaluates the result at zero. A simple Haskell implementation encodes polynomials and applies rules for linearity, composition of operators, and the product rule.

The key result is that this pairing is symmetric: swapping p and q leaves its value unchanged. That lets computation “flip” a complicated differential operator and a complicated expression, choosing instead to apply the complicated operator to a simpler polynomial. For the two-dimensional Laplacian, pairing with x²+y² confines all intermediate results to a small span - x²+y², 2x, 2y, and 2 - so an implementation need track only four coefficients, not a full Hessian. The same strategy extends to any constant-coefficient differential operator; for example, the biharmonic operator can use a similarly compact space rather than a full fourth-order Taylor expansion. This links the approach to earlier Laplacian methods, optimized differentiation software, Taylor-mode AD, quantum mechanics, and umbral calculus.

Read on blog.sigfpe.com6 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.