Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design and construct a computer program in one of the following languages C++ that will illustrate the effects of rounding errors and truncation errors. Documentation

Design and construct a computer program in one of the following languages C++ that will illustrate the effects of rounding errors and truncation errors.

Documentation for the main module/program should be placed before any code and should include: PROGRAMMER: your name COURSE: CSCI 3231 (include section #) DATE: e.g., March 23, 2021 Also, note that the arguments of all trigonometric functions in this course are measured in radians.

image text in transcribed

The following is a plot of the function f(x) = sin(x3) + x2 : + 1 3 2 -10 -0.5 0.5 10 15 20 In order to illustrate the effects of the two major error sources, rounding and truncation, attempt to determine an approximation to the derivative of f(x) at x = 1.0 radians using the difference approximation given below. (The true answer is 2 + 3 cos(1) or about 3.620906917604419152202810). Use the formula: f'(x) = (f(x+h) f(x)) /h with h=1,0.5, 0.25, ... 1.8189894035459e-12 (i.e., keep halving h until it is less than 2.0-12.) Print out the values of h, your approximation to f(x), and the error in the approximation for each value of h used. This error will include the effects of both truncation and rounding. Write down (in your output file or in another file submitted with your program) any conclusions that you can make from these experiments. The following is a plot of the function f(x) = sin(x3) + x2 : + 1 3 2 -10 -0.5 0.5 10 15 20 In order to illustrate the effects of the two major error sources, rounding and truncation, attempt to determine an approximation to the derivative of f(x) at x = 1.0 radians using the difference approximation given below. (The true answer is 2 + 3 cos(1) or about 3.620906917604419152202810). Use the formula: f'(x) = (f(x+h) f(x)) /h with h=1,0.5, 0.25, ... 1.8189894035459e-12 (i.e., keep halving h until it is less than 2.0-12.) Print out the values of h, your approximation to f(x), and the error in the approximation for each value of h used. This error will include the effects of both truncation and rounding. Write down (in your output file or in another file submitted with your program) any conclusions that you can make from these experiments

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

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions

Question

What are the stages of project management? Write it in items.

Answered: 1 week ago