The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Fittiing a function involving an integral using OC
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

csuguosheng

UK
Posts

Posted - 02/23/2007 :  07:32:11 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.0
Operating System:WinXP
Expression£ºy=integral[p1^2*(p2+x)/(p3+x)^2]dp2,from 0 to 500, where x is the independent var, y is the dependent var, p1,p3 are parameters.

I have seen posts about the similiar problem, solutions are given in http://www.originlab.com/www/support/resultstech.aspx?language=english&ID=121.
But I know only a little about scripts, so I still don't know what to do. A very easy to follow example to use LabTalk to solve the problem was given in http://www.originlab.com/forum/topic.asp?TOPIC_ID=3812. But LabTalk takes more than one hour for my fitting.
So my question is, can anyone give an similar procedure using Origin C, which is easy to follow?
Thanks!
Sheng

zachary_origin

China
Posts

Posted - 02/26/2007 :  8:50:39 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Sheng,

When I am trying to write the OC code for the function, I find it is easy to get the symbolic integeration of the expression. So why not use the integrated result for fitting?

Zachary
OriginLab Technical Services.



Edited by - zachary_origin on 02/27/2007 04:08:01 AM
Go to Top of Page

csuguosheng

UK
Posts

Posted - 02/27/2007 :  03:17:53 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks zachary. Actually the function I gave is not the original function I use for fitting. For the sake of easy reading I just showed an example. The function I need cannot be integrated analytically, i.e, it has to be integrated numerically.
The function is: y=(P4^2/(P4^2+x^2))*Integrate[exp(-z)/((P1+P2*x)^2+(z-P3*x)^2)]dz,z from 0 to 500,where x is the dependent parameter;y is the independent parameter; P1,P2,P3,P4 are the fitting parameters.
I can use TabTalk to do the fitting but it takes too long(more than an hour sometime).So I wonder using Origin C may shorten the running time.
Look forward to see your response!
Thanks again!
Sheng
Go to Top of Page

zachary_origin

China
Posts

Posted - 02/27/2007 :  03:58:32 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply

double dU = 500.0; // the upper endpoint of the interval
double dL = 0.0; // the lower endpoint of the interval
double z;
int nSteps = 100; // the integrating interval will be broken into nsteps for calculation. this will affect the fitting speed and precision.
double dz = (dU-dL)/(double)nSteps;
double dFz; // F(z);
double dFzz; // F(z+dz);
double dInteg = 0.0;
for (int ii=0; ii<nSteps; ii++)
{
if(ii==0)
dFz = exp(-z)/((P1+P2*x)*(P1+P2*x)+(z-P3*x)*(z-P3*x));
else
dFz = dFzz;
z += dz;
dFzz = exp(-z)/((P1+P2*x)*(P1+P2*x)+(z-P3*x)*(z-P3*x));
dInteg += 0.5*(dFz+dFzz)*dz;
}
y = P4*P4*dInteg/(P4*P4+x*x);



Zachary
OriginLab Technical Services.

Go to Top of Page

csuguosheng

UK
Posts

Posted - 02/27/2007 :  04:08:58 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks so much zachary. I will try the codes soon.
Sheng
Go to Top of Page

csuguosheng

UK
Posts

Posted - 03/05/2007 :  12:06:13 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello Zachary,
I tried your codes to do the fitting just now. The fitting doesn't work... it just says "Chi-sqr is not reduced.
Total 0 rounds in this session"
I don't know what's the problem.Is it possible for me to send you my data for fitting by email?
My email address is csuguosheng@yahoo.com.
Thanks!
Go to Top of Page

zachary_origin

China
Posts

Posted - 03/05/2007 :  9:10:10 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Sheng,

You can send the data to tech@originlab.com or zachary@originlab.com.cn with a note on this posted topic.

Zachary
OriginLab Technical Services.




Edited by - zachary_origin on 03/05/2007 9:14:31 PM
Go to Top of Page

csuguosheng

UK
Posts

Posted - 03/06/2007 :  03:24:22 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks zachary!
I have sent you the data.
Really appreciate your kind help!
Sheng
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000