Ticket #1470: maxima-16.2-fix.patch

File maxima-16.2-fix.patch, 10.5 KB (added by mhansen, 11 years ago)
• sage/calculus/calculus.py

```# HG changeset patch
# User Mike Hansen <mhansen@gmail.com>
# Date 1219431365 25200
# Node ID f9d448db9622a8d1b8874db5596a917efd7c25bd
# Parent  c338578a38b3ef1ff0610fdc07f447016ff030f6
Fixed synchronization problem with Maxima 5.16.2

diff -r c338578a38b3 -r f9d448db9622 sage/calculus/calculus.py```
 a sage: f = integral(sin(x^2)); f sqrt(pi)*((sqrt(2)*I + sqrt(2))*erf((sqrt(2)*I + sqrt(2))*x/2) + (sqrt(2)*I - sqrt(2))*erf((sqrt(2)*I - sqrt(2))*x/2))/8 sage: print f (sqrt(2)  I + sqrt(2)) x sqrt( pi) ((sqrt(2)  I + sqrt(2)) erf(------------------------) 2 (sqrt(2)  I - sqrt(2)) x + (sqrt(2)  I - sqrt(2)) erf(------------------------))/8 2 (sqrt(2)  I + sqrt(2)) x (sqrt( pi) ((sqrt(2)  I + sqrt(2)) erf(------------------------) 2 (sqrt(2)  I - sqrt(2)) x + (sqrt(2)  I - sqrt(2)) erf(------------------------)))/8 2 """ if not self._has_been_simplified(): self = self.simplify() sage: f = log(log(x))/log(x) sage: forget(); assume(x<-2); lim(f, x=0, taylor=True) und limit(log(log(x))/log(x), x, 0) Here ind means "indefinite but bounded": sage: lim(sin(1/x), x = 0) x y  + Sqrt[--] FresnelS[Sqrt[--] x] 2                 Pi sage: print f.integral(x) z                                         (sqrt(2)  I + sqrt(2)) x x y  + sqrt( pi) ((sqrt(2)  I + sqrt(2)) erf(------------------------) 2 (sqrt(2)  I - sqrt(2)) x + (sqrt(2)  I - sqrt(2)) erf(------------------------))/8 2 z x y  + (sqrt( pi) ((sqrt(2)  I + sqrt(2)) (sqrt(2)  I + sqrt(2)) x erf(------------------------) + (sqrt(2)  I - sqrt(2)) 2 (sqrt(2)  I - sqrt(2)) x erf(------------------------)))/8 2 We integrate the above function in maple now: sage: g = maple(f); g                             # optional -- requires maple """ try: v = self._maxima_().quad_qags(var(x), a, b, desired_relative_error, maximum_num_subintervals) a, b, epsrel=desired_relative_error, limit=maximum_num_subintervals) except TypeError, err: if "ERROR" in str(err): raise ValueError, "Maxima (via quadpack) cannot compute the integral to that precision" else: raise TypeError, err #This is just a work around until there is a response to #http://www.math.utexas.edu/pipermail/maxima/2008/012975.html if 'quad_qags' in str(v): raise ValueError, "Maxima (via quadpack) cannot compute the integral to that precision" return float(v[0]), float(v[1]), Integer(v[2]), Integer(v[3])
• sage/calculus/desolvers.py

`diff -r c338578a38b3 -r f9d448db9622 sage/calculus/desolvers.py`
 a sage: f = function('f', x) sage: de = lambda y: diff(y,x,x) - 2*diff(y,x) + y sage: desolve_laplace(de(f(x)),["x","f"]) "x*%e^x*(?%at('diff(f(x),x,1),x=0))-f(0)*x*%e^x+f(0)*%e^x" "x*%e^x*('at('diff(f(x),x,1),x=0))-f(0)*x*%e^x+f(0)*%e^x" sage: desolve_laplace(de(f(x)),["x","f"],[0,1,2]) 'x*%e^x+%e^x'
• sage/combinat/combinat.py

`diff -r c338578a38b3 -r f9d448db9622 sage/combinat/combinat.py`
 a When \$x = 1\$, this coincides with Riemann's zeta function. The Dirichlet L-functions may be expressed as a linear combination of Hurwitz zeta functions. Note that if you use floting point inputs, then the results may be slightly off. EXAMPLES: sage: hurwitz_zeta(3,1/2,6) 8.41439000000000 sage: hurwitz_zeta(1.1,1/2,6) sage: hurwitz_zeta(11/10,1/2,6) 12.1041000000000 sage: hurwitz_zeta(1.1,1/2,50) 12.103813495683744469025853545548130581952676591199 sage: hurwitz_zeta(11/10,1/2,50) 12.103813495683755105709077412966680619033648618088 REFERENCES: http://en.wikipedia.org/wiki/Hurwitz_zeta_function
