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
 Double integration using NAG and d01sjc
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

tskisiu

Poland
Posts

Posted - 12/16/2010 :  11:02:05 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 8.1SR3
Operating System: WinXP

I would be very grateful if someone could help me with the following problem:
I am fitting :

my function has three fitting parameters: R, L, I0
the code is as follows:
#pragma warning(error : 15618)
#include <origin.h>
#include <oc_nag8.h>
struct user
{
double R, L, fitX;
};
static double NAG_CALL f_callback(double alfa, Nag_User *comm)
{
struct user *sp = (struct user *)(comm->p);
double R_2,L_2, fitX, Rdependent, Ldependent,cylinder;

R_2=sp->R;
L_2=sp->L;
fitX=sp->fitX;
Rdependent=2*J1(fitX*R_2*sin(alfa))/(fitX*R_2*sin(alfa));
Ldependent=sin(0.5*fitX*L_2*cos(alfa))/(fitX*L_2*cos(alfa));
cylinder=Rdependent*Ldependent*Rdependent*Ldependent*sin(alfa);
return (cylinder);
}

//----------------------------------------------------------
//
void _nlsfCylinderFormFactor(
// Fit Parameter(s):
double I0, double R, double L,
// Independent Variable(s):
double x,
// Dependent Variable(s):
double& y)
{
// Beginning of editable part
double epsabs = 0.00001, epsrel = 0.0000001, result, abserr;
Integer max_num_subint = 100;
Nag_QuadProgress qp;
static NagError fail;

Nag_User comm;
struct user s;
s.R = R;
s.L = L;
s.fitX = x;
comm.p = (Pointer)&s;

d01sjc(f_callback, 0.0, PI/2.0, epsabs, epsrel, max_num_subint, &result, &abserr, &qp, &comm, &fail);



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 = I0*result;
}

I am using integrator d01sjc to integrate f_callback over all alpha range, and it works very well. Now, I would like to introduce function w(L) so that the total fitting expression is:


How should I do it? I would be grateful for any suggestions, but a code example would be best.
  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