[CppAD] Arbitrary levels of autodifferentiation
Brad Bell
bradbell at seanet.com
Mon Jun 4 08:05:00 EDT 2018
When a function f(x) is recorded, CppAD allows for the computation of arbitrary order derivatives of
f(x). The multilevel option; e.g., AD< AD<double> > allows one to use arbitrary order derivatives of
f(x) to express a function g(x) and then take derivatives of g(x).
As you have noticed, in this case the function f(x) would be ADFun< AD<double> > and g(x) would be
ADFun<double>.
It is possible that you could do what you are asking for using template meta programmings, but I
have never tried.
I think that the research code stalingrad does automatic differentiation with the derivatives having
the same type as the original functions; see
https://github.com/Functional-AutoDiff/STALINGRAD
On 06/03/2018 04:35 PM, Andrew Spielberg wrote:
> Hi all,
>
> I am trying to come up with a way to get arbitrary levels of AutoDifferentiation using CppAD. Given
> a function f : R-->R, I would like to be able to differentiate expressions such as, say:
>
> g(x) = (f'(x) + f''(x)) * f(x)
>
> in order to get dg/dx.
>
> Now, obviously, I can try to rewrite this as a single function just in f whose derivative will be
> equal to dg/dx, but it that is not always possible. To this end, I am aware of the multiple levels
> example:
>
> https://coin-or.github.io/CppAD/doc/mul_level.cpp.htm
> <https://coin-or.github.io/CppAD/doc/mul_level.cpp.htm>
>
> However, as far as I can tell, the number of differentiations here must be known a priori, and the
> correct number of nestings of ADFun must be chosen up front. In some cases though (say, when
> dealing with series of unknown length), that number won't be known up front.
>
> I am wondering if there is a way to get arbitrary levels of autodifferentiation somehow, so that I
> can treat gradients not unlike an arithmetic function. I was thinking, it might be possible with
> only two levels of ADFun - every time a ADFun<ADFun<T>> is differentiated, it returns an ADFun<T> -
> and then maybe this can be rewrapped in a new ADFun< > before being reused. I don't know if this
> works though.
>
> Are arbitrary levels possible? If not, is there another way to achieve what I want?
>
>
> _______________________________________________
> CppAD mailing list
> CppAD at list.coin-or.org
> https://list.coin-or.org/mailman/listinfo/cppad
>
More information about the CppAD
mailing list