December 2005
Beginner to intermediate
618 pages
20h 19m
English
expm1
Calculates the natural exponential of a number, minus one
#include <math.h> doubleexpm1( doublex); floatexpm1f( floatx); long doubleexpm1l( long doublex);
The return value of the expm1() function is one less than
e raised to the power of the
function’s argument, or ex, where
e is Euler’s number,
2.718281.... The expm1() function
is designed to yield a more accurate result than the expression
exp(x)-1, especially when the value of the
argument is close to zero. If the result is beyond the range of the
function’s type, a range error occurs.
/* let y = (−e^(−2x) − 1 ) / (e^(−2x) + 1), for certain values of x */
double w, x, y;
if (( x > 1.0E-12 ) && ( x < 1.0 ))
{ w =expm1( -(x+x) );
y = − w / ( w + 2.0 );
}
else
/* ... handle other values of x ... */Read now
Unlock full access