Return-Path: X-Original-To: apmail-commons-dev-archive@www.apache.org Delivered-To: apmail-commons-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 886E618530 for ; Wed, 17 Feb 2016 03:41:24 +0000 (UTC) Received: (qmail 30146 invoked by uid 500); 17 Feb 2016 03:41:24 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 29999 invoked by uid 500); 17 Feb 2016 03:41:23 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 29986 invoked by uid 99); 17 Feb 2016 03:41:23 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Feb 2016 03:41:23 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id E65451804EF for ; Wed, 17 Feb 2016 03:41:22 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.821 X-Spam-Level: X-Spam-Status: No, score=-0.821 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id A32Fg_RhLqJ1 for ; Wed, 17 Feb 2016 03:41:20 +0000 (UTC) Received: from mail-vk0-f46.google.com (mail-vk0-f46.google.com [209.85.213.46]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 8FF5A5FADA for ; Wed, 17 Feb 2016 03:41:19 +0000 (UTC) Received: by mail-vk0-f46.google.com with SMTP id e6so3675595vkh.2 for ; Tue, 16 Feb 2016 19:41:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=Qsjy6h3LOB5RQpg8KyW1KXTiHf+NSqtvPHoSEva/QCw=; b=YFmUqlP5HoTb5SO4zf2nIQjzpThsft2SFbto9rlGnpCbNFWI0wO11Ja6mqefaeexWW FBfxRS/STxsduC41cTeXL8tzV78aGnW4z+bg3EvpTFY6FVIR99jRy8cqJQd53iCOxC9T h3cdltiYwXTkQu+s2Jlcj1f0XdAJV6YQ9IW0Acyw3Rxq2T0x47osf04Mpv0DCAoSmEuw 8Yqi5O/lSkkXthe72Ep2w4hLUaXC3JKFv0XtEfRnDBadIlgIleX0HLawK605rwFPrafF ZqhcU3+eS5rwOKR4W2nGw9k98NiygcG3WZfGSPAGJf7QkH7SuUTzTyiEsXfdz+x70f3z 1GMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=Qsjy6h3LOB5RQpg8KyW1KXTiHf+NSqtvPHoSEva/QCw=; b=UXT9qV1r6i49T6GdkbVuIV0bF7snOAmSUPnLy0Pov2Sc0vR7QZGuGtw+xWVLYXf/NG veoA1x0eLsOxYLMkjZnpbWXSSfF/8uzf6khhfoEawYG9CtMo9bMLsVLhJppYSsJMVKLM 2UADwBFLeTr/l/qDL4/b0rB3yugCEsJF4lxy9lHCp2ITLPx0+B6S0T4omwCeDX4n6TGN 7ID6G9GYcmRMyBdX0N5xT0n7mfZAyhh8GIDUeSdtYFwgezubvREvifuFeDJc20mY0ZCV 3xvAxA1Ie//+80qInt3vmC5KvOyjB6sTC0u7H7Y4JMAYbFAiFWF0AzZbiqczZnAyvqwT of0w== X-Gm-Message-State: AG10YOS9L61JZQIUBrrgh2FeUIjGvsnY42SUHeuHlkKm59tFBv17gWxaXuqAQB13a3ZHYwsF0upnPf1J7elGbQ== MIME-Version: 1.0 X-Received: by 10.31.58.193 with SMTP id h184mr21719151vka.111.1455680477568; Tue, 16 Feb 2016 19:41:17 -0800 (PST) Received: by 10.176.68.163 with HTTP; Tue, 16 Feb 2016 19:41:17 -0800 (PST) Date: Tue, 16 Feb 2016 22:41:17 -0500 Message-ID: Subject: [math] New finite differencing framework for math4 From: Fran Lattanzio To: dev@commons.apache.org Content-Type: text/plain; charset=UTF-8 Hello all, I have created a pull request with a new univariate finite difference framework for [math]. The main features of this framework are: 1. *Exact* calculation of the coefficients for any stencil type (forward, backward, central), derivative order, and accuracy order. This is done by solving the system of linear equations generated by repeated Taylor expansion, using the field LU decomp over BigFractions. This is actually an important feature because it ensures there is no roundoff error in the coefficients; and we can tell if a coefficient is *exactly* zero. 2. Separation of derivative calculation and bandwidth selection - specifically, there is a strategy interface that decides the bandwidth, based on point at which the derivative is desired (and the nature of the stencil, etc). 3. Several canned bandwidth strategies: a. A fixed bandwidth. b. A "rule-of-thumb" strategy (which covers far more general cases than the rule-of-thumb suggested in a certain numerical cookbook). c. An adaptive strategy that estimates the error scale of the finite difference function in order to determine the optimal bandwidth. This is done using a technique akin to Richardson extrapolation. d. A decorator strategy to round bandwidths to a power-of-two. (Using powers-of-two bandwidths is good because they have exact IEEE floating point representations, so x +/- h will be correct to full precision.) Strategies b. and c. can also accept a function condition error parameter. This is quite important if you know that the underlying function is not computed to full machine precision, e.g. the function is an approximation accurate to 1e-10; or done over the IEEE 32s rather than 64s. Bandwidth strategy c. is derived from a thesis published by Ravi Mathur. Mathur provides formulae that shows how to find the optimal bandwidth - optimal in the sense that it will minimize the total error (which is a delicate balancing act!). His thesis can be found here: https://repositories.lib.utexas.edu/bitstream/handle/2152/ETD-UT-2012-05-5275/MATHUR-DISSERTATION.pdf?sequence=1 (This is the first implementation of Mathur's ideas that I have seen. Most of his work is thorough, so although this implementation is "new" and thus not considered an industry standard, I think it is definitely worth including. Some initial numerical experiments confirm as much.) These strategies should cover the vast majority of use cases, and of course the strategy interface allows users to implement anything bespoke if the need arises. I am working on generating more unit tests now. For now, there are only relatively simple tests for the coefficient generation and "integration tests" that compare analytical vs. numerical derivatives. If this is something that the community wants to include in math4, I will be happy to fully flesh them out. I am also working on a multivariate version. Generating the coefficients is easy... the tricky part for the multivariate case is the bandwidth strategies. The fixed bandwidth strategy is obviously trivial. I am trying to expand Mathur's work to the multivariate case to derive analogous rule-of-thumb and adaptive strategies but the equations are bit ticklish in the multivariate world. In any case, the JIRA ticket and pull request are here: https://issues.apache.org/jira/browse/MATH-1325 https://github.com/apache/commons-math/pull/24 Any suggestions are welcome, Fran. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org