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
 Double integral fit

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
hishamm Posted - 12/22/2016 : 2:16:45 PM
Hi,
I have a function with double integral, I would like to ask how can I fit this function using Origin?
Thanks

Hisham
5   L A T E S T    R E P L I E S    (Newest First)
yuki_wu Posted - 12/28/2016 : 12:29:25 AM
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
hishamm Posted - 12/27/2016 : 06:27:20 AM
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
yuki_wu Posted - 12/27/2016 : 12:41:34 AM
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
hishamm Posted - 12/26/2016 : 04:23:08 AM
Hi yuki_wu
Do you have any example of double integration using the idea you suggest?


Hisham
yuki_wu Posted - 12/23/2016 : 12:39:01 AM
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

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