byuflowlab / ImplicitAD.jl

Automates adjoints. Forward and reverse mode algorithmic differentiation around implicit functions (not propagating AD through), as well as custom rules to allow for mixed-mode AD or calling external (non-AD compatible) functions within an AD chain.
MIT License
25 stars 6 forks source link

Alternative method for providing partial derivatives? #7

Closed taylormcd closed 2 years ago

taylormcd commented 2 years ago

The current method for providing user-defined jacobians could be simplified by allowing users to return the jacobian matrix from the solution procedure instead. Then a new function for the jacobian wouldn't have to be defined since it is often already computed as part of the solution procedure. The relevant modifications to make this happen are in the solve-drdy branch.

andrewning commented 2 years ago

Let me make sure I understand. There is already a function to provide that Jacobian if you have it drdy. Are you suggesting a different format for the solve function so you return them both at the same time? Like y, A = solve(x, p) where A = ∂r/∂y. We could of course accomplish that already on the user side by caching the value of A when solve was called, then returning it in a simple function. I could see how this might be more convenient, although for packages like NLsolve the residual and Jacobian are separate functions.