Advertisement
Guest User

Untitled

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