The Program is coded 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)