Question: This is C programming Thank you Please select an option: a) Evaluate exponential function b) Evaluate sin function c) Exit The only options valid are




This is C programming
Thank you
Please select an option: a) Evaluate exponential function b) Evaluate sin function c) Exit The only options valid are from a to c. Any other option should display a message warning the user, and asking to try again. The program will finish only when option c is chosen. If a orb is chosen, the program will ask the user to enter a value for X, and number of terms (t); after the values are entered, o the program will call a function to evaluate the corresponding series, o the function will return the value, and then it will display the result of comparing the value obtained using the series to the value obtained using the corresponding function (exp or sin) in math.h, and the percent error(difference between your calculation and the value from the math.h function), . immediately after (press any key to continue), the program will display the menu again. Background: The exp and sin of x, can be obtained using power series: x" X2 X3 X4 = 1+x+ + n! 2!3! 4! 00 exp(x) = e = { + + n=0 sin(x) = =1)"x2n+2 x3 x5 = X 3! 5! (2n + 1)! n=0 Vexp - Vmath.h %e = 1000 Vmath.h Example: Since time is limited, we won't evaluate the series all the way to co; instead we will ask the user for a number of terms to be considered, say t. For example if the user chose to evaluate the exponential function for x=0.5, and t-4: 0.52 0.53 0.54 exp(0.5) = 20.5 = 1 + 0.5 +- + -= 1.6484 n! 2! 3! 4! 0.51 + n=0 Now, using the exp function in math.h: exp(0.5) - 1.648721 We now calculate the %error using the formula: Vexp Vmath.h %e = Vmath.h %e 1000 Where Vexp is the value obtained using the input parameters x and t, and V math.h is the value obtained using the math.h function Thus, 1.6484 1.648721 %e = 1.648721 +100= 0.0172 Using these values, the program should display a table like: t result math.h 0.5 4 1.6484 1.6487 X %error 0.0172 Please enter the values for each menu item: Please Enter A to Evaluate exponential function Please Enter B to Evaluate sin function Please Enter C to Exit Enter a choice: r Enter a choice between A to C or a to c:^ Enter a choice between A to C or a to c: 8 Enter a choice between A to C or a to c: A Enter a value for x and number of terms: 0.5 6 x t result math.h %error 0.5000 6 1.6487 1.6487 0.0001 Please enter the values for each menu item: Please Enter A to Evaluate exponential function Please Enter B to Evaluate sin function Please Enter C to Exit Enter a choice: B Enter a value for x and number of terms: 1.54 result math.h %error 1.5000 4 0.9975 0.9975 0.0002 Please enter the values for each menu item: Please Enter A to Evaluate exponential function Please Enter B to Evaluate sin function Please Enter C to Exit Enter a choice between A to C or a to c: b Enter a value for x and number of terms: 3.5 4 X t result math.h %error 3.5000 4 -0.3284 -0.3508 6.3841 Please enter the values for each menu item: Please Enter A to Evaluate exponential function Please Enter B to Evaluate sin function Please Enter C to Exit Enter a choice: C Enter a value for x and number of terms: 1.5 4 result math.h %error 1.5000 4 0.9975 0.9975 0.0002
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
