Ticket #6111: trac_6111-stein_referee.patch

File trac_6111-stein_referee.patch, 14.8 KB (added by was, 10 years ago)
  • doc/en/constructions/plotting.rst

    # HG changeset patch
    # User William Stein <wstein@gmail.com>
    # Date 1243227412 25200
    # Node ID 28779f9a33ec032cfdf35379b907afd1ece4859e
    # Parent  049029db5fa8ea5fb301e48fc65ab1ca799fa4d3
    6111 -- william stein referee patch
    
    diff -r 049029db5fa8 -r 28779f9a33ec doc/en/constructions/plotting.rst
    a b  
    3939    sage: f3 = lambda x:exp(x)
    4040    sage: f4 = lambda x:sin(2*x)
    4141    sage: f = Piecewise([[(0,1),f1],[(1,2),f2],[(2,3),f3],[(3,10),f4]])
    42     sage: P = f.plot()
     42    sage: f.plot()
    4343
    4444Other function plots can be produced as well:
    4545
     
    9292
    9393    sage: L = [[1+5*cos(pi/2+pi*i/100), tan(pi/2+pi*i/100)*\
    9494    ...   (1+5*cos(pi/2+pi*i/100))] for i in range(1,100)]
    95     sage: p = line(L, rgbcolor=(1/4,1/8,3/4))
     95    sage: line(L, rgbcolor=(1/4,1/8,3/4))
    9696
    9797A blue hypotrochoid (3 leaves):
    9898
     
    101101    sage: n = 4; h = 3; b = 2
    102102    sage: L = [[n*cos(pi*i/100)+h*cos((n/b)*pi*i/100),\
    103103    ...   n*sin(pi*i/100)-h*sin((n/b)*pi*i/100)] for i in range(200)]
    104     sage: p = line(L, rgbcolor=(1/4,1/4,3/4))
     104    sage: line(L, rgbcolor=(1/4,1/4,3/4))
    105105
    106106A blue hypotrochoid (4 leaves):
    107107
     
    110110    sage: n = 6; h = 5; b = 2
    111111    sage: L = [[n*cos(pi*i/100)+h*cos((n/b)*pi*i/100),\
    112112    ...   n*sin(pi*i/100)-h*sin((n/b)*pi*i/100)] for i in range(200)]
    113     sage: p = line(L, rgbcolor=(1/4,1/4,3/4))
     113    sage: line(L, rgbcolor=(1/4,1/4,3/4))
    114114
    115115A red limaçon of Pascal:
    116116
     
    118118
    119119    sage: L = [[sin(pi*i/100)+sin(pi*i/50),-(1+cos(pi*i/100)+cos(pi*i/50))]\
    120120    ...   for i in range(-100,101)]
    121     sage: p = line(L, rgbcolor=(1,1/4,1/2))
     121    sage: line(L, rgbcolor=(1,1/4,1/2))
    122122
    123123A light green trisectrix of Maclaurin:
    124124
     
    126126
    127127    sage: L = [[2*(1-4*cos(-pi/2+pi*i/100)^2),10*tan(-pi/2+pi*i/100)*\
    128128    ...   (1-4*cos(-pi/2+pi*i/100)^2)] for i in range(1,100)]
    129     sage: p = line(L, rgbcolor=(1/4,1,1/8))
     129    sage: line(L, rgbcolor=(1/4,1,1/8))
     130
     131
     132A green lemniscate of Bernoulli (we omit i==100 since that would give a 0 division error):
     133
     134::
     135
     136    sage: v = [(1/cos(-pi/2+pi*i/100), tan(-pi/2+pi*i/100)) for i in range(1,200) if i!=100 ]
     137    sage: L = [(a/(a^2+b^2), b/(a^2+b^2)) for a,b in v]
     138    sage: line(L, rgbcolor=(1/4,3/4,1/8))
    130139
    131140
    132141.. index:: plot;curve using surf
  • sage/calculus/all.py

    diff -r 049029db5fa8 -r 28779f9a33ec sage/calculus/all.py
    a b  
    1 ## from calculus import (SymbolicExpressionRing,
    2 ##                       is_SymbolicExpressionRing,
    3 ##                       is_SymbolicExpression,
    4 ##                       is_SymbolicVariable,
    5 ##                       CallableSymbolicExpressionRing,
    6 ##                       is_CallableSymbolicExpressionRing,
    7 ##                       is_CallableSymbolicExpression,
    8 ##                       is_SymbolicExpression,
    9 ##                       is_SymbolicExpressionRing)
    10 
    111from calculus import maxima as maxima_calculus
    122from calculus import (laplace, inverse_laplace,
    133                      limit, lim, clear_functions)
  • sage/calculus/calculus.py

    diff -r 049029db5fa8 -r 28779f9a33ec sage/calculus/calculus.py
    a b  
    339339    -  ``b`` - (optional) upper endpoint of definite
    340340       integral
    341341
    342     - ``algorithm`` - (default: 'maxima')
     342    - ``algorithm`` - (default: 'maxima')  one of
     343
     344              - 'maxima' - use maxima (the default)
     345             
     346              - 'sympy' - use sympy (also in Sage)
     347             
     348              - 'mathematica_free' - use http://integrals.wolfram.com/
    343349
    344350    EXAMPLES::
    345351
     
    438444    We integrate the same function in both Mathematica and Sage (via
    439445    Maxima)::
    440446
     447        sage: _ = var('x, y, z')
    441448        sage: f = sin(x^2) + y^z
    442449        sage: g = mathematica(f)                           # optional  -- requires mathematica
    443         sage: print g                                      # optional
     450        sage: print g                                      # optional -- requires mathematica
    444451                  z        2
    445452                 y  + Sin[x ]
    446         sage: print g.Integrate(x)                         # optional
     453        sage: print g.Integrate(x)                         # optional -- requires mathematica
    447454                    z        Pi                2
    448455                 x y  + Sqrt[--] FresnelS[Sqrt[--] x]
    449456                             2                 Pi
    450457        sage: print f.integral(x)
    451458        y^z*x + 1/8*((I - 1)*sqrt(2)*erf((1/2*I - 1/2)*sqrt(2)*x) + (I + 1)*sqrt(2)*erf((1/2*I + 1/2)*sqrt(2)*x))*sqrt(pi)
     459
     460    Alternatively, just use algorithm='mathematica_free' to integrate via Mathematica
     461    over the internet (deos NOT require a mathematica license!)::
     462
     463        sage: _ = var('x, y, z')
     464        sage: f = sin(x^2) + y^z
     465        sage: f.integrate(algorithm="mathematica_free")       # optional -- requires internet
     466        sqrt(pi)*sqrt(1/2)*fresnels(sqrt(2)*x/sqrt(pi)) + y^z*x
     467
     468    We can also use Sympy::
     469
     470        sage: _ = var('x, y, z')
     471        sage: (x^y-z).integrate(y)
     472        -y*z + x^y/log(x)
     473        sage: (x^y-z).integrate(y,algorithm="sympy")
     474        -y*z + x^y/log(x)
     475   
    452476       
    453477    We integrate the above function in maple now::
    454478
     
    13011325        sage: g.substitute_function(cr, (sin(x) + cos(x)).function(x))
    13021326        -(sin(a) - cos(a))*b
    13031327
    1304     In Sage 4.0, basic arithmetic with unevaluated functions is not
     1328    In Sage 4.0, basic arithmetic with unevaluated functions is no
    13051329    longer supported::
    13061330   
    13071331        sage: x = var('x')
     
    13741398
    13751399def dummy_diff(*args):
    13761400    """
    1377     This function is called when when 'diff' appears in a Maxima
    1378     string.
     1401    This function is called when 'diff' appears in a Maxima string.
    13791402
    13801403    EXAMPLES::
    13811404
  • sage/calculus/functional.py

    diff -r 049029db5fa8 -r 28779f9a33ec sage/calculus/functional.py
    a b  
    171171   
    172172    ::
    173173   
    174         sage: print integral( exp(-x^2), x )
     174        sage: integral( exp(-x^2), x )
    175175        1/2*sqrt(pi)*erf(x)
    176176   
    177177    We define the Gaussian, plot and integrate it numerically and
     
    213213   
    214214    Sage does not know how to compute this integral either::
    215215   
    216         sage: print integral( exp(-x^2)*ln(x), x, 0, oo)
     216        sage: integral( exp(-x^2)*ln(x), x, 0, oo)
    217217        integrate(e^(-x^2)*log(x), x, 0, +Infinity)
    218218   
    219219    This definite integral is easy::
  • sage/calculus/functions.py

    diff -r 049029db5fa8 -r 28779f9a33ec sage/calculus/functions.py
    a b  
    114114        sage: jacobian(g, (x,y))
    115115        [2*x - 2*y      -2*x]
    116116
    117     The Jacobian of the Jacobian should give us the "second derivative", the Hessian matrix::
     117    The Jacobian of the Jacobian should give us the "second derivative", which is the Hessian matrix::
    118118   
    119119        sage: jacobian(jacobian(g, (x,y)), (x,y))
    120120        [ 2 -2]
  • sage/calculus/var.pyx

    diff -r 049029db5fa8 -r 28779f9a33ec sage/calculus/var.pyx
    a b  
    8484    .. note::
    8585
    8686       The new function is both returned and automatically injected
    87        into the global namespace.  If you use var in library code, it
    88        is better to use sage.calculus.calculus.function, since it
    89        won't touch the global namespace.
     87       into the global namespace.  If you use this function in library
     88       code, it is better to use sage.calculus.calculus.function,
     89       since it won't touch the global namespace.
    9090
    9191    EXAMPLES::
    9292
     
    158158    from sage.symbolic.ring import is_SymbolicVariable
    159159    for i in range(65,65+26) + range(97,97+26):
    160160        if G.has_key(chr(i)) and is_SymbolicVariable(G[chr(i)]):
    161             #We check to see if there is a corresponding pyobject
    162             #associated with the expression.  This will work for
    163             #constants which we want to keep by will fail for
    164             #variables that we want to delete.
     161            # We check to see if there is a corresponding pyobject
     162            # associated with the expression.  This will work for
     163            # constants which we want to keep, but will fail for
     164            # variables that we want to delete.
    165165            try:
    166166                G[chr(i)].pyobject()
    167167            except TypeError:
  • sage/functions/other.py

    diff -r 049029db5fa8 -r 28779f9a33ec sage/functions/other.py
    a b  
    190190        x_original = x
    191191
    192192        from sage.rings.all import RealIntervalField           
    193         #If x can be coerced into a real interval, then we should
    194         #try increasing the number of bits of precision until
    195         #we get the ceiling at each of the endpoints is the same.
    196         #The precision will continue to be increased up to maximum_bits
    197         #of precision at which point it will raise a value error.
     193        # If x can be coerced into a real interval, then we should
     194        # try increasing the number of bits of precision until
     195        # we get the ceiling at each of the endpoints is the same.
     196        # The precision will continue to be increased up to maximum_bits
     197        # of precision at which point it will raise a value error.
    198198        bits = 53
    199199        try:
    200200            x_interval = RealIntervalField(bits)(x)
     
    217217                raise ValueError, "x (= %s) requires more than %s bits of precision to compute its ceiling"%(x, maximum_bits)
    218218           
    219219        except TypeError:
    220             #If x cannot be coerced into a RealField, then
    221             #it should be left as a symbolic expression.
     220            # If x cannot be coerced into a RealField, then
     221            # it should be left as a symbolic expression.
    222222            return SFunction.__call__(self, SR(x_original))
    223223
    224224    def _eval_(self, x):
     
    319319
    320320        from sage.rings.all import RealIntervalField
    321321
    322         #If x can be coerced into a real interval, then we should
    323         #try increasing the number of bits of precision until
    324         #we get the floor at each of the endpoints is the same.
    325         #The precision will continue to be increased up to maximum_bits
    326         #of precision at which point it will raise a value error.
     322        # If x can be coerced into a real interval, then we should
     323        # try increasing the number of bits of precision until
     324        # we get the floor at each of the endpoints is the same.
     325        # The precision will continue to be increased up to maximum_bits
     326        # of precision at which point it will raise a value error.
    327327        bits = 53
    328328        try:
    329329            x_interval = RealIntervalField(bits)(x)
     
    346346                raise ValueError, "x (= %s) requires more than %s bits of precision to compute its floor"%(x, maximum_bits)
    347347           
    348348        except TypeError:
    349             #If x cannot be coerced into a RealField, then
    350             #it should be left as a symbolic expression.
     349            # If x cannot be coerced into a RealField, then
     350            # it should be left as a symbolic expression.
    351351            return SFunction.__call__(self, SR(x_original))
    352352
    353353    def _eval_(self, x):
  • sage/interfaces/maxima.py

    diff -r 049029db5fa8 -r 28779f9a33ec sage/interfaces/maxima.py
    a b  
    755755        if self._expect is None: return
    756756        r = randrange(2147483647)
    757757        s = marker + str(r+1)
     758
     759        # The 0; *is* necessary... it comes up in certain rare cases
     760        # that are revealed by extensive testing.  Don't delete it. -- william stein
    758761        cmd = '''0;sconcat("%s",(%s+1));\n'''%(marker,r)
    759762        self._sendstr(cmd)
    760763        try:
  • sage/interfaces/qepcad.py

    diff -r 049029db5fa8 -r 28779f9a33ec sage/interfaces/qepcad.py
    a b  
    24482448            {'x': 1.618033988749895?}
    24492449        """
    24502450        points = self.sample_point()
    2451         # from sage.symbolic.ring import var
    2452         # vars = [var(v) for v in self._parent._varlist]
    24532451        vars = self._parent._varlist
    24542452
    24552453        return dict([(vars[i], points[i]) for i in range(len(points))])
  • sage/matrix/matrix_symbolic_dense.pyx

    diff -r 049029db5fa8 -r 28779f9a33ec sage/matrix/matrix_symbolic_dense.pyx
    a b  
    160160            sage: m = matrix(SR, 2, [sqrt(2), 3, pi, e])
    161161            sage: cmp(m,m)
    162162            0
    163             sage: cmp(m,3)
    164             1
     163            sage: cmp(m,3) in [-1,1]
     164            True
    165165        """
    166166        return self._richcmp(right, op)
    167167
     
    210210        Compare self and right.
    211211
    212212        Currently the corresponding maxima matrices are expanded and compared.
    213         We example first, since, eg., this would fail otherwise::
     213        We example first, since, e.g., this would fail otherwise::
    214214
    215215            sage: m = matrix(SR,2,[1..4]); n = m^2
    216216            sage: exp(m+n) - exp(m)*exp(n) == 0       # indirect test
  • sage/matrix/tests.py

    diff -r 049029db5fa8 -r 28779f9a33ec sage/matrix/tests.py
    a b  
    3939    sage: matrix(QQ['x,y'], 2, 2, [1, 1, 1, 1]) / x
    4040    [1/x 1/x]
    4141    [1/x 1/x]
    42     sage: matrix(CC, 2, 2, [1, 1, 1, 1]) / I
     42    sage: A = matrix(CC, 2, 2, [1, 1, 1, 1]) / I; A
    4343    [-1.0*I -1.0*I]
    4444    [-1.0*I -1.0*I]
    45     sage: _.parent()
     45    sage: A.parent()
    4646    Full MatrixSpace of 2 by 2 dense matrices over Symbolic Ring
    4747
    4848We test an example det computation where linbox gave an incorrect
  • sage/rings/complex_interval.pyx

    diff -r 049029db5fa8 -r 28779f9a33ec sage/rings/complex_interval.pyx
    a b  
    466466            ...
    467467            TypeError
    468468       
    469         Here's a conversion to Maxima happens, which results in a type
     469        Here a conversion to Maxima happens, which results in a type
    470470        error::
    471471       
    472472            sage: a = CIF(2.3)
  • sage/rings/infinity.py

    diff -r 049029db5fa8 -r 28779f9a33ec sage/rings/infinity.py
    a b  
    12081208            sage: import sympy
    12091209            sage: bool(oo == sympy.oo) # indirect doctest
    12101210            True
    1211             sage: #bool(SR(oo) == sympy.oo)
     1211            sage: bool(SR(oo) == sympy.oo)
    12121212            True
    12131213        """
    12141214        import sympy