# HG changeset patch
# User Michael Yurko <myurko@gmail.com>
# Date 1263834424 18000
# Node ID b432d0632e2faf9cf6b43c93497368e4e73f67ea
# Parent 38c92a750c105b4d90fb3df018199fae5b4bc155
Add the non-offset logarithmic integral, li(x).
diff -r 38c92a750c10 -r b432d0632e2f 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 38c92a750c10 -r b432d0632e2f 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, |
… |
… |
|
367 | 366 | finally: |
368 | 367 | mp.mp.prec = old_prec |
369 | 368 | return mp.mpmath_to_sage(mp_ret,prec) |
| 369 | |
| 370 | def li(x, prec = None): |
| 371 | r""" |
| 372 | Computes li(x). |
| 373 | |
| 374 | This is the function |
| 375 | |
| 376 | .. math:: |
| 377 | |
| 378 | mathrm{li}(x) = int_0^x frac{1}{log t} , dt |
| 379 | |
| 380 | Note that li has a singularity at x = 1 and will return -infinity and |
| 381 | that this function is different from Li(x), the offset logarithmic |
| 382 | integral. |
| 383 | |
| 384 | |
| 385 | ALGORITHM: Computed using mpmath. |
| 386 | |
| 387 | INPUT: |
| 388 | |
| 389 | |
| 390 | - ``x`` - a number. |
| 391 | |
| 392 | |
| 393 | OUTPUT: |
| 394 | |
| 395 | |
| 396 | - ``li(x)`` - a number |
| 397 | |
| 398 | |
| 399 | EXAMPLES:: |
| 400 | |
| 401 | sage: li(2) |
| 402 | 1.04516378011749 |
| 403 | sage: li(2) |
| 404 | 1.04516378011749 |
| 405 | sage: li(5) |
| 406 | 3.63458831003265 |
| 407 | sage: li(1000) |
| 408 | 177.609657990152 |
| 409 | sage: li(10^5) |
| 410 | 9629.80900105080 |
| 411 | sage: prime_pi(10^5) |
| 412 | 9592 |
| 413 | sage: li(1+i) |
| 414 | 0.613911669221196 + 2.05958421419258*I |
| 415 | sage: li(100-100*i) |
| 416 | 32.0130215797631 - 20.9049537358912*I |
| 417 | sage: li(1) |
| 418 | -infinity |
| 419 | |
| 420 | """ |
| 421 | if prec == None: |
| 422 | try: |
| 423 | prec = x.prec() |
| 424 | except AttributeError: |
| 425 | prec = 53 |
| 426 | import sage.libs.mpmath.all as mp |
| 427 | return mp.call(mp.li,x,prec=prec) |
370 | 428 | |
371 | 429 | from sage.rings.polynomial.polynomial_real_mpfr_dense import PolynomialRealDense |
372 | 430 | |