sin(x) = x - (x^3)/3! + (x^5)/5! - (x^7)/7! + (x^9)/9! - (x^11)/11! + (x^13)/13!To compute the value of sin(x) we will calculate only the first few terms of the infinite series. The number of terms used will be specified by the user. In the equation above, only 7 terms have been displayed. Also, in the equation above the expression 7! (read seven factorial) stands for 1 2 3 4 5 6 7. In general, n! stands for the product of 1 through n. The Taylor series we use works very well with angles expressed in radians, but most people are more familiar with angles expressed in degrees. So, the output of your program should have a table of sine values for angles between 0 and 360. To convert from degrees to radians, use the formula:
radians = PI * degrees / 180This is enough information for you to compute the sine values for the table. You are, of course, not allowed to use the sine function in the math library. This exercise is to show you how sine values are actually computed. Finally, the format of your output should conform to the description in the sample run below -- i.e., report a sine value every 5 degrees, have three values per line, seven digits of precision and nicely formatted output. When you have determined that your program works correctly, try running the program using different numbers of terms. Check the results of your program against a calculator (be sure you have the calculator in degree mode) or a calculus textbook. You should notice that the table is more accurate when you include more terms. How many terms are needed before your program correctly determined that sin(360) is 0?
lassie% a.out This program prints out a table of sine values. The values are computed using a Taylor series. You may specify the number terms in the Taylor series. Enter the number of terms: 8 Table of Sines sin( 0) = 0.0000000 sin( 5) = 0.0871557 sin( 10) = 0.1736482 sin( 15) = 0.2588190 sin( 20) = 0.3420201 sin( 25) = 0.4226183 sin( 30) = 0.5000000 sin( 35) = 0.5735764 sin( 40) = 0.6427876 sin( 45) = 0.7071068 sin( 50) = 0.7660444 sin( 55) = 0.8191520 sin( 60) = 0.8660254 sin( 65) = 0.9063078 sin( 70) = 0.9396926 sin( 75) = 0.9659258 sin( 80) = 0.9848078 sin( 85) = 0.9961947 sin( 90) = 1.0000000 sin( 95) = 0.9961947 sin(100) = 0.9848078 sin(105) = 0.9659258 sin(110) = 0.9396926 sin(115) = 0.9063078 sin(120) = 0.8660254 sin(125) = 0.8191520 sin(130) = 0.7660444 sin(135) = 0.7071068 sin(140) = 0.6427876 sin(145) = 0.5735764 sin(150) = 0.5000000 sin(155) = 0.4226182 sin(160) = 0.3420200 sin(165) = 0.2588189 sin(170) = 0.1736479 sin(175) = 0.0871553 sin(180) = -0.0000008 sin(185) = -0.0871570 sin(190) = -0.1736501 sin(195) = -0.2588220 sin(200) = -0.3420247 sin(205) = -0.4226253 sin(210) = -0.5000105 sin(215) = -0.5735921 sin(220) = -0.6428107 sin(225) = -0.7071406 sin(230) = -0.7660934 sin(235) = -0.8192225 sin(240) = -0.8661260 sin(245) = -0.9064503 sin(250) = -0.9398931 sin(255) = -0.9662059 sin(260) = -0.9851966 sin(265) = -0.9967310 sin(270) = -1.0007352 sin(275) = -0.9971967 sin(280) = -0.9861656 sin(285) = -0.9677560 sin(290) = -0.9421464 sin(295) = -0.9095809 sin(300) = -0.8703701 sin(305) = -0.8248916 sin(310) = -0.7735919 sin(315) = -0.7169875 sin(320) = -0.6556671 sin(325) = -0.5902946 sin(330) = -0.5216130 sin(335) = -0.4504494 sin(340) = -0.3777216 sin(345) = -0.3044466 sin(350) = -0.2317518 sin(355) = -0.1608878 sin(360) = -0.0932458 lassie%