Opened 3 years ago

Closed 2 years ago

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

Reported by: Owned by: Emmanuel Charpentier major sage-9.2 symbolics Frédéric Chapoton Emmanuel Charpentier N/A 90679c3 90679c38dca8f770ff8227d8fdf2d3ac9d86ed83

### Description

```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)
f(b)
sage: F1(a, b).diff(a)
-f(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)
4175
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)()
220
221     for arg in derivative_parse(args):
--> 222         F = F._derivative(arg)
223     return F
224

/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/integral.py in _tderivative_(self, f, x, a, b, diff_param)
254             ans = SR.zero()
255         return (ans + f.subs(x == b) * b.diff(diff_param)
--> 256                     - f.subs(x == a) * a.diff(diff_param))
257
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)
490
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)
503
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         dummy_error_message.name = 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.

### comment:1 Changed 3 years ago by Erik Bray

Milestone: sage-9.0 → sage-9.1

Ticket retargeted after milestone closed

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

Milestone: sage-9.1 → 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 2 years ago by Frédéric Chapoton

Authors: → Frédéric Chapoton → u/chapoton/28656 → 90679c38dca8f770ff8227d8fdf2d3ac9d86ed83 new → needs_review

here is a fix

New commits:

 ​90679c3 `trac 28656 some fix for derivative of integrals wrt bound`

### comment:4 Changed 2 years ago by Emmanuel Charpentier

Status: needs_review → 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 `README.md`, 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_review → needs_work

reviewer name is missing

### comment:6 Changed 2 years ago by Emmanuel Charpentier

Reviewers: → Emmanuel Charpentier needs_work → positive_review

Wups ! Fixed...

### comment:7 Changed 2 years ago by Volker Braun

Branch: u/chapoton/28656 → 90679c38dca8f770ff8227d8fdf2d3ac9d86ed83 → fixed positive_review → closed
Note: See TracTickets for help on using tickets.