Adaptive numerical differentiation