Ticket #11888: trac_11888-doctests.patch

File trac_11888-doctests.patch, 7.0 KB (added by kini, 8 years ago)

apply to $SAGE_ROOT/devel/sage

  • sage/functions/log.py

    # HG changeset patch
    # Parent b0c867efcf3e990324fa4b22c20166aa78f67187
    # User Keshav Kini <keshav.kini@gmail.com>
    # Date 1326194143 -28800
    
    trac #11888: fix docstring, doctests
    
    diff --git a/sage/functions/log.py b/sage/functions/log.py
    a b  
    443443
    444444class Function_lambert_w(BuiltinFunction):
    445445    r"""
    446         The principle branch of the Lambert W function `W_0(z)`.
     446    The principal branch of the Lambert W function `W_0(z)`.
    447447
    448         This function satisfies the equation:
     448    This function satisfies the equation
    449449
    450         .. math::
     450    .. math::
    451451
    452             z = W_0(z) e^{W_0(z)}
     452        z = W_0(z) e^{W_0(z)}
    453453
    454         IMPUT:
     454    INPUT:
    455455
    456         ``z`` - a complex number
     456    - ``z`` - a complex number
    457457
    458         ALGORITHM:
     458    ALGORITHM:
    459459
    460         Numerical evaluation is handled using the mpmath library.
     460    Numerical evaluation is handled using the mpmath library.
    461461
    462         REFERENCES:
     462    REFERENCES:
    463463
    464         http://en.wikipedia.org/wiki/Lambert_W_function
     464    - http://en.wikipedia.org/wiki/Lambert_W_function
    465465
    466         EXAMPLES::
     466    EXAMPLES::
    467467
    468             sage: lambert_w(1.0)
    469             0.567143290409784
    470             sage: lambert_w(-1).n()
    471             -0.318131505204764 + 1.33723570143069*I
    472             sage: lambert_w(-1.5 + 5*I)
    473             1.17418016254171 + 1.10651494102011*I
     468        sage: lambert_w(1.0)
     469        0.567143290409784
     470        sage: lambert_w(-1).n()
     471        -0.318131505204764 + 1.33723570143069*I
     472        sage: lambert_w(-1.5 + 5*I)
     473        1.17418016254171 + 1.10651494102011*I
    474474
    475             sage: lambert_w(RealField(100)(1))
    476             0.56714329040978387299996866221
     475        sage: lambert_w(RealField(100)(1))
     476        0.56714329040978387299996866221
    477477
    478             sage: S = solve(e^(5*x)+x==0, x, to_poly_solve=True)
    479             sage: z = S[0].rhs(); z
    480             -1/5*lambert_w(5)
    481             sage: N(z)
    482             -0.265344933048440
     478        sage: S = solve(e^(5*x)+x==0, x, to_poly_solve=True)
     479        sage: z = S[0].rhs(); z
     480        -1/5*lambert_w(5)
     481        sage: N(z)
     482        -0.265344933048440
    483483
    484        Check the defining equation numerically at `z=5`::
     484    Check the defining equation numerically at `z=5`::
    485485
    486             sage: N(lambert_w(5)*exp(lambert_w(5)) - 5)
    487             0.000000000000000
     486        sage: N(lambert_w(5)*exp(lambert_w(5)) - 5)
     487        0.000000000000000
     488    """
    488489
    489     """
    490490    def __init__(self):
    491491        """
    492492        See the docstring for :meth:`Function_lambert_w`.
  • sage/symbolic/random_tests.py

    diff --git a/sage/symbolic/random_tests.py b/sage/symbolic/random_tests.py
    a b  
    1414
    1515        sage: from sage.symbolic.random_tests import _mk_full_functions
    1616        sage: [f for (one,f,arity) in _mk_full_functions()]
    17         [Ei, abs, arccos, arccosh, arccot, arccoth, arccsc, arccsch,
    18         arcsec, arcsech, arcsin, arcsinh, arctan, arctan2, arctanh,
    19         binomial, ceil, conjugate, cos, cosh, cot, coth, csc, csch,
    20         dickman_rho, dilog, dirac_delta, elliptic_e, elliptic_ec,
    21         elliptic_eu, elliptic_f, elliptic_kc, elliptic_pi, erf, exp,
    22         factorial, floor, heaviside, imag_part, integrate,
    23         kronecker_delta, log, polylog, real_part, sec, sech, sgn, sin,
    24         sinh, tan, tanh, unit_step, zeta, zetaderiv]
     17        [Ei, abs, arccos, arccosh, arccot, arccoth, arccsc, arccsch, arcsec,
     18        arcsech, arcsin, arcsinh, arctan, arctan2, arctanh, binomial, ceil,
     19        conjugate, cos, cosh, cot, coth, csc, csch, dickman_rho, dilog,
     20        dirac_delta, elliptic_e, elliptic_ec, elliptic_eu, elliptic_f,
     21        elliptic_kc, elliptic_pi, erf, exp, factorial, floor, heaviside,
     22        imag_part, integrate, kronecker_delta, lambert_w, log, polylog,
     23        real_part, sec, sech, sgn, sin, sinh, tan, tanh, unit_step, zeta,
     24        zetaderiv]
    2525
    2626    Note that this doctest will fail whenever a Pynac function is added or
    2727    removed.  In that case, it is very likely that the doctests for
     
    234234        sage: from sage.symbolic.random_tests import *
    235235        sage: set_random_seed(2)
    236236        sage: random_expr(50, nvars=3, coeff_generator=CDF.random_element)
    237         (euler_gamma - v3^(-e) + (v2 - factorial(-e/v2))^(((2.85879036573 - 1.18163393202*I)*v2 + (2.85879036573 - 1.18163393202*I)*v3)*pi - 0.247786879678 + 0.931826724898*I)*arccsc((0.891138386848 - 0.0936820840629*I)/v1) - (0.553423153995 - 0.5481180572*I)*v3 + 0.149683576515 - 0.155746451854*I)*v1 + arccsch(pi + e)*elliptic_f(khinchin*v2, 1.4656989704 + 0.863754357069*I)
     237        -v1*elliptic_kc((0.0666829501658 + 0.206976992303*I)/(v3 + e))/v3 +
     238        heaviside(arccosh(-(abs(v2 -
     239        floor(-v3))^(-real_part(elliptic_e(-0.703991792631 + 0.750156228797*I,
     240        -(1.21734510331 - 1.22580558833*I)*pi*v1)))*e^(arctan2(imag_part(v2) -
     241        imag_part(floor(-v3)), real_part(v2) -
     242        real_part(floor(-v3)))*imag_part(elliptic_e(-0.703991792631 +
     243        0.750156228797*I, -(1.21734510331 -
     244        1.22580558833*I)*pi*v1)))*sin(-log(abs(v2 -
     245        floor(-v3)))*imag_part(elliptic_e(-0.703991792631 + 0.750156228797*I,
     246        -(1.21734510331 - 1.22580558833*I)*pi*v1)) - arctan2(imag_part(v2) -
     247        imag_part(floor(-v3)), real_part(v2) -
     248        real_part(floor(-v3)))*real_part(elliptic_e(-0.703991792631 +
     249        0.750156228797*I, -(1.21734510331 -
     250        1.22580558833*I)*pi*v1)))*imag_part(arccsc((0.891138386848 -
     251        0.0936820840629*I)/v1)) - abs(v2 -
     252        floor(-v3))^(-real_part(elliptic_e(-0.703991792631 + 0.750156228797*I,
     253        -(1.21734510331 - 1.22580558833*I)*pi*v1)))*e^(arctan2(imag_part(v2) -
     254        imag_part(floor(-v3)), real_part(v2) -
     255        real_part(floor(-v3)))*imag_part(elliptic_e(-0.703991792631 +
     256        0.750156228797*I, -(1.21734510331 -
     257        1.22580558833*I)*pi*v1)))*cos(-log(abs(v2 -
     258        floor(-v3)))*imag_part(elliptic_e(-0.703991792631 + 0.750156228797*I,
     259        -(1.21734510331 - 1.22580558833*I)*pi*v1)) - arctan2(imag_part(v2) -
     260        imag_part(floor(-v3)), real_part(v2) -
     261        real_part(floor(-v3)))*real_part(elliptic_e(-0.703991792631 +
     262        0.750156228797*I, -(1.21734510331 -
     263        1.22580558833*I)*pi*v1)))*real_part(arccsc((0.891138386848 -
     264        0.0936820840629*I)/v1)) + v3^(-0.48519994364 - 0.485764091302*I) +
     265        0.0909404921682*real_part(v3)/(real_part(v3)^2 + imag_part(v3)^2) +
     266        0.281538203756*imag_part(v3)/(real_part(v3)^2 + imag_part(v3)^2) -
     267        0.647983235144*real_part(v1) - 1.20665952957*imag_part(v1))*v1))
    238268        sage: random_expr(5, verbose=True)
    239         About to apply dirac_delta to [1]
    240         About to apply arccsch to [0]
    241         About to apply <built-in function add> to [0, arccsch(0)]
    242         arccsch(0)
     269        About to apply <built-in function mul> to [v1, e]
     270        About to apply <built-in function div> to [v1*e, 1]
     271        v1*e
    243272    """
    244273    vars = [(1.0, sage.calculus.calculus.var('v%d' % (n+1))) for n in range(nvars)]
    245274    if ncoeffs is None: