0
$\begingroup$

I was trying to answer this question: $\frac{\mathrm d}{\mathrm dt}\int_{t-\mathrm d1}^t \int_h^t f(s) \,\mathrm ds\,\mathrm dh$. I got the accepted answer by hand (using the Leibniz integral rule) but why does Mathematica (and Maple) give the seemingly wrong $\mathrm d_{{1}}f \left( t \right) \color{orange}{-}\int_{t-\mathrm d_{{1}}}^{t}\!f \left( s \right) \,{\rm d}s=\mathrm d_{{1}}f \left( t \right) \color{orange}{-}F \left( t \right) \color{orange}{+} F \left( t-\mathrm d _{{1}} \right)$ instead of $\mathrm d_{{1}}f \left( t \right) \color{lime}{+}\int_{t-\mathrm d_{{1}}}^{t}\!f \left( s \right) \,{\rm d}s=\mathrm d_{{1}}f \left( t \right) \color{lime}{+}F \left( t \right) \color{lime}{-} F \left( t-\mathrm d _{{1}} \right)$

The Mathematica code I used is D[Integrate[Integrate[f[s], {s, h, t}], {h, t - d1, t}], t].

$\endgroup$
11
  • 1
    $\begingroup$ I think Mathematica is right, but I have dyslexia. I could be wrong. $\endgroup$
    – Michael E2
    May 27, 2020 at 13:29
  • $\begingroup$ Until the observed behavior has been confirmed by other users to be a bug, do not use the bugs tag. $\endgroup$ May 27, 2020 at 13:29
  • 1
    $\begingroup$ You can write the integral more simply as D[Integrate[f[s], {h, t - d1, t}, {s, h, t}], t] - you don't need to write Integrate twice. $\endgroup$
    – flinty
    May 27, 2020 at 13:33
  • 1
    $\begingroup$ @flinty Note it is a different computation that is supposed to be mathematically equivalent. If you think there's a bug, the form might be important. In this case, I think it's irrelevant. I think Leponzo made a mistake in the by-hand check. $\endgroup$
    – Michael E2
    May 27, 2020 at 13:39
  • 1
    $\begingroup$ Sometimes, to make it easier on myself, I work with a negative-index Derivative[]: D[Integrate[Derivative[-1][f][t] - Derivative[-1][f][h], {h, t - d1, t}], t]. $\endgroup$ May 27, 2020 at 13:55

1 Answer 1

2
$\begingroup$

Let the inner integral result be $F(t)-F(h)$ where $F$ is the antiderivative of $f$. Then break $\int_{t-d1}^{t}F(t)-F(h)\mathrm{dh}$ into $\int_{t-d1}^{t}F(t)\mathrm{dh}$ and $-\int_{t-d1}^{t} F(h)\mathrm{dh}$.

The first integral is just $hF(t)\Big|_{t-d1}^{t}=t F(t)-(t-d1)F(t)=d1 F(t)$.

The second integral is $-\int_{t-d1}^{t} F(h)\mathrm{dh}=G(t-d1)-G(t)$ where $G$ is the antiderivative of $F$.

Differentiate with respect to $t$ and we get: $$ \frac{d}{dt}\left[d1 F(t) +G(t-d1)-G(t)\right]=d1 F'(t)+G'(t-d1)-G'(t) \\ =d1f(t)+\left[F(t-d1)-F(t)\right]=d1f(t)-\left[F(t)-F(t-d1)\right] $$ I added the brackets for emphasis. Notice how $\left[F(t)-F(t-d1)\right]$ is just $\int_{t-d1}^{t}f(h)\mathrm{dh}$ we set up at the start. Therefore without needing the Leibniz rule at all Mathematica is correct in saying: D[Integrate[Integrate[f[s], {s, h, t}], {h, t - d1, t}], t] == d1*f[t] - Integrate[f[s], {s, -d1 + t, t}]

$\endgroup$
7
  • 1
    $\begingroup$ Slightly modifying the code I posted in an earlier comment: D[Integrate[Derivative[-1][f][t], {h, t - d1, t}] - Integrate[Derivative[-1][f][h], {h, t - d1, t}], t]. $\endgroup$ May 27, 2020 at 15:32
  • 1
    $\begingroup$ Ah yes I didn't realize Derivative[-1][f][t] was a thing. Hopefully seeing it step by step assures Leponzo this is not a bug. $\endgroup$
    – flinty
    May 27, 2020 at 15:36
  • $\begingroup$ Thanks! I added my own version of the answer (consistent with Mathematica, Maple, and the Leibniz integral rule) here (although I still can't pinpoint where the accepted answer there went wrong). $\endgroup$
    – Leponzo
    May 27, 2020 at 17:42
  • $\begingroup$ @MichaelE2 Still didn't get what's wrong :( $\endgroup$
    – Leponzo
    May 27, 2020 at 22:29
  • $\begingroup$ @Leponzo your answer there looks fine to me. $\endgroup$
    – flinty
    May 27, 2020 at 22:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.