Replace hand-derived differentiation with a numerical gradient check for f(x)=x². This is the smallest useful test for an autodiff engine.
Required APIdef finite_difference_gradient(x, epsilon):
return estimated_gradientBehaviorThink through the mechanism first if you want the extra reasoning step. It never blocks the editor.
finite_difference_gradient(3.0, 0.001)the estimate should agree with the analytic derivative 2*x
finite_difference_gradient(0.0, 0.1)the minimum has a zero slope
2 hidden edge tests run after the visible contract passes.
Run Tests to see the contract verdicts here.