coin-or / ADOL-C

A Package for Automatic Differentiation of Algorithms Written in C/C++
Other
145 stars 27 forks source link

Use tape within a tape definition #13

Closed svigerske closed 1 year ago

svigerske commented 4 years ago

Issue created by migration from Trac.

Original creator: zampanteymedio

Original creation time: 2015-02-27 11:24:22

Assignee: @awalther1

Version: 2.0

I didn't know how to contact you, so I'm opening a ticket.

I have a function f(x). I have another function g(x) which is a function of f(x) and its partial derivatives. I want the derivatives of g(x).

My first guess was to add f(x) into a tape, then add g(x) into another tape that uses the first tape. I couldn´t find any method to retrieve the partials of f(x) as adouble... How can I do that? Is there another way to obtain the derivatives of g(x)?

Thanks!

svigerske commented 4 years ago

Comment by @kkulshre created at 2015-03-17 16:16:40

You may contact us and a lot of other ADOL-C user at the mailing list adol-c@list.coin-or.org and the replies there are usually timely.

Your use case is what is known as nested derivatives. The derivatives of a function f(x) are not available as adoubles. This type is only present to create a trace, derivative computation is not done using this type.

However you can program your g(x) as infact a function g(x,y) where y represents the Jacobian or Gradient of f(x). Then you can first compute the derivatives of f(x) from your first trace and then pass them as independent variables to evaluate the derivatives of g(x,y). However if you need a total derivative you'd still need to invert the Jacobian of f(x) by hand.

If you have more questions please send us some example code on the mailing list, and we can help you to get it to compute the correct derivatives.