Browse Source

add cos function

master
fdai7848 11 months ago
parent
commit
ae634ac3a2
  1. 1
      src/exponent.h
  2. 21
      src/reihen.c
  3. 1
      src/reihen.h

1
src/exponent.h

@ -3,6 +3,5 @@
double p(double exp, double base);
double powerD(double exp, double base);
double absD(double x);
#endif // exponent.h

21
src/reihen.c

@ -42,7 +42,6 @@ double pi(double eps){
}
double sinD(double degrees){
if (degrees>=360.0){
degrees = squashDegreesTo360(degrees);
}
@ -61,3 +60,23 @@ double sinD(double degrees){
}
return sum;
}
double cosD(double degrees){
if (degrees>=360.0){
degrees = squashDegreesTo360(degrees);
}
double sum = 0.0;
double currvalue;
double radian = radians(degrees);
double power;
unsigned long long faculty;
for (int i = 0; i <= 9; i++)
{
currvalue = 1.0;
currvalue *= powerD(2*i, radian);
currvalue /= fac(2*i);
if(i%2==0) sum += currvalue;
else sum -= currvalue;
}
return sum;
}

1
src/reihen.h

@ -6,5 +6,6 @@ double euler();
double pi();
double radians(double degrees);
double sinD(double degrees);
double cosD(double degrees);
#endif // reihen.h
Loading…
Cancel
Save