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

Commit

Permalink
#16941 : Add a hold parameter for symbolic integrals.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thierry Monteil committed Sep 6, 2014
1 parent a86cf93 commit 721dc23
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/sage/symbolic/integration/integral.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def _normalize_integral_input(f, v=None, a=None, b=None):
raise TypeError('only one endpoint was given!')
return f, v, a, b

def integrate(expression, v=None, a=None, b=None, algorithm=None):
def integrate(expression, v=None, a=None, b=None, algorithm=None, hold=False):
r"""
Returns the indefinite integral with respect to the variable
`v`, ignoring the constant of integration. Or, if endpoints
Expand Down Expand Up @@ -342,6 +342,8 @@ def integrate(expression, v=None, a=None, b=None, algorithm=None):
- 'mathematica_free' - use http://integrals.wolfram.com/
To prevent automatic evaluation use the ``hold`` argument.
EXAMPLES::
sage: x = var('x')
Expand Down Expand Up @@ -385,6 +387,16 @@ def integrate(expression, v=None, a=None, b=None, algorithm=None):
sage: integral(sin(x), (y, pi, 2*pi))
pi*sin(x)
Using the ``hold`` parameter it is possible to prevent automatic
evaluation, which can then be evaluated via :meth:`simplify`::
sage: integral(x^2, x, 0, 3)
9
sage: a = integral(x^2, x, 0, 3, hold=True) ; a
integrate(x^2, x, 0, 3)
sage: a.simplify()
9
Constraints are sometimes needed::
sage: var('x, n')
Expand Down Expand Up @@ -694,8 +706,8 @@ def integrate(expression, v=None, a=None, b=None, algorithm=None):
raise ValueError("Unknown algorithm: %s" % algorithm)
return integrator(expression, v, a, b)
if a is None:
return indefinite_integral(expression, v)
return indefinite_integral(expression, v, hold=hold)
else:
return definite_integral(expression, v, a, b)
return definite_integral(expression, v, a, b, hold=hold)

integral = integrate

0 comments on commit 721dc23

Please sign in to comment.