[CppAD] Using existing derivative code combined with AD

Marcel Rehberg marcel.rehberg at uni-ulm.de
Fri Mar 15 06:24:30 EDT 2013


Hi Piotr,

maybe you are looking for

http://www.coin-or.org/CppAD/Doc/user_atomic.htm

which I have used for a case like you described. However, you have to  
implement derivatives in forward and reverse mode and as Taylor  
Coefficients, which is a little tedious. I worked along the examples and  
it worked quite well in the end. I could send you code but its depends  
alot on how your g function is implemented.

Regards

Marcel


On Fri, 15 Mar 2013 09:37:54 +0100, Piotr Dobaczewski  
<piotr.dobaczewski at ibs.org.pl> wrote:

> Hi Brad,
>
> I think, I am looking for something you've described.
>
> I would like to use AD to compute derivatives of expressions of form:  
> f(g(h(x))),
> where f and h are tractable using AD (e.g. I have the source code),  
> while g
> is not. For g, I can only evaluate it and its derivatives for given x.  
> How does
> one plug direct function and derivative evaluation into CppAD, assuming  
> one
> is given pointers to functions evaluating g and its derivatives?
>
> Best Regards
> Piotr Dobaczewski
>
> Original message:
>
>  > Perhaps Dominik's reply below answered your question, or perhaps you
>  > were looking for something simpler. For example, use AD to compute
>  > derivatives of f(g, x, y) and then use the change rule, and your
>  > knowledge of the derivatives of g, to get the derivatives of f[ g(x),  
> x,
>  > y ] ?
>
>  > Am Mittwoch, den 05.01.2011, 14:53 +1100 schrieb Scott Foster:
>  >> Hi,
>  >>
>  >> I have a function of the form f(g(x),x,y), which has a scalar  
> outcome.
>  >> The function g(x) requires iteration and can't be auto-differentiated
>  >> easily but its derivative can be found using other methods  
> (numerical).
>  >>     The function f(.,.,.) is pretty horrible in itself but it is a
>  >> predefined sequence of operations and is an ideal candidate for AD.
>  >>
>  >> So, what I want to do is to use AD to differentiate f(.,.,.) but to  
> tell
>  >> CppAD, somehow, to use the hard-wired code whenever it comes across
>  >> g(x).  I do not know how to do this.  It is what I want to learn how  
> to do.
>  >>
>  >> I'm assuming that this is a pretty common problem but I haven't been
>  >> able to find any mention in the documentation.  Of course, that  
> doesn't
>  >> mean that it isn't there -- just that I haven't found it:-)
>  >>
>  >> Any help would be very appreciated.
>  >>
>  >> Scott
>  >>
>  >
>  > _______________________________________________
>  > CppAD mailing list
>  > CppAD at list.coin-or.org
>  > http://list.coin-or.org/mailman/listinfo/cppad
>  >
>


-- 
Ulm University - Institute for Numerical Mathematics


More information about the CppAD mailing list