Advertisement
greedydev

Untitled

Sep 21st, 2022
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.27 KB | None | 0 0
  1. // Calculate the sine of x with precision of eps
  2. double mysin(double x, double eps) {
  3.     double y = 0;
  4.     double term = x;
  5.     int i = 1;
  6.     while (fabs(term) > eps) {
  7.         y += term;
  8.         term = -term * x * x / ((2 * i) * (2 * i + 1));
  9.         i++;
  10.     }
  11.     return y;
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement