Skip to content

Instantly share code, notes, and snippets.

@DemianD
Created August 16, 2018 14:10
Show Gist options
  • Save DemianD/c2a6f9c034da72d9816aa21aa989ef18 to your computer and use it in GitHub Desktop.
Save DemianD/c2a6f9c034da72d9816aa21aa989ef18 to your computer and use it in GitHub Desktop.
mijn_sinus.c
#include <math.h>
#include <stdio.h>
float mijn_sinus(float radials) {
int i = 3;
float teller = radials;
int noemer = 1;
float som = teller / noemer;
while(fabs(teller/noemer) > 0.00001) {
teller = teller * radials * radials * -1;
noemer = i * (i-1) * noemer;
som += teller / noemer;
i += 2;
}
return som;
}
int main() {
printf("%f \n", sin(2));
printf("%f \n", mijn_sinus(2));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment