From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8439 invoked by alias); 27 Sep 2016 23:10:04 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 8414 invoked by uid 89); 27 Sep 2016 23:10:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS,URIBL_RED autolearn=ham version=3.3.2 spammy=burnus, Burnus, tangent, quadrant X-Spam-User: qpsmtpd, 2 recipients X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 27 Sep 2016 23:09:53 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=svr-ies-mbx-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1bp1VW-00040y-TL from joseph_myers@mentor.com ; Tue, 27 Sep 2016 16:09:51 -0700 Received: from digraph.polyomino.org.uk (137.202.0.87) by svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Wed, 28 Sep 2016 00:09:47 +0100 Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.86_2) (envelope-from ) id 1bp1VP-0000eY-Nv; Tue, 27 Sep 2016 23:09:43 +0000 Date: Wed, 28 Sep 2016 01:12:00 -0000 From: Joseph Myers To: Tobias Burnus CC: Fritz Reese , , Subject: Re: [PATCH, Fortran] Extension: COTAN and degree-valued trig intrinsics with -fdec-math In-Reply-To: <20160926155930.GA24746@physik.fu-berlin.de> Message-ID: References: <20160926155930.GA24746@physik.fu-berlin.de> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-SW-Source: 2016-09/txt/msg02076.txt.bz2 On Mon, 26 Sep 2016, Tobias Burnus wrote: > Regarding the decimal trigonometric functions, the internet suggests to > use > sin (fmod ((x), 360) * M_PI / 180) > instead of > sin (x * M_PI / 180) > to yield better results for angles which are larger than +/-360 degrees. Actually for good results you should reduce to the interval +/-45 degrees (which may require swapping which of sin and cos is used, or between tangent and cotangent, and then adjusting the sign of the result, depending on the quadrant the original argument was in). Consider e.g. cos of an argument close to 90 degrees; subtracting 90 and taking -sin of the result converted to radians gives a good result, converting 90 directly to radians and taking cos of that yields large errors (in ulps) for such input. (Unfortunately MPFR doesn't have sinpi etc., or the variants sinu etc. suggested in its TODO file, which would be helpful for implementing these functions for constant arguments.) -- Joseph S. Myers joseph@codesourcery.com