Created
April 21, 2018 12:58
-
-
Save higham/5c32cce0532ed5c863615d588548518d to your computer and use it in GitHub Desktop.
Complex step approximation to derivative.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fd = complex_step(f,x,h) | |
%COMPLEX_STEP Complex step approximation to derivative. | |
% fd = COMPLEX_STEP(f,x,h) computes the complex step approximation | |
% fd to the derivative of f at x, using step h (default 1e-100). | |
if nargin < 3, h = 1e-100; end | |
fd = imag( f(x + sqrt(-1)*h) )/h; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment