Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The program is done in C++ PART 3: TRUNCATION ERROR (25pts) All your source code for this part needs to be a file called lablpart3.cc.

image text in transcribedThe program is done in C++

PART 3: TRUNCATION ERROR (25pts) All your source code for this part needs to be a file called lablpart3.cc. Sample output of your program should look like: In numerical analysis, the term "truncation error" is typically related to the error introduced by not using all the terms in a series expansion or a limited number of iterations used in approximations to differential equation solutions. To illustrate this, I would like for you to calculate the truncation error in calculating the value of 2 using the following power series. Float Results: forward answer = (2k + 1)! 1 3 15 35 315 693 v2 = 223+1 (kl)2 = 2*8* 64256409616384 forward %error = backward answer = You need to create code to calculate the v2 using backward %error = Double Results: 20 terms using float precision 80 terms using double precision forward answer = You will compare your answer to the actual value to 20 decimal places: forward %error = V2 = 1.41421356237309504880 backward answer = backward %error = In your program declare two arrays: float fTerms[20]: double dTerms[80]: to hold the individual values for each term in the power series. Calculate and store the value of each term once using float and the other using doubles. Beware of the large numbers that result in the numerator and denominator of the terms. Design ways to deal with any overflows that occur. Once you have calculated the terms for both floats and double you need to sum up the terms for each type from largest to smallest. Then you need to determine the sum from smallest to largest for both types. In theory you would think it should not make a difference which order you sum the values, but you should see a difference in the result. Is there a difference between the two summations? Why do you think there would be a difference between the forward and backward summations? (Answer On Turn-in sheet) PART 3: TRUNCATION ERROR (25pts) All your source code for this part needs to be a file called lablpart3.cc. Sample output of your program should look like: In numerical analysis, the term "truncation error" is typically related to the error introduced by not using all the terms in a series expansion or a limited number of iterations used in approximations to differential equation solutions. To illustrate this, I would like for you to calculate the truncation error in calculating the value of 2 using the following power series. Float Results: forward answer = (2k + 1)! 1 3 15 35 315 693 v2 = 223+1 (kl)2 = 2*8* 64256409616384 forward %error = backward answer = You need to create code to calculate the v2 using backward %error = Double Results: 20 terms using float precision 80 terms using double precision forward answer = You will compare your answer to the actual value to 20 decimal places: forward %error = V2 = 1.41421356237309504880 backward answer = backward %error = In your program declare two arrays: float fTerms[20]: double dTerms[80]: to hold the individual values for each term in the power series. Calculate and store the value of each term once using float and the other using doubles. Beware of the large numbers that result in the numerator and denominator of the terms. Design ways to deal with any overflows that occur. Once you have calculated the terms for both floats and double you need to sum up the terms for each type from largest to smallest. Then you need to determine the sum from smallest to largest for both types. In theory you would think it should not make a difference which order you sum the values, but you should see a difference in the result. Is there a difference between the two summations? Why do you think there would be a difference between the forward and backward summations? (Answer On Turn-in sheet)

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

Students also viewed these Databases questions

Question

What are the essentials of a good speech?

Answered: 1 week ago

Question

Why does sin 2x + cos2x =1 ?

Answered: 1 week ago

Question

What are DNA and RNA and what is the difference between them?

Answered: 1 week ago

Question

Why do living creatures die? Can it be proved that they are reborn?

Answered: 1 week ago

Question

Discuss five types of employee training.

Answered: 1 week ago

Question

Identify the four federally mandated employee benefits.

Answered: 1 week ago