Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Fordiff: 9. Starting with your fordiff.m code, write code called testdiff.m where instead of choosing h, use a loop to output the error for h

image text in transcribed

Fordiff:image text in transcribedimage text in transcribed

9. Starting with your fordiff.m code, write code called testdiff.m where instead of choosing h, use a loop to output the error for h the true derivative at your input x. I recommend a for loop with i=1:8 and use this to set the value of h. Do the output errors agree with the theory ten reduces the error by a factor of ten? Add your answer as comment to the code. 10-1, 10-2, -.. , 108. You will have to calculate that reducing h by a factor of Add a second loop to your code that replaces the first order forward difference approximation with the second order forward difference approximation. Do the output errors agree with the theory that reducing h by a factor of ten reduces the error by a factor of one hundred? Add your answer as comment to the code. We shall revisit this odd behavior later. Make sure you follow the guidelines with regard to commenting, preamble, and nicely for- matted output. Submit your Matlab file. input ('Enter a value for x '); input ('Enter a value for h '); h % Derivative: (1/h)* (sqrt (x) +h-sqrt (x)); % Output stuff: fprintf('the value of F is %15.10f ' ,F); 5. Write a Matlab program called fordiff1.m that asks the user to input an x value and a small h value. The program should calculate the square root of x, approximate the derivative of the function Va and print them both to the screen. You should be descriptive in your output. For the approximate derivative, the definition of derivative suggests f'(x) ~ }(f(x+h) f(x)) for given r and small h, with f(x)= Vx

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

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions

Question

1.who the father of Ayurveda? 2. Who the father of taxonomy?

Answered: 1 week ago

Question

Commen Name with scientific name Tiger - Wolf- Lion- Cat- Dog-

Answered: 1 week ago