Advertisement
Guest User

Untitled

a guest
Nov 15th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | None | 0 0
  1. #define _CRT_SECURE_NO_DEPRECATE
  2. #include <stdio.h>
  3. #include <math.h>
  4. #include <locale.h>
  5. #include <conio.h>
  6.  
  7. #define PI 3.1415926535
  8.  
  9. double taylor_sin(double x0, double prev, int step, int max) {
  10.     double cur = -prev * x0*x0 / ((2 * step - 1)*(2 * step - 2));
  11.  
  12.     if (step < max)
  13.         return cur + taylor_sin(x0, cur, ++step, max);
  14.  
  15.     else
  16.         return cur;
  17. }
  18.  
  19.  
  20. double sin_t(double x0, int max) {
  21.     return x0 + taylor_sin(x0, x0, 2, max);
  22. }
  23.  
  24. int main()
  25. {
  26.     setlocale(LC_ALL, "rus");
  27.     setlocale(LC_NUMERIC, "eng");
  28.  
  29.     printf("%lf", sin_t(PI, 10));
  30.  
  31.     _getch();
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement