#include "optbase.h"
double f(double *x)
{
//return 1.5*x[0]*x[0] + 0.5*x[1]*x[1] - x[0]*x[1] -2*x[0];{-2, 4}
//return (x[0] - 2)*(x[0] - 2)*(x[0] - 2)*(x[0] - 2) + (x[0] - 2*x[1])*(x[0] - 2*x[1]);{0, 3}
return 100*(x[1] - x[0]*x[0])*(x[1] - x[0]*x[0]) + (1 - x[0])*(1 - x[0]);//{0,0}
//return x[0]*x[0]*(4 - 2.1*x[0]*x[0] + x[0]*x[0]*x[0]*x[0]/3) + x[0]*x[1] - 4*x[1]*x[1]*(1 - x[1]*x[1]);//{+-0.1,0}{+-1.5,0}
//return x[0]*x[0]*(x[0]*x[0] - 14) + x[1]*x[1]*(x[1]*x[1] - 38) - 24*x[0] + 120*x[1];//{0,0}{-2,1}{-2,3.01}{2,3}
//return 0.1*x[0]*(x[0]-1)*(x[0]-4)*(x[0]-7) + 0.1*x[1]*(x[1]-2)*(x[1]-5)*(x[1]-8) + 0.1*x[2]*(x[2]-3)*(x[2]-6)*(x[2]-9);//{0,0,0}{3,0,0}{0,5,-2}{0,5,0}{0,3,-1}{5,0,7}{3,0,4}{3,0,5}
}
int main(int argc, char** argv)
{
int n = 2;
float x1, x2;
x1 = atof(argv[1]);
x2 = atof(argv[2]);
double start[] = {x1, x2};
double opt[n];
conjugate(f, n, start, opt, 20, 1, 1.2, 1e-3);
print(opt, n);
return 0;
}