Question: For python: The derivative of a function f at x=a can be approximated by f(a)hf(a+h)f(a). The approximation error is O(h), hence the approximation will be
For python:
The derivative of a function f at x=a can be approximated by f(a)hf(a+h)f(a). The approximation error is O(h), hence the approximation will be better for smaller values of the step size h. 1. (10 pt) Implement a function which computes an approximation for the derivative of a function f at x=a. - The function should receive the name of the function implementing f, the point a, and the step size h. - The function should return the approximate value of the derivative. - Write a program that uses your function to compute approximations of f(x) for f(x)= exp(x2), first at x=1 and then at x=2, for decreasing step sizes h. Scientific Programming Project 1 Numerical optimization - Start with h=0.1 and decrease h10 times by a factor 10 . - Print in each step the value of h and the error, i.e., the difference between the approximation of f(x) and the exact value of f(x)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
