I think I have found an easier way: dual numbers, and using the chain rule. Recall the Taylor expansion of f(x + y×epsilon)
:
We get two terms: f(x) + y×epsilon×(d/dx f(x))
.
epsilon is any nilpotent basis other than 0 which returns 0 when squared.
The value y
can be treated as a seed value, which can be set to 1. Thus, we get:
f(x) + epsilon×(d/dx f(x))
.
We can use real or complex values. When floats are used, the traditional dual number system is used with real numbers. When complex numbers are used, we get a four-dimensional system, the dual-complex numbers. The dual-complex numbers form a two-dimensional field over the complex numbers. Two classes can be created: Dual, and DualComplex. That is how its done, with forward and backward mode autodiff.
I think I have found an easier way: dual numbers, and using the chain rule. Recall the Taylor expansion of `f(x + y×epsilon)`:
We get two terms: `f(x) + y×epsilon×(d/dx f(x))`.
epsilon is any nilpotent basis other than 0 which returns 0 when squared.
The value `y` can be treated as a seed value, which can be set to 1. Thus, we get:
`f(x) + epsilon×(d/dx f(x))`.
We can use real or complex values. When floats are used, the traditional dual number system is used with real numbers. When complex numbers are used, we get a four-dimensional system, the dual-complex numbers. The dual-complex numbers form a two-dimensional field over the complex numbers. Two classes can be created: Dual, and DualComplex. That is how its done, with forward and backward mode autodiff.
edited Mar 2 at 5:07 pm