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

Testing derivatives via Integral

Open freemin7 opened this issue 4 years ago • 2 comments

The fundamental theorem of calculus says that differential problems can also be expressed as Integral problems. Certain functions like clamp, max, min lack a definition of derivatives at every point. When you perform a finite difference approximation the result will certainly be in doubt around these points. Integrals would be mostly immune against those defects.

Do you have any thoughts on idea?

freemin7 avatar Apr 17 '20 20:04 freemin7

I would be more inclined to suggest using either forwards- or reverse- differencing around discontinuities. i.e you set up your tests so that finite differences avoids the discontinuities. See eg. FiniteDifferences.forward_fdm and FiniteDifferences.reverse_fdm.

While I agree that quadrature-based tests are appealing, I would imagine they'll also struggle in the vicinity of discontinuities since they usually assume some form of smoothness.

willtebbutt avatar Apr 18 '20 12:04 willtebbutt

It's an interesting idea. But I feel like it would be hard to get accuracy. Also really expensive at higher dimensions? Not sure.

Testing both sides of discontinualities is I think pretty standard.

Would be interesting to see it coded up and tested. Even if it doesn't work great, would still make an interesting blog post

oxinabox avatar Apr 18 '20 12:04 oxinabox