Code covered by the BSD License  

Highlights from
Numerical Differentiation

5.0

5.0 | 1 rating Rate this file 7 Downloads (last 30 days) File Size: 249.76 KB File ID: #22807
image thumbnail

Numerical Differentiation

by Husam Aldahiyat

 

28 Jan 2009 (Updated 03 Feb 2009)

Performs single dimensional differentiation numerically.

| Watch this File

File Information
Description

This is a GUI which performs numerical differentiation of a function over a number of equaly spaced points. Also with it is a code that grants the coefficients used for numerical differentiation.

The pictures and example should be more than enough for understanding how to use the file.

 Example:

 npoints=3;
 Order=1;
 d=datnum(npoints,Order)
 d=
 -1.5 2 -0.5 % Forward
 -0.5 -0 0.5 % Central
  0.5 -2 1.5 % Backward
 
% The result is a matrix consisting of coefficients that can be
% used to numerically differentiate, like this:
 
 x=1;
 f=inline('cos(x)')
 h=.1;

 s = ( d(1,1)*f(x) + d(1,2)*f(x+h) + d(1,3)*f(x+2*h) )/h^Order
 s =
       -0.8444

 s = ( d(2,1)*f(x-h) + d(2,2)*f(x) + d(2,3)*f(x+h) )/h^Order
 s =
      -0.84007
 
 s = ( d(3,1)*f(x-2*h) + d(3,2)*f(x-h) + d(3,3)*f(x) )/h^Order
 s =
      -0.84413

% The true answer is s = -0.84147

The code uses the Symbolic Math Toolbox to obtain the true value (in order to calculate the error). If you don't have the Symbolic Math Toolbox then you won't enjoy this benefit (program still works though).

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
Adaptive Robust Numerical Differentiation

MATLAB release MATLAB 7.4 (R2007a)
Other requirements Symbolic Math Toolbox (Optional)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
07 Dec 2009 Zas Babyk  
Please login to add a comment or rating.
Updates
30 Jan 2009

Symbolic Math Toolbox is now an optional feature

03 Feb 2009

Edited description

Tag Activity for this File
Tag Applied By Date/Time
differentiation Husam Aldahiyat 29 Jan 2009 16:58:33
numerical Husam Aldahiyat 29 Jan 2009 16:58:33
differences Husam Aldahiyat 29 Jan 2009 16:58:33
divided Husam Aldahiyat 29 Jan 2009 16:58:33
differences faris johari 26 Oct 2010 10:59:07
differentiation faris johari 26 Oct 2010 10:59:17
differentiation Shijing Lu 20 May 2011 18:37:52

Contact us at files@mathworks.com