Return-Path: Delivered-To: apmail-commons-issues-archive@locus.apache.org Received: (qmail 56263 invoked from network); 7 May 2008 13:39:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 May 2008 13:39:21 -0000 Received: (qmail 79480 invoked by uid 500); 7 May 2008 13:39:21 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 79418 invoked by uid 500); 7 May 2008 13:39:21 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 79407 invoked by uid 99); 7 May 2008 13:39:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 May 2008 06:39:21 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 May 2008 13:38:44 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id DEF3B234C10A for ; Wed, 7 May 2008 06:38:58 -0700 (PDT) Message-ID: <1643499418.1210167538912.JavaMail.jira@brutus> Date: Wed, 7 May 2008 06:38:58 -0700 (PDT) From: "Brent Worden (JIRA)" To: issues@commons.apache.org Subject: [jira] Resolved: (MATH-204) BrentSolver throws IllegalArgumentException In-Reply-To: <712585362.1210106097271.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/MATH-204?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Brent Worden resolved MATH-204. ------------------------------- Resolution: Fixed Fix Version/s: 1.3 SVN 654100. added root checks for the endpoints. > BrentSolver throws IllegalArgumentException > -------------------------------------------- > > Key: MATH-204 > URL: https://issues.apache.org/jira/browse/MATH-204 > Project: Commons Math > Issue Type: Bug > Affects Versions: 1.2 > Environment: Win XP > Reporter: Mick > Assignee: Brent Worden > Priority: Minor > Fix For: 1.3 > > > I am getting this exception: > java.lang.IllegalArgumentException: Function values at endpoints do not have different signs. Endpoints: [-100000.0,1.7976931348623157E308] Values: [0.0,-101945.04630982173] > at org.apache.commons.math.analysis.BrentSolver.solve(BrentSolver.java:99) > at org.apache.commons.math.analysis.BrentSolver.solve(BrentSolver.java:62) > The exception should not be thrown with values [0.0,-101945.04630982173] because 0.0 is positive. > According to Brent Worden, the algorithm should stop and return 0 as the root instead of throwing an exception. > The problem comes from this method: > public double solve(double min, double max) throws MaxIterationsExceededException, > FunctionEvaluationException { > > clearResult(); > verifyInterval(min, max); > > double yMin = f.value(min); > double yMax = f.value(max); > > // Verify bracketing > if (yMin * yMax >= 0) { > throw new IllegalArgumentException > ("Function values at endpoints do not have different signs." + > " Endpoints: [" + min + "," + max + "]" + > " Values: [" + yMin + "," + yMax + "]"); > } > // solve using only the first endpoint as initial guess > return solve(min, yMin, max, yMax, min, yMin); > } > One way to fix it would be to add this code after the assignment of yMin and yMax: > if (yMin ==0 || yMax == 0) { > return 0; > } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.