1. Engineering
  2. Computer Science
  3. please write separated c code for both parts 3 and...

Question: please write separated c code for both parts 3 and...

Question details
Please write separated C++ code for both parts 3 and 4

PART 3: TRUNCATION ERROR 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 using the following power series. (2k1) 13 15 35315 693 2*+1(el)2 28 64 256 409616384 Please use your program to determine how many terms in the power series are needed to use the full precision of a float and then of a double (i.e. when the number values stop changing). You will compare your answer to the actual value of 2 given 60 decimal places: 21.414213562373095048801688724209698078569671875376948073176679 For this experiment, you can use a global double variable. double sqrt-2 = 1.4 1 421 3562373095048801 688724209698078569671 875376948073176679 In your Labl directory, please call your source code lablpart3.cc. An example of the output of your program might look like: Input the number of terms in the power series using FLOATS: 4 # terms 1 approx # % error # # terms # approx # 96 errors 96 Etc.. Input the number of terms in the power series using DOUBLES: 4 approx # % error # # terms 2 approx # % error . # Etc...

PART 4: ERROR PUZZLE I would like you to create code to calculate v2 using 100 terms of the power series from Part 3. You will compare your answer to the actual value given in Part 3 However, there is a little bit of a twist in this last part. First, I would like you to calculate a cumulative sum in order from the largest term to the smallest term in the power series. Then, I would then like for you to sum the values in the reverse order, by putting each term in the power series in an array with correct number of elements. You can then use a sum term that starts summing from the beginning of the array for the forward summation. You can compare this answer to the sum starting at the end of the array 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. Please make sure your program shows the difference between the two. Also, please do this with float tvpes and then double tv Is there a difference between the two summation? Why do you think there would be a difference between these the forward and backward summations? In your Labl directory, please call your source code lablpart4.cc. Sample output of your program should look like Float Results forward approx = <your value> forward %error : <your value> backward approx-<your value> backward %error-<your value> Double Results: forward approx- <your value> forward %error <your value> backward approx- <your value> backward %error <your value>
Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution