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?
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?
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

f to be a NumericFunction is enough: Block[{f}, SetAttributes[f, {NumericFunction}]; Integrate[f'[x], {x, 0, t}]]
– Michael E2
Apr 08 '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:
Block[{f},
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}} );
Usage:
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 *)
Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign!
– Nov 24 '14 at 20:45f[x_]:= Log@x.... – Dr. belisarius Nov 24 '14 at 20:49Integrate[D[f[x],x], {x,0,t}]returns-f[0] + f[t]but in v.10.0.1 it returns unevaluated. – Alexey Popkov Nov 24 '14 at 22:39