Exponential function

Compute E**X where E is Euler's number e. E**X is EXP function. This function is defined:


where FACT is the factorial function and X is any number.

Unit: internal function, external function without procedure statement
Parameters: a number X, a positive integer P - number of significant digits of EXP(X), default is 9
Interface: the ECONST function, for P<=200 or the E function for P>200
Returns: the first P significant decimal digits of EXP(X)

EXP: procedure
parse arg X, P
if P = "" then P = 9; numeric digits P
Y = X % 1
if ABS(X - Y) > 0.5 then Y = Y + SIGN(X)
X = X - Y
Sum = 1; Term = 1
do J = 1
  Term = Term * X / J; NewSum = Sum + Term
  if NewSum = Sum then leave
  Sum = NewSum
if Y = 0 then return Sum
return (ECONST() ** Y) * Sum


EXP(2.1879653,16) returns 8.917051119945531
VISUAL BASIC MsgBox(EXP(2.1879653)) displays 8.91705111994553


cover contents index main page

last modified 8th August 2001
Copyright 2000-2001 Vladimir Zabrodsky
Czech Republic.