[CppAD] Multiple Levels of AD

Brad Bell bradbell at seanet.com
Sat Jul 26 11:44:18 EDT 2008


While doing calculations in AD<Base>, CppAD records all the operations 
so that it can compute derivatives.

Then, when computing the derivatives, the calculates are done in the 
Base  type. If the base type is AD<Other> then the derivative 
calculations will be recorded, so that derivatives can be computed with 
type Other.

Thus, if k is a small number, you could do the calculation discussed 
below using multiple levels of AD.

For example, if f_0 is calculation in AD< AD< AD<double> > >,
then f_1 could be calculated  in AD< AD<double> >,
f_2 in AD<double>,
and f_3 in double.



Mathias Wagner wrote:
> Hi,
>
> I just started using algorithmic differentiation. I wonder wether it  
> is possible to get the derivative of a function as an ADFun object of  
> the same level.
> I have looked into the mul_level example, but this is not enough for  
> my purpose.
>
>
> I would like to use it for solving a differential equation
>
> d/dk f_k(x) = 1/(1+f_k''(x))
>
> f_k''(x) denotes the second derivative w.r.t. to x. The value of is  
> not changed during the iteration.
>
> f_0 is given analytically.
>
> So for example I can start with
>
> f_1(x) = f_0(x) + 1/(1+f''_0(x)) as a first step.
>
> Using the approach described in mul_level I can define f_0 using  
> ADDDouble and get f_0(x) as ADDouble so I can differentiate f''_0(x).
>
> In the next steps in the iteration I end up with
>
> f_2(x) = f_1(x) + 1/(1+f''_1(x))
>
> which I can calculate because I can calculate the derivatives of f_1(x).
>
> But this value will then be a double and I cannot differentiate it.
>
> I hope you can understand my problem.
>
> Is there any way to get this done using AD? I expect it to be very  
> slow, because it probably requires to keep the full history of the  
> iteration of f_k, but this should be acceptable.
>
> Mathias
>
>
>
>   



More information about the CppAD mailing list