T O P I C R E V I E W |
Martin Helmholtz |
Posted - 06/09/2011 : 11:49:41 AM Origin Ver.8.0 and Service Release 4 Operating System: WINDOWS XP
Hi,
i would like to fit the following funktion: y=N+2*sum [(N-k)*cos(k*x*d)*exp(-(d/2pi)^2*x^2*nc*g+ln(pi*k)))*exp(-k^2*x^2*dd^2/2)] and the sum is from k=1 to k=N
Therefore wrote a little scrpit in the Fitting Function Organizer using a Y-Script: ***************************************** // Independent Variables x
// Dependnet Variables y
// Parameters nc, dd
double d=64.5; double g=0.5772; double vec=0; int N=100; int k=1;
for(k=1;k<=N;k+1){ vec +=(N-k)*cos(k*x*d)*exp(-(d/2/pi)^2*x^2*nc*(g+ln(pi*k)))*exp(-k^2*x^2*dd^2/2); } y=N+2*vec; ***************************************************
Now is the calculation very slow, exspecially for large N.
Is it possible to write this in a "Origin C" script to make it faster?
Regards, Martin |
1 L A T E S T R E P L I E S (Newest First) |
larry_lan |
Posted - 06/10/2011 : 01:30:16 AM So, it's a definite integral. You can call NAG library to do that if you use Origin C. But it's some what complicated. Here is an example.
http://wiki.originlab.com/~originla/howto/index.php?title=Tutorial:Fitting_with_Integral_using_NAG_Library
Thanks Larry |
|
|