Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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()
image text in transcribed

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

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

More Books

Students also viewed these Databases questions

Question

What is DDL?

Answered: 1 week ago