Opened 12 months ago

Closed 4 months ago

#28656 closed defect (fixed)

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

Reported by: charpent 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) Commit: 90679c38dca8f770ff8227d8fdf2d3ac9d86ed83
Dependencies: Stopgaps:


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 10 months ago by embray

  • Milestone changed from sage-9.0 to sage-9.1

Ticket retargeted after milestone closed

comment:2 Changed 6 months ago by mkoeppe

  • Milestone changed from sage-9.1 to sage-9.2

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

comment:3 Changed 5 months ago by chapoton

  • Authors set to Frédéric Chapoton
  • Branch set to u/chapoton/28656
  • Commit set to 90679c38dca8f770ff8227d8fdf2d3ac9d86ed83
  • Status changed from new to needs_review

here is a fix

New commits:

90679c3trac 28656 some fix for derivative of integrals wrt bound

comment:4 Changed 5 months ago by charpent

  • Status changed from needs_review to positive_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 5 months ago by vbraun

  • Status changed from positive_review to needs_work

reviewer name is missing

comment:6 Changed 5 months ago by charpent

  • Reviewers set to Emmanuel Charpentier
  • Status changed from needs_work to positive_review

Wups ! Fixed...

comment:7 Changed 4 months ago by vbraun

  • Branch changed from u/chapoton/28656 to 90679c38dca8f770ff8227d8fdf2d3ac9d86ed83
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.