# commons-issues mailing list archives

##### Site index · List index
Message view
Top
From Sébastien Brisard (Updated) (JIRA) <j...@apache.org>
Subject [jira] [Updated] (MATH-700) Alter the contract of UnivariateRealSolverUtils.bracket() to handle piecewise constant functions
Date Thu, 03 Nov 2011 04:25:32 GMT
```
[ https://issues.apache.org/jira/browse/MATH-700?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Sébastien Brisard updated MATH-700:
-----------------------------------

Attachment: MATH-700-bracketStrict.diff

Attached file {{MATH-700-bracketStrict.diff}} proposes a new method --{{bracketStrict}}--
to handle the case considered here.
Do you think there is any use for this method (otherwise, I'll declare it as a protected method
in {{ContinuousDistribution}}).

> 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
>         Attachments: MATH-700-bracketStrict.diff
>
>
> 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.