# HG changeset patch
# User Michael Yurko <myurko@gmail.com>
# Date 1256420492 14400
# Node ID 2a871d1a48d07eda4e716c7c61d08637c7bb3927
# Parent 1fac9be25e7f4993428e2d758c570143ab1707c6
Add the nonoffset logarithmic integral, li(x).
diff r 1fac9be25e7f r 2a871d1a48d0 sage/functions/all.py
a

b


26  26  from transcendental import (exponential_integral_1, 
27  27  gamma_inc, incomplete_gamma, 
28  28  zeta, zeta_symmetric, 
29   Li, Ei, 
 29  Li, li, Ei, 
30  30  dickman_rho) 
31  31  
32  32  from special import (bessel_I, bessel_J, bessel_K, bessel_Y, 
diff r 1fac9be25e7f r 2a871d1a48d0 sage/functions/transcendental.py
a

b


24  24  import sage.rings.complex_field as complex_field 
25  25  import sage.rings.real_double as real_double 
26  26  import sage.rings.complex_number 
27   from sage.gsl.integration import numerical_integral 
28  27  
29  28  from sage.rings.all import (is_RealNumber, RealField, 
30  29  is_ComplexNumber, ComplexField, 
… 
… 

344  343  finally: 
345  344  mp.mp.prec = old_prec 
346  345  return mp.mpmath_to_sage(mp_ret,prec) 
 346  
 347  def li(x, prec = None): 
 348  r""" 
 349  Computes li(x). 
 350  
 351  This is the function 
 352  
 353  .. math:: 
 354  
 355  mathrm{li}(x) = int_0^x frac{1}{log t} , dt 
 356  
 357  Note that li has a singularity at x = 1 and will return infinity and 
 358  that this function is different from Li(x), the offset logarithmic 
 359  integral. 
 360  
 361  
 362  ALGORITHM: Computed using mpmath. 
 363  
 364  INPUT: 
 365  
 366  
 367   ``x``  a number. 
 368  
 369  
 370  OUTPUT: 
 371  
 372  
 373   ``li(x)``  a number 
 374  
 375  
 376  EXAMPLES:: 
 377  
 378  sage: li(2) 
 379  1.04516378011749 
 380  sage: li(2) 
 381  1.04516378011749 
 382  sage: li(5) 
 383  3.63458831003265 
 384  sage: li(1000) 
 385  177.609657990152 
 386  sage: li(10^5) 
 387  9629.80900105080 
 388  sage: prime_pi(10^5) 
 389  9592 
 390  sage: li(1) 
 391  infinity 
 392  
 393  """ 
 394  if prec == None: 
 395  try: 
 396  prec = x.prec() 
 397  except AttributeError: 
 398  prec = 53 
 399  import sage.libs.mpmath.all as mp 
 400  return mp.call(mp.li,x,prec=prec) 
347  401  
348  402  import math 
349  403  def _one_over_log(t): 