Question: (python) Question 4: Part A (1pt - manually graded) Modify the code below so that dx is provided as an argument. Write your new code
(python) Question 4: Part A (1pt - manually graded)
Modify the code below so that dx is provided as an argument. Write your new code in the code cell below!
def derivative(f): dx = .001 return lambda x : (f(x+dx) - f(x))/dx
def derivative(f,dx): # YOUR CODE HERE raise NotImplementedError()
Question 4: Part B (2pts - manually graded)
Write a function kthDerivative(f,dx,k) that takes in a function f a step-size dx and a non-negative integer k and returns the kth derivative of f with stepsize dx.
I've started this code below for you. HINT: You are free to call the derivative function above.
def kthDerivative(f,dx,k): """Assumes f is a function, dx is a positive float, k is a non-negative int. Returns a new function that is an approximation of the kth derivative of f, using step-size dx.""" # YOUR CODE HERE raise NotImplementedError()
Question 4: Part C (1pt - manually graded)
Use this code to evaluate the third derivative of ()=4g(x)=x4 at =10x=10 with stepsize .0001.0001. How does this compare with the true answer? What happens if you try larger and smaller stepsizes?
# YOUR CODE HERE raise NotImplementedError()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
