From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dean Rasheed <dean.a.rasheed@gmail.com>
Cc: Peter Eisentraut <peter_e@gmx.net>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Subject: Re: Proposal: Trigonometric functions in degrees
Date: Mon, 26 Oct 2015 18:51:05 -0400
Message-ID: <5178.1445899865@sss.pgh.pa.us> (raw)
In-Reply-To: <CAEZATCXr7yioJHRXjgnu6f2W=tH5zuPtGmvxV0eT3WPgGKpSQg@mail.gmail.com>
References: <CAEZATCXxdzxb2Mvi0-Xvp43tfvw-bUi703HdAJuLUd7dt5-ZgQ@mail.gmail.com>
<562E82F7.2060704@gmx.net>
<CAEZATCXRWw9qnWFMrh-B+gbNuVNG3HKgpHgTY1kZ=OhdoGE1Wg@mail.gmail.com>
<1671.1445890789@sss.pgh.pa.us>
<CAEZATCXr7yioJHRXjgnu6f2W=tH5zuPtGmvxV0eT3WPgGKpSQg@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
Dean Rasheed <dean.a.rasheed@gmail.com> writes:
> Personally I'd rather have sind(30) be exactly 0.5, even if
> sind(29.999...) or sind(30.000...1) ended up the wrong side of it.
TBH, sir, if you think that you are too dangerous to be allowed anywhere
near any numerical analysis code. Preserving mathematical properties like
monotonicity is *far* more important than whether sin(30 degrees) comes
out exact or not. You can do proofs about the behavior of algorithms
using these functions if you can ensure monotonicity; but exactness of
values is always going to depend on subtle details of the floating point
format.
I think using a range reduction to some fractional part of the circle is a
reasonable way of trying to deal with these concerns, but I really really
do not want to see it special-casing point values in a way that doesn't
guarantee monotonicity.
It may be that guaranteeing the sin(30) case is just not very feasible,
and we should content ourselves with getting the 0/90/180/270/360 cases
exactly, which we could do with a mod 90 initial reduction. Doing mod 30
or mod 45 would require sewing together pieces of the curve that might not
meet exactly, if we were unlucky. (I've not tried it though.)
What have you got in mind for tan() and the rest?
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, dean.a.rasheed@gmail.com, peter_e@gmx.net
Subject: Re: Proposal: Trigonometric functions in degrees
In-Reply-To: <5178.1445899865@sss.pgh.pa.us>
References: <CAEZATCXxdzxb2Mvi0-Xvp43tfvw-bUi703HdAJuLUd7dt5-ZgQ@mail.gmail.com> <562E82F7.2060704@gmx.net> <CAEZATCXRWw9qnWFMrh-B+gbNuVNG3HKgpHgTY1kZ=OhdoGE1Wg@mail.gmail.com> <1671.1445890789@sss.pgh.pa.us> <CAEZATCXr7yioJHRXjgnu6f2W=tH5zuPtGmvxV0eT3WPgGKpSQg@mail.gmail.com> <5178.1445899865@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox