100% Guaranteed Results


MA202 – IIIT Vadodara Solved
$ 29.99
Category:

Description

5/5 – (1 vote)

MA202 Numerical Techniques
LAB#4 Numerical Differentiation
1. Difference approximations of the first derivative of a function: For a function f(x) of a variable x, its first derivative is defined as,
(1)
However, this gives our computers a headache, since they do not know how to consider the limit. Any input number given to computers must be a definite number and can be neither too small nor too large to be understood by the computer. The ‘theoretically’ infinitesimal number h involved in this equation is a problem. A simple approximation for computational implementation is the forward difference approximation
, (2)
where h is a finite step size. How far equation (2) approximation from the true value of (1)? In order to do the error analysis, we take the Taylor series expansion of f(x + h) about x as
(3)
where f(n)(x) is the differentiation of f(x) at nth order. Now, let us approximate first order derivative of f(x), i.e., f(1)(x). Subtracting f(x) from both sides and dividing both sides by the step size h yields
, (4)
where h is a finite step size.
Df1(x,h) = f(1)(x) + O(h), (5)
where O(g(h)) denotes a truncation error term proportional to g(h) for |h| ≺ 1. This means that the error of the forward difference approximation (2) of the first derivative is proportional to the step size h, or, equivalently, in the order of h.
Now, in order to derive another approximation formula for the first derivative having a smaller error, let’s remove the first-order term with respect to h from Eq. (4) by substituting 2h for h, and subtracting this result from two times the equation. Then, we get
Df2(x,h) = f(1)(x) + O(h2), (6)
which can be regarded as an improvement over Eq. (4), since it has the truncation error of O(h2) for |h| ≺ 1.
The backward difference approximation Db1(x,h)= Df1(x,−h) also has an error of O(h) and can be processed to yield an improved version having a truncation error of O(h2).
In order to derive another approximation formula for the first derivative, we take the Taylor series expansion of f(x + h) and f(x − h) up to the fifth order in equation (3) and divide the difference between these two equations by 2h to get the central difference approximation for the first derivative as
Dc2(x,h) = f(1)(x) + O(h2), (7)
which has an error of O(h2) similarly to Eqs.(5) and (6). This can also be processed to yield an improved version having a truncation error of O(h4).
22Dc2(x,h) − Dc2(x,2h) = f0(x) + O(h4). (8)
Furthermore, this procedure can be formularized into a general formula, called ‘Richardson’s extrapolation’, for improving the difference approximation of the derivatives.
Difference approximation for the second derivative using central difference method
For a function f(x) of a variable x, its second derivative is defined as,
. (9)
where h is the step size.
Q. 1: (a) Write a MATLAB script to calculate numerical derivative of tan−1(x) at x = 1. (b) Find the error using forward difference, backward difference, and central difference methods. Comment on order of accuracy.
(c) Plot the error using log-log scale for the step size h = 1e − 04.
(d) Use step sizes ranging from 10−1 to 10−8. Plot the error using log-log scale for each of your step sizes.(Note: Use array operations not a for loop).
(e) Comment on trade-off between truncation error and roundoff error, i.e., look atthe minima of different methods in the graphs.
Q. 2: Write a MATLAB script to calculate first order as well as second order numerical derivative of 2 − x + ln(x) at x = 1.
Repeat the steps (b), (c), (d), and (e) of Q.1
Q. 3: (a) Write a MATLAB script to calculate partial derivative of
f(x) = sin(x1)exp(−x2) (10)
at x1 = 0.5 and x2 = 1.
(b) Find the error using central difference method.
(c) Plot the error using log-log scale for the step size h = 1e − 06.
Page 2 of 2

Reviews

There are no reviews yet.

Be the first to review “MA202 – IIIT Vadodara Solved”

Your email address will not be published. Required fields are marked *

Related products