f(t)=4*besselk(0,2*Pi*t);
G = gammamellininvinit([0,0]);
g(t)=gammamellininv(G,t);
{
  for(a=1,30,
    for(b=-5,5,
      my(z = a/12+I*b/6, e = exponent(f(z)-g(z)));
      if(e > -101, warning(z,":",e))))
}

GR(s)=Pi^-(s/2)*gamma(s/2);
gmellininv(Vga)=
{ my(c = 1,A,B,T);
  localbitprec(getlocalbitprec()+64);
  my(f(s) = prod(i=1,#Vga,GR(s+Vga[i])));
  A = [-oo,Pi/2];
  B = [+oo,Pi/2];
  T = intfuncinit(t=A,B, f(c + I*t));
  z->my(a=-log(z));intnum(t=A,B, exp(a*I*t), T)*exp(a*c) / (2*Pi);
}

chk(Vga,f,t) = exponent(f(t)-gammamellininv(Vga,t));
L=[[0],[1],[1/2],[3/2],[0,0],[0,1/2],[0,1],[0,2],[0,3],[0,0,0],[0,0,1/2],[0,0,1],[0,1,1],[0,1,2],[0,1,3/2],[0,0,0,0,0]];
M=apply(gmellininv,L);
S=[1/2,3/2,2,3,4, 1/2+I,3/2+I,2+I,3+I,4+I];
{
  for(i=1,#L,
    my(G = gammamellininvinit(L[i]));
    for(j=1,5, \\ gmellininv does not support complex z
      my(e = chk(G,M[i],S[j]));
      if(e > -121, warning([1,i,j],":",e))));
}

chkd(v,w,t)=exponent(derivnum(s=t,gammamellininv(v,s))-gammamellininv(w,t));
{
  for(i=1,#L,
    my(v); if(1, localbitprec(320); v = gammamellininvinit(L[i]));
    my(w = gammamellininvinit(L[i], 1));
    for(j=1,#S,
      if(j<=5 || denominator(L[i])==1,
        my(e = chkd(v,w,S[j]));
        if(e > -117, warning([2,i,j], ":", e)))));
}

{
  my(e = exponent(gammamellininv([0,1/2,1,3/2],5)-2^(3/2)*exp(-4*Pi*sqrt(5))));
  if (e > -128, error("[0,1/2,1,3/2]:5",":",d));
}

gammamellininv([0],121.)
gammamellininv(1,0)

G = gammamellininvinit([1], 2);
a(z) = 4*Pi*z*exp(-Pi*z^2)*(2*Pi*z^2-3);
f(z) = exponent(a(z) - gammamellininv(G,z));
f(I)
f(2+I)

chk(f)= my(a = f()); localbitprec(getlocalbitprec()+64); exponent(a - f());
chk(()->gammamellininv([0,10^-38],3/10))
chk(()->gammamellininv([0,1+10^-38],3/10))
chk(()->gammamellininv([1/2,1/2+10^-38],3/10))
chk(()->gammamellininv([0,1/2,1/2+10^-38,10^-38],3/10))
chk(()->gammamellininv([0,1/2,10^-38,10^-38],3/10))

gammamellininvasymp([0],10)
gammamellininvasymp([0,1/2],10)

gammamellininvasymp(1,10)
gammamellininv(1,1)
gammamellininv(gammamellininvinit(1),1)

localprec(100); gammamellininvinit([1/3*I,-1/3*I]); \\#2283

localbitprec(220); gammamellininvinit(concat(vector(5,i,[0,1])));
gammamellininvinit(vector(9,i,1));

localbitprec(180);gammamellininvinit([-2,-2,-1,-1,0,0,1]); \\#2502

\\ERRORS
gammamellininvasymp([])
gammamellininvinit([])
gammamellininvinit(x,-2)
