check(a,b) = my(t = abs((a-b)/b)); if (t, ceil(log(t)/log(10)), -oo);

default(realprecision, 211);
pi=Pi;

localbitprec(620); v = vector(128,n,n*sin(1/n));
\p115
check(limitnum(n -> n*sin(1/n)), 1)
check(limitnum(v), 1)
check(limitnum(n -> n^2*sin(1/n^2),2), 1)
check(limitnum(n -> (1+1/n)^n), exp(1))

f(n) = n! / (n^n*exp(-n)*sqrt(2*Pi*n));
asympnum(f)
bestappr(asympnumraw(f,10), 2^60)
asympnum(n->log(1+1/n^2),2)[1..17]

\p115
asympnum(n->log(1+1/n^pi),pi)[1..17]
bestappr(asympnumraw(n->log(1+1/n^pi),17,pi),2^60)
asympnum(v)

\p38
log(limitnum(n->(1+1/n)^n))
limitnum(n->sum(j=1,n,sqrt(j)/j^2),1/2) - zeta(3/2)

limitnum(n->n^2*(1-cos(1/n)),2)

v2(N,mul = 1) =
{ my(q = mul*N, V);
  if (q == 1, return ([1/3]));
  V = vector(q); V[1] = V[2] = 1;
  for(n = 2, q - 1,
    V[n+1] = ((2*n + 1)*V[n] + 3*(n - 1)*V[n-1]) / (n + 2));
  f = (n -> 3^n / n^(3/2));
  return (vector(N, n, V[n*mul] / f(n*mul)));
}
limitnum(v2) > 1e6
limitnum(N->v2(N,10))-3/sqrt(12*Pi)

h(n)=
{ \\ 1.612 makes a difference between 32-bit/64-bit archs
  localbitprec(ceil(bitprecision(1.) * 1.8));
  my(a=1,A=1,B=1.);
  vector(n, i, a=B/i; A+=a; B+=A; a);
}
H=h(1849);
b(n)=log(H[n])-(2*sqrt(n)-3/4*log(n));
localprec(57); C=-1/2-log(2*sqrt(Pi));
check(limitnum(n->b(n^2)), C)
check(limitnum(n->b(20*n), 1/2), C)
asympnum(n->b(n^2)-C)
asympnum(n->lngamma(n+1)-(n+1/2)*log(n)+n-1/2*log(2*Pi))
asympnum(a->if(a%40==0,a^(-5/2)*I,0))

\\ Errors, keep at end
asympnum(1)
limitnum(1)
limitnum(n->1,-1)
