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
 Y-Script vs. C
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Martin Helmholtz

1 Posts

Posted - 06/09/2011 :  11:49:41 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

larry_lan

China
Posts

Posted - 06/10/2011 :  01:30:16 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
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