lines 6-140 of file: xrst/theory/atan_reverse.xrst

{xrst_begin atan_reverse}

Inverse Tangent and Hyperbolic Tangent Reverse Mode Theory
##########################################################

We use the reverse theory
:ref:`standard math function<reverse_theory@Standard Math Functions>`
definition for the functions :math:`H` and :math:`G`.
In addition, we use the forward mode notation in
:ref:`atan_forward-name` for

.. math::

   B(t) = 1 \pm X(t) * X(t)

We use :math:`b`
for the *p*-th order Taylor coefficient
row vectors corresponding to :math:`B(t)`
and replace :math:`z^{(j)}` by

.. math::

   ( z^{(j)} , b^{(j)} )

in the definition for :math:`G` and :math:`H`.
The zero order forward mode formulas for the
:ref:`atan<atan_forward-name>`
function are

.. math::
   :nowrap:

   \begin{eqnarray}
      z^{(0)}  & = & F ( x^{(0)} ) \\
      b^{(0)}  & = & 1 \pm x^{(0)} x^{(0)}
   \end{eqnarray}

where :math:`F(x) = \R{atan} (x)` for :math:`+`
and :math:`F(x) = \R{atanh} (x)` for :math:`-`.
For orders :math:`j` greater than zero we have

.. math::
   :nowrap:

   \begin{eqnarray}
   b^{(j)} & = &
      \pm \sum_{k=0}^j x^{(k)} x^{(j-k)}
   \\
   z^{(j)} & = & \frac{1}{j} \frac{1}{ b^{(0)} }
   \left(
      j x^{(j)}
      - \sum_{k=1}^{j-1} k z^{(k)}  b^{(j-k)}
   \right)
   \end{eqnarray}

If :math:`j = 0`, we note that
:math:`F^{(1)} ( x^{(0)} ) =  1 / b^{(0)}` and hence

.. math::
   :nowrap:

   \begin{eqnarray}
   \D{H}{ x^{(j)} } & = &
   \D{G}{ x^{(j)} }
   + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(0)} }
   + \D{G}{ b^{(j)} } \D{ b^{(j)} }{ x^{(0)} }
   \\
   & = &
   \D{G}{ x^{(j)} }
   + \D{G}{ z^{(j)} } \frac{1}{ b^{(0)} }
   \pm \D{G}{ b^{(j)} } 2 x^{(0)}
   \end{eqnarray}

If :math:`j > 0`, then for :math:`k = 1, \ldots , j-1`

.. math::
   :nowrap:

   \begin{eqnarray}
   \D{H}{ b^{(0)} } & = &
   \D{G}{ b^{(0)} }
   + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ b^{(0)} }
   \\
   & = &
   \D{G}{ b^{(0)} }
   - \D{G}{ z^{(j)} } \frac{ z^{(j)} }{ b^{(0)} }
   \\
   \D{H}{ x^{(j)} } & = &
   \D{G}{ x^{(j)} }
   + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(j)} }
   + \D{G}{ b^{(j)} } \D{ b^{(j)} }{ x^{(j)} }
   \\
   & = &
   \D{G}{ x^{(j)} }
   + \D{G}{ z^{(j)} } \frac{1}{ b^{(0)} }
   \pm \D{G}{ b^{(j)} } 2 x^{(0)}
   \\
   \D{H}{ x^{(0)} } & = &
   \D{G}{ x^{(0)} }
   + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(0)} }
   + \D{G}{ b^{(j)} } \D{ b^{(j)} }{ x^{(0)} }
   \\
   & = &
   \D{G}{ x^{(0)} }
   \pm \D{G}{ b^{(j)} } 2 x^{(j)}
   \\
   \D{H}{ x^{(k)} } & = &
   \D{G}{ x^{(k)} }
   + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(k)} }
   + \D{G}{ b^{(j)} } \D{ b^{(j)} }{ x^{(k)} }
   \\
   & = &
   \D{G}{ x^{(k)} }
   \pm \D{G}{ b^{(j)} } 2 x^{(j-k)}
   \\
   \D{H}{ z^{(k)} } & = &
   \D{G}{ z^{(k)} }
   + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ z^{(k)} }
   + \D{G}{ b^{(j)} } \D{ b^{(j)} }{ z^{(k)} }
   \\
   & = &
   \D{G}{ z^{(k)} }
   - \D{G}{ z^{(j)} } \frac{k b^{(j-k)} }{ j b^{(0)} }
   \\
   \D{H}{ b^{(j-k)} } & = &
   \D{G}{ b^{(j-k)} }
   + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ b^{(j-k)} }
   + \D{G}{ b^{(j)} } \D{ b^{(j)} }{ b^{(j-k)} }
   \\
   & = &
   \D{G}{ b^{(j-k)} }
   - \D{G}{ z^{(j)} } \frac{k z^{(k)} }{ j b^{(0)} }
   \end{eqnarray}

{xrst_end atan_reverse}
