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
 digamma function for curve fitting
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

friedman

USA
4 Posts

Posted - 09/30/2015 :  12:52:25 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 2015
Operating System:Mac with crossover

I want to define a NL fitting function that includes the digamma function. How do I do this?

Hideo Fujii

USA
1582 Posts

Posted - 10/01/2015 :  3:13:06 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi friedman,

Origin includes NAG numerical library which contains polygamma function in the category of Approximations
of Special Functions:
http://www.nag.com/numeric/CL/nagdoc_cl09/html/S/sconts.html#s

You can define your user-defined fit function which calls a NAG function. You see the following tutorial to learn
how to call a NAG function from your fit function definition:
http://www.originlab.com/doc/Tutorials/Fitting-Integral-NAG

I hope the above information is helpful.

--Hideo Fujii
OriginLab
Go to Top of Page

friedman

USA
4 Posts

Posted - 10/02/2015 :  11:23:42 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
That example is for integration. I want to fit to a function:

F(C*x/p)-F(C*x/(p-2*A))-2*F(C*x/(p+A+B))

Where F(z)=ln(z)+digamma(0.5+1/z) and A,B,C are constants, p is the fitting parameter, and x is the independent variable. I know I need to somehow use the NAG function s15aec.

I don't see how to do this given the example suggested. I don't know how to program in C whatsoever. I can only copy and paste the example, which doesn't really apply here.
Go to Top of Page

friedman

USA
4 Posts

Posted - 10/02/2015 :  11:46:20 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Here's my code:

What is wrong? It keeps saying "too many arguments passed to function."
#pragma numlittype(push, TRUE)
#pragma warning(error : 15618)
#include <origin.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 <OC_nag8.h>

// Add code here for other Origin C functions that you want to define in this file,
// and access in your fitting function.

// 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.


//----------------------------------------------------------
//
void _nlsflocalization(
// Fit Parameter(s):
double tp, double y0,
// Independent Variable(s):
double x,
// Dependent Variable(s):
double& y)
{
const double ta=1;
const double tb=1;
const double tc=1;
// Beginning of editable part

static NagError fail1;
static NagError fail2;
static NagError fail3;
double part1 = tc*x/tp;
double part2 = tc*x/(tp-2*ta);
double part3 = tc*x/(tp+ta+tb);
y= y0*(ln(part1) + s15aec(part1,0, &fail1) - ln(part2) - s15aec(part2,0, &fail2)-2*ln(part3)-2*s15aec(part3,0,&fail));
if(fail1.code !=NE_NOERROR)
printf("%s\n",fail1.message);
if(fail2.code !=NE_NOERROR)
printf("%s\n",fail2.message);
if(fail3.code !=NE_NOERROR)
printf("%s\n",fail2.message);

// End of editable part
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