This is using the Taylor series to find the value of the sine of an angle between -1 and +1, but what I'm trying to do is get the value of every degree, print it, go to the next degree, then print, etc...
def Fac(n):
r=1
for c in range(n,1,-1):
r*=c #r=r*c
return r
def Pow(x,n):
r=1
for c in range(0,n):
r*=x
return r
def Sign(i): #i will be the number of the term we are on for Taylor
r=1
for c in range(0,i):
r*=-1
return r
def Rad(a):
return a*3.141592654/180
def SinTerm(x,n,i):
y=Sign(i)*Pow(x,n)/Fac(n)
return y
def main():
for c in range(0,361):
a=c
i=3
n=1
sum=0
for c in range(0,i):
sum+=SinTerm(Rad(a),n,c)
n+=2
print "Taylor COSINE sum = ", sum
while True:
main()
I thought making range(0,361) would show all the values separately, but it adds up all the values of 0-360 degrees instead. How would I make it so the sin value for every degree is shown separately? I would prefer answers that guide me in the right direction, not give the answer away out right.