Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 14383 invoked from network); 31 Mar 2004 16:22:20 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 31 Mar 2004 16:22:20 -0000 Received: (qmail 61460 invoked by uid 500); 31 Mar 2004 16:22:10 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 61431 invoked by uid 500); 31 Mar 2004 16:22:09 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 61407 invoked from network); 31 Mar 2004 16:22:09 -0000 Received: from unknown (HELO hume.tsdinc.steitz.com) (209.249.229.10) by daedalus.apache.org with SMTP; 31 Mar 2004 16:22:09 -0000 Received: from Lavoie.tsdinc.steitz.com ([209.249.229.4]) by hume.tsdinc.steitz.com with Microsoft SMTPSVC(5.0.2195.6713); Wed, 31 Mar 2004 11:21:49 -0500 Received: from steitz.com ([130.13.97.180]) by Lavoie.tsdinc.steitz.com with Microsoft SMTPSVC(5.0.2195.6713); Wed, 31 Mar 2004 11:21:49 -0500 Message-ID: <406AF01A.3030109@steitz.com> Date: Wed, 31 Mar 2004 09:21:46 -0700 From: Phil Steitz User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020830 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jakarta Commons Developers List Subject: Re: [math] Some changes to Polynomial References: <20040331061446.71646.qmail@web41308.mail.yahoo.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 31 Mar 2004 16:21:49.0557 (UTC) FILETIME=[44F48A50:01C4173C] X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Al Chou wrote: > --- Phil Steitz wrote: > >>0. To help debug the SplineInterpolater (PR #28019 et al), I need to >>expose the coefficients in o.a.c.m.analysis.Polynomial as a read-only >>property (returning an array copy). Any objections to adding this? > > > +1 if you do it by adding a package-level-accessible (i.e., no access modifier > keyword; the JUnit test would be able to access it by being in the same > package) getter method -- which sounds like what you're proposing. > > I actually intended to make this public, but read-only and using copy semantics. Any client should have (read-only) access to this basic property of the Polynomial, IMHO. Phil > >>While reviewing the code, I also noticed that the current impl uses >>"naive" evaluation (using Math.pow, etc.). I would like to change this to >>use Horner's Method. Here is what I have ready to commit: >> >>1. Add protected static double evaluate(double[] coefficients, double >>argument) implementing Horner to get the function value; and change >>value(double) to just call this. >> >>2. Add protected static double[] differentiate(double[] coefficients) to >>return the coefficients of the derivative of the polynomial with >>coefficients equal to the actual parameter. Then change >>firstDerivative(x) to just return >>evaluate(differentiate(coefficients), x). Similar for secondDerivative. >>I could adapt Horner for the derivatives, but that seems messy to me and >>the slight memory cost to create the temp arrays seems worth it. >> >>3. I would also like to add >>public PolynomialFunction derivative() { >> return new PolynomialFunction(differentiate(coefficients)); >>} >> >>Any objections to this? > > > +1, these sound reasonable. > > > >>Interestingly, while Horner's method should give better numerics, it >>actually fails to get within 1E-15 for one of the quintic test cases, >>performing worse than the "naive" impl. The error is in the 16th >>significant digit, which is not surprising. I would like to change the >>tolerance to 1E-12 (current tests actually succeed at 1E-14). >> >>Phil > > > I wonder why that is? Does Math.pow() use higher-than-double precision and > then cast down to double? I think we should consider carefully what is implied > by the fact that Horner's method has worse precision. Also, I would in > principle like to leave the tolerance as tight as possible, 1E-14 in this case. > > > > Al > > __________________________________ > Do you Yahoo!? > Yahoo! Finance Tax Center - File online. File on time. > http://taxes.yahoo.com/filing.html > > --------------------------------------------------------------------- > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org > For additional commands, e-mail: commons-dev-help@jakarta.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org