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