00001 #include <TooN/optimization/golden_section.h>
00002 #include <iostream>
00003 #include <cmath>
00004 #include <cstdlib>
00005
00006 using namespace TooN;
00007 using namespace std;
00008
00009
00010
00011 double f(double x)
00012 {
00013 return abs(x-1.2) + .2 * sin(5*x);
00014 }
00015
00016
00017 int main()
00018 {
00019 cout << golden_section_search(-3., .5, 3., f) << endl;
00020
00021 cout << "Value should be: " << " 1.2000 -0.0559 " << endl;
00022 }
00023