## `exp` -- the exponential function

#### Introduction

`exp``(x)` represents the value of the exponential function at the point x.

#### Call(s)

`exp(x)`

#### Parameters

`x` | - | an arithmetical expression

#### Returns

an arithmetical expression

### Overloadable:

`x`

#### Side Effects

When called with a floating point argument, the function is sensitive to the environment variable `DIGITS` which determines the numerical working precision.

#### Related Functions

`ln`, `log`

#### Details

- The exponential function is defined for all complex arguments.
- For most exact arguments, an unevaluated function call is returned subject to some simplifications:
  - Calls of the form exp(q*PI*I) with integer or rational q are rewritten such that q lies in the interval [0,2). Explicit results are returned if the denominator of q is 1, 2, 3, 4, 5, 6, 8, 10, or 12.
  - Further, the following special values are implemented:
    - exp(0) = 1,
    - exp(infinity) = infinity,
    - exp(-infinity) = 0.
  - A call of the form exp(c*ln(y)) with an unevaluated ln(y) and a constant c (i.e., of type `Type::Constant`) yields the result y^c.
  - The call exp(f(y)) yields the result y/f(y), if f is `lambertV` or `lambertW`.
- Floating point results are computed, when the argument is a floating point number.

  Numerical overflow/underflow may happen, when the absolute value of the real part of a floating point argument x is large. A protection against underflow is implemented: if Re(x) < -10^6, then `exp(`x`)` may return the truncated result `0.0`. Cf. example 2.

- The keyword `E` is an alias for `exp(1)`.

#### Example 1

We demonstrate some calls with exact and symbolic input data:

    >> E, exp(2), exp(-3), exp(1/4), exp(1 + I), exp(x^2)

                                                                  2
              exp(1), exp(2), exp(-3), exp(1/4), exp(1 + I), exp(x )

Floating point values are computed for floating point arguments:

    >> exp(1.23), exp(4.5 + 6.7*I), exp(1.0/10^20), exp(123456.7)

          3.421229536, 82.31014791 + 36.44342846 I, 1.0,

             3.660698702e53616

Some special symbolic simplifications are implemented:

    >> exp(I*PI), exp(x - 22*PI*I), exp(3 + I*PI)

                                -1, exp(x), -exp(3)

    >> exp(ln(-2)), exp(ln(x)*PI), exp(lambertW(5))

                                    PI       5
                               -2, x  , -----------
                                        lambertW(5)

#### Example 2

The truncated result `0.0` may be returned for floating point arguments with negative real parts. This prevents numerical underflow:

    >> exp(-5.81*10^6), exp(-5.82*10^6)

                             1.148529374e-2523251, 0.0

    >> exp(-5.81*10^6 + 10^10*I), exp(-5.82*10^6 + 10^10*I)

                1.002803534e-2523251 - 5.599149896e-2523252 I, 0.0

No such protection is implemented for numerical overflow:

    >> exp(5.81*10^6)

                                8.706786458e2523250

    >> exp(5.82*10^6)

          Error: Overflow/underflow in arithmetical operation;
          during evaluation of 'exp::float'

#### Example 3

System functions such as `limit`, `series`, `expand`, `combine` etc. handle expressions involving `exp`:

    >> limit(x*exp(-x), x = infinity), series(exp(x/(x + 1)), x = 0)

                                  2    3    4       5
                                 x    x    x    19 x       6
                      0, 1 + x - -- + -- + -- - ----- + O(x )
                                 2    6    24    120

    >> expand(exp(x + y + (sqrt(2) + 5)*PI*I))

                                                    1/2
                          - exp(x) exp(y) exp(I PI 2   )

    >> combine(%, exp)

                                                 1/2
                             - exp(x + y + I PI 2   )

#### Changes

- Some of the simplification rules were modified. As protection against numerical underflow, the truncated value `0.0` may now be returned for floating point arguments with large negative real part. The special values `exp(infinity) = infinity` and `exp(-infinity) = 0` were implemented.

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000