Description
Differentiation and Richardson Extrapolation
i. Open the colab file shared in BUX.
ii. Create a copy of that shared file in your drive.iii. Rename the colab filename using the format Name-ID-Lab Section
Part 1: Differentiation: Forward, Backward, And Central
We have already learnt about forward differentiation, backward diferentiation and central differentiation. In this part of the assignment we will write methods to calculate these values and check how they perform.
The equations are as follows,
Task 1: You need to implement the functions backward_diff (f, h, x), central_diff (f, h, x), error_1(f, f_prime, h, x).
From this portion of the implementation you will get to know how to calculate the forward differentiation, backward differentiation, and central differentiation. The forward differentiation is done for you.
Part 2: Richardson Extrapolation
We used central difference method to calculate derivatives of functions in the task. In this task we will use Richardson extrapolation to get a more accurate result. Let,
Task 2: You need to implement the functions dh(f, h, x), dh1(f, h, x), error(f, hs, x_i).
a. The function dh(f, h, x) takes three parameters as input: a function f, a value h, and a set of values x.
b. The function dh1(f, h, x) takes the same type of values as dh(f, h, x) as input. It calculates the derivative using the previously defined dh(f, h, x) function and using equation 5.8
and returns the values.
c. The error(f, hs, x_i) function takes a function f as input. It also takes a list of different values of h as hs and a specific value as x_i as input. It calculates the derivatives as point x_i using both functions described in B and C, i.e. dh and dh1.
Task 3:
Using
a. the polynomial, p, from Part-2,
b. error_1 function from Part-1,
c. and error_2 function from Part-2,
find the differentiation errors when
● hs = [3.5, 0.55, 0.3, .17, 0.1, 0.055, 0.03, 0.017, 0.01], and
● x = 2.0
Plot “error vs h” curves for each of the five errors in a single graph (There should be plots of 5 equations in your graph, i.e., graphs for errors that you achieved using functions of central, forward, backward, dh and dh1 methods).
[Note that the graphs for central differentiation and dh should overlap.]
Reviews
There are no reviews yet.