Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #include <locale.h>
- int main()
- {
- setlocale(LC_ALL, "russian");
- double x, e, Sl, Sr;//e - эпсилон, Sl - сумма правой части, Sr - сумма правой части.
- int n = 0;
- double chff(double x1){//Функция гипербалического коссинуса
- double S;
- S = (exp(x1)+exp(0-x1))/2;
- return S;
- }
- double fac(double x1){//Функция факториала
- double S;
- S = 1;
- for(double i = 1.; i <= x1; i++){
- S *= i;
- }
- return S;
- }
- printf("Введите значение x: ");
- scanf("%lf", &x);
- Sl = chff(x);
- printf("Введите эпсилон: ");
- scanf("%lf", &e);
- Sr = 1;
- while (fabs(Sl-Sr)>e && n < 1000){
- n++;
- Sr += (pow(x, 2*n))/(fac(2*n));
- }
- if (n==1000){
- printf("За 1000 шагов функция не сошлась");
- }else{
- printf("Левая часть = %lf, Правая часть = %lf, Вычесленно за %d шагов.", Sl, Sr, n);
- }
- scanf("%lf", &e);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement