Question: 10. You are to write a C++ program that approximates the value of ex using the series expansion: ex1+x+2!x2+3!x3++N!xN where N is the maximum number

10. You are to write a C++ program that approximates the value of ex using the series expansion: ex1+x+2!x2+3!x3++N!xN where N is the maximum number of terms in your series. Before writing the program, answer the following questions (you are turning in these answers): a) What values are to be initialized before executing the loop? b) What are the equations you will use in your loop body? c) What is your test condition? d) Write your program using a for loop. In order to test your series solution, you should compare to the exact solution using the function exp(x). Compute the error using the formula: error=abs(seriesexp(x))/exp(x) where series is your solution, exp(x) is the reference solution using the cmath function, and abs is a cmath function that returns the absolute value of the argument. (Note that you should use type double for x, series, etc.) e) To validate your program, choose x=1. For this value of x, with N=16, you should get an error on the order of 8e16. If you set x=0.1, what value of N results in a comparable error
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
