There's some hope that the problem might be solved internally within Integrate
, but I don't see how to do it. I can offer a workaround based on symmetrizeIntegrate[]
from an earlier Q&A. First some utility functions. They may be used to implement the idea that, given that $f$ is an integrable, odd function, then $f(x)$ may be replaced by its odd part $[f(x)-f(-x)]/2$, which is symbolically an odd expression.
(* Odd-function operators *)
ClearAll[oddPart, oddSym];
oddPart[f_] := ReplaceAll[f -> Function[x, (f[x] - f[-x])/2]];
oddSym[f_[x_]] :=
ReplaceAll[{g :
f[x] | Derivative[_][f][x] :> (g /. f -> Function[t, -f[-t]])}];
Within the internal auxiliary code for Integrate
are two functions Integrate`ImproperDump`OddFunction[]
and Integrate`ImproperDump`EvenFunction[]
. I don't know what their purpose is, but it makes one hope that maybe Integrate
can do what the OP wants. Combined with oddPart[]
above, they can tell whether an expression is odd or even.
Integrate`ImproperDump`OddFunction[Cos[x]*f''[x] // oddPart[f], x]
{Integrate`ImproperDump`OddFunction[Sin[x]*f''[x] // oddPart[f], x],
Integrate`ImproperDump`EvenFunction[Sin[x]*f''[x] // oddPart[f], x]}
Integrate`ImproperDump`OddFunction[Sin[x]*f'''[x] // oddPart[f], x]
(*
True
{False, True}
True
*)
They even work with assumptions and an indefinite-order derivative of an odd function — very encouraging!:
Integrate`ImproperDump`OddFunction[
Cos[x]*Derivative[n][f][x] // oddPart[f], x]
Assuming[Mod[n, 2] == 0, (* n is even *)
Integrate`ImproperDump`OddFunction[
Cos[x]*Derivative[n][f][x] // oddPart[f], x]
]
(*
False
True
*)
Despite all that encouragement, I failed to discover a way to get Integrate
to apply the odd-symmetry to the integral. So I resorted to working outside Integrate
and applying the symmetry via the utilities and symmetrizeIntegrate[]
, which averages the integrand and its reflection in a vertical line through the midpoint of the interval of integration. (This is a standard calculus trick.)
ClearAll[symmetrizeIntegrate];
SetAttributes[symmetrizeIntegrate, HoldAll];
symmetrizeIntegrate[Integrate[f_, {x_, a_, b_}, opts___]] :=
Integrate[(f + (f /. x -> a + b - x))/2, {x, a, b}, opts];
Indefinite example: Derivative order n
, separated into odd and even cases. The three steps that implement the main idea follow the three //
, the last trying to undo the conversion to the odd part in the first step. It converts back to original integrand in the OP's example, but that won't happen in every case.
Simplify[
Integrate[Cos[x]*D[f[x], {x, n}] //
oddPart[f], (* convert to odd expression *)
{x, -a, a}] //
symmetrizeIntegrate //
oddSym[f[-x]], (* optional: put back in terms of f[x] *)
Mod[n, 2] == 1] (* n odd *)
(* Integrate[Cos[x] Derivative[n][f][x], {x, -a, a}] *)
Simplify[
Integrate[Cos[x]*D[f[x], {x, n}] //
oddPart[f],
{x, -a, a}] //
symmetrizeIntegrate //
oddSym[f[-x]],
Mod[n, 2] == 0] (* n even *)
(* 0 *)
Definite example: n = 2
.
Integrate[Cos[x]*f''[x] //
oddPart[f],
{x, -a, a}] //
symmetrizeIntegrate
(* 0 *)