Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit 75edb7b

Browse files
committed
24028: Held definite integrals don't translate to SymPy; cosmetics
1 parent 8d9c008 commit 75edb7b

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

src/sage/interfaces/sympy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def _sympysage_integral(self):
289289
sage: sx = Symbol('x')
290290
sage: assert integral(x, x, hold=True)._sympy_() == Integral(sx, sx)
291291
sage: assert integral(x, x, hold=True) == Integral(sx, sx)._sage_()
292-
sage: assert integral(x, x, 0, 1, hold=True)._sympy_() == Integral(sx, (sx,0,1)) # known bug
292+
sage: assert integral(x, x, 0, 1, hold=True)._sympy_() == Integral(sx, (sx,0,1))
293293
sage: assert integral(x, x, 0, 1, hold=True) == Integral(sx, (sx,0,1))._sage_()
294294
"""
295295
from sage.misc.functional import integral

src/sage/symbolic/integration/integral.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def _print_latex_(self, f, x):
137137
class DefiniteIntegral(BuiltinFunction):
138138
def __init__(self):
139139
"""
140-
Symbolic function representing a definite integral.
140+
The symbolic function representing a definite integral.
141141
142142
EXAMPLES::
143143
@@ -156,7 +156,7 @@ def __init__(self):
156156

157157
def _eval_(self, f, x, a, b):
158158
"""
159-
Returns the results of symbolic evaluation of the integral
159+
Return the results of symbolic evaluation of the integral
160160
161161
EXAMPLES::
162162
@@ -185,7 +185,7 @@ def _eval_(self, f, x, a, b):
185185

186186
def _evalf_(self, f, x, a, b, parent=None, algorithm=None):
187187
"""
188-
Returns numerical approximation of the integral
188+
Return a numerical approximation of the integral
189189
190190
EXAMPLES::
191191
@@ -209,7 +209,7 @@ def _evalf_(self, f, x, a, b, parent=None, algorithm=None):
209209

210210
def _tderivative_(self, f, x, a, b, diff_param=None):
211211
"""
212-
Returns derivative of symbolic integration
212+
Return the derivative of symbolic integration
213213
214214
EXAMPLES::
215215
@@ -233,7 +233,7 @@ def _tderivative_(self, f, x, a, b, diff_param=None):
233233

234234
def _print_latex_(self, f, x, a, b):
235235
r"""
236-
Returns LaTeX expression for integration of a symbolic function.
236+
Convert this integral to LaTeX notation
237237
238238
EXAMPLES::
239239
@@ -254,6 +254,22 @@ def _print_latex_(self, f, x, a, b):
254254
dx_str = "{d %s}"%(latex(x))
255255
return "\\int_{%s}^{%s} %s\\,%s"%(latex(a), latex(b), latex(f), dx_str)
256256

257+
def _sympy_(self, f, x, a, b):
258+
"""
259+
Convert this integral to the equivalent SymPy object
260+
261+
The resulting SymPy integral can be evaluated using ``doit()``.
262+
263+
EXAMPLES::
264+
265+
sage: integral(x, x, 0, 1, hold=True)._sympy_()
266+
Integral(x, (x, 0, 1))
267+
sage: _.doit()
268+
1/2
269+
"""
270+
from sympy.integrals import Integral
271+
return Integral(f, (x, a, b))
272+
257273
definite_integral = DefiniteIntegral()
258274

259275

0 commit comments

Comments
 (0)