[CppAD] Using existing derivative code combined with AD

Brad Bell bradbell at seanet.com
Sat Mar 16 09:12:57 EDT 2013


On 03/15/2013 03:24 AM, Marcel Rehberg wrote:
> Hi Piotr,
>
> maybe you are looking for
>
> http://www.coin-or.org/CppAD/Doc/user_atomic.htm

1. Note that, if your browser supports MathML,
http://www.coin-or.org/CppAD/Doc/user_atomic.xml
is easier to read.

2. This feature is intended to increase the speed of derivative 
evaluation for functions where you know a program that will compute the 
derivatives. You could apply this idea to the case below, but there is 
another possible alternative; see below:

... snip ...
>>
>> > 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.

There are some special tricks for AD of functions (like g) that require 
iteration to evaluate. For example, suppose that g(x) is defined by
h(g, x) = 0
and one uses Newton's method to iterate and solve for g(x). Then one can 
evaluate the derivative of g(x) using the formula
h_g ( g(x) , x ) * g'(x) + h_x ( g(x), x) = 0
where h_g is the partial of h w.r.t g and h_x is the partial of h w.r.t 
x; i.e.,
g'(x) = - h_g( g(x), x)^{-1} h_x ( g(x), x)

You could then use AD to compute h_g, and h_x. Then get g'(x), then use 
AD to get f_g, f_x, f_y, and use the chain rule to get derivatives of f( 
g(x) , x , y ). While this applies to scalar value g(x), it also applies 
to vector valued g(x) (so long as the implicit function theorem applies).





>> >>
>> >> 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
>> >
>>
>
>



More information about the CppAD mailing list