Degree 16, final answer
This commit is contained in:
parent
c73b94f5f9
commit
d9b8e481aa
1 changed files with 4 additions and 2 deletions
|
@ -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, deg_12;
|
||||
double deg_2, deg_4, deg_6, deg_8, deg_10, deg_12, deg_14, deg_16;
|
||||
double cosine;
|
||||
|
||||
if(x < 0) x = -x;
|
||||
|
@ -44,6 +44,8 @@ double cos(double x) {
|
|||
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);
|
||||
deg_14 = deg_12 * deg_2 * 2 / (14 * 13);
|
||||
deg_16 = deg_14 * deg_2 * 2 / (16 * 15);
|
||||
|
||||
/*
|
||||
In case you aren't familiar with the theory of a Taylor
|
||||
|
@ -75,7 +77,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 - deg_12;
|
||||
cosine = -1 + deg_2 - deg_4 + deg_6 - deg_8 + deg_10 - deg_12 + deg_14 - deg_16;
|
||||
|
||||
return cosine;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue