Origin Version (Select Help-->About Origin): 7.5 SR4
Operating System: Window XP Professional
I'm trying to fit the data with a function, which includes summation and integral. The fitting function is
y(x) = P1*sum(n=0 to k){F(n,P2,P3,x)+G(P4,x)*integral[H(n,P2,P3,P4,s),s=0 to x]}.
where, P1..P4 are the fitting parameters.
I'm not good at Origin C. After reading several topics in the forum, I wrote some codes for fitting. But, it took half a day to fit the data. I want to reduce the fitting time. But, I don't know what to do. I believe there is someone who help me solve this problem.
My code is as follows.
double dSum = 0;
int ser=nsum;
double dU = x;
double dL = 0.0;
double b = dL;
int nSteps = nint;
double db = (dU-dL)/nSteps;
double dF;
double dFF;
double dInteg = 0.0;
for(int n = 0; n < ser; n++)
{
for (int ii = 0; ii < nSteps; ii++)
{
if (ii == 0)
dF = H(n,P2,P3,P4,s);
else
dF = dFF;
b += db;
dFF = H(n,P2,P3,P4,s);
dInteg += 0.5*(dF + dFF)*db;
}
dSum += F(n,P2,P3,x)+G(P4,x)*dInteg;
}
y = P1*dSum;
Here I set the values of nsum and nint to fixed ones. For nsum=60 and nint=500, it took more than 8 hours. The number of data was ~ 500.