Need help approximating sine function in python using Taylor Series
<p>I'm very new to Python, and am trying to approximate the sine function using <a href="http://i.imgur.com/6GMBhgt.png?1" rel="nofollow">this</a> series.</p>

<p>My code looks like this:</p>

<pre><code>import math
def sin(x,n):
sine = 0
for i in range(n):
    sign = (-1)**i
    sine = sine + ((x**(2.0*i-1))/factorial(2**i-1))*sign
return sine
</code></pre>

<p>This does not return the answer that I was hoping for, but I am very confused and can't find my mistake... or maybe I'm just going about this the wrong way entirely (as I said, I'm very new to python and to programming in general).</p>

<p>It seems similar to the program that I had to write a while ago to approximate pi given <a href="http://i.imgur.com/SxebUNY.png" rel="nofollow">this</a> series:</p>

<pre><code>def piApprox(n):
pi = 0
for i in range(n):
    sign = (-1)**i
    pi = pi + 1.0/(2*i+1)*sign
return 4*pi
</code></pre>

<p>I don't know if that is useful in any way, but it's what I was trying to use that to figure out my sine method.  Any help fixing this or pointing me in the right direction would be greatly appreciated!</p>
