Compare commits

...

2 commits

Author SHA1 Message Date
a51c11701f Turns out, it only needed to be degree 10! 2022-10-09 12:09:07 -05:00
664c0d433a Smol documentation 2022-10-09 12:08:55 -05:00
2 changed files with 5 additions and 13 deletions

View file

@ -1,6 +1,9 @@
#ifndef _ARCH_UNISTD_ILP_H #ifndef _ARCH_UNISTD_ILP_H
#define _ARCH_UNISTD_ILP_H #define _ARCH_UNISTD_ILP_H
/*
32-bit ISA, 32-bit int, long, pointer, and offset_t
*/
#define _POSIX_V6_ILP32_OFF32 1 #define _POSIX_V6_ILP32_OFF32 1
#define _POSIX_V7_ILP32_OFF32 1 #define _POSIX_V7_ILP32_OFF32 1

View file

@ -10,14 +10,13 @@
The taylor poly is centered at pi, with a radius of The taylor poly is centered at pi, with a radius of
convergence of no less than pi, making it roughly accurate convergence of no less than pi, making it roughly accurate
between 0 and 2 * pi. The polynomial is up to x^20, so it between 0 and 2 * pi. The polynomial is up to x^10, which I've
should be pretty accurate within that range. confirmed as being accurate being 0 and 2 * pi.
*/ */
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;
double deg_12, deg_14, deg_16, deg_18, deg_20;
double cosine; double cosine;
if(x < 0) x = -x; if(x < 0) x = -x;
@ -44,11 +43,6 @@ 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);
deg_14 = deg_12 * deg_2 * 2 / (14 * 13);
deg_16 = deg_14 * deg_2 * 2 / (16 * 15);
deg_18 = deg_16 * deg_2 * 2 / (18 * 17);
deg_20 = deg_18 * deg_2 * 2 / (20 * 19);
/* /*
In case you aren't familiar with the theory of a Taylor In case you aren't familiar with the theory of a Taylor
@ -79,13 +73,8 @@ double cos(double x) {
Plus, since we're taking advantage of cosine being an Plus, since we're taking advantage of cosine being an
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?
(Of course, I've not done the radius of convergence work
for this to find out how many degrees we need to get a
radius of convergence of pi, so I may have used too many
terms, anyways. Not that I can't reduce that...)
*/ */
cosine = -1 + deg_2 - deg_4 + deg_6 - deg_8 + deg_10; cosine = -1 + deg_2 - deg_4 + deg_6 - deg_8 + deg_10;
cosine = cosine - deg_12 + deg_14 - deg_16 + deg_18 + deg_20;
return cosine; return cosine;
} }