Prev Next Index-> contents reference index search external Up-> CppAD Example General mul_level change_param.cpp Example-> get_started.cpp General ExampleUtility ListAllExamples testvector wno_conversion General-> ad_fun.cpp ad_in_c.cpp conj_grad.cpp cppad_eigen.hpp hes_minor_det.cpp hes_lu_det.cpp interface2c.cpp jac_minor_det.cpp jac_lu_det.cpp mul_level ode_stiff.cpp mul_level_ode.cpp mul_level_adolc_ode.cpp ode_taylor.cpp stack_machine.cpp mul_level-> mul_level.cpp change_param.cpp change_param.cpp Headings-> Purpose

$\newcommand{\W}[1]{ \; #1 \; } \newcommand{\R}[1]{ {\rm #1} } \newcommand{\B}[1]{ {\bf #1} } \newcommand{\D}[2]{ \frac{\partial #1}{\partial #2} } \newcommand{\DD}[3]{ \frac{\partial^2 #1}{\partial #2 \partial #3} } \newcommand{\Dpow}[2]{ \frac{\partial^{#1}}{\partial {#2}^{#1}} } \newcommand{\dpow}[2]{ \frac{ {\rm d}^{#1}}{{\rm d}\, {#2}^{#1}} }$
Computing a Jacobian With Constants that Change

Purpose
In this example we use two levels of taping so that a derivative can have constant parameters that can be changed. To be specific, we consider the function $f : \B{R}^2 \rightarrow \B{R}^2$ $$f(x) = p \left( \begin{array}{c} \sin( x_0 ) \\ \sin( x_1 ) \end{array} \right)$$ were $p \in \B{R}$ is a parameter. The Jacobian of this function is $$g(x,p) = p \left( \begin{array}{cc} \cos( x_0 ) & 0 \\ 0 & \cos( x_1 ) \end{array} \right)$$ In this example we use two levels of AD to avoid computing the partial of $f(x)$ with respect to $p$, but still allow for the evaluation of $g(x, p)$ at different values of $p$.
Input File: example/general/change_param.cpp