Here’s a cool thread from Bob Carpenter on the Stan forums, “A new continuation-based autodiff by refactoring,” on the inner workings of Stan. Enjoy. P.S. Just for laffs, see this post from 2010 which is the earliest mention of autodiff I could find on the …