lines 7-61 of file: example/general/mul_level.cpp {xrst_begin mul_level.cpp} {xrst_spell adouble dx } Multiple Level of AD: Example and Test ###################################### See Also ******** :ref:`base2ad.cpp-name` Purpose ******* In this example, we use ``AD< AD >`` (level two taping), the compute values of the function :math:`f : \B{R}^n \rightarrow \B{R}` where .. math:: f(x) = \frac{1}{2} \left( x_0^2 + \cdots + x_{n-1}^2 \right) We then use ``AD`` (level one taping) to compute the directional derivative .. math:: f^{(1)} (x) * v = x_0 v_0 + \cdots + x_{n-1} v_{n-1} where :math:`v \in \B{R}^n`. We then use ``double`` (no taping) to compute .. math:: \frac{d}{dx} \left[ f^{(1)} (x) * v \right] = v This is only meant as an example of multiple levels of taping. The example :ref:`hes_times_dir.cpp-name` computes the same value more efficiently by using the identity: .. math:: \frac{d}{dx} \left[ f^{(1)} (x) * v \right] = f^{(2)} (x) * v The example :ref:`mul_level_adolc.cpp-name` computes the same values using Adolc's type ``adouble`` and CppAD's type ``AD`` . Source ****** {xrst_literal // BEGIN C++ // END C++ } {xrst_end mul_level.cpp}