# commons-issues mailing list archives

##### Site index · List index
Message view
Top
From Sébastien Brisard (Created) (JIRA) <j...@apache.org>
Subject [jira] [Created] (MATH-700) Alter the contract of UnivariateRealSolverUtils.bracket() to handle piecewise constant functions
Date Tue, 01 Nov 2011 08:50:32 GMT
```Alter the contract of UnivariateRealSolverUtils.bracket() to handle piecewise constant functions
------------------------------------------------------------------------------------------------

Key: MATH-700
URL: https://issues.apache.org/jira/browse/MATH-700
Project: Commons Math
Issue Type: Improvement
Affects Versions: 3.0
Reporter: Sébastien Brisard
Priority: Minor

The current contract of {{o.a.c.m.analysis.solvers.UnivariateRealSolverUtils.bracket(UnivariateRealFunction
function, double initial, double lowerBound, double upperBound, int maximumIterations)}} states
that
{quote}
This method attempts to find two values a and b satisfying
* {{lowerBound <= a < initial < b <= upperBound}}
* {{f(a) * f(b) <= 0}}

If f is continuous on [a,b], this means that a and b bracket a root of f.
{quote}

I don't think there is any problem with the current implementation. However, if f is constant,
equal to zero on a whole interval, this implementation does not guarantee that the whole interval
is bracketed. I therefore propose that the contract is changed to
* {{f(a) * f(b) < 0}}

This entails only a minor correction to the {{bracket()}} method: line 267 of UnivariateRealSolverUtils
...{{while ((fa * fb > 0.0) && (numIterations < maximumIterations)}}...
I think it would be safe to replace this line with
...{{while ((fa * fb >= 0.0) && (numIterations < maximumIterations)}}...

Do you agree in principle? I'll run the current tests to check that this change is indeed
safe.

--
This message is automatically generated by JIRA.