Difference between revisions of "Expm1"

 
Line 8: Line 8:
 
or
 
or
 
:<code>1-[[Exp]](x)</code>
 
:<code>1-[[Exp]](x)</code>
In the second case, the result is the negation of <code>_Expm1(x)</code>.
+
In the second case, the result is the negation of <code>_Expm1(x)</code>. The expression must have exactly this form, with a literal constant 1.
  
 
The result of evaluating <code>_Expm1(x)</code> is <code>[[Exp]](x)-1</code>.  Direct evaluation of <code>Exp(x)-1</code> loses precision when <code>x</code> is small (i.e., <code>abs(x)<<1</code>), so by using <code>_Expm1(x)</code> instead it avoids numeric round-off problems.
 
The result of evaluating <code>_Expm1(x)</code> is <code>[[Exp]](x)-1</code>.  Direct evaluation of <code>Exp(x)-1</code> loses precision when <code>x</code> is small (i.e., <code>abs(x)<<1</code>), so by using <code>_Expm1(x)</code> instead it avoids numeric round-off problems.

Latest revision as of 23:36, 27 October 2022

New to Analytica 6.3

_Expm1(x)

This is an internal function that is used to evaluate an expression of the form:

Exp(x)-1

or

1-Exp(x)

In the second case, the result is the negation of _Expm1(x). The expression must have exactly this form, with a literal constant 1.

The result of evaluating _Expm1(x) is Exp(x)-1. Direct evaluation of Exp(x)-1 loses precision when x is small (i.e., abs(x)<<1), so by using _Expm1(x) instead it avoids numeric round-off problems.

When the parser sees an expression in either of the above forms, it replaces the expression with a direct call to _Expm1(x).

Note: For very small x, Exp(x)-1≈1.

Examples

Exp(1e-20)-1 → 1e-20
Local ex:=Exp(1-20) Do ex-1 → 0 { This one does not use _Expm1, and hence looses all precision }

See also

Comments


You are not allowed to post comments.