Using matlab,  Make a table of the error of the three-point centered-difference formula for f ′(0), where f (x) = sinx − cosx, with h = 10−1,...,10−12, as in the table in Section 5.1.2. Draw a plot of the results. Does the minimum error correspond to the theoretical expectation?

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Using matlab, 

Make a table of the error of the three-point centered-difference formula for f ′(0), where f (x) = sinx − cosx, with h = 10−1,...,10−12, as in the table in Section 5.1.2. Draw a plot of the results. Does the minimum error correspond to the theoretical expectation?

Expert Solution
Step 1: Aalgorithm :
  1. Define the function Error converting from MathML to accessible text..
  2. Define the analytical derivative Error converting from MathML to accessible text..
  3. Create an array of step sizes Error converting from MathML to accessible text. ranging from 1 0 to the power of negative 1 end exponent to 1 0 to the power of negative 12 end exponent in decreasing order (e.g., using Error converting from MathML to accessible text.).
  4. Initialize arrays to store errors and approximations.
  5. For each step size Error converting from MathML to accessible text.:
    • Compute the approximation using the centered-difference formula: Error converting from MathML to accessible text..
    • Compute the error as the absolute difference between the approximation and the analytical derivative: Error converting from MathML to accessible text..
    • Store the error and approximation in their respective arrays.
  6. Display a table showing step size, approximation, and error.
  7. Create a log-log plot with step sizes on the x-axis and errors on the y-axis.
  8. Label the x-axis as "Step Size (h)" and the y-axis as "Error".
  9. Add a title to the plot.
  10. Turn on the grid for the plot.
  11. Display the plot.
  12. Define the function Error converting from MathML to accessible text..
  13. Define the analytical derivative Error converting from MathML to accessible text..
  14. Create an array of step sizes Error converting from MathML to accessible text. ranging from 1 0 to the power of negative 1 end exponent to 1 0 to the power of negative 12 end exponent in decreasing order (e.g., using Error converting from MathML to accessible text.).
  15. Initialize arrays to store errors and approximations.
  16. For each step size Error converting from MathML to accessible text.:
    • Compute the approximation using the centered-difference formula: Error converting from MathML to accessible text..
    • Compute the error as the absolute difference between the approximation and the analytical derivative: Error converting from MathML to accessible text..
    • Store the error and approximation in their respective arrays.
  17. Display a table showing step size, approximation, and error.
  18. Create a log-log plot with step sizes on the x-axis and errors on the y-axis.
  19. Label the x-axis as "Step Size (h)" and the y-axis as "Error".
  20. Add a title to the plot.
  21. Turn on the grid for the plot.
  22. Display the plot.
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 20 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

where is the Matlab coding, it was asked to do using Matlab

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Fundamentals of Boolean Algebra and Digital Logics
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education