function(x,k=10){ # this function computes the upper tail probability K(x) # for the limit distribution of D*sqrt((m+n)/(m*n)) # to an absolute error of epsilon 1e-7 epsilon = 1e-7 j = seq(1,k,1) y = 2*sum(((-1)^(j+1))*exp(-2*j^2*x^2)) k2=2*k j = seq(1,k2,1) y2 = 2*sum(((-1)^(j+1))*exp(-2*j^2*x^2)) if(y2==0) return(0) while(abs(y2-y)> epsilon){ k=k2 y=y2 k2=2*k j = seq(1,k2,1) y2=2*sum((-1)^(j+1)*exp(-2*j^2*x^2)) } list(y2,k2) }