recommended method for unit testing
Suppose I write a function f(x, y). Is there a recommended API for unit testing that it works (at least runs) with ForwardDiff? For example, the minimum requirement would be that it is capable of handling Dual numbers, and returns Duals too (is there anything else?).
Currently I am just generating arguments of random Duals and then check that the return type has the same element type. But it is pretty ad hoc, and I would prefer to do the right thing.
This is a very good question. Currently, ForwardDiff uses finite differencing to check against its test suite, but it would be quite useful to have a more formal verification tool that could prove a target Julia program's differentiability. Testing against finite differencing is really annoying due to its approximation error.
Another possibility is complex step differentiation, https://blogs.mathworks.com/cleve/2013/10/14/complex-step-differentiation/