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
 Double integral fit
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

hishamm

Israel
3 Posts

Posted - 12/22/2016 :  2:16:45 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi,
I have a function with double integral, I would like to ask how can I fit this function using Origin?
Thanks

Hisham

yuki_wu

896 Posts

Posted - 12/23/2016 :  12:39:01 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Hisham,

You can call a NAG function to perform higher dimension integral.

Please take a look at this tutorial that will show you how to create a fitting function with a definite integral using a NAG integration routine:
http://www.originlab.com/doc/Tutorials/Fitting-Integral-NAG

Different with the tutorial above, you need to call NAG function d01wcc to perform higher dimension integration.

An example of accessing NAG integrator d01wcc by using Origin C can be referred:
http://www.originlab.com/doc/OriginC/examples/OriginC-Quadrature-Integral#Multi-dimension_Integral_Function.28Origin80_SR0.29

Also, more information about NAG function d01wcc is available in the document:
http://www.originlab.com/pdfs/nagcl25/manual/pdf/d01/d01wcc.pdf

Regards and Merry Christmas!

Yuki
OriginLab
Go to Top of Page

hishamm

Israel
3 Posts

Posted - 12/26/2016 :  04:23:08 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi yuki_wu
Do you have any example of double integration using the idea you suggest?


Hisham
Go to Top of Page

yuki_wu

896 Posts

Posted - 12/27/2016 :  12:41:34 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Hisham,

Let me take a simple example:
1. I will fit the following model as illustrated:


2. Press F9 to open the Fitting Function Organizer dialog and then create a new function as below:


3. Click the button beside the Function box to open the code builder
4. Add the header file for the NAG functions.
#include <OC_nag.h>

5.Define your fitting model.

static double NAG_CALL f(Integer n, double z[], Nag_User *comm)
{
  double tmp_pwr;
  tmp_pwr = z[0]+z[1];
  return tmp_pwr;
}

6.Edit your fitting function.

void _nlsfnag_integration_fitting(
// Fit Parameter(s):
double amp,
// Independent Variable(s):
double x,
// Dependent Variable(s):
double& y)
{
    // Beginning of editable part
    Integer ndim = 2;  // the integral dimension
    Integer maxpts = 1000*2;  // maximum number of function evaluation 
    double a[4], b[4];
    Integer k;
	
    static NagError fail;
    double finval;
    Integer minpts;
    double acc, eps;
    Nag_User comm;
	
    for (k=0; k < 2; ++k)  // integration interval
    {
        a[k] = amp;
        b[k] = x;
    }
    eps = 0.0001; // set the precision
    minpts = 0;

    d01wcc(ndim, f, a, b, &minpts, maxpts, eps, &finval, &acc, &comm, &fail);
	
    y = finval;
    // End of editable part
}


7. Click Compile button, and then Return to Dialog
8. Click Save button
9. Click Simulate button to check the fitting function

Hope it helps.

Regards,
Yuki
OriginLab

Edited by - yuki_wu on 12/27/2016 12:50:47 AM
Go to Top of Page

hishamm

Israel
3 Posts

Posted - 12/27/2016 :  06:27:20 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Yuki_wu,
I tried as you explained the problem is in the compiling it show me an error like that:
C:\Users\admin\AppData\Local\OriginLab\93\TMP\OriginC\NLSF\_nlfDI.fit(18) :Error, Function argument n is not used inside the function body

C:\Users\admin\AppData\Local\OriginLab\93\TMP\OriginC\NLSF\_nlfDI.fit(18) :Error, Function argument z is not used inside the function body

C:\Users\admin\AppData\Local\OriginLab\93\TMP\OriginC\NLSF\_nlfDI.fit(17) :Error, error(s) found in compiling function f



How can I define it inside the function body??!!
Thank you for the help!


Hisham
Go to Top of Page

yuki_wu

896 Posts

Posted - 12/28/2016 :  12:29:25 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Hisham,

I may forget to mentioned that please remove these two lines at the beginning:

#pragma numlittype(push, TRUE)
#pragma warning(error : 15618)

Now you can try the example once again.

Regards,
Yuki
OriginLab
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