I was wrong! Degree 12!
This commit is contained in:
parent
a51c11701f
commit
c73b94f5f9
1 changed files with 3 additions and 2 deletions
|
@ -16,7 +16,7 @@
|
||||||
double cos(double x) {
|
double cos(double x) {
|
||||||
double pi = M_PI; /* Really, me?! -Kat */
|
double pi = M_PI; /* Really, me?! -Kat */
|
||||||
int temp;
|
int temp;
|
||||||
double deg_2, deg_4, deg_6, deg_8, deg_10;
|
double deg_2, deg_4, deg_6, deg_8, deg_10, deg_12;
|
||||||
double cosine;
|
double cosine;
|
||||||
|
|
||||||
if(x < 0) x = -x;
|
if(x < 0) x = -x;
|
||||||
|
@ -43,6 +43,7 @@ double cos(double x) {
|
||||||
deg_6 = deg_4 * deg_2 * 2 / (6 * 5);
|
deg_6 = deg_4 * deg_2 * 2 / (6 * 5);
|
||||||
deg_8 = deg_6 * deg_2 * 2 / (8 * 7);
|
deg_8 = deg_6 * deg_2 * 2 / (8 * 7);
|
||||||
deg_10 = deg_8 * deg_2 * 2 / (10 * 9);
|
deg_10 = deg_8 * deg_2 * 2 / (10 * 9);
|
||||||
|
deg_12 = deg_10 * deg_2 * 2 / (12 * 11);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
In case you aren't familiar with the theory of a Taylor
|
In case you aren't familiar with the theory of a Taylor
|
||||||
|
@ -74,7 +75,7 @@ double cos(double x) {
|
||||||
even function, we don't need any terms less than 0, so
|
even function, we don't need any terms less than 0, so
|
||||||
why *center* at zero and include negatives?
|
why *center* at zero and include negatives?
|
||||||
*/
|
*/
|
||||||
cosine = -1 + deg_2 - deg_4 + deg_6 - deg_8 + deg_10;
|
cosine = -1 + deg_2 - deg_4 + deg_6 - deg_8 + deg_10 - deg_12;
|
||||||
|
|
||||||
return cosine;
|
return cosine;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue