Code covered by the BSD License  

Highlights from
Numerical derivative of analytic function

4.0

4.0 | 1 rating Rate this file 21 Downloads (last 30 days) File Size: 2.82 KB File ID: #11870

Numerical derivative of analytic function

by Daniel Ennis

 

02 Aug 2006 (Updated 16 Aug 2006)

Calculate the numerical derivative of an analytic function with different methods.

| Watch this File

File Information
Description

% This function returns the numerical derivative of an analytic function.
% Of special note, is the incorporation of the "complex step-derivative"
% approach which offers greatly improved derivative accuracy compared to
% forward and central difference approximations. This is especially germain
% when accuracy at the level of machine precision is a concern.
%
% This function was motivated by: http://www.biomedicalcomputationreview.org authored by Michael Sherman
% -The function with no inputs generates the example used in the above link.
% -For more information see the following citation which is also found in the above link:
% --Martins JR, Sturdza P, and Alonso JJ
% http://portal.acm.org/citation.cfm?id=838250.838251
% The complex-step derivative approximation
% ACM Trans. Math. Softw. 29(3) (2003)
%
% SYNTAX: dfdx=deriv(f,x,h,method)
%
% INPUTS: f - A function a handle (eg f=@(x) sin(x))
% x - Interval over which f(x) is defined
% h - Derivative step-size
% method - Numerical methods used to compute derivative
% 'forward2' - Two point forward difference
% 'forward3' - Three point forward difference
% 'central2' - Two point central difference
% 'central4' - Four point central difference
% 'complex' - Complex step-derivative approximation
%
% OUTPUTS: dfdx - Numerical estimate of the derivative of f(x)
%
% DBE 2006.07.31

Acknowledgements
This submission has inspired the following:
Adaptive Robust Numerical Differentiation
MATLAB release MATLAB 7.1.0 (R14SP3)
Other requirements Version must support function handles.
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
21 May 2007 Sunil Arya

It is good for the biginers in matlab compuation

13 Jun 2009 Juliette Salexa

I'm looking for a package that approximates derivatives for NUMERICALLY defined functions (not analytic) ..

I have two arrays:
x=0:0.5:10 , and fun= a vector that defines my function at each of those values of x.

Now I want the derivative of fun with respect to x at each value of x.

Does such a package exist ??

Please login to add a comment or rating.
Updates
16 Aug 2006

Minor fix of the "description."

Tag Activity for this File
Tag Applied By Date/Time
numerical derivative Daniel Ennis 22 Oct 2008 08:34:20
complex derivative Daniel Ennis 22 Oct 2008 08:34:20
differentiate Daniel Ennis 22 Oct 2008 08:34:20
general Daniel Ennis 22 Oct 2008 08:34:20
differentiate Peter Simon 26 Jan 2010 19:03:12
differentiate Chih-Ying Hsiao 17 Feb 2010 23:02:01

Contact us at files@mathworks.com