Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <complex>
  4. #include <cstring>
  5. using namespace std;
  6.  
  7.  
  8. int n,a=0,b=2;
  9. double y,x,step, min=INT_MAX, res;
  10. cout << "How much portions ";
  11. cin >> n;
  12. step =(double)(b-a)/n;
  13. x = a;
  14. for(int i= 0; i<n; i++){
  15.     x+=step;
  16.     y = log10(cosh(x))-tanh(x)+0.5;
  17.     if(min > y){
  18.         min = y;
  19.         res = x;
  20.     }
  21. }
  22.     cout << "The min value is  "<<min<<"   The answer is  "<< res<<endl;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement