Let us consider that we have a value x and we have to calculate the sum of sine(x) series. In a sine(x) series, there are multiple terms such that,
sine(x) = x− x^3/fact(3) + x^5/fact(5) −x^7/fact(7)....
In order to solve the particular series-based problem, we will first take the degree as the input and convert it into radian. To find out the sum of the total number of terms in this series, we will first iterate over all the given terms and find out the sum by operations.
Take input of Limit and degree.
Iterate over the terms and find out the sum by using the power function.
Print the output.
n = 5 deg = 10 deg = deg*3.14/180 p=1 f=1 s=deg sine=−1 for i in range(3,n+1,2): deg = deg*sine p = pow(deg,i) f = f*i*(i−1) s = s+p/f print("The sum of the series of sine(10) is:", s)
Running the above code snippet will generate the output as,
The sum of the series of sine(10) is: 0.17356104142876477