Origin Version: OriginPrp 8 SR0
Operating System: Windows 7
Hi everyone,
My name is Helena, I'm trying to adjust some experimental data through a function that has an integral, and it has the following form:

The integral is about "x" (independent variable of my integral) and the fit is about "t" (independent variable of my fitting), to make this fit I used the "Nag function" as indicated by the tutorials. The code is as follows:
#include <origin.h>
#include <oc_nag8.h>
struct user // parameters in the integrand
{
double Kan,temp;
};
static double NAG_CALL f_callback(double x, Nag_User *comm)
{
struct user *sp = (struct user *)(comm->p);
double Kan,temp,Mv,Dm,sigma,u0,H,kb,T,t0,A,B,C,E;
Mv=170356;
Dm=12.6E-9;
sigma=0.45;
u0=1.256E-6;
H=130000;
kb=1.3807E-23;
T=300;
t0=1E-9;
A=Mv*exp(2*sigma*sigma)/(Dm*sqrt(2*PI)*sigma);
B=u0*PI*Mv*H/(6*kb*T);
C=PI/(6*kb*T);
E=u0*Mv*H/2;
Kan = sp->Kan;
temp = sp->temp;
return A * exp((log(x/Dm))^2/(2*sigma*sigma))*((1/tanh(B*x*x*x))-(1/(B*x*x*x)))*(1-exp(-(temp/t0)*((1-(E/Kan)^2)*(1-(E/Kan))*exp(-Kan*C*x^3*(1-(E/Kan))^2)+(1-(E/Kan)^2)*(1+(E/Kan))*exp(-Kan*C*x^3*(1+(E/Kan))^2))));
}
//----------------------------------------------------------
//
void _nlsffuncionintegral(
// Fit Parameter(s):
double k,
// Independent Variable(s):
double t,
// Dependent Variable(s):
double& y)
{
// Beginning of editable part
double epsabs = 0.00001, epsrel = 0.0001;
Integer max_num_subint = 200;
double result, abserr;
Nag_QuadProgress qp;
Nag_User comm;
struct user s;
s.Kan = k;
s.temp = t;
comm.p = (Pointer)&s;
d01smc(f_callback, 1E-7, 1E-9,epsabs, epsrel, max_num_subint, &result, &abserr, &qp, &comm, &fail);
if (fail.code != NE_NOERROR)
printf("%s\n", fail.message);
//if (fail.code != NE_INT_ARG_LT && fail.code != NE_BAD_PARAM && fail.code != NE_ALLOC_FAIL)
//{
//NAG_FREE(qp.sub_int_beg_pts);
//NAG_FREE(qp.sub_int_end_pts);
//NAG_FREE(qp.sub_int_result);
//NAG_FREE(qp.sub_int_error);
//}
y = result;
// End of editable part
}
I do not have problems when compiling, but when simulating the function or when trying to fit it, the only thing I obtain is a constant line with zero value.
What can I do in this case? I would greatly appreciate your help.