<p>I have to create the sin function from scratch in my Comp Sci class, and I am getting close to a solution. However, I am still having a few problems. If I put in a value of .5PI or less it works, but otherwise I get the incorrect result. Here is the code I have so far:</p>

<pre><code>double i=1;
double sinSoFar = 0;
int term = 1;
while(i &gt;= .000001)
{
    i = pow(-1, term + 1) * pow(sinOf, 2*term-1) / factorial(2*term-1);
    sinSoFar=sinSoFar + i;
    term++;
}
</code></pre>

Some advices:
Start with term = 0. The canonical MacLaurin expansion also does
compute the powers and the factorial
while you are cycling
(that is, updating them at each step). Maybe the problem is within pow() or factorial().
EDIT. Suggestion: once you have computed the k-th term, you can compute the (k+1)-th one by:
Multiplying by (-1)
Multiplying by sinOf^2
Dividing by (2k+2)(2k+3)
In this way you can completely
avoid
the computation of powers and factorials.