Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ld l = -1e4, r = 1e4;
- ld x1 = l + (r-l)*phi2;
- ld x2 = r - (r-l)*phi2;
- ld f1 = f(x1, d), f2 = f(x2, d);
- while(r - l > e) {
- if(d == 0) {
- int tmp = 1;
- }
- if(f1 < f2) {
- r = x2;
- x2 = x1;
- f2 = f1;
- x1 = l + (r-l)*phi2;
- f1 = f(x1, d);
- }
- else {
- l = x1;
- x1 = x2;
- f1 = f2;
- x2 = r - (r-l)*phi2;
- f2 = f(x2, d);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment