[ADMB Users] mfexp looks wrong

dave fournier davef at otter-rsch.com
Wed Feb 27 09:29:41 PST 2013


It certainly looks like the function mfexp
is not differentiable at b.



dvariable mfexp(const prevariable& x, double b)
   {
     if (x<=b && x>=-b)
     {
       return exp(x);
     }
     else if (x>b)
     {
       return exp(b)*(1.+2.*(x-b))/(1.+x-b);
     }
// etc
}



Also for df1b2 caclculations it should be three times differentiable.
something like

double mfexp2(double x,double b)
{
   if (x<=b && x>=-b)
   {
     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));
   }
//etc

}
appears to be twice differentiable at b.














More information about the Users mailing list