File Exchange

image thumbnail

Complex step Jacobian

version 1.0 (1.43 KB) by

Calculate Jacobian using complex step differentiation

5 Downloads

Updated

View License

Complex step differentiation (CSD) has many advantages in efferency and accuracy over finite difference approaches (central, forward and backward). This code demonstrates how the Jacobian matrix of a given function at the reference point can be calculated using the CSD approach.

Comments and Ratings (6)

Huck Febbo

In both this file and the hessian, can you please add functionality to deal with:

K>> [J,z]=jacobiancsd(fun,x)
Error using atan2
Inputs must be real.

http://www.mathworks.com/help/matlab/ref/atan2.html

They talk about improving these methods here:

http://aero-comlab.stanford.edu/Papers/martins.aiaa.01-0921.pdf

Xianzhen

Dear mr. Cao,

Your program is working perfectly. However there are two things I am curious about>
1. Why does the step size depend on the number of independent variables?
2. If we are computing a derivative of a function of one independent variable, and the derivative is for example 0.2, we are faced with the division (0.2eps)/eps. Why does Matlab not evaluate 0.2eps as 0 therefore leading to the incorrect derivative 0?

Thank You in forward

Yi Cao

Yi Cao (view profile)

Angshul,

eps is the minimal distinguishable vnumer for a particular precision system. For double precision, eps = 2^(-52) and for single precision, eps = 2^(-23). Use "help eps" to find more details.

The complex step differentiation approach can use the minimum step size to get the maximum accuracy. Hence eps is the best step the algorithm can use.

HTH.

Yi

the step size 'eps' is not specified? Do U suggest a value?

V. Poor

Updates

Update the example

MATLAB Release
MATLAB 7.5 (R2007b)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video