bridge/class-master/depend/pari/src/basemath/trans3.c
/* Lambert W function using Newton, increasing prec */
Lambert W function using Newton, increasing prec
Lambert W function using Newton increasing prec
GEN
mplambertW(GEN y)
{
  pari_sp av = avma;
  GEN x;
  long p = 1, s = signe(y);
  ulong mask = quadratic_prec_mask(realprec(y)-1);
  if (s<0) pari_err_DOMAIN("Lw", "y", "<", gen_0, y);
  if(s==0) return rcopy(y);
  x = mplambertW0(rtor(y, LOWDEFAULTPREC));
  while (mask!=1)
  {
    p <<= 1; if (mask & 1) p--;
    mask >>= 1;
    x = rtor(x, p+2);
    x = mulrr(x, divrr(subsr(1, mplog(divrr(x,y))),addrs(x,1)));
  }
  return gerepileuptoleaf(av,x);
}
GEN mplambertW ( GEN y ) { pari_sp av = avma ; GEN x ; long p = 1 , s = signe ( y ) ; ulong mask = quadratic_prec_mask ( realprec ( y ) - 1 ) ; if ( s < 0 ) pari_err_DOMAIN ( " " , " " , " " , gen_0 , y ) ; if ( s == 0 ) return rcopy ( y ) ; x = mplambertW0 ( rtor ( y , LOWDEFAULTPREC ) ) ; while ( mask != 1 ) { p <<= 1 ; if ( mask & 1 ) p -- ; mask >>= 1 ; x = rtor ( x , p + 2 ) ; x = mulrr ( x , divrr ( subsr ( 1 , mplog ( divrr ( x , y ) ) ) , addrs ( x , 1 ) ) ) ; } return gerepileuptoleaf ( av , x ) ; }
Lambert W function using Newton, increasing prec
Lambert W function using Newton increasing prec