[Developers] FW: [ADMB Users] mfexp looks wrong

Hans J. Skaug Hans.Skaug at math.uib.no
Thu Feb 28 06:48:29 PST 2013


Dave,

What is your recommendation: introduce mfexp2 or replace the existing mfexp?

Hans

-----Original Message-----
From: users-bounces at admb-project.org [mailto:users-bounces at admb-project.org] On Behalf Of dave fournier
Sent: Wednesday, February 27, 2013 6:36 PM
To: users at admb-project.org
Subject: Re: [ADMB Users] mfexp looks wrong


a complete twice differentiable version with different upper and lower
bounds b and  -c



double mfexp2(const double& x,double b,double c)
{
   if (x<=b && x>=-c)
   {
     return exp(x);
   }
   else if (x>b)
   {
     double y=x-b;
     double y2=square(y);
     return exp(b)*(1.+y/(1.+y) +1.5*y2/(1.+y2));
   }
   else
   {
     double y=-x-c;
     double y2=square(y);
     return 1.0/(exp(c)*(1.+y/(1.+y) +1.5*y2/(1.+y2)));
   }
}

_______________________________________________
Users mailing list
Users at admb-project.org
http://lists.admb-project.org/mailman/listinfo/users


More information about the Developers mailing list