Question: Please solve it quickly In addition to the 'cos' pre-defined function, which is found in the 'cmath' library, the cosine of an angle 'x' (given

 Please solve it quickly In addition to the 'cos' pre-defined function,

which is found in the 'cmath' library, the cosine of an angle

'x' (given in radians), can be estimated using the following series: 00

Please solve it quickly

In addition to the 'cos' pre-defined function, which is found in the 'cmath' library, the cosine of an angle 'x' (given in radians), can be estimated using the following series: 00 cos(x) (-1)k (2k)! -xk k=0 The series can be written as: cos(x) = 1 x2 x4 + 2! 4! x6 r8 + 6! 8! Write a C++ program that reads a list of angles (in degrees) and the values of k (k represents the number of terms in the above series) from an input file called (input.txt). The program should only accept angles between 0 and 180. When invalid angle is read from the file, an error message should be displayed (see the given sample output) The program should include the following user-defined functions: 1. Function 1 is called factorial, which is used to compute the factorial to be used in the above series. 1. Function 2 is called series, which is used to compute the estimated cosine as given by the above series and calculate the Error Marign (difference between cos(x) given by cmath and the estimated cos(x) based on the given series) and send the program outputs to another file called (output.txt) as shown below. Hint: Use the same given data in the input file to check your code. Do not use materials that we did not teach you such as struct, pointers, and 2-d arrays input.txt 5 3 3 100 25 33 190 50 86 3 4 output.txt 100 25 COS Estimated Value -0.173871 -0.173873 0.906284 0.906284 0.83863 0.83863 ** angle is out of the range 0.642701 0.642693 0.0695623 0.0695781 Error Margin 1.64296e-006 3.255e-008 2.99544e-007 33 190 50 86 ** 8.28016e-006 1.57461e-005

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!