Compressed Differentiation

Version 1.3.0.0 (2.74 KB) by Oren
The package differentiates symbolic multivariate functions fast and efficiently
239 Downloads
Updated 31 Oct 2014

View License

Differentiating a function of many variables a large number of times can be very slow and memory consuming. The Matlab function jacobian.m differentiates symbolic functions, but it does so without exploiting the sparse structure of the derivatives (how many nonzero derivatives there are), and the symmetry of mixed derivatives.
The new function compderivs.m performs the differentiation in a compressed manner. With each differentiation, only the nonzero unique derivatives are differentiated. The function returns compressed vectors (collected in a cell array) that contain only the nonzero unique derivatives, and matrices (collected in a cell array) that uncompress the compressed vectors.
A test file shows that compderivs.m is faster than using jacobian.m iteratively, especially if one has to evaluate the symbolic derivatives numerically. Also, memory consumption is much lower, because only the nonzero unique derivatives are stored.

Details are provided in the paper Levintal, Oren, "Fifth Order Perturbation Solution to DSGE Models".

Cite As

Oren (2024). Compressed Differentiation (https://www.mathworks.com/matlabcentral/fileexchange/48035-compressed-differentiation), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2013a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.3.0.0

Sub function create_UW changed. The change does not affect the output of compderivs, but may resolve future incompatibility problems.

1.2.0.0

The function logical is used to detect zeros of symbolic variables.

1.1.0.0

The subfunction create_UW is included in the main function.

1.0.0.0