Fit1.cin

From TORI
Jump to navigation Jump to search

// Fit1.cin is routine that approximate tetration to base \(b=\exp(a)\) for \(0.05<a<2\) ; \(\mathrm{tet}_b(z)\) is approximated for \(|z|<1\) using the fruncated Taylor expansion of

// \(\mathrm{tet}_b(z) - \ln(z+2)\)

// keeping cubic terms. This is provides accuracy sufficient to make the camera–ready plots of tetration for moderate values of the imaginary part of the argument; in particular, it can be used for real values of the argument.

z_type old0(z_type d){ z_type q=sqrt(d); return -1.0018
+(0.15128484821526975*(1.+33.04715298851381*q-3.51771875598067*d)*q)/
(1.+3.2255053261256337*q) +   (-0.5 + log(2.))/d;}
z_type old1(z_type d){ z_type q=sqrt(d); return
1.1 - 2.608785958462561*(1. - 0.6663562294911147*sqrt(d))*
  sqrt(d) - (-0.625 + log(2.) )/d ;}
z_type old2(z_type d){ z_type q=sqrt(d); return
-0.96 + 3.0912038297987596*(1.+0.6021398048785328*d)*q/(1. + 4.240467556480155*d)  + 
 (-0.6666666666666666 + log(2.))/d;}
z_type old3(z_type d){ z_type q=sqrt(d); return 1.2 - 10.44604984418533*
(1.+0.2137568928431227*q+0.3693275254470449*d)*q/
(1.+4.95715636660691*q + 7.70233216637738*d)
- ( - 131./192. + log(2.))/d ;}
z_type new0(z_type d){ z_type q=sqrt(d); return 
       q*(0.137467 + q*(4.94969 + q*0.0474179))/( 1. + q*(3.23171 + q*0.471222)) + 
       (-(1./2.)+log(2.))/d -1.;}
z_type new1(z_type d){ z_type q=sqrt(d); return 
q*(-0.424278 +q*(1.75166 +q*(-1.46524 + q*0.93347)))/
( 0.0312142+q*(-0.267478 + q)) + (-(5./8.) + log(2.))/d -1. ;} 
z_type new2(z_type d){ z_type q=sqrt(d); return 
q*(3.39255 + q*(16.1046 +q*(-19.5216 + q*10.7458)))/
( 1. + q*(4.1274 + q*5.25449)) + (-(2./3.) + log(2.))/d -1.;}
z_type new3(z_type d){ z_type q=sqrt(d); return  // This is not misprint, there is d, not q.
0.16*q*(1. + q*(27.7934 + q*(358.688 +q*(-259.233 + d*61.6566))))/
     (1. - 8.1192*q + 37.087*d) + (-131./192. + log(2))/d -1. ;}
z_type git(z_type d, z_type x) { 
if(Re(d)>log(2.))
return  new0(d)+x*(new1(d)+x*(new2(d)+x*new3(d))); 
return  old0(d)+x*(old1(d)+x*(old2(d)+x*old3(d)));
}
z_type fit1(z_type d, z_type x) { DB L=log(2.);
               if(Re(d)<.001) { if(Re(x)>-1) return 1.;
                                if(Re(x)<-1) return -990.; }
               return (x+1.)*(git(d,x)*x+1.)+ log(x+2.)/d - log(2.)/d*(1.+x);}
 z_type FIT1(z_type d,z_type z){ 
       if(Re(d)<.03) { if(Re(z)<-1.) return (-30.); return 1.;}
   if(Re(z)<-.5)return log(FIT1(d,z+1.))/d;
   if(Re(z)>.5) return exp(d*FIT1(d,z-1.));
    return fit1(d,z);}

// Approximation of \(\mathrm{tet}_b(z)\) can be extracted as FIT1(log(b),z)