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
 Origin Forum
 Sum in fit function
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

espenhjo

Norway
20 Posts

Posted - 09/18/2003 :  02:47:26 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi,
I have a function containing a sum of n functions with n going from 1 to infinite (or in practice from 1 to 100). How should I write this function in the NLSF?
Do I have to implement some sort of loop in the function with accumulating values, or should I use an integral instead?

Regards,
Espen

easwar

USA
1965 Posts

Posted - 09/20/2003 :  2:24:07 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Espen,

Please take a look at this knowledge base item and see if this applies to you:
http://www.originlab.com/www/support/resultstech.asp?ItemID=121&VersionID=All&CatID=Fitting&TypeID=Tip&Language=Details&TitleID=Fitting+with+Integrals+<!--+math+data+NLSF+-->

If not, please post more details, such as the expression, or contact your local tech support office for more help.

Easwar
OriginLab.

Go to Top of Page

espenhjo

Norway
20 Posts

Posted - 09/22/2003 :  05:35:44 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks Easwar,
I found some help in the article “Fitting with Integrals”. I am not completely satisfied though, so I’ll tell you what my problem is.
I have one dataset for the independent variable, q, and one set of experimental values constituting the dependent variable, E. There is one unknown parameter, a, that I want to extract from the NLSF. The other parameters, D and big delta, are known.

The equation looks like:


What I figured out is that I could exchange the summation with an integral and set n to a high number, e.g. 100 or 1000. By guessing the value for a, the integral part of the equation could be calculated for each q and build a dataset in a column. The next column would then give the integrals using the integral command on the previous column. We then store a as a temporary parameter (e.g. STORE). Then the full equation could be calculated in the next dataset. The experimental data is then set equal to this last dataset. The whole sequence is then run again if a has changed.
What do you think? Does this sound as a good solution? Could anyone help me with some code here that is Origin C compatible?

Regards,
Espen
Go to Top of Page

espenhjo

Norway
20 Posts

Posted - 09/22/2003 :  05:45:28 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I guess it's hard for you to see the equation as long as it is situated on my harddisk!
Here it is:

Go to Top of Page

easwar

USA
1965 Posts

Posted - 09/22/2003 :  1:27:25 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Espen,

Thanks for posting more details and the equation etc. I gather that you have Origin 7 and so can use Origin C in NLSF.

With Origin C, you do not have to use a dataset to compute the sum, but can do this directly inside the funciton.

Let me take a simple equation to illustrate.
Say, your fitting function is:
E(q) = q^2 + Summation_over_n(n * q / a)
where a is a fitting parameter.

Define a new function in NLSF where you specify 'a' as the fitting parameter, and then name the indep var as 'q' and dep var as 'E'.
Click the 'Edit in Code Builder' button, and enter the following in the editable region:
// Beginning of editable part
double dSum = 0;
for(int n = 1; n < 101; n++)
{
dSum += n * q / a;
}
E = q^2 + dSum;

You can then try fitting with this function. May want to simulate some data with this function, add some random noise to the simulation, and fit that with the function to see how it works. Note here that the summation is from 1 to 100. You could define a Constant in NLSF to hold the limit to which the summation should be performed, rather than hard coding it in the function.

Hope this helps and you can change this to incorporate your function.

Easwar
OriginLab.

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