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 for Programming
 Forum for Origin C
 NE_QUAD_NO_CONV error on 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

Surst

Germany
1 Posts

Posted - 04/24/2013 :  05:23:49 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
OriginPro 0.0.0G (32-bit)
Windows XP

Hi everyone, I'm having problems with fitting using an integral. My code is as following

#pragma numlittype(push, TRUE)
#pragma warning(error : 15618)
#include <origin.h>

#include <oc_nag8.h>

struct user   // parameters in the integrand
{
	double c, dE, p, E1, E;
 
};
// Function supplied by user, return the value of the integrand at a given x.
static double NAG_CALL f_callback(double x, Nag_User *comm) 
{
        struct user *sp = (struct user *)(comm->p);
 
        double dE, p, E1, E, b;
        p = sp->p;
        E1 = sp->E1;
        dE = sp->dE;
        E = sp->E;
 
	double EE = E-x-E1;
	double arg = EE*EE/(dE*dE*2.0)-p*ln(E-E1);
	return (arg < 30) ? exp(-arg) : 0.0;
}

double epsabs = 1E-12, epsrel = 0.00001;
epsrel = ebs;
 
Integer max_num_subint = 500;
 
double result, abserr;
 
Nag_QuadProgress qp;
 
static NagError fail;
 
        Nag_User comm;	
struct user s;
        //s.c = c;
        s.dE = dE;
        s.p = p;
        s.E1 = E1;
        s.E = x;
        comm.p = (Pointer)&s;
        
if (x > E1)
	d01smc(f_callback, Nag_Infinite, Nag_Infinite, epsabs, epsrel, max_num_subint, &result, &abserr, &qp, &comm, &fail);
else
	result = 0.0;
 
 if (fail.code != NE_NOERROR)
 {
         result = 0.0;
         printf("%s\n", fail.message);
 }
 
if (fail.code != NE_INT_ARG_LT && fail.code != NE_BAD_PARAM && fail.code != NE_ALLOC_FAIL)
{
	NAG_FREE(qp.sub_int_beg_pts);
	NAG_FREE(qp.sub_int_end_pts);
	NAG_FREE(qp.sub_int_result);
	NAG_FREE(qp.sub_int_error);
}
 
y = b + c*result;

When I simulate the function (manage fit functions, F9), the function looks quite good, but for some parameters it got "holes" in it. This means, the numerical integration fails with the error "NE_QUAD_NO_CONV: The integral is probably divergent or slowly convergent." I'm pretty sure that it's not divergent, so are there parameters, with which I can give the calculation more time or something like this?

Thanks for helping.

Penn

China
644 Posts

Posted - 05/08/2013 :  10:08:47 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

You can change the max number of iterations, so to make the calculation more time. If you are using Origin 9, you can do it as following:

1. In NLFit dialog, select Settings tab, and then activate Advanced from the top-left panel.
2. In the top-right panel, find the tree node Fit Control: Iterations: Max. Number of Iterations, then change the number you want.

For more details, you can refer to this page.

Penn
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