Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_DEPRECATE
- #include <stdio.h>
- #include <math.h>
- #include <locale.h>
- #include <conio.h>
- #define PI 3.1415926535
- double taylor_sin(double x0, double prev, int step, int max) {
- double cur = -prev * x0*x0 / ((2 * step - 1)*(2 * step - 2));
- if (step < max)
- return cur + taylor_sin(x0, cur, ++step, max);
- else
- return cur;
- }
- double sin_t(double x0, int max) {
- return x0 + taylor_sin(x0, x0, 2, max);
- }
- int main()
- {
- setlocale(LC_ALL, "rus");
- setlocale(LC_NUMERIC, "eng");
- printf("%lf", sin_t(PI, 10));
- _getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement