0% found this document useful (0 votes)
57 views1 page

CS2201 Worksheet 08

This document contains 5 questions asking the student to write Python programs to: 1) Calculate and plot a function and its derivative using forward difference formula 2) Calculate and plot a function and its derivative using central difference formula 3) Investigate how error changes in the central difference method with step size h 4) Calculate a derivative using the five-point formula 5) Calculate a second derivative approximation The student is instructed to do the work on a laptop, phone, or by writing answers by hand if no other option is available. Relevant videos and slides are available on the welearn site.

Uploaded by

Ananda Dasgupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views1 page

CS2201 Worksheet 08

This document contains 5 questions asking the student to write Python programs to: 1) Calculate and plot a function and its derivative using forward difference formula 2) Calculate and plot a function and its derivative using central difference formula 3) Investigate how error changes in the central difference method with step size h 4) Calculate a derivative using the five-point formula 5) Calculate a second derivative approximation The student is instructed to do the work on a laptop, phone, or by writing answers by hand if no other option is available. Relevant videos and slides are available on the welearn site.

Uploaded by

Ananda Dasgupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

CS2201 Worksheet 08

Work out the problems on your laptop/phone (there are several nice python
interpreters that work on Android - I prefer qpython - but you may find some
other app more to your taste. If you do not have access to any of these, write
out our answers - scan them and upload (but this should be the absolute last
resort!).
You will find link to the relevant videos and lecture slides on welearn.

Q 1) Write a program that calculates and plots the function

2
f (x) = x2 e−x

and its first derivative calculated using the forward difference formula on the
same graph.
Q 2) Repeat the last problem, but this time use the central difference for-
mula.
Q 3) Write a program to investigate the way the error in the central difference
method changes with changing step size h.
Q 4) Write a program that will calculate the derivative using the five-point
formula (see the video and/or the lecture slide)
Q 5) Write a program that will calculate the second derivative of a given
function using the approximation

f (x + h) − 2f (x) + f (x − h)
f 00 (x) ≈
h2

You might also like