Re: Review: Patch for phypot - Pygmy Hippotause - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Review: Patch for phypot - Pygmy Hippotause
Date
Msg-id 27598.1279464632@sss.pgh.pa.us
Whole thread Raw
In response to Re: Review: Patch for phypot - Pygmy Hippotause  (Dean Rasheed <dean.a.rasheed@gmail.com>)
List pgsql-hackers
Dean Rasheed <dean.a.rasheed@gmail.com> writes:
> No. If x is 1e8 * y, then y will only affect the result in the 16th
> place. You can see this if you do a simple series expansion:

> sqrt(1+yx^2) = 1 + 1/2 yx^2 + O(yx^4)

Sigh, I went looking for that expansion yesterday and didn't find it.
Should've tried harder.  I was relying on a gut feeling that it would
behave approximately like ln(1+x).

> For most cases, the new algorithm is no more accurate than the old
> one. The exception is when *both* x and y are very small. In this
> case, it protects against incorrect underflows to 0.

Yeah, I think you're right.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: dividing money by money
Next
From: Tom Lane
Date:
Subject: Parsing of aggregate ORDER BY clauses