BlackBeltPanda
New member
- Joined
- May 28, 2014
- Messages
- 3
Hello,
So I'm writing a program that plots 16 points of a circle, with center (0,0) and radius 0.5. I have no access to any higher math functions, like sin, cos, or even factorials, so I'm attempting to write my own functions.
Basically, up until about 90 degrees, sin and cos are accurate. Here are my formulas:
Factorials:
Where n is the given number
n should now be equal to n!
Sin:
Where n is the given number
Cos:
Where n is the given number
Am I missing something or not understanding something? Cos(270) should be 0, but my function returns -4.7655522868. =/
So I'm writing a program that plots 16 points of a circle, with center (0,0) and radius 0.5. I have no access to any higher math functions, like sin, cos, or even factorials, so I'm attempting to write my own functions.
Basically, up until about 90 degrees, sin and cos are accurate. Here are my formulas:
Factorials:
Where n is the given number
Code:
i = n-1
While i>0:
n = n*i
i = i-1
Sin:
Where n is the given number
Code:
r = (n/180)*3.1415926535 (convert degrees to radians)
sin = r - ((r^3)/3!) + ((r^5)/5!) - ((r^7)/7!)
Cos:
Where n is the given number
Code:
r = (n/180)*3.1415926535 (convert degrees to radians)
cos = 1 - ((r^2)/2!) + ((r^4)/4!) - ((r^6)/6!)
Am I missing something or not understanding something? Cos(270) should be 0, but my function returns -4.7655522868. =/
Last edited: