computer science lab HW
ECE-206 (Friday), Spring 2016 Exercise #08 Page 1 of 1
Exercise #08: C++ Programming - User Defined Functions
Prelab: Preliminary C++ Program.
Given the McLaurin series
sin(x) = x – x3 /(3!) + x5 /(5!) – x7 /(7!) + x9 /(9!) + . . . where x is in radian.
cos(x) = 1 – x2 /(2!) + x4 /(4!) – x6 /(6!) + x8 /(8!) + . . . where x is in radian.
1. Write two functions g(x) = sin(x) and h(x) = cos(x) using the series above to obtain accuracy
to 5 decimal places.
2. Write a C++ program that uses the functions above to calculate f(n) for integer n = 0 to 6
where
f (n) = 5 g(n) * h(4000 π n + π /3)
= 5 sin(n) * cos(4000 π n + π /3) and 0 <= n <=6
Run Output Format Requirement
n 5 sin(n) cos(4000 π n + π /3) f(n)
---------------------------------------------------------------------------------
Material to Submit
Post Lab: Well documented and correct C++ program., and run output
Reference: sin(x) and cos(x) programs on the course website.
As always, have the instructor verify that your program work as intended.