numericalderivative.benchmark_method

numericalderivative.benchmark_method(function, derivative_function, test_points, compute_first_derivative, verbose=False)

Compute the first derivative on a set of test points

Parameters:
functionfunction

The function.

derivative_functionfunction

The exact first derivative of the function.

test_pointslist(float)

The list of x points where the derivative is to be evaluated

compute_first_derivativefunction

The method to compute the first derivative. The calling sequence must be f_prime_approx, f_eval = compute_first_derivative(function, x) where f_prime_approx is the approximate value of the first derivative, f_eval is the number of function evaluations, function is the function and x is the point.

verbosebool

Set to True to print intermediate messages.

Returns:
average_relative_errorfloat, > 0

The average relative error between the approximate first derivative and the exact first derivative

average_fevalfloat

The average number of function evaluations

datalist(floats)

For each test point, a list of 3 floats: x, relative error, number of function evaluations.