• sage/functions/piecewise.py

`diff -r c338578a38b3 -r f9d448db9622 sage/functions/piecewise.py`
 a interval endpoints. EXAMPLES: sage: x = PolynomialRing(QQ, 'x').0 sage: R. = QQ['x'] sage: f1 = x^0 sage: f2 = 10*x - x^2 sage: f3 = 3*x^4 - 156*x^3 + 3036*x^2 - 26208*x sage: f = Piecewise([[(0,3),f1],[(3,10),f2],[(10,20),f3]]) sage: f.critical_points() [5.0, 12.000000000000171, 12.9999999999996, 14.000000000000229] sage: expected = [5, 12, 13, 14] sage: all(abs(e-a) < 0.001 for e,a in zip(expected, f.critical_points())) True """ maxima = sage.interfaces.all.maxima x = PolynomialRing(QQ,'x').gen()
• sage/interfaces/expect.py

`diff -r c338578a38b3 -r f9d448db9622 sage/interfaces/expect.py`
 a def _object_class(self): return ExpectElement def function_call(self, function, args=[]): def function_call(self, function, args=[], kwds={}): """ EXAMPLES: sage: maxima.quad_qags(x, x, 0, 1, epsrel=1e-4) [0.5,5.5511151231257...E-15,21,0] sage: maxima.function_call('quad_qags', [x, x, 0, 1], {'epsrel':'1e-4'}) [0.5,5.5511151231257...E-15,21,0] """ if function == '': raise ValueError, "function name must be nonempty" if function[:2] == "__": for i in range(len(args)): if not isinstance(args[i], ExpectElement): args[i] = self.new(args[i]) return self.new("%s(%s)"%(function, ",".join([s.name() for s in args]))) for key, value in kwds.iteritems(): kwds[key] = self.new(value) return self.new("%s(%s)"%(function, ",".join([s.name() for s in args]+ ['%s=%s'%(key,value.name()) for key, value in kwds.items()]))) def call(self, function_name, *args): return self.function_call(function_name, args) def call(self, function_name, *args, **kwds): return self.function_call(function_name, args, kwds) def _contains(self, v1, v2): raise NotImplementedError def __repr__(self): return "%s"%self._name def __call__(self, *args): return self._parent.function_call(self._name, list(args)) def __call__(self, *args, **kwds): return self._parent.function_call(self._name, list(args), kwds) class FunctionElement(SageObject): def __repr__(self): return "%s"%self._name def __call__(self, *args): return self._obj.parent().function_call(self._name, [self._obj] + list(args)) def __call__(self, *args, **kwds): return self._obj.parent().function_call(self._name, [self._obj] + list(args), kwds) def help(self): print self._sage_doc_()
• sage/interfaces/maxima.py

`diff -r c338578a38b3 -r f9d448db9622 sage/interfaces/maxima.py`
 a if self._expect is None: return r = randrange(2147483647) s = marker + str(r+1) cmd = '''sconc("%s",(%s+1));\n'''%(marker,r) cmd = '''sconcat("%s",(%s+1));\n'''%(marker,r) self._sendstr(cmd) try: self._expect_expr(timeout=0.5) EXAMPLES: sage: maxima.version() '5.13.0' '5.16.2' """ return maxima_version() sage: maxima.clear('x'); maxima.clear('f') sage: f = maxima.de_solve_laplace("diff(f(x),x,2) = 2*diff(f(x),x)-f(x)", ["x","f"]) sage: f f(x)=x*%e^x*(?%at('diff(f(x),x,1),x=0))-f(0)*x*%e^x+f(0)*%e^x f(x)=x*%e^x*('at('diff(f(x),x,1),x=0))-f(0)*x*%e^x+f(0)*%e^x sage: print f ! x  d        !                  x          x 0.52848223531423071361790491935415653021675547587292866196865279321015401702040079 """ from sage.rings.all import Integer v = self.quad_qags(var, a, b, desired_relative_error, maximum_num_subintervals) v = self.quad_qags(var, a, b, epsrel=desired_relative_error, limit=maximum_num_subintervals) return v[0], v[1], Integer(v[2]), Integer(v[3]) def integral(self, var='x', min=None, max=None):