Nested AD for this kind of thing is asymptotically much worse than numerical. If you’re going to use anything else, the thing to try is:
Nested AD for this kind of thing is asymptotically much worse than numerical. If you’re going to use anything else, the thing to try is: