Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write VBA functions to calculate the using the Maclaurin cosine series, and comp

ID: 673749 • Letter: W

Question

Write VBA functions to calculate the using the Maclaurin cosine series, and compare the values for cos(x) from your program to those given by the Excel spreadsheet and VBA built-in functions:

Write a VBA function, , to calculate the value of the individual terms in the series as functions of and . Note: VBA does not have a factorial function, but you can borrow Excel’s factorial function using WorksheetFunction.Fact, for example, nFact = WorksheetFunction.Fact(n).

Write a VBA function, MacCos_n(x,nf), that finds the sum of the terms in the series from to a user designated value, . You can do this using a For…Next loop where the loops starts at and ends at. This will allow you to compare the values of your MacCos_n function to the VBA and Excel cosine functions for different values of .

Write a VBA function, MacCos_tol(x,tol), that converges the Maclaurin cosine series to a user selected tolerance, , where the tolerance is defined by the expression:

You can do this using While….WEnd loop or a Do While loop.

8. Write VBA functions to calculate the cos(x) using the Maclaurin cosine series, and compare the values for cos(x) from your program to those given by the Excel spreadsheet and VBA built-in functions: -1)1 2 Tn(n,x |cos(x) = (-1)n zm

Explanation / Answer

function cosfrommaclurin(t as double,no is inetegr) as double

dim cos as double

dim n as integer

dim sin as integer

dim coumute is double

comupte =1

t =1;

sin =1

cos=1

for n =1 to i

compute = compute *(2*n-1)*2*n

sign =sin*!;

cos=cos+sin(1/compute)*t^(2*n)

next n

mccalaurin =cos

end function

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote