Using lambdas'/functional programming features in Java 8, we can use some pretty concise and clear notation to approximate the derivative of a function at an x which is differentiable.
Derivatives::derive
accepts a function, f(x)
, and returns its first derivative, f'(x)
, approximated using an arbitrarily low DX value, 0.0001
.
Adapted from Joe Marshall's blogpost.