5
$\begingroup$

I have an implicit function $f$. It is an odd function such that we get zero if we do a symmetric integration of $\int^{a}_{-a} \frac{d^nf(x)}{dx^n} dx$ when $n$ is an even natural number. However, when $n$ is odd, the integration does not evaluate to zero.

The function $f$ is juxtaposed with other trigonometric functions in my calculations. How can I teach Mathematica that $f$ is odd so that when I apply the "FullSimplify" function, the Mathematica should evaluate the symmetric integration of f to zero?

For instance, if I had taught Mathematica that function is odd and $n$ is even natual number, the integration $\int^{a}_{-a} cos(x) \frac{d^nf (x)}{dx^n} dx$ should evaluate to zero, and $\int^{a}_{-a} sin(x) \frac{d^nf(x)}{dx^n} dx$ should not.

Example of Mathematica code: Without specifying any explicit expression for f, the code

Integrate[Cos[x] D[f[x], {x, 2}], {x, -a, a}]

should return zero and

Integrate[Sin[x] D[f[x], {x, 2}], {x, -a, a}]

should not. I feel there may be a way to do it using Assumptions. The cos and sin functions in the code above should be replaced by any even and odd functions, respectively.

$\endgroup$
4
  • 2
    $\begingroup$ What happens if you apply the identity for odd functions, $f(x) = [f(x)-f(-x)]/2$? $\endgroup$
    – Michael E2
    Commented Aug 31, 2022 at 22:07
  • $\begingroup$ f(x). Did I make a mistake in writing the question? @MichaelE2 Sorry, I did not follow your comment. $\endgroup$
    – akr
    Commented Aug 31, 2022 at 22:17
  • 2
    $\begingroup$ I don't understand how your problem is set up in code, so I don't know how to advise on how to implement the suggestion. You can post an example in code, or try to see if the idea can be applied. The idea is that, while Mathematica cannot tell whether $f(x)$ is odd, the equivalent expression $[f(x)-f(-x)]/2$ is provably odd whatever $f(x)$ is. $\endgroup$
    – Michael E2
    Commented Aug 31, 2022 at 22:22
  • $\begingroup$ Thank you for your reply @MichaelE2. I edited the question. $\endgroup$
    – akr
    Commented Aug 31, 2022 at 22:30

2 Answers 2

5
$\begingroup$

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  *)
$\endgroup$
1
  • $\begingroup$ Thanks a lot, @Michael E2! I learned a lot from your answer. $\endgroup$
    – akr
    Commented Sep 2, 2022 at 14:38
3
$\begingroup$

Something can be done in such a way. First, we consider the derivative of the integral $\int_a^a\cos x f''(x)\,dx$ w.r.t. the parameter $a$

D[Integrate[Cos[x]*D[f[x], {x, 2}], {x, -a, a}], a]

Second, under the assumption that the function $f$ (and its second derivative) is odd, we simplify it to zero by

FullSimplify[D[Integrate[Cos[x]*D[f[x], {x, 2}], {x, -a, a}], a], 
Assumptions -> f''[x_] + f''[-x_] == 0]

0

This implies that the integral under consideration is a constant. Since for a==0 we have 0, we conclude that constant equals zero.

$\endgroup$

Your Answer

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

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