Thanks! Btw, I'm using Origin 7.5 demo version.
I checked the NAG library, but it contains In(x,1) or I1(x) and I0(x) only. I need the I2(x). I tried to make one for I2(x), using NLSF user defined function, but I don't know if I'm doing it right. The reference for the modified bessel function (in series form) is Arfken and Weber,Mathematical Methods for Physicist , 5th ed, pg 710.
#include <stdio.h>
#include <data.h>
#include <math.h>
#include <utilities.h>
// Add your special include files here.
// For example, if you want to fit with functions from the NAG library,
// add the header file for the NAG functions here.
#include <NAG\OCN_s.h>
// Add code here for other Origin C functions that you want to define in this file,
// and access in your fitting function.
double factorial(int x)
{
int i;
double factx = 1;
for(i=1; i<=x ; i++ )
factx *= i;
return factx;
}
double bessel_i2(double y)
{
int v=2.0;
double Isum;
for(int s = 1; s < 101; s++)
Isum += (1.0/(factorial(s)*factorial(s+v)))*pow((y/2.0),2.0*s + v);
return Isum;
}
// You can access C functions defined in other files, if those files are loaded and compiled
// in your workspace, and the functions have been prototyped in a header file that you have
// included above.
// You can access NLSF object methods and properties directly in your function code.
// You should follow C-language syntax in defining your function.
// For instance, if your parameter name is P1, you cannot use p1 in your function code.
// When using fractions, remember that integer division such as 1/2 is equal to 0, and not 0.5
// Use 0.5 or 1/2.0 to get the correct value.
// For more information and examples, please refer to the "User-Defined Fitting Function"
// section of the Origin Help file.
//----------------------------------------------------------
// FRAP Model for Diffusion Type-Uniform Circular Beam
void _nlsfAxelrod_eqn14(
// Fit Parameter(s):
double tau, double K, double countk,
// Independent Variable(s):
double t,
// Dependent Variable(s):
double& fk)
{
// Beginning of editable part
double dsum=0;
double y=2.0*tau/t;
double bessel_i0=nag_bessel_i0(y);
for(int k=0;k<=countk;k++)
{
int w=2*k+2;
dsum += (pow(-1, k) * factorial(w) * factorial(k+1) * pow(tau/t,k+2.0))/(pow(factorial(k),2.0) * pow(factorial(k+2),2));
}
fk = 1- (tau/t) * exp(-y) * (bessel_i0+ bessel_i2(y)) + 2*dsum;
// End of editable part
}
Edited by - jadedungao on 10/05/2004 03:41:08 AM