Advertisement
TrickmanOff

Untitled

Apr 14th, 2020
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. ld l = -1e4, r = 1e4;
  2.     ld x1 = l + (r-l)*phi2;
  3.     ld x2 = r - (r-l)*phi2;
  4.     ld f1 = f(x1, d), f2 = f(x2, d);
  5.    
  6.     while(r - l > e) {
  7.         if(d == 0) {
  8.             int tmp = 1;
  9.         }
  10.         if(f1 < f2) {
  11.             r = x2;
  12.             x2 = x1;
  13.             f2 = f1;
  14.             x1 = l + (r-l)*phi2;
  15.             f1 = f(x1, d);
  16.         }
  17.         else {
  18.             l = x1;
  19.             x1 = x2;
  20.             f1 = f2;
  21.             x2 = r - (r-l)*phi2;
  22.             f2 = f(x2, d);
  23.         }
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement