1. In HW 07 you wrote a program to calculate the sin (x)" using the Maclaurin arcsine series. For
HW 08 you are to write a program that uses the Maclaurin cosine series to find cos (x):
cos(x) =
(-1)n
(2n)!
In ( n, x )
n=0
(-1)n
(2n)!
While the Maclaurin cosine series converges very rapidly for x $ 7, the number of terms
required increases rapidly for x > I. Excel encounters problems with determining the factorial
of numbers larger than 50 because of the limits of how exponentials are stored in memory;
however, since the cosine function is a periodic function, cos(x) = -cos (x + 7) and cos(x) =
cos (x + 2x). By taking this periodicity into account in your program, you only have to converge
the Taylor series for x < n, since the cos(n) = -1.
a. Write a program to converge the Maclaurin cosine series and test it for values of x < 2n.
b. Modify your program so that if x > 2x it calculates the cos(x) by finding cos (x) =
cos (Modulus (x, 2n)) where Modulus (a, b) is the remainder of a/b. VBA has a
modulus operator with the syntax = a MOD b. You should experiment with the MOD
operator to be sure you understand how it functions.
c. Modify your program so that if it < > < 2x it calculates the cos (x) by finding
cos (x) = -cos (x - I).
d. Add error handling code to your program to trap any errors that result when the user
enters a non-numeric value for x.
e. Modify your program to allow the user to output both the cos (x) and the number of
terms required in the Maclaurin series and the value of the last term evaluated by
converting it into an array function. This requires converting your Maclaurin cosine
function into an array function. See the example from the lecture.
2. Add comments to your programs to explain the different sections of the program and what they
do.