Need for missing functions log1p and expm1

For the Compleat Fan
Post Reply
sjain59
Posts: 3
Joined: Fri Apr 30, 2021 4:47 pm

Need for missing functions log1p and expm1

Post by sjain59 »

Dear Sir,

For small x << 1, ln(1+x) and exp(x)-1 and sinh(x) are close to x. This means there is loss of several digits of precision when calculating exp(x)-1 from exp(x) because we taking difference of two numbers almost equal to one another and to 1. Likewise there is similar error in ln1+x) and sinh(x) when calculated from ln(x) and exp(x) for small x.

ANSI Forth, C, and x87 FPU provide instructions expm1(x) and log1p(x) to meet this need. Once expm1 and log1p are provided, accurate computation of sinh, asinh, tanh, atanh also becomes possible for small x.

Therefore I request that expm1 and log1p be provided in newLisp.

sjain59
Posts: 3
Joined: Fri Apr 30, 2021 4:47 pm

Re: Need for missing functions log1p and expm1

Post by sjain59 »

I believe all hyperbolic functions can be computed accurately over entire range of x, given exp, log (or ln), expm1 and log1p. The x87 FPU instruction set provides exp, log, expm1 and log1p and not the hyperbolic functions. In fact the infrequently used hyperbolic functions could be removed from newLisp when expm1 and log1p (flnp1 in ANSI Forth) are present. The hyperbolic functions could easily be provided as an add on script/library.

Post Reply