-florian66-

cos s

Jan 1st, 2017
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.20 KB | None | 0 0
  1. float cos(float x, int n)
  2. {
  3. int a = 8*n - 6;
  4. int b = 4*n*n - 2*n; // 2n(2n-1)
  5. float s = 1;
  6.  
  7. int i;
  8.  
  9. x = x*x; //x²
  10.  
  11. for(i=0;i<n;i++)
  12.     {
  13.     s = 1 - x*s/b;
  14.     b -= a;
  15.     a -= 8;
  16.     }
  17.  
  18. return s;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment