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

 In addition to the 'cos' pre-defined function, which is found in

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)! k=0 The series can be written as: ). = -72k x2 cos(x) = 1 + x6 r8 + 6! 8! 2! 4! ... 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 (angles.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 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

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!