From b51acc04a3d2b9125b96ab1f2028d58318387304 Mon Sep 17 00:00:00 2001 From: Michael Baudin <31351465+mbaudin47@users.noreply.github.com> Date: Fri, 29 Nov 2024 15:26:19 +0100 Subject: [PATCH] Improve roadmap (#2) * Clarify comments * Added a new roadmap goal * Fixes installation from Pip procedure --- README.md | 9 +++++++- numericalderivative/DerivativeBenchmark.py | 6 ++--- numericalderivative/DumontetVignes.py | 6 ++--- .../FiniteDifferenceFormula.py | 22 ++++++++++++++++--- .../GillMurraySaundersWright.py | 6 ++--- 5 files changed, 36 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 3452a4e..1d8aaff 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,6 @@ To install from Pip: ```bash pip install numericalderivative -python setup.py install ``` ## References @@ -70,4 +69,12 @@ python setup.py install benchmark problems - Use a relative precision in SteplemanWinarsky and GillMurraySaundersWright. - Remove NumericalDerivative: move it to FiniteDifferenceFormula. +- Add finite_differences from menum and cite (Baudin, 2023). +Reference : https://github.com/mbaudin47/menum_code +https://github.com/mbaudin47/menum_code/blob/cec64dea8d205da796d1f578b42948115257b3bb/Scripts-Eleves/Py3/numdiff.py#L801 + +- Implement the method of: + +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. + diff --git a/numericalderivative/DerivativeBenchmark.py b/numericalderivative/DerivativeBenchmark.py index 3267964..3513c72 100644 --- a/numericalderivative/DerivativeBenchmark.py +++ b/numericalderivative/DerivativeBenchmark.py @@ -305,9 +305,9 @@ def __init__(self, alpha=1.0e6): References ---------- - Gill, P. E., Murray, W., Saunders, M. A., & Wright, M. H. (1983). - Computing forward-difference intervals for numerical optimization. - SIAM Journal on Scientific and Statistical Computing, 4(2), 310-321. + - Gill, P. E., Murray, W., Saunders, M. A., & Wright, M. H. (1983). + Computing forward-difference intervals for numerical optimization. + SIAM Journal on Scientific and Statistical Computing, 4(2), 310-321. """ if alpha <= 0.0: raise ValueError(f"alpha = {alpha} should be > 0") diff --git a/numericalderivative/DumontetVignes.py b/numericalderivative/DumontetVignes.py index 2bfaf01..82ace04 100644 --- a/numericalderivative/DumontetVignes.py +++ b/numericalderivative/DumontetVignes.py @@ -3,9 +3,9 @@ """ 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. +- 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. """ import numpy as np diff --git a/numericalderivative/FiniteDifferenceFormula.py b/numericalderivative/FiniteDifferenceFormula.py index 487a837..89f75be 100644 --- a/numericalderivative/FiniteDifferenceFormula.py +++ b/numericalderivative/FiniteDifferenceFormula.py @@ -82,13 +82,18 @@ def compute_third_derivative(self, step): third_derivative : float The approximate f'''(x). + 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. """ t = np.zeros(4) t[0] = self.function_eval(self.x + 2 * step) t[1] = -self.function_eval(self.x - 2 * step) # Fixed wrt paper t[2] = -2.0 * self.function_eval(self.x + step) t[3] = 2.0 * self.function_eval(self.x - step) # Fixed wrt paper - third_derivative = np.sum(t) / (2 * step**3) # Eq. 27 et 35 + third_derivative = np.sum(t) / (2 * step**3) # Eq. 27 and 35 in (D&V, 1977) return third_derivative def compute_first_derivative_central(self, step): @@ -134,11 +139,17 @@ def compute_first_derivative_forward(self, step): ------- second_derivative : float An estimate of f''(x). + + References + ---------- + - Gill, P. E., Murray, W., Saunders, M. A., & Wright, M. H. (1983). + Computing forward-difference intervals for numerical optimization. + SIAM Journal on Scientific and Statistical Computing, 4(2), 310-321. """ step = (self.x + step) - self.x # Magic trick if step <= 0.0: raise ValueError("Zero computed step. Cannot perform finite difference.") - # Eq. 1, page 311 in (GMS, 1983) + # Eq. 1, page 311 in (GMS&W, 1983) x1 = self.x + step first_derivative = (self.function(x1) - self.function(self.x)) / step return first_derivative @@ -166,11 +177,16 @@ def compute_second_derivative_central(self, step): second_derivative : float An estimate of f''(x). + References + ---------- + - Gill, P. E., Murray, W., Saunders, M. A., & Wright, M. H. (1983). + Computing forward-difference intervals for numerical optimization. + SIAM Journal on Scientific and Statistical Computing, 4(2), 310-321. """ step = (self.x + step) - self.x # Magic trick if step <= 0.0: raise ValueError("Zero computed step. Cannot perform finite difference.") - # Eq. 8 page 314 + # Eq. 8 page 314 in (GMS&W, 1983) second_derivative = ( self.function_eval(self.x + step) - 2 * self.function_eval(self.x) diff --git a/numericalderivative/GillMurraySaundersWright.py b/numericalderivative/GillMurraySaundersWright.py index aff8566..f169a09 100644 --- a/numericalderivative/GillMurraySaundersWright.py +++ b/numericalderivative/GillMurraySaundersWright.py @@ -3,9 +3,9 @@ """ References ---------- -Gill, P. E., Murray, W., Saunders, M. A., & Wright, M. H. (1983). -Computing forward-difference intervals for numerical optimization. -SIAM Journal on Scientific and Statistical Computing, 4(2), 310-321. +- Gill, P. E., Murray, W., Saunders, M. A., & Wright, M. H. (1983). + Computing forward-difference intervals for numerical optimization. + SIAM Journal on Scientific and Statistical Computing, 4(2), 310-321. """ import numpy as np