[J3] C TS 18661

Van Snyder van.snyder at jpl.nasa.gov
Wed Jan 30 13:52:27 EST 2019


On Wed, 2019-01-30 at 12:55 -0500, Steve Lionel via J3 wrote:
> I'd be interested to learn more about expm1 and log1p - I have not yet 
> researched what these do or what they're used for. I'd certainly defer 
> to the judgement of people closer to applications that might make use of 
> these.

The series expansion for exp(x) has a leading "1" term.

exp(x) = 1 + x + x^2/2! + x^3/3! + ....

Where exp(x)-1 appears, and x is near zero, computing exp(x) and then
subtracting 1 cancels leading digits.  The smaller x, the more leading
digits cancel.  An approximation that computes exp(x)-1 directly doesn't
have this problem.  For x sufficiently small, taking a few terms of the
Taylor series works well.  For large x, computing exp(x) and subtracting
1 works well (because exp(x) isn't near 1).  For x > -log(epsilon(x)) it
isn't even necessary to subtract 1,  For middling x, an economized
Chebychev series, or maybe a Padé approximation, works well.  This has
been known for decades.

Where log(x+1) appears, and x is approximately zero, digits of x are
truncated.  The nearer x is to zero, the more digits are truncated.  For
example, in single precision, if x is near 1.0e-6, but has six or seven
significant digits, x+1 has only one of the significant digits of x.

Considerations are similar to those for exp(x)-1.

Steve mentioned TOMS papers by Peter Tang.  I think they were algorithm
papers that included code.





More information about the J3 mailing list