Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <complex>
- #include <cstring>
- using namespace std;
- int n,a=0,b=2;
- double y,x,step, min=INT_MAX, res;
- cout << "How much portions ";
- cin >> n;
- step =(double)(b-a)/n;
- x = a;
- for(int i= 0; i<n; i++){
- x+=step;
- y = log10(cosh(x))-tanh(x)+0.5;
- if(min > y){
- min = y;
- res = x;
- }
- }
- cout << "The min value is "<<min<<" The answer is "<< res<<endl;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement