7
$\begingroup$

Here is some Mathematica code:

kroneckerIntegral = Integrate[Sin[m*Pi*x]*Sin[n*Pi*x], {x, 0, 1}, Assumptions -> {n \[Element] Integers, m \[Element] Integers}]
FullSimplify[kroneckerIntegral, {n \[Element] Integers, m \[Element] Integers}]
FullSimplify[Integrate[Sin[m*Pi*x]*Sin[m*Pi*x], {x, 0, 1}], {m \[Element] Integers}]

The resulting Mathematica output of these three lines is:

$$\frac{n \sin (\pi m) \cos (\pi n)-m \cos (\pi m) \sin (\pi n)}{\pi m^2-\pi n^2}$$ $$0$$ $$\frac{1}{2}$$

So essentially kroneckerIntegral can be written in terms of a Kronecker delta as $\frac{\delta_{mn} - \delta_{-nm}}{2}$, which is also a direct result of the well known Fourier orthogonality relations.

Now how do I get Mathematica to simplify the integral to that expression? The reason I want to do this is because I have some long calculation that involves a few of these integrals and it would be convenient to tell Mathematica e.g. in form of a rule that I need this expression in terms of the Kronecker delta.

$\endgroup$
3
  • 2
    $\begingroup$ Actually, the result isn't what you state. It's $\frac{1}{2}(\delta_{m,n}-\delta_{m,-n})$. $\endgroup$
    – Jens
    Jun 13, 2017 at 18:27
  • 1
    $\begingroup$ Related: Teaching Mathematica more about DiracDelta and KroneckerDelta $\endgroup$
    – Jens
    Jun 13, 2017 at 18:46
  • $\begingroup$ @Jens thanks for the linked question and that correction! I completely forgot about those negative numbers ;) I added your result to the question. $\endgroup$ Jun 14, 2017 at 5:56

1 Answer 1

4
$\begingroup$

Edit: updated with Jens' correct term.


Not sure if this is exactly what you are looking for, but it gets you close? Uses Inactivate to do a replace of the integral...

term = Inactivate[ Integrate[Sin[m*Pi*x]*Sin[m*Pi*x], {x, 0, 1}] ]
kroneckerTerm = term/.term->1/2(KroneckerDelta[m,n]-KroneckerDelta[m,-n])

kroneckerTerm/.{n->2,m->3}

(*  0 *)

kroneckerTerm/.{n->2,m->2}

(*  1/2 *)

If you are trying to do a find and replace on some really large expression, you can inactivate the whole thing, do a replace, and Activate it. For example...

bigterm = Inactivate[
          Integrate[Sin[m*Pi*x]*Sin[m*Pi*x], {x, 0, 1}] + 
          Integrate[Sin[m*Pi*x]*Sin[m*Pi*x], {x, 0, 1}]^2 + 
          Sin[Integrate[Sin[m*Pi*x]*Sin[m*Pi*x], {x, 0, 1}]]
          ];

(bigterm/. term -> 1/2 (KroneckerDelta[m, n] - KroneckerDelta[m, -n]))//Activate

(*  1/2 (-KroneckerDelta[m, -n] + KroneckerDelta[m, n])  
   + 1/4 (-KroneckerDelta[m, -n] + KroneckerDelta[m, n])^2  
   + Sin[1/2 (-KroneckerDelta[m, -n] + KroneckerDelta[m, n])]  *)
$\endgroup$
2
  • $\begingroup$ +1 awesome stuff, exactly what I needed! $\endgroup$ Jun 14, 2017 at 8:24
  • $\begingroup$ Glad to help! Props to @Carl Woll for turning me on to Inactivate $\endgroup$
    – MikeY
    Jun 14, 2017 at 12:23

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.