Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Solve and provide MATLAB code. (b) Write a function, MyCenteredDifference, that takes in a function f, a point (or points) x, and a step size

(b) Write a function, MyCenteredDifference, that takes in a function f, a point (or points) x, and a step Solve and provide MATLAB code.

(b) Write a function, MyCenteredDifference, that takes in a function f, a point (or points) x, and a step size h that represents the spacing between the x points. The function should return an approximated derivative of f using centered differences at each x point. Using your function, approximate the derivative Dh f' using step sizes h = for n = 1,2, 3, ..., 15 on the interval [1, 2]. Compare the results of your function to the true derivatives f'(x) = 3x + cos(x) by computing the error 2n En = max |f'(x) - Dh(x)| X Print your results in and the error ratio a table that has as columns: n, the error En(x), En (x) En-1(a) where E (x) Eo (x) 1. =

Step by Step Solution

3.34 Rating (157 Votes )

There are 3 Steps involved in it

Step: 1

Define the function fx and its true derivative fx fX 3x2cosx trueder... 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

Numerical Methods With Chemical Engineering Applications

Authors: Kevin D. Dorfman, Prodromos Daoutidis

1st Edition

1107135117, 978-1107135116

More Books

Students also viewed these Databases questions