/* Example program for the praxis package */ #include "praxis.h" /* function to be minimized, array c contains the parameters, n their number) */ double energy(double* c, int* n) { double eng; eng = c[0]*c[0]+(c[1]-1.0)*(c[1]-1.0) +c[2]*c[2] +(c[3]+1.0)*(c[3]+1.0); return eng; } void main(void) { double fmin; double c[4]; c[0] = 2.5; c[1] = 2.5; c[2] = 17.0; c[3] = 2.5; fmin = praxis(energy, c, 4); /* This calls the minimization code arguments are the name of the function to be minimized, the array of parameters c and their number n */ printf("Energy : %f\n", fmin); printf(" %3.5f %3.5f %3.5f %3.5f\n", c[0], c[1], c[2], c[3]); }