Question: Academic 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



Academic 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: 1) k cos(x) (2k)! x2k k=0 The series can be written as: r2 x 8 cos(x) = 1 + .. + 2! 4! 6! 8! Write a C++ program that reads a list of angles (in degrees) and the values of k (k represen the number of terms in the above series) from an input file called (angles.txt). The program should only accept angles between 0 and 180. When invalid angle is read fror 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 fact, which is used to compute the the factorial to be used in the above series. 1. Function 2 is called series_sum, which is used to compute the estimated cosine as giver by the above series and calculate the Error Marign (difference between cos(x) given by 1. Function 1 is called fact, which is used to compute the the factorial to be used in the above series. 1. Function 2 is called series sum, 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 (results.txt) as shown below. Hint: Use the same given data in the input file (angles.txt) to check your code. Do not use materials that we did not teach you such as struct, pointers, and 2-d arrays angles.txt 190 100 25 4. 5 3 3 3 4 33 50 86 results.txt Estimated Value COS
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
