diff --git a/src/dichotomie.ts b/src/dichotomie.ts index 0bc2f5d4eaac2c9843a9a99e9f98b2de22c98935..0233446fa8c2230ca154cb82e7eec14c0348ed1d 100644 --- a/src/dichotomie.ts +++ b/src/dichotomie.ts @@ -517,7 +517,13 @@ export class Dichotomie extends Debug { tolAct = 1e-15 * Math.abs(b) + errorTol / 2; newStep = (c - b) / 2; - if (Math.abs(newStep) <= tolAct && Math.abs(fb) < 0.1) { + if ( + Math.abs(newStep) <= tolAct + && ( + Math.abs(fb) < errorTol + || Math.abs(fb / (Math.abs(fb) - Math.abs(fc))) < 1 + ) + ) { return b; // Acceptable approx. is found }