# Ticket #7377: trac_7377-fastcalculus-rebased.patch

File trac_7377-fastcalculus-rebased.patch, 14.6 KB (added by jpflori, 11 years ago)

Rebased on Sage 4.6.1, fixed changes in sage.symbolic.integration.external

• ## sage/calculus/calculus.py

```# HG changeset patch
# User Nils Bruin <nbruin@sfu.ca>
# Date 1265693495 28800
# Node ID b9db51bba0134fddc27b3af64ca95f987abb4423
# Parent  d1def36a6fbc238838fca35740574e46fc6f8064
Fast calculus interface

diff -r d1def36a6fbc -r b9db51bba013 sage/calculus/calculus.py```
 a f1 """ maxima = sage.interfaces.maxima_lib.maxima #maxima = Maxima(init_code = ['display2d:false', 'domain: complex', #                             'keepfloat: true', 'load(to_poly_solver)', 'load(simplify_sum)'], #                script_subdirectory=None) ######################################################## def symbolic_sum(expression, v, a, b, algorithm='maxima'): raise ValueError, "summation limits must not depend on the summation variable" if algorithm == 'maxima': sum  = "'sum(%s, %s, %s, %s)" % tuple([repr(expr._maxima_()) for expr in (expression, v, a, b)]) try: result = maxima.simplify_sum(sum) result = result.ratsimp() return expression.parent()(result) return maxima.sr_sum(expression,v,a,b) except TypeError, error: s = str(error) if "divergent" in s or 'Pole encountered' in s: if algorithm == 'maxima': if dir is None: l = ex._maxima_().limit(v, a) l = maxima.sr_limit(ex, v, a) elif dir in ['plus', '+', 'right', 'above']: if dir == 'above': from sage.misc.misc import deprecation deprecation("the keyword 'above' is deprecated. Please use 'right' or '+' instead.", 'Sage version 4.6') l = ex._maxima_().limit(v, a, 'plus') l = maxima.sr_limit(ex, v, a, 'plus') elif dir in ['minus', '-', 'left', 'below']: if dir == 'below': from sage.misc.misc import deprecation deprecation("the keyword 'below' is deprecated. Please use 'left' or '-' instead.", 'Sage version 4.6') l = ex._maxima_().limit(v, a, 'minus') l = maxima.sr_limit(ex, v, a, 'minus') elif algorithm == 'maxima_taylor': if dir is None: l = ex._maxima_().tlimit(v, a) l = maxima.sr_tlimit(ex, v, a) elif dir == 'plus' or dir == 'above' or dir == 'from_right': l = ex._maxima_().tlimit(v, a, 'plus') l = maxima.sr_tlimit(ex, v, a, 'plus') elif dir == 'minus' or dir == 'below' or dir == 'from_left': l = ex._maxima_().tlimit(v, a, 'minus') l = maxima.sr_tlimit(ex, v, a, 'minus') elif algorithm == 'sympy': if dir is None: import sympy
• ## sage/interfaces/maxima.py

`diff -r d1def36a6fbc -r b9db51bba013 sage/interfaces/maxima.py`
 a """ return maxima_version() ##some helper functions to wrap tha calculus use of the maxima interface. ##these routines expect arguments living in the symbolic ring and return something ##that is hopefully coercible into the symbolic ring again. def sr_integral(self,*args): return args[0]._maxima_().integrate(*args[1:]) def sr_sum(self,expression,v,a,b): sum  = "'sum(%s, %s, %s, %s)" % tuple([repr(expr._maxima_()) for expr in (expression, v, a, b)]) result = self.simplify_sum(sum) result = result.ratsimp() return expression.parent()(result) def sr_limit(self,ex,*args): return ex._maxima_().limit(*args) def sr_tlimit(self,ex,*args): return ex._maxima_().tlimit(*args) ##     def display2d(self, flag=True): ##         """ ##         Set the flag that determines whether Maxima objects are def __doctest_cleanup(): import sage.interfaces.quit sage.interfaces.quit.expect_quitall()
• ## sage/interfaces/maxima_lib.py

`diff -r d1def36a6fbc -r b9db51bba013 sage/interfaces/maxima_lib.py`
`diff -r d1def36a6fbc -r b9db51bba013 sage/symbolic/integration/external.py`