In mathematics, the sine is a trigonometric function and is represented as sin( ). In this post I will show you how to write a program to calculate sum of sine series.
|x in degrees: 60
number of terms ‘n’: 3
Take input for degrees and number of terms from the user and is stored in ‘x’ and ‘n’ variables. We defined a ‘sin’ function and those ‘x’ and ‘n’ are passing as arguments in to it. To convert degrees to radians a for loop is used. The sine expansion formula is used to find the value of every term. The statement round(sin(x,n),2 prints the round value of sin(x,n) for two numbers after the decimal point. If you want to print four numbers after the decimal point you can give 4 instead of 2. This process continues till the number of terms is equal to ‘n’ value. Finally the sum of sine series is printed.