Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- main()
- {
- float k=0, x, u=(x*x)/2, r, s=u, es=1e-3;
- while (fabs(u)>=es)
- {
- r=(pow(-1, k+1)*pow(x,k+2))/(k+1);
- u*=r;
- s+=u;
- k++;
- }
- cout<<"Sum = "<<s;
- getch();
- }
- main()
- {
- int n=0, u=1;
- float eps=1e-3, s=u, s1, x;
- while (abs(u)>=eps)
- {
- n++;
- u=pow(-1,n)*n;
- s+=u;
- }
- s1=1/(1-x);
- if (fabs(s-s1)<=eps) cout<<"To4noe zna4enie";
- else cout<<"Neto4noe zna4enie";
- getch();
- }
- const double eps = 1e-8;
- double series(double x, double epsilon)
- {
- double term = x*x/2.0, sum = term;
- for(int k = 0; fabs(term) > epsilon; ++k)
- {
- sum += (term *= -x*(k+1)/double((k+2)*(k+3)));
- }
- return sum;
- }
- int main(int argc, const char * argv[])
- {
- for(double x = -1.0; x <= 1.0; x += 0.1)
- {
- cout << fixed << setprecision(2) << setw(5) << x
- << setprecision(10) << setw(15) << series(x,eps) << endl;
- }
- }
- const double eps = 1e-8;
- double series(double x, double epsilon)
- {
- double term = 1.0, sum = term;
- while(fabs(term) > epsilon)
- {
- sum += term *= x;
- }
- return sum;
- }
- int main(int argc, const char * argv[])
- {
- for(double x = -0.9; x <= 0.9; x += 0.1)
- {
- cout << fixed << setprecision(2) << setw(5) << x
- << setprecision(10) << setw(15) << series(x,eps)
- << setw(15) << (1.0/(1-x)) << endl;
- }
- }
Add Comment
Please, Sign In to add comment