Question: Modify the code to verify numerically that the approximation of f ' ( x 0 ) given by the formula f ( x 0 -

Modify the code to verify numerically that the approximation of f'(x0) given by the formula
f(x0-2h)-8f(x0-h)+8f(x0+h)-f(x0+2h)12h
is of order 4, namely the truncation error goes to zero as h4.
from numpy import sin, cos
from matplotlib import pyplot as plt
x0=1
N=8
h=[0]**N
err =[0]**N
for i in range (N) :
h[i]=110****i
err[i]?a=bs(sin(x+h[i])-sin(x-h[i])hi2-cos(x))
plt.clf()
plt. for i in h
plt. legend(['error', 'slope 1', 'slope 2'], loc='upper right')
plt.show()
 Modify the code to verify numerically that the approximation of f'(x0)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!