0% found this document useful (0 votes)
55 views

Experiment 4 - Numerical Differentiation

This document outlines an experiment on numerical differentiation using MATLAB. It defines numerical differentiation methods, analyzes different techniques, and demonstrates MATLAB usage for computing numerical derivatives. The objectives are to define numerical differentiation methods, analyze techniques, demonstrate MATLAB usage, and construct script files. Required tools are a PC and MATLAB. Example MATLAB functions for numerical differentiation like diff are provided. Exercises involve estimating derivatives of x^2cosx using forward, backward, and centered finite differences at step sizes of 0.1 and 0.01.

Uploaded by

TTK MARVIN
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views

Experiment 4 - Numerical Differentiation

This document outlines an experiment on numerical differentiation using MATLAB. It defines numerical differentiation methods, analyzes different techniques, and demonstrates MATLAB usage for computing numerical derivatives. The objectives are to define numerical differentiation methods, analyze techniques, demonstrate MATLAB usage, and construct script files. Required tools are a PC and MATLAB. Example MATLAB functions for numerical differentiation like diff are provided. Exercises involve estimating derivatives of x^2cosx using forward, backward, and centered finite differences at step sizes of 0.1 and 0.01.

Uploaded by

TTK MARVIN
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

LEE MARVIN I.

BIAS
Name:__________________________________ 12-09-22
Date:_____________________
ECEA106L/FOPI01
Course & Section:_________________________ ECE-O/2ND YEAR
Program & Year:____________

Experiment 4
Numerical Differentiation

Objectives
By the end of the experiment, the student should be able to
 define the different numerical differentiation methods.
 analyze the different techniques in numerical differentiation.
 demonstrate the usage of matlab in computing numerical differentiation.
 construct a script file for numerical differentiation operation.

Tools Required
 Personal Computer/Desktop Computer/Computer Workstation
 MATLAB software

MATLAB FUNCTIONS

diff Difference and approximate derivative.


diff(X), for a vector X, is [X(2)-X(1) X(3)-X(2) ... X(n)-X(n-1)].
diff(X), for a matrix X, is the matrix of row differences,
[X(2:n,:) - X(1:n-1,:)].
diff(X), for an N-D array X, is the difference along the first
non-singleton dimension of X.
diff(X,N) is the N-th order difference along the first non-singleton
dimension (denote it by DIM). If N >= size(X,DIM), diff takes
successive differences along the next non-singleton dimension.
diff(X,N,DIM) is the Nth difference function along dimension DIM.
If N >= size(X,DIM), diff returns an empty array.

Examples:
h = .001; x = 0:h:pi;
diff(sin(x.^2))/h is an approximation to 2*cos(x.^2).*x
diff((1:10).^2) is 3:2:19

If X = [3 7 5 0 9 2]
then diff(X,1,1) is [-3 2 -3], diff(X,1,2) is [4 -2 9 -7],
diff(X,2,2) is the 2nd order difference along the dimension 2, and
diff(X,3,2) is the empty matrix.

Exercise:

1. Open your numerical differentiation lecture notes and estimate the derivative of the function, x2cosx at xi= 1 using
forward finite divided differences at step sizes h = 0.1 and h = 0.01 applying the truncated and the more accurate
formula for h = 0.01 step size.

2. Open your numerical differentiation lecture notes and estimate the derivative of the function, x2cosx at xi= 1 using
backward finite divided differences at step sizes h = 0.1 and h = 0.01 applying the truncated and the more accurate
formula for h = 0.01 step size.
3. Open your numerical differentiation lecture notes and estimate the derivative of the function, x2cosx at xi= 1 using
centered finite divided differences at step sizes h = 0.1 & h = 0.01 applying the truncated and the more accurate formula
for h = 0.01 step size.

4. Open your numerical differentiation lecture notes and improved the estimated derivative of the function, x2cosx at
xi= 1 using Richardson’s extrapolation on the finite divided differences techniques at step sizes h = 0.1 & h = 0.01.
Answer: (forward finite divided differences)
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________

Syntax:
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
Answer: (backward finite divided differences)
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________

Syntax:
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
Answer: (centered finite divided differences)
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________

Syntax:
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
Answer: (Richardson’s extrapolation)
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________

Syntax:
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________
__________________________________________________________________________________________________

You might also like