Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <cmath>
- using namespace std;
- void tabl(double *, double *, double *);
- double sum(double *, double *, int *);
- int main1()
- {
- double a = -0.9, b = 0.9, eps = 0.0001;
- cout << "\t\t" << "x" << "\t\t" << "F(x)" << "\t\t\t" << "sum" << "\t\t\t" << "n" << endl;
- tabl(&a,&b,&eps);
- system("pause");
- return 0;
- }
- void tabl(double *a, double *b, double *eps)
- {
- int n=0;
- for (double x = *a; x < *b; x += (*b - *a) / 10)
- {
- cout << "\t\t" << x << "\t\t" << cos(x - 4) << "\t\t" << sum(&x, eps, &n);
- cout << "\t\t" << n << endl;
- }
- }
- double sum(double *x, double *eps, int *n)
- {
- double s = 0, chis = 1, znam = 1;
- *n = 0;
- while (fabs(chis/znam)>*eps)
- {
- s += chis / znam;
- *n += 1;
- chis *= (-(4 - *x)*(4 - *x));
- znam *= 2 * (*n)*(2 * (*n) - 1);
- }
- return s;
- }
Add Comment
Please, Sign In to add comment