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
 All Forums
 Origin Forum
 Origin Forum
 Y-Script vs. C

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

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

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000