ENH: optimize._jacobian: use _differentiate to compute accurate Jacobian #20630
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reference issue
gh-20063
Towards gh-17059
What does this implement/fix?
Adds a private function to compute accurate Jacobians using a finite difference approximation. Vectorized to compute Jacobian at an arbitrary number of points in a single call.
Additional information
Example: evaluate the gradient of the Rosenbrock function in three dimensions at 10 points.
(Tests demonstrate evaluation of true Jacobians; i.e., for functions$\mathbf{R}^m \rightarrow \mathbf{R}^n$ .)
Yes, this requires that the callable be vectorized. If it is not, it is trivial for the user to vectorize it. For example,
We can include an example in the documentation if need be.
Adding a
batch
parameter to reduce memory usage (to control the number of partial derivatives that are taken in a single call) can be a separate PR.Implementation of a
_hessian
function in terms of_jacobian
is simple. The thing that might take a bit of thought there is the status messages, error estimates, function eval counts, etc.. since there are nested calls.