# 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 sage: f3 = lambda x:exp(x) sage: f4 = lambda x:sin(2*x) sage: f = Piecewise([[(0,1),f1],[(1,2),f2],[(2,3),f3],[(3,10),f4]]) sage: P = f.plot() sage: f.plot() Other function plots can be produced as well: sage: L = [[1+5*cos(pi/2+pi*i/100), tan(pi/2+pi*i/100)*\ ...   (1+5*cos(pi/2+pi*i/100))] for i in range(1,100)] sage: p = line(L, rgbcolor=(1/4,1/8,3/4)) sage: line(L, rgbcolor=(1/4,1/8,3/4)) A blue hypotrochoid (3 leaves): sage: n = 4; h = 3; b = 2 sage: L = [[n*cos(pi*i/100)+h*cos((n/b)*pi*i/100),\ ...   n*sin(pi*i/100)-h*sin((n/b)*pi*i/100)] for i in range(200)] sage: p = line(L, rgbcolor=(1/4,1/4,3/4)) sage: line(L, rgbcolor=(1/4,1/4,3/4)) A blue hypotrochoid (4 leaves): sage: n = 6; h = 5; b = 2 sage: L = [[n*cos(pi*i/100)+h*cos((n/b)*pi*i/100),\ ...   n*sin(pi*i/100)-h*sin((n/b)*pi*i/100)] for i in range(200)] sage: p = line(L, rgbcolor=(1/4,1/4,3/4)) sage: line(L, rgbcolor=(1/4,1/4,3/4)) A red limaçon of Pascal: sage: L = [[sin(pi*i/100)+sin(pi*i/50),-(1+cos(pi*i/100)+cos(pi*i/50))]\ ...   for i in range(-100,101)] sage: p = line(L, rgbcolor=(1,1/4,1/2)) sage: line(L, rgbcolor=(1,1/4,1/2)) A light green trisectrix of Maclaurin: sage: L = [[2*(1-4*cos(-pi/2+pi*i/100)^2),10*tan(-pi/2+pi*i/100)*\ ...   (1-4*cos(-pi/2+pi*i/100)^2)] for i in range(1,100)] sage: p = line(L, rgbcolor=(1/4,1,1/8)) sage: line(L, rgbcolor=(1/4,1,1/8)) A green lemniscate of Bernoulli (we omit i==100 since that would give a 0 division error): :: sage: v = [(1/cos(-pi/2+pi*i/100), tan(-pi/2+pi*i/100)) for i in range(1,200) if i!=100 ] sage: L = [(a/(a^2+b^2), b/(a^2+b^2)) for a,b in v] sage: line(L, rgbcolor=(1/4,3/4,1/8)) .. index:: plot;curve using surf
• ## sage/calculus/all.py

`diff -r 049029db5fa8 -r 28779f9a33ec sage/calculus/all.py`
 a ## from calculus import (SymbolicExpressionRing, ##                       is_SymbolicExpressionRing, ##                       is_SymbolicExpression, ##                       is_SymbolicVariable, ##                       CallableSymbolicExpressionRing, ##                       is_CallableSymbolicExpressionRing, ##                       is_CallableSymbolicExpression, ##                       is_SymbolicExpression, ##                       is_SymbolicExpressionRing) from calculus import maxima as maxima_calculus from calculus import (laplace, inverse_laplace, limit, lim, clear_functions)
• ## sage/calculus/calculus.py

`diff -r 049029db5fa8 -r 28779f9a33ec sage/calculus/calculus.py`
 a -  ``b`` - (optional) upper endpoint of definite integral - ``algorithm`` - (default: 'maxima') - ``algorithm`` - (default: 'maxima')  one of - 'maxima' - use maxima (the default) - 'sympy' - use sympy (also in Sage) - 'mathematica_free' - use http://integrals.wolfram.com/ EXAMPLES:: We integrate the same function in both Mathematica and Sage (via Maxima):: sage: _ = var('x, y, z') sage: f = sin(x^2) + y^z sage: g = mathematica(f)                           # optional  -- requires mathematica sage: print g                                      # optional sage: print g                                      # optional -- requires mathematica z        2 y  + Sin[x ] sage: print g.Integrate(x)                         # optional sage: print g.Integrate(x)                         # optional -- requires mathematica z        Pi                2 x y  + Sqrt[--] FresnelS[Sqrt[--] x] 2                 Pi sage: print f.integral(x) 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) Alternatively, just use algorithm='mathematica_free' to integrate via Mathematica over the internet (deos NOT require a mathematica license!):: sage: _ = var('x, y, z') sage: f = sin(x^2) + y^z sage: f.integrate(algorithm="mathematica_free")       # optional -- requires internet sqrt(pi)*sqrt(1/2)*fresnels(sqrt(2)*x/sqrt(pi)) + y^z*x We can also use Sympy:: sage: _ = var('x, y, z') sage: (x^y-z).integrate(y) -y*z + x^y/log(x) sage: (x^y-z).integrate(y,algorithm="sympy") -y*z + x^y/log(x) We integrate the above function in maple now:: sage: g.substitute_function(cr, (sin(x) + cos(x)).function(x)) -(sin(a) - cos(a))*b In Sage 4.0, basic arithmetic with unevaluated functions is not In Sage 4.0, basic arithmetic with unevaluated functions is no longer supported:: sage: x = var('x') def dummy_diff(*args): """ This function is called when when 'diff' appears in a Maxima string. This function is called when 'diff' appears in a Maxima string. EXAMPLES::
• ## sage/calculus/functional.py

`diff -r 049029db5fa8 -r 28779f9a33ec sage/calculus/functional.py`
 a :: sage: print integral( exp(-x^2), x ) sage: integral( exp(-x^2), x ) 1/2*sqrt(pi)*erf(x) We define the Gaussian, plot and integrate it numerically and Sage does not know how to compute this integral either:: sage: print integral( exp(-x^2)*ln(x), x, 0, oo) sage: integral( exp(-x^2)*ln(x), x, 0, oo) integrate(e^(-x^2)*log(x), x, 0, +Infinity) This definite integral is easy::
• ## sage/calculus/functions.py

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

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

`diff -r 049029db5fa8 -r 28779f9a33ec sage/functions/other.py`
 a x_original = x from sage.rings.all import RealIntervalField #If x can be coerced into a real interval, then we should #try increasing the number of bits of precision until #we get the ceiling at each of the endpoints is the same. #The precision will continue to be increased up to maximum_bits #of precision at which point it will raise a value error. # If x can be coerced into a real interval, then we should # try increasing the number of bits of precision until # we get the ceiling at each of the endpoints is the same. # The precision will continue to be increased up to maximum_bits # of precision at which point it will raise a value error. bits = 53 try: x_interval = RealIntervalField(bits)(x) raise ValueError, "x (= %s) requires more than %s bits of precision to compute its ceiling"%(x, maximum_bits) except TypeError: #If x cannot be coerced into a RealField, then #it should be left as a symbolic expression. # If x cannot be coerced into a RealField, then # it should be left as a symbolic expression. return SFunction.__call__(self, SR(x_original)) def _eval_(self, x): from sage.rings.all import RealIntervalField #If x can be coerced into a real interval, then we should #try increasing the number of bits of precision until #we get the floor at each of the endpoints is the same. #The precision will continue to be increased up to maximum_bits #of precision at which point it will raise a value error. # If x can be coerced into a real interval, then we should # try increasing the number of bits of precision until # we get the floor at each of the endpoints is the same. # The precision will continue to be increased up to maximum_bits # of precision at which point it will raise a value error. bits = 53 try: x_interval = RealIntervalField(bits)(x) raise ValueError, "x (= %s) requires more than %s bits of precision to compute its floor"%(x, maximum_bits) except TypeError: #If x cannot be coerced into a RealField, then #it should be left as a symbolic expression. # If x cannot be coerced into a RealField, then # it should be left as a symbolic expression. return SFunction.__call__(self, SR(x_original)) def _eval_(self, x):
• ## sage/interfaces/maxima.py

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

`diff -r 049029db5fa8 -r 28779f9a33ec sage/interfaces/qepcad.py`
 a {'x': 1.618033988749895?} """ points = self.sample_point() # from sage.symbolic.ring import var # vars = [var(v) for v in self._parent._varlist] vars = self._parent._varlist 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 sage: m = matrix(SR, 2, [sqrt(2), 3, pi, e]) sage: cmp(m,m) 0 sage: cmp(m,3) 1 sage: cmp(m,3) in [-1,1] True """ return self._richcmp(right, op) Compare self and right. Currently the corresponding maxima matrices are expanded and compared. We example first, since, eg., this would fail otherwise:: We example first, since, e.g., this would fail otherwise:: sage: m = matrix(SR,2,[1..4]); n = m^2 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 sage: matrix(QQ['x,y'], 2, 2, [1, 1, 1, 1]) / x [1/x 1/x] [1/x 1/x] sage: matrix(CC, 2, 2, [1, 1, 1, 1]) / I sage: A = matrix(CC, 2, 2, [1, 1, 1, 1]) / I; A [-1.0*I -1.0*I] [-1.0*I -1.0*I] sage: _.parent() sage: A.parent() Full MatrixSpace of 2 by 2 dense matrices over Symbolic Ring We 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 ... TypeError Here's a conversion to Maxima happens, which results in a type Here a conversion to Maxima happens, which results in a type error:: sage: a = CIF(2.3)
• ## sage/rings/infinity.py

`diff -r 049029db5fa8 -r 28779f9a33ec sage/rings/infinity.py`
 a sage: import sympy sage: bool(oo == sympy.oo) # indirect doctest True sage: #bool(SR(oo) == sympy.oo) sage: bool(SR(oo) == sympy.oo) True """ import sympy