From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32600 invoked by alias); 25 Mar 2016 21:18:42 -0000 Mailing-List: contact gsl-discuss-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gsl-discuss-owner@sourceware.org Received: (qmail 32578 invoked by uid 89); 25 Mar 2016 21:18:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.8 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:sk:mail-bn, H*r:sk:na01-bn, 02, H*r:157.56.111 X-HELO: na01-bn1-obe.outbound.protection.outlook.com Received: from mail-bn1bon0139.outbound.protection.outlook.com (HELO na01-bn1-obe.outbound.protection.outlook.com) (157.56.111.139) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA256 encrypted) ESMTPS; Fri, 25 Mar 2016 21:18:30 +0000 Authentication-Results: holoborodko.com; dkim=none (message not signed) header.d=none;holoborodko.com; dmarc=none action=none header.from=colorado.edu; Received: from palken-co-ll.ngdc.noaa.gov (140.172.179.43) by CY1PR0301MB0906.namprd03.prod.outlook.com (10.160.165.17) with Microsoft SMTP Server (TLS) id 15.1.427.16; Fri, 25 Mar 2016 21:18:26 +0000 Subject: Re: GSL K0/K1 To: , Pavel Holoborodko References: <56F42FED.8060500@colorado.edu> <56F4304C.3000907@colorado.edu> <56F5998F.40902@lanl.gov> From: Patrick Alken Message-ID: <56F5AB1F.8090006@colorado.edu> Date: Fri, 25 Mar 2016 21:18:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: <56F5998F.40902@lanl.gov> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: DM3PR10CA0027.namprd10.prod.outlook.com (25.164.12.37) To CY1PR0301MB0906.namprd03.prod.outlook.com (25.160.165.17) X-MS-Office365-Filtering-Correlation-Id: 893f89d6-6909-435b-d1bf-08d354f3013c X-Microsoft-Exchange-Diagnostics: 1;CY1PR0301MB0906;2:tfqCUa6Oho4v45ErpaMTX+nYxX01NiHIs0mRrNptf96NzgaXox8RPFLQ+zIKfb1Ny5qM/VoncFQUgB+WjwcoNnX1zFwEyQAGJhyzD5q6y2IVqE8bM7OzAsdYI4QCYlSg5iCgI0WLPR3C9g2Id87OnWisB9cBToTm5vFb5IqezsmmlAJ/Mg/bredvc6s+E1ES;3:uiS0NaHM41nJ+ZZpi22+E/7CytIANr5VDmTCHzjydz3xdtWOadwiIibvQJwWS6/nGcyvhFGGBZAJBrPcZnZVKkimzEs9DXHkjIrENdugCLIDz81Z7Rz03OQp+Rv4I0lN;25:voU9MqAnCgJ+2GzVG2Bp4whSctQDy6Cttu8ujprM5UdVyPcUK9c8PsYqCPDegWdvfPVL/DxR399fxUbNBkOCV0Troa1+sMGoPTFslhZSgRNDTj92OqVIjR9XcAajxkCTFLhu18sKE51rG1RfMDQ38cGLOUDsysujL9yGXchrINXo17itpifo86BA6pupqOVZ85NRsBrO9b/JPhjkqrRW7XJe4twtR5N13hWRMOd6lxxHxXYlgLt2JA9PBtG6BVOo38l3eAKPw3pQm/mh7Q56yxTzp7IcHlTbATiYMOUKfJiMgEtgAhjiLe30lyqrK9GwKPT0X5IYYgrYnIw2bRcJdwfxZ22t41MuU3LDdPy2apcrPAskKNp8+5FR6OVx7BmifUqie1751nvv+OvMXXkJem1sziQc23/VUZ43sZS0azFR21/1ojXvQKP64vSROsE65uqHAEGBr6LXmrlKVKV1lBmWAQok5RrpD/9Ku008vixytgbwkzr7XhfBXdqjnrAUR3D4BI3f5KhJoIUy2p6VC3u6gTsN4HGlVNEiXw0X/nj4TRq9+ydyv9eiuXPTWDED X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB0906; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001);SRVR:CY1PR0301MB0906;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB0906; X-Microsoft-Exchange-Diagnostics: 1;CY1PR0301MB0906;4:95/cJOO4JWBdEprJASaNif29dMk9zcu4jEcz+2tnGdiG4KCrB46zKhsVGGDvr2eG73RCNUFHzQhZmXwwTwBpcpEq3ybrQd6S0/JVCSHR8SOkcmc07SNhOd2shx7FwrroLZf2e3AaADSOVjlWHIrdJgpz9PRMiCkf1XMSrDJ/KZNxmJjb2JJ/M2MIXBlsiARLkXjXhSDMTcGOfbtbILEXOmmaittFcjmrr+UEEOsiXneMVOjFMudINrxC8D8E8ErPolF62TjgTv3DakpTkeKYE+8DJfBa0i/hMmfukiPEqEzjeALI69ZAr4sYD7V70d14yp0LbN2s4JhzZmg8/wAAPUdysvconyE6pb6ElkXpuOMBOTvDw5CE/IDG5tpgVD7Z X-Forefront-PRVS: 0892FA9A88 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(377454003)(24454002)(52314003)(5008740100001)(3846002)(65816999)(75432002)(50986999)(23676002)(230700001)(5004730100002)(87266999)(80316001)(5001770100001)(89122001)(50466002)(2906002)(76176999)(92566002)(83506001)(47776003)(189998001)(1096002)(107886002)(42186005)(90282001)(88552002)(59896002)(65956001)(6116002)(586003)(77096005)(33656002)(66066001)(2950100001)(36756003)(54356999)(81166005)(65806001);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR0301MB0906;H:palken-co-ll.ngdc.noaa.gov;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTFQUjAzMDFNQjA5MDY7MjM6QXVkVlVlZ01RbnMxTGhUWG0vUU55WC81?= =?utf-8?B?aFNkU3R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liUW1DdHo1THYrTGhuR0M5YU9tZC9IR0F5OEZ3dVFKY21mTXEwQTlE?= =?utf-8?B?TTNKNkZjakN4VFdsQ0E0MnJzMlRibW5keTVSMEJFczk5TmN4SGpiMmFkaWNo?= =?utf-8?B?U2JEazFWditzSXlkT1FtcEppNURZNkgzaTNHNlAzMWN5bCt3RjJnZHhCdHE2?= =?utf-8?B?akQ4bm5YZTBqSldQRU5pZ2d0czNSZDQxeS9udWFTYnBwcUlPNm1vSEdSVWd1?= =?utf-8?B?aHUvM1FYa0o4VWtMUEVIcVVuc3V2UURpaHBMVDRjR2JBcTRLaUVKWk5DUUgw?= =?utf-8?B?bXBjK0hvR1VVRUVaSUNacm1qLzRsWlNTbzR3NjE5aVFQR1V1bFB1ci9zd09u?= =?utf-8?B?eUxvaGxKbkxValorZzBkbjd4bzMzRDUzajBlTFB0QnVaMnFTSEdiOUcxTHNW?= =?utf-8?B?amsyZmtGRkJlV3FHSXZiK2xoRnFySHBJL3RvOEJLQ2tyU0llK0ZMVktlZ3By?= =?utf-8?Q?AvFEZs4wdRtnUpvikiLnr3ohZfiNf?= X-Microsoft-Exchange-Diagnostics: 1;CY1PR0301MB0906;5:bbqLeX2sRrhkDfKRZPJdufAj5M1NrG/uA+cxIKN9QDLKm8ts9I/CES1IBVCA1oDDLjH2faeOS9vsn6h7K4wdl0JDqW8FWin3ZnVL8DXriG6YqPFW1g2DmOZApxKUmFkqPZ/drxDb1zLuYssy0y6oSg==;24:Q/XiyrCW6G/kJy3qVnUpkhw7XR9RaTAIlm+qEQLEyGKXg0iEa7ZVweORJirUxZKXQUYkKc0fwcEysVo453rHHpFA1hSJSL7MfBWN5GEugTE= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: colorado.edu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2016 21:18:26.2671 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB0906 X-SW-Source: 2016-q1/txt/msg00027.txt.bz2 Gerard, Yes sorry for including you so late in the discussion! Pavel (cc'd) found that some of the GSL Chebyshev coefficients copied over from SLATEC were rounded incorrectly (ie: just the very last digit or two was off which caused quite a large error near x=2 for K0 and K1). The original GSL / SLATEC implementations broke up the K0/K1 interval in 3 pieces: [0,2] [2,8] [8,inf] Pavel developed new approximations using the intervals: [0,1] (new rational approximation from Pavel) [1,8] (new Chebyshev from Pavel) [8,inf] (original GSL Chebyshev) which avoids the troublesome point x=2 and has an overall lower error when compared with arbitrary precision libraries over many random points. In principle we could simply correct the SLATEC rounding errors, but Pavel's new method has even lower error than the corrected Chebyshev series. During some exhaustive numerical testing with random values, Pavel found fairly good upper limits to the error on the K0/K1 on each of the 3 intervals, which is why we think we should change the error estimate to the empirical values found through the numerical simulations. Pavel found similar problems in I0/I1 which he is now working on correcting. Patrick On 03/25/2016 02:03 PM, Gerard Jungman wrote: > > As you say, this is the first I have seen of this. > The results look very good. > > I briefly compared the code to the old version. > It looks like you changed the domains for some > of the expansions as well as the coefficients > and some of the fractional transformations. > So that's a lot of differences to track. > > Just glancing at the differences, I cannot tell > why it is so much better. Do you know exactly > what happened? > > The main problem seemed to be for x in (1,2). > The big break in the 1/x plots at x=2 suggests > that there was a problem in the coefficients > in that domain. Chebyshev expansions should > not behave that way; they should provide > essentially uniform error over the domain. > > Was it some kind of typo in the tables? > That's what it looks like to me. But > maybe not... in fact I don't see how > that would have happened. > > Maybe it was something more subtle. The basic method, > of course, goes back to SLATEC, so I suppose that > version has the same problems...? > > > We can and should have a discussion about error estimates > in general. But I will create another thread for that, so > as not to expand or hijack this topic. > > > As for the method and error estimates for K0 and K1, I am > trying to understand myself what is happening there. Most > of it is straightforward; the only problem is the domain > x <= 2.0. I wrote this code about 20 years ago and > haven't looked at it since. The assumption was that > the original SLATEC was basically best possible, so > it did not get a lot of scrutiny. > > I looked at the SLATEC source. In the code I refer to "bk0.f", > although it seems to actually be called "besk0.f", so maybe > there have been further changes to SLATEC since then? > > Anyway, SLATEC uses this method where it evaluates I0 for > some reason. So I do the same. I have no idea why they do > this. Maybe there is an original paper somewhere that > explains it. Clearly it is not necessary, and it's > much cleaner to avoid this dependency as well. > If the expansion was correct in the old code, > then the error must have been creeping in > through the evaluation of I0. > > Has anybody checked I0? If it is also messed up, > then maybe we have found the culprit. > > The error estimate in that section is just an application > of some derivative estimates for that particular expression. > But why that expression is used is entirely a mystery to me. > > > A brief comment on the random testing: This is a good way > to estimate the coefficient in the uniform error bound. > But in principle it should not be necessary. There must > be rigorous bounds for these expansions based on the > uniformity of the Chebyshev expansions. Can the > necessary coefficients be evaluated directly as > part of the computation of the expansions? That > would be best of all. These error bounds could > be documented somewhere for posterity, at the > least. > > -- > G. Jungman > > > On 03/24/2016 12:22 PM, Patrick Alken wrote: >> Pavel, >> >> The Bessel function results look good. If everything is tested you >> can >> merge it all into the master branch. I'm cc'ing gsl-discuss so that this >> discussion will start to be archived. >> >> Regarding the error estimates, an attempt was made early on in GSL to >> provide error estimates for all the special functions. From section 7.2 >> of the manual: >> >> ---- >> The field val contains the value and the field err contains an estimate >> of the absolute error in the value. >> ---- >> >> I confess I don't fully understand all the error estimation, or even how >> accurate the estimates are. I don't know if any studies were done to >> verify the accuracy of these error estimates. One of the original GSL >> developers (Gerard Jungman) wrote a lot of this code (I've cc'd him on >> this email) - maybe he can help shed light on this. >> >> Since you've already done exhaustive comparisons of your new Bessel >> functions against arbitrary precision libraries, maybe you could simply >> change the error estimate to be: >> >> err = factor * GSL_DBL_EPSILON >> >> where factor are the numbers you've found in your error analysis. This >> way the calculation would be very fast (and probably more accurate than >> the current error estimation). >> >> We can wait and see if Gerard has any suggestions on this too. >> >> Gerard - since you haven't been following this email chain, Pavel has >> found more accurate Chebyshev expansions for the Bessel K0/K1 functions >> which have lower errors than the original GSL implementations when >> compared with arbitrary precision libraries. Through lots of random >> testing he has found upper limits on the errors of each function given >> by some positive constant times GSL_DBL_EPSILON. We are wondering if its >> safe to change the error estimation of these functions (I don't know the >> origin of the current calculations for these error estimates). >> >> Patrick >