SHARE
TWEET

Untitled

a guest Sep 22nd, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top