From: Joseph Myers <joseph@codesourcery.com>
To: Tobias Burnus <tobias.burnus@physik.fu-berlin.de>
Cc: Fritz Reese <fritzoreese@gmail.com>, <gcc-patches@gcc.gnu.org>,
<fortran@gcc.gnu.org>
Subject: Re: [PATCH, Fortran] Extension: COTAN and degree-valued trig intrinsics with -fdec-math
Date: Wed, 28 Sep 2016 01:12:00 -0000 [thread overview]
Message-ID: <alpine.DEB.2.20.1609272303400.17432@digraph.polyomino.org.uk> (raw)
In-Reply-To: <20160926155930.GA24746@physik.fu-berlin.de>
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
next prev parent reply other threads:[~2016-09-27 23:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-26 16:11 Tobias Burnus
2016-09-27 11:06 ` Fritz Reese
2016-09-28 1:12 ` Joseph Myers [this message]
-- strict thread matches above, loose matches on Subject: below --
2016-09-26 14:20 Fritz Reese
2016-09-26 19:08 ` Toon Moene
2016-09-28 19:04 ` Steve Kargl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.20.1609272303400.17432@digraph.polyomino.org.uk \
--to=joseph@codesourcery.com \
--cc=fortran@gcc.gnu.org \
--cc=fritzoreese@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=tobias.burnus@physik.fu-berlin.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).