9. Write a Python function sin(x,n) to calculate the value of sin(x) using its Taylor series expansion up to
n terms. Compare the values of sin(x) for different values of n with correct value.
Answers
Answered by
0
Answer:
import math
def sin(x,n):
sine = 0
for i in range(n):
sign = (-1)**i
pi=22/7
y=x*(pi/180)
sine = sine + ((y**(2.0*i+1))/math.factorial(2*i+1))*sign
return sine
x=int(input("Enter the value of x in degrees:"))
n=int(input("Enter the number of
Similar questions
Social Sciences,
6 months ago
Accountancy,
6 months ago
Science,
6 months ago
Physics,
1 year ago
English,
1 year ago
Social Sciences,
1 year ago
Social Sciences,
1 year ago