Hi I am new to using alglib, and I want to use the following code, but for my own equation of parameter estimation, therefore I have replaced the function and x and y data points with mine, however I cannot get it to successfully compute.

Please can anyone see my mistake?

Thanks

Alex Walker

**Code:**

#include "stdafx.h"

#include <stdlib.h>

#include <stdio.h>

#include <math.h>

#include "interpolation.h"

using namespace alglib;

void function_debt_func(const real_1d_array &c, const real_1d_array &x, double &func, void *ptr)

{

//

// this callback calculates f(c,x)=c[0]*(1+c[1]*(pow(x[0]-1999,c[2])-1))

//

//func = c[0]*(1+c[1]*(pow(x[0]-1999,c[2])-1));

func = (1/(c[0]*c[1]))*(c[2]-asinh(sinh(c[2])*exp(c[0]*x[0]*2*pi())));

}

int main(int argc, char **argv)

{

real_2d_array x = "[1,2,3,4,5]";

real_1d_array y = "[1.9, 1.7, 1.45, 1.3, 1.2]";

real_1d_array c = "[1, 1, 1]";

double epsf = 0;

double epsx = 1.0e-5;

real_1d_array bndl = "[-inf, -10, 0.1]";

real_1d_array bndu = "[+inf, +10, 2.0]";

real_1d_array s = "[1, 1, 1]";

ae_int_t maxits = 0;

ae_int_t info;

lsfitstate state;

lsfitreport rep;

double diffstep = 1.0e-5;

lsfitcreatef(x, y, c, diffstep, state);

lsfitsetcond(state, epsf, epsx, maxits);

lsfitsetbc(state, bndl, bndu);

lsfitsetscale(state, s);

alglib::lsfitfit(state, function_debt_func);

lsfitresults(state, info, c, rep);

printf("%d\n", int(info)); // EXPECTED: 2

printf("%s\n", c.tostring(-2).c_str()); // EXPECTED: [4.142560E+12, 0.434240, 0.565376]

return 0;

}

My function is the line func = ...