From 7773767656fe6ea67b06583342144d96d958427a Mon Sep 17 00:00:00 2001 From: "f.combes" Date: Wed, 25 Mar 2026 18:20:15 +0100 Subject: [PATCH] fix(core): improve belonging of point to interval The test to determine whether a point belongs to the interval [0,1] is not robust to numerical errors. However, it is necessary to allow points that are slightly outside the bounds. Tests have shown that a numerical error of up to 1e-10 can occur in some cases. --- .../hipparchus/analysis/polynomials/SmoothStepFactory.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hipparchus-core/src/main/java/org/hipparchus/analysis/polynomials/SmoothStepFactory.java b/hipparchus-core/src/main/java/org/hipparchus/analysis/polynomials/SmoothStepFactory.java index 32973e160..32f7d8ec4 100644 --- a/hipparchus-core/src/main/java/org/hipparchus/analysis/polynomials/SmoothStepFactory.java +++ b/hipparchus-core/src/main/java/org/hipparchus/analysis/polynomials/SmoothStepFactory.java @@ -209,9 +209,9 @@ private static int pascalTriangle(final int k, final int n) { * @throws MathIllegalArgumentException if input is not between [0:1] */ public static void checkBetweenZeroAndOneIncluded(final double input) throws MathIllegalArgumentException { - if (input < 0 || input > 1) { - throw new MathIllegalArgumentException( - LocalizedCoreFormats.INPUT_EXPECTED_BETWEEN_ZERO_AND_ONE_INCLUDED); + if (input < 0 - 1E-10 || input > 1 + 1E-10) { + throw new MathIllegalArgumentException( + LocalizedCoreFormats.INPUT_EXPECTED_BETWEEN_ZERO_AND_ONE_INCLUDED, input); } }