Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python we mentioned a way of approximating the derivative of a function fat a point x, by the slope of a straight ine through fx

image text in transcribed

python we mentioned a way of approximating the derivative of a function fat a point x, by the slope of a straight ine through fx - d) and fx+d). More precisely, the formula is (fx+d) fx - d)/(2 d As the distance dtends to zero, we expect this approximation to grow closer to the real derivative f(x). However, this fails to take into account the floating point round-off error in the calculation of fx + d) and fix d), which may become larger relative to the size of 2 d To measure this effect, we can compare the approximation with the true derivative, for cases where the latter is known. For example, if fx) ex(which is available in python as math.exp), we know that the derivative is fx) fx. (a) Write a function that computes the approximation of f(x), with a parameter for the distance d. As python allows you to pass functions as arguments, you can write a (simple) function that does this calculation for any function fand point X. (b) Write another function that calculates the error as the absolute difference between the approximate and true derivative, for given values of x and d, using the exponential function as f. Generate a series of diminishing values for d, from, say, 0.1 down to 10-15. You can do this with list comprehension and the range function: ds [10* ori in range(1,16)] Calculate and plot the error for each d-value in this range. What can you observe

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Administration The Essential Reference

Authors: Brian Laskey, David Kreines

1st Edition

1565925165, 978-1565925168

More Books

Students also viewed these Databases questions