numericalderivative.SXXNProblem1

class numericalderivative.SXXNProblem1(x=-8.0, interval=[-12.0, 12.0])

Create an exponential derivative benchmark problem

See page 14 in (Shi, Xie, Xuan & Nocedal, 2022)

The function is:

\[f(x) = \left(\exp(x) - 1\right)^2\]

for any \(x\). The test point is \(x = -8\).

According to (Shi, Xie, Xuan & Nocedal, 2022), this function has "extremely small first and second order derivatives at t = -8". A naive choice of the step for forward differences can result in extremely large step and huge error.

Parameters:
xfloat

The point where the derivative should be computed for a single test.

intervallist of 2 floats

The lower and upper bounds of the benchmark problem. This can be useful for benchmarking on several points. We must have interval[0] <= interval[1].

Methods

get_fifth_derivative()

Return the fifth derivative of the function of the problem

get_first_derivative()

Return the first derivative of the function of the problem

get_fourth_derivative()

Return the fourth derivative of the function of the problem

get_function()

Return the function of the problem

get_interval()

Return the interval of the problem

get_name()

Return the name of the problem

get_second_derivative()

Return the second derivative of the function of the problem

get_third_derivative()

Return the third derivative of the function of the problem

get_x()

Return the input point of the problem

References

  • Shi, H. J. M., Xie, Y., Xuan, M. Q., & Nocedal, J. (2022). Adaptive finite-difference interval estimation for noisy derivative-free optimization. SIAM Journal on Scientific Computing, 44 (4), A2302-A2321.

__init__(x=-8.0, interval=[-12.0, 12.0])

Create a benchmark problem for numerical derivatives of a function

This provides the function and the exact first derivative. This makes it possible to check the approximation of the first derivative using a finite difference formula. This class also provides the second, third, fourth and fifth derivative. This makes it possible to compute the optimal step for various finite difference formula.

Parameters:
functionfunction

The function

first_derivativefunction

The first derivative of the function

second_derivativefunction

The second derivative of the function

third_derivativefunction

The third derivative of the function

fourth_derivativefunction

The fourth derivative of the function

fifth_derivativefunction

The fifth derivative of the function

xfloat

The point where the derivative should be computed for a single test.

intervallist of 2 floats

The lower and upper bounds of the benchmark problem. This can be useful for benchmarking on several points. We must have interval[0] <= interval[1].

References

  • Dumontet, J., & Vignes, J. (1977). Détermination du pas optimal dans le calcul des dérivées sur ordinateur. RAIRO. Analyse numérique, 11 (1), 13-25.

  • Adaptive numerical differentiation. R. S. Stepleman and N. D. Winarsky. Journal: Math. Comp. 33 (1979), 1257-1264

Examples

The next example creates a benchmark problem.

>>> import numericalderivative as nd
>>> problem = nd.ExponentialProblem()
>>> x = problem.get_x()
>>> function = problem.get_function()
>>> first_derivative = problem.get_first_derivative()

Print a problem.

>>> problem = nd.ExponentialProblem()
>>> print(problem)

The next example creates a benchmark experiment.

>>> import numericalderivative as nd
>>> benchmark = nd.BuildBenchmark()
>>> number_of_problems = len(benchmark)
>>> for i in range(number_of_problems):
>>>     problem = benchmark[i]
>>>     name = problem.get_name()
>>>     print(f"Problem #{i}: {name}")

Methods

__init__([x, interval])

Create a benchmark problem for numerical derivatives of a function

get_fifth_derivative()

Return the fifth derivative of the function of the problem

get_first_derivative()

Return the first derivative of the function of the problem

get_fourth_derivative()

Return the fourth derivative of the function of the problem

get_function()

Return the function of the problem

get_interval()

Return the interval of the problem

get_name()

Return the name of the problem

get_second_derivative()

Return the second derivative of the function of the problem

get_third_derivative()

Return the third derivative of the function of the problem

get_x()

Return the input point of the problem

get_fifth_derivative()

Return the fifth derivative of the function of the problem

Returns:
fifth_derivativefunction

The fifth derivative of the function

get_first_derivative()

Return the first derivative of the function of the problem

Returns:
first_derivativefunction

The first derivative of the function

get_fourth_derivative()

Return the fourth derivative of the function of the problem

Returns:
fourth_derivativefunction

The fourth derivative of the function

get_function()

Return the function of the problem

Returns:
functionfunction

The function

get_interval()

Return the interval of the problem

Returns:
intervallist of 2 floats

The interval

get_name()

Return the name of the problem

Returns:
namestr

The name

get_second_derivative()

Return the second derivative of the function of the problem

Returns:
second_derivativefunction

The second derivative of the function

get_third_derivative()

Return the third derivative of the function of the problem

Returns:
third_derivativefunction

The third derivative of the function

get_x()

Return the input point of the problem

Returns:
xfloat

The input point