[CppAD] Arbitrary levels of autodifferentiation

Andrew Spielberg aespielberg at gmail.com
Sun Jun 3 19:35:50 EDT 2018


 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

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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/cppad/attachments/20180603/90983526/attachment.html>


More information about the CppAD mailing list