Author |
Topic  |
|
espenhjo
Norway
20 Posts |
Posted - 09/18/2003 : 02:47:26 AM
|
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 |
|
espenhjo
Norway
20 Posts |
Posted - 09/22/2003 : 05:35:44 AM
|
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
|
 |
|
espenhjo
Norway
20 Posts |
Posted - 09/22/2003 : 05:45:28 AM
|
I guess it's hard for you to see the equation as long as it is situated on my harddisk! Here it is:

|
 |
|
easwar
USA
1965 Posts |
Posted - 09/22/2003 : 1:27:25 PM
|
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.
|
 |
|
|
Topic  |
|
|
|