ForwardDiff.jl icon indicating copy to clipboard operation
ForwardDiff.jl copied to clipboard

recommended method for unit testing

Open tpapp opened this issue 8 years ago • 2 comments

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.

tpapp avatar Dec 03 '17 17:12 tpapp

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.

jrevels avatar Dec 04 '17 16:12 jrevels

Another possibility is complex step differentiation, https://blogs.mathworks.com/cleve/2013/10/14/complex-step-differentiation/

cossio avatar Oct 04 '18 16:10 cossio