I was wrong! Degree 12!

This commit is contained in:
Kat R. 2022-10-09 12:11:07 -05:00
parent a51c11701f
commit c73b94f5f9

View file

@ -16,7 +16,7 @@
double cos(double x) {
double pi = M_PI; /* Really, me?! -Kat */
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;
if(x < 0) x = -x;
@ -43,6 +43,7 @@ double cos(double x) {
deg_6 = deg_4 * deg_2 * 2 / (6 * 5);
deg_8 = deg_6 * deg_2 * 2 / (8 * 7);
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
@ -74,7 +75,7 @@ double cos(double x) {
even function, we don't need any terms less than 0, so
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;
}