Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Simple Integration Problem

Hi, these simple steps used to work in Sage 8.0. They now give an error in 8.9. I tried in CoCalc, same problem. Do I need to change anything? If this is a Sage regression, how can I work around it? Thanks.

Sage 8.0 behavior:

sage: var('x t')
(x, t)

sage: psi = function('psi')(x, t)

sage: integrate(conjugate(psi) * diff(psi, x), x)
integrate(conjugate(psi(x, t))*diff(psi(x, t), x), x)

In 8.9 it gives:

┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 8.9, Release Date: 2019-09-29                     │
│ Using Python 2.7.15. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: var('x t')
(x, t)
sage: psi = function('psi')(x, t)
sage: integrate(conjugate(psi) * diff(psi, x), x)
---------------------------------------------------------------------------
...
ValueError: No differentiation variable specified.

Posting the complete trace below:

sage: var('x t')
(x, t)
sage: psi = function('psi')(x, t)
sage: integrate(conjugate(psi) * diff(psi, x), x)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-3-13afb3c477cd> in <module>()
----> 1 integrate(conjugate(psi) * diff(psi, x), x)

/home/bryanso/sage-8.9/local/lib/python2.7/site-packages/sage/misc/functional.pyc in integral
(x, *args, **kwds)
    751     """
    752     if hasattr(x, 'integral'):
--> 753         return x.integral(*args, **kwds)
    754     else:
    755         from sage.symbolic.ring import SR

/home/bryanso/sage-8.9/local/lib/python2.7/site-packages/sage/symbolic/expression.pyx in sage
.symbolic.expression.Expression.integral (build/cythonized/sage/symbolic/expression.cpp:64036
)()
  12360                     R = ring.SR
  12361             return R(integral(f, v, a, b, **kwds))
> 12362         return integral(self, *args, **kwds)
  12363
  12364     integrate = integral

/home/bryanso/sage-8.9/local/lib/python2.7/site-packages/sage/symbolic/integration/integral.p
yc in integrate(expression, v, a, b, algorithm, hold)
    912         return integrator(expression, v, a, b)
    913     if a is None:
--> 914         return indefinite_integral(expression, v, hold=hold)
    915     else:
    916         return definite_integral(expression, v, a, b, hold=hold)

/home/bryanso/sage-8.9/local/lib/python2.7/site-packages/sage/symbolic/function.pyx in sage.s
ymbolic.function.BuiltinFunction.__call__ (build/cythonized/sage/symbolic/function.cpp:11847)
()
    996             res = self._evalf_try_(*args)
    997             if res is None:
--> 998                 res = super(BuiltinFunction, self).__call__(
    999                         *args, coerce=coerce, hold=hold)
   1000

/home/bryanso/sage-8.9/local/lib/python2.7/site-packages/sage/symbolic/function.pyx in sage.s
ymbolic.function.Function.__call__ (build/cythonized/sage/symbolic/function.cpp:6927)()
    490                     (<Expression>args[0])._gobj, hold)
    491         elif self._nargs == 2:
--> 492             res = g_function_eval2(self._serial, (<Expression>args[0])._gobj,
    493                     (<Expression>args[1])._gobj, hold)
    494         elif self._nargs == 3:

/home/bryanso/sage-8.9/local/lib/python2.7/site-packages/sage/symbolic/integration/integral.p
yc in _eval_(self, f, x)
     92         for integrator in self.integrators:
     93             try:
---> 94                 A = integrator(f, x)
     95             except (NotImplementedError, TypeError):
     96                 pass

/home/bryanso/sage-8.9/local/lib/python2.7/site-packages/sage/symbolic/integration/external.p
yc in sympy_integrator(expression, v, a, b)
     66     else:
     67         result = sympy.integrate(ex, (v, a._sympy_(), b._sympy_()))
---> 68     return result._sage_()
     69
     70 def mma_free_integrator(expression, v, a=None, b=None):

/home/bryanso/sage-8.9/local/lib/python2.7/site-packages/sage/interfaces/sympy.pyc in _sympys
age_integral(self)
    307     """
    308     from sage.misc.functional import integral
--> 309     f, limits = self.function._sage_(), list(self.limits)
    310     for limit in limits:
    311         if len(limit) == 1:

/home/bryanso/sage-8.9/local/lib/python2.7/site-packages/sage/interfaces/sympy.pyc in _sympys
age_mul(self)
    204     s = 1
    205     for x in self.args:
--> 206         s *= x._sage_()
    207     return s
    208

/home/bryanso/sage-8.9/local/lib/python2.7/site-packages/sage/interfaces/sympy.pyc in _sympys
age_derivative(self)
    333     f = self.args[0]._sage_()
    334     args = [[a._sage_() for a in arg] if isinstance(arg,tuple) else arg._sage_() for
arg in self.args[2:]]
--> 335     return derivative(f, *args)
    336
    337 def _sympysage_order(self):

/home/bryanso/sage-8.9/local/lib/python2.7/site-packages/sage/calculus/functional.pyc in deri
vative(f, *args, **kwds)
    129     """
    130     try:
--> 131         return f.derivative(*args, **kwds)
    132     except AttributeError:
    133         pass

/home/bryanso/sage-8.9/local/lib/python2.7/site-packages/sage/symbolic/expression.pyx in sage
.symbolic.expression.Expression.derivative (build/cythonized/sage/symbolic/expression.cpp:255
45)()
   4172             ValueError: No differentiation variable specified.
   4173         """
-> 4174         return multi_derivative(self, args)
   4175
   4176     diff = differentiate = derivative

/home/bryanso/sage-8.9/local/lib/python2.7/site-packages/sage/misc/derivative.pyx in sage.mis
c.derivative.multi_derivative (build/cythonized/sage/misc/derivative.c:3016)()
    217     if not args:
    218         # fast version where no arguments supplied
--> 219         return F._derivative()
    220
    221     for arg in derivative_parse(args):

/home/bryanso/sage-8.9/local/lib/python2.7/site-packages/sage/symbolic/expression.pyx in sage
.symbolic.expression.Expression._derivative (build/cythonized/sage/symbolic/expression.cpp:25
887)()
   4234                 return self.gradient()
   4235             else:
-> 4236                 raise ValueError("No differentiation variable specified.")
   4237         if not isinstance(deg, (int, long, sage.rings.integer.Integer)) \
   4238                 or deg < 1:

ValueError: No differentiation variable specified.