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
 Modified Bessel Function

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
jadedungao Posted - 10/04/2004 : 12:18:13 PM
Origin Version (Select Help-->About Origin):
Operating System: XP

Hi! Does Origin have a built-in Modified Bessel function? thanks! jade

3   L A T E S T    R E P L I E S    (Newest First)
easwar Posted - 10/05/2004 : 1:41:14 PM
Hi Jade,

I suggest that you define the bessel_i2 function outside of NLSF, by adding it in a C file, such as adding to the LT_math.c file which contains the other NAG functions.

Then, you can do Set Column Value or use the Function Plotter to plot the function and see if it generates correct values. You may need to compare with some other product, or some tabulated values that the reference book you are using may have listed.

Once you have verified that your bessel_i2 function is generating correct values, then you can continue to access it from the main body of the fitting function as you are doing now.

Easwar
OriginLab



Edited by - easwar on 10/05/2004 1:42:26 PM
jadedungao Posted - 10/05/2004 : 02:22:29 AM
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
easwar Posted - 10/04/2004 : 2:52:14 PM
Hi Jade,

If you have version 6.1 or earlier, these functions are not available in Origin.

If you have version 7, the NAG library chapters that are included with Origin have a Special Functions chapter from which these functions are available. Look under Programming Help file and then under Global Functions->NAG Functions-> NAG Approximations of Special Functions.

If you have version 7.5, the functions are still accessible from NAG as mentioned above, but they are also wrapped in Origin C so that one could use them directly from script for set column values etc. Look under the Programming help files under the topic "Extended LabTalk Commands->Math".

Easwar
OriginLab



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