Hacker News new | ask | show | jobs
by adamnemecek 2664 days ago
AD relies on dual numbers. Dual numbers are more suited for doing calculus.

Structurally, dual numbers are numbers of the form a + b * e (where e is epsilon s.t. e^2 = 0 but e != 0. Think of it as the imaginary constant but instead of i^2 = -1, you have e^2=0).

For example, multiplication of two dual numbers (a + b * e)(c + d * e) = (ac + ad * e + bc * e +bd * e^2). Since e^2 = 0, you end up with (ac + (ad + bc) * e).

Here comes the magic. Dual numbers let you evaluate a function and get the derivative at that point by just evaluating the function. In the above, example, if this was the result of a function, ac is the value of the function and ad + bc is the derivative of that function at that value.

https://blog.demofox.org/2014/12/30/dual-numbers-automatic-d...

1 comments

Before looking at the wiki I thought, huh, Grassmann numbers on HN?
You are not wrong.