Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- double Sh(double x, double eps)
- {
- double an = x, sum = an;
- int i = 0;
- while (fabs(an) > eps)
- { an *= -(x*x)/((2*i+1)*(2*i+2));
- sum += an;
- i++;
- }
- return sum;
- }
- double Sder(double x, double eps)
- {
- double an = 1, sum = an;
- int i = 0;
- while (fabs(an) > eps)
- { an *= -(((x*x*(2*i+3)))/((2*i+1)*(2*i+1)*(2*i+2)));
- sum += an;
- i++;
- }
- return sum;
- }
- int main()
- {
- double x, eps;
- for (x=0; x<=1.8; x+=0.1)
- {
- cout << "\nSh(" << x << ") = " << Sh(x, eps);
- cout<<"\nSder(" << x << ") = " << Sder(x, eps);
- cout<<"\nSright(" << x << ") = " << (Sh(x+0.1,eps)-Sh(x, eps))/0.1;
- cout<<"\nSleft(" << x << ") = " << (Sh(x, eps)-Sh(x-0.1,eps))/0.1;
- cout<<"\nSaver(" << x << ") = " << (Sh(x+0.1, eps)-Sh(x-0.1,eps))/0.2;
- cout << "\nxcos(" << x << ") = "<< x*cos(x);
- cout << "\n" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment