# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
# SPDX-FileCopyrightText: Bradley M. Bell <bradbell@seanet.com>
# SPDX-FileContributor: 2003-22 Bradley M. Bell
# ----------------------------------------------------------------------------

{xrst_begin exp_forward}
{xrst_spell
   expm
}

Exponential Function Forward Mode Theory
########################################

Derivatives
***********
If :math:`F(x)` is :math:`\R{exp} (x)` or :math:`\R{expm1} (x)`
the corresponding derivative satisfies the equation

.. math::

   1 * F^{(1)} (x) - 1 * F (x)
   =
   d^{(0)}
   =
   \left\{ \begin{array}{ll}
      0 & \R{if} \; F(x) = \R{exp}(x)
      \\
      1 & \R{if} \; F(x) = \R{expm1}(x)
   \end{array} \right.

where the equation above defines :math:`d^{(0)}`.
In the
:ref:`standard math function differential equation<forward_theory@Standard Math Functions@Differential Equation>` ,
:math:`A(x) = 1`,
:math:`B(x) = 1`,
and :math:`D(x) = d^{(0)}`.
We use :math:`a`, :math:`b`, :math:`d`,
and :math:`z` to denote the
Taylor coefficients for
:math:`A [ X (t) ]`,
:math:`B [ X (t) ]`,
:math:`D [ X (t) ]`,
and :math:`F [ X(t) ]` respectively.

Taylor Coefficients Recursion
*****************************
For orders :math:`j = 0 , 1, \ldots`,

.. math::
   :nowrap:

   \begin{eqnarray}
   z^{(0)} & = & F ( x^{(0)} )
   \\
   e^{(0)} & = & d^{(0)} + z^{(0)}
   \\
   e^{(j+1)}
   & = & d^{(j+1)} + \sum_{k=0}^{j+1} a^{(j+1-k)} * z^{(k)}
   \\
   & = & z^{(j+1)}
   \\
   z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} }
   \left(
      \sum_{k=1}^{j+1} k x^{(k)} e^{(j+1-k)}
      - \sum_{k=1}^j k z^{(k)}  b^{(j+1-k)}
   \right)
   \\
   & = & x^{(j+1)} d^{(0)}
      + \frac{1}{j+1} \sum_{k=1}^{j+1} k x^{(k)} z^{(j+1-k)}
   \end{eqnarray}

{xrst_end exp_forward}
