Numerical Differentiation Of Noisy, Nonsmooth, Multidimensional Data

The function that I need to numerically differentiate are multivariable functions but the method can be easily extended from univariable functions to multivariable function I suppose. This function computes the numerical derivative of the function fat the point x using an adaptive forward difference algorithm with a step-size of h. The function is evaluated only at points greater than x, and never at x itself. The derivative is returned inresult and an estimate of its absolute error is returned inabserr. This function should be used if has a discontinuity at x, or is undefined for values less than x. Regularizing the differentiation process with total-variation produces a noiseless derivative with a correctly located, sharp jump. The discrepancy of the values from ±1 are due to contrast loss, an artifact of total variation methods in the presence of noise.

Zooming in further, we see the greater curvature penalty on the