lines 7-56 of file: example/sparse/sub_sparse_hes.cpp

{xrst_begin sub_sparse_hes.cpp}
{xrst_spell
   nv
}

Computing Sparse Hessian for a Subset of Variables
##################################################

Purpose
*******
This example uses
:ref:`multiple levels of AD<mul_level-name>`
to compute the Hessian for a subset of the variables
without having to compute the sparsity pattern for the entire function.

See Also
********
:ref:`sparse_sub_hes.cpp-name` , :ref:`sparsity_sub.cpp-name` ,

Function
********
We consider the function
:math:`f : \B{R}^{nu} \times \B{R}^{nv}  \rightarrow \B{R}` defined by

.. math::

   f (u, v) =
   \left( \sum_{j=0}^{nu-1} u_j^3 \right)
   \left( \sum_{j=0}^{nv-1} v_j \right)

Subset
******
Suppose that we are only interested computing the function

.. math::

   H(u, v) = \partial_u \partial_u f (u, v)

where this Hessian is sparse.

Example
*******
The following code shows one way to compute this subset of the
Hessian of :math:`f`.
{xrst_literal
   // BEGIN C++
   // END C++
}

{xrst_end sub_sparse_hes.cpp}
