Taking the following formula, is my code consistant?

sin(x) = x - (x^3)/3! + (x^5)/5! + ... +
(-1)^i*(x^(2*i+1))/(2*i+1)!


1
2
3
4
5
6
7
8
9
10
11
12

	for(;prec<10;++prec)
	{
		
		work=heapvar_pow(deg,(prec*2)+1);
		work/=heapvar_factorial((prec*2)+1);
		work*=heapvar_pow(negone,prec);
		answer+=work;
		//answer+= heapvar_pow(negone,prec) *  heapvar_pow(deg,(prec*2)+1) / heapvar_factorial((prec*2)+1) ;	
	}



I have to break them into individual parts because heapvar has a bug which
causes the result to turn zero. Anyways I'm getting the wrong results, and
belive the power and factorial functions are working correctly.

Now I want to ask if I have the formula inputted correctly?
closed account (o1vk4iN6)
http://cplusplus.com/forum/general/65838/

Gotta learn to debug your own code sometime.
Topic archived. No new replies allowed.