I want mathematica to do

Integrate[D[f[x],x], {x,0,t}]

and achieve the answer f[t]-f[0]. But Mathematica doesn't intergrate it.

Any ideas?

  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – user9660 Nov 24 '14 at 20:45
  • $\begingroup$ Try with f[x_]:= Log@x .... $\endgroup$ – Dr. belisarius Nov 24 '14 at 20:49
  • $\begingroup$ No problem in $Version -> "8.0 for Microsoft Windows (64-bit) (October 7, 2011)". Integrate[D[f[x], x], {x, 0, t}] (* Out[284]= -f[0] + f[t] *) $\endgroup$ – Dr. Wolfgang Hintze Nov 24 '14 at 21:46
  • 1
    $\begingroup$ I confirm that in v.8.0.4 Integrate[D[f[x],x], {x,0,t}] returns -f[0] + f[t] but in v.10.0.1 it returns unevaluated. $\endgroup$ – Alexey Popkov Nov 24 '14 at 22:39

I'd use this nice method by Jens how to simplify symbolic integration (notice, need the SetAttributes for version 10)

Clear[f, ff];
f /: Integrate[f[x_], x_] := ff[x];
SetAttributes[ff, {NumericFunction}]
Integrate[f[x], {x, 0, t}] /. ff -> f

Mathematica graphics

  • 1
    $\begingroup$ Actually, simply declaring f to be a NumericFunction is enough: Block[{f}, SetAttributes[f, {NumericFunction}]; Integrate[f'[x], {x, 0, t}]] $\endgroup$ – Michael E2 Apr 8 '17 at 21:58

Mathematica solves the equivalent differential equation:

y[t] /. First@DSolve[{y'[t] == f'[t], y[0] == 0}, y, t]
  -f[0] + f[t]

Another approach is to add an assumption, in the form of an upvalue for the limit of f, that makes f continuous:

 f /: Limit[f[x_], x_ -> c_, ___] := f[c];
 Integrate[D[f[x], x], {x, 0, t}]
(*  -f[0] + f[t]  *)

It works because Integrate evaluates the antiderivative by means of directional limits at the end points. This observation, perhaps, indicates why Mathematica does not automatically apply the Fundamental Theorem of Calculus to the integral: It is not valid in all cases. In fact, the result above is not valid in all cases, since it yield zero for the following positive (and divergent!) integrand:

% /. f -> (1/(2 # - t)^2 &)
(*  0  *)

You could define the following substitution:

integrateByIndefiniteSub = 
  Integrate[arg_, {x_, xLow_, xHigh_}] :> 
    Subtract @@ (Integrate[arg, x] /. {{x -> xHigh}, {x -> xLow}} );


Integrate[D[f[x],x], {x,0,t}] /. integrateByIndefiniteSub
(* Returns:   -f[0] + f[t] *)

This method takes advantage of the fact that Mathematica can do the simplifications properly in an indefinite integral. It first evaluates the indefinite integral, and then subs in the bounds and subtracts.

However, when Mathematica can't antidifferentiate it, you end up with something unhelpful:

Integrate[g[x], {x, a, b}] /. integrateByIndefiniteSub
(* Returns:   -∫ g[a] d a  + ∫ g[b] d b  *)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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