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
English,
4 months ago
Physics,
4 months ago
English,
4 months ago
Physics,
8 months ago
English,
8 months ago
Social Sciences,
11 months ago
Social Sciences,
11 months ago