Opened 3 years ago

Closed 2 years ago

#28656 closed defect (fixed)

Incorrect behaviour of diff of an (hold) integral WRT its bounds.

Reported by: Emmanuel Charpentier Owned by:
Priority: major Milestone: sage-9.2
Component: symbolics Keywords:
Cc: Merged in:
Authors: Frédéric Chapoton Reviewers: Emmanuel Charpentier
Report Upstream: N/A Work issues:
Branch: 90679c3 (Commits, GitHub, GitLab) Commit: 90679c38dca8f770ff8227d8fdf2d3ac9d86ed83
Dependencies: Stopgaps:

Status badges


Seen in this ask.sagemath question, clarified in this sage-devel thread :

sage: var("t, a, b")
(t, a, b)
sage: f=function("f")
sage: F1(a, b)=integrate(f(t), t, a, b)
sage: F1(a, b).diff(b)
sage: F1(a, b).diff(a)

So far, so good. But:

sage: F2(x)=integrate(f(t),t,0,x)
sage: F2(x).diff(x)
AttributeError                            Traceback (most recent call last)
<ipython-input-20-708f39997373> in <module>()
----> 1 F2(x).diff(x)

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

/usr/local/sage-python3/local/lib/python3.7/site-packages/sage/misc/derivative.pyx in sage.misc.derivative.multi_derivative (build/cythonized/sage/misc/derivative.c:3118)()
    221     for arg in derivative_parse(args):
--> 222         F = F._derivative(arg)
    223     return F

/usr/local/sage-python3/local/lib/python3.7/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression._derivative (build/cythonized/sage/symbolic/expression.cpp:26060)()
   4244         sig_on()
   4245         try:
-> 4246             x = self._gobj.diff(ex_to_symbol(symbol._gobj), deg)
   4247         finally:
   4248             sig_off()

/usr/local/sage-python3/local/lib/python3.7/site-packages/sage/symbolic/integration/ in _tderivative_(self, f, x, a, b, diff_param)
    254             ans =
    255         return (ans + f.subs(x == b) * b.diff(diff_param)
--> 256                     - f.subs(x == a) * a.diff(diff_param))
    258     def _print_latex_(self, f, x, a, b):

/usr/local/sage-python3/local/lib/python3.7/site-packages/sage/structure/element.pyx in sage.structure.element.Element.__getattr__ (build/cythonized/sage/structure/element.c:4608)()
    487             AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'
    488         """
--> 489         return self.getattr_from_category(name)
    491     cdef getattr_from_category(self, name):

/usr/local/sage-python3/local/lib/python3.7/site-packages/sage/structure/element.pyx in sage.structure.element.Element.getattr_from_category (build/cythonized/sage/structure/element.c:4717)()
    500         else:
    501             cls = P._abstract_element_class
--> 502         return getattr_from_other_class(self, cls, name)
    504     def __dir__(self):

/usr/local/sage-python3/local/lib/python3.7/site-packages/sage/cpython/getattr.pyx in sage.cpython.getattr.getattr_from_other_class (build/cythonized/sage/cpython/getattr.c:2614)()
    392         dummy_error_message.cls = type(self)
    393 = name
--> 394         raise AttributeError(dummy_error_message)
    395     attribute = <object>attr
    396     # Check for a descriptor (__get__ in Python)

AttributeError: 'sage.rings.rational.Rational' object has no attribute 'diff'

Highly annoying. The explanation given by Nils Bruin seems perfectly reasonable.

Change History (7)

comment:1 Changed 3 years ago by Erik Bray

Milestone: sage-9.0sage-9.1

Ticket retargeted after milestone closed

comment:2 Changed 3 years ago by Matthias Köppe

Milestone: sage-9.1sage-9.2

Moving tickets to milestone sage-9.2 based on a review of last modification date, branch status, and severity.

comment:3 Changed 2 years ago by Frédéric Chapoton

Authors: Frédéric Chapoton
Branch: u/chapoton/28656
Commit: 90679c38dca8f770ff8227d8fdf2d3ac9d86ed83
Status: newneeds_review

here is a fix

New commits:

90679c3trac 28656 some fix for derivative of integrals wrt bound

comment:4 Changed 2 years ago by Emmanuel Charpentier

Status: needs_reviewpositive_review

On Debian running on core i7 + 16 GB RAM, pulling this branch on top of 9.1 upgrades the latter to 9.2.beta0. When using all system packages recommended by, this gives 11 permanent failures ; however, most of them have already been reported for 9.1.rc3 using the same system packages, and explained away ; none of them seems to be integration-related.

==> (tentative) positive_review.

However, a check on a system using Sage packages would be useful.

comment:5 Changed 2 years ago by Volker Braun

Status: positive_reviewneeds_work

reviewer name is missing

comment:6 Changed 2 years ago by Emmanuel Charpentier

Reviewers: Emmanuel Charpentier
Status: needs_workpositive_review

Wups ! Fixed...

comment:7 Changed 2 years ago by Volker Braun

Branch: u/chapoton/2865690679c38dca8f770ff8227d8fdf2d3ac9d86ed83
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.