1

My question pertains to the inconsistency that may arise in indefinite integrals vs definite integrals in Mathematica due to the indefinite integral being discontinuous as explained here.

I want to evaluate the following integral and obtain the result as a function of n and m, the latter is absolutely crucial to me :

$ g(n,x) = \sqrt{\frac{2}{(n+2)^2 - 1}} \left\{ (n+2) \cos[(n+2) \pi x] - \cot(\pi x) \sin[ (n+2) \pi x] \right\}$ and $x_{nm}(n,m) = \int_0^1 dx\ g(n,x)\ x\ g(m,x)$.

Naively, integrating this results in a non-converging integral. So, I tried to do an indefinite integral and take the limits and then subtract to get the result. This gives me inconsistent result when n=m and when |n-m| is even. In both cases I get indeterminate result whereas if I go with definite integral (while specifying the value of n and m) then in the former I get finite result and in the latter I get 0. Except this the method works absolutely fine.

I realize that this comes from the discontinuity in the anti-derivative obtained using Integrate and I have read the blog post linked above but can't make it work for me. Can someone please help me resolve the inconsistency?

All Mathematica Code pertaining to this is below :-

g[n_, x_] := 
  Sqrt[2/((n + 2)^2 - 
    1)] ((n + 2)*Cos[\[Pi]*(n + 2)*x] - 
     Cot[\[Pi]*x]*Sin[(n + 2)*\[Pi]*x]);

Integrate[ g[n, x] * g[m, x] *x, {x, 0, 1}, 
 Assumptions -> {n \[Element] Integers, m \[Element] Integers}] (* Indeterminate *)

Integrate[ g[n, x] * g[m, x] *x, x, 
 Assumptions -> {n \[Element] Integers, m \[Element] Integers}]

(* Output-

2 Sqrt[1/(3 + 4 m + m^2)] Sqrt[1/(
 3 + 4 n + 
  n^2)] (-(1/(
    2 (m - n) (4 + m + n) \[Pi]))((
      2 (2 + m) (3 + 4 m + m^2) (2 + 
         n) Cos[(2 + m) \[Pi] x] Cos[(2 + n) \[Pi] x])/((-m + n) (4 + 
         m + n) \[Pi]) - (1/(
      2 \[Pi]))(-((
         E^(I (m - n) \[Pi] x) (m^2 - m (-1 + 4 n + n^2) - 
            3 (2 + 4 n + n^2)) Hypergeometric2F1[1, (m - n)/2, 
           1/2 (2 + m - n), E^(2 I \[Pi] x)])/(m - n)) - (
        E^(I (2 + m - n) \[Pi] x) (6 + m^2 + 4 n + n^2 + 
           m (7 + 4 n + n^2)) Hypergeometric2F1[1, 1/2 (2 + m - n), 
          1/2 (4 + m - n), E^(2 I \[Pi] x)])/(2 + m - n) + (
        1/((2 + m + n) (4 + m + n)))
        E^(-2 I (3 + m + 
            n) \[Pi] x) (-E^(
             I (2 + m + n) \[Pi] x) (12 + m^3 + 14 n + 6 n^2 + n^3 + 
              m^2 (9 + 5 n + n^2) + 
              m (20 + 19 n + 7 n^2 + n^3)) Hypergeometric2F1[
             1, -2 - m/2 - n/2, -1 - m/2 - n/2, E^(2 I \[Pi] x)] - 
           E^(I (4 + m + n) \[Pi] x) (m^3 - m^2 (-5 + 3 n + n^2) - 
              3 (8 + 18 n + 8 n^2 + n^3) - 
              m (2 + 27 n + 11 n^2 + n^3)) Hypergeometric2F1[
             1, -1 - m/2 - n/2, -(m/2) - n/2, E^(2 I \[Pi] x)])) - (
      1/(2 \[Pi]))((
        E^(-I (m - n) \[Pi] x) (6 + m^2 + 4 n + n^2 + 
           m (7 + 4 n + n^2)) Hypergeometric2F1[1, 1/2 (-m + n), 
          1/2 (2 - m + n), E^(2 I \[Pi] x)])/(m - n) + (
        E^(-I (-2 + m - n) \[Pi] x) (m^2 - m (-1 + 4 n + n^2) - 
           3 (2 + 4 n + n^2)) Hypergeometric2F1[1, 1/2 (2 - m + n), 
          1/2 (4 - m + n), E^(2 I \[Pi] x)])/(-2 + m - n) + (
        1/((4 + m + n) (6 + m + n)))(E^(
           I (4 + m + n) \[Pi] x) (m^3 - m^2 (-7 + 3 n + n^2) - 
             m n (35 + 13 n + n^2) - 
             3 (12 + 26 n + 10 n^2 + n^3)) Hypergeometric2F1[1, 
            1/2 (4 + m + n), 1/2 (6 + m + n), E^(2 I \[Pi] x)] + 
          E^(I (6 + m + n) \[Pi] x) (24 + m^3 + 22 n + 8 n^2 + n^3 + 
             m^2 (11 + 5 n + n^2) + 
             m (34 + 27 n + 9 n^2 + n^3)) Hypergeometric2F1[1, 
            1/2 (6 + m + n), 1/2 (8 + m + n), E^(2 I \[Pi] x)])) + (
      2 (3 + 4 m + m^2) (2 + 
         n)^2 Sin[(2 + m) \[Pi] x] Sin[(2 + n) \[Pi] x])/((-m + 
         n) (4 + m + n) \[Pi])) + (1/(2 (m - n) (4 + m + n) \[Pi]))
   x (2 (3 + 4 m + m^2) (2 + 
         n) Cos[(2 + n) \[Pi] x] Sin[(2 + m) \[Pi] x] - 
      2 ((2 + m) (3 + 4 n + n^2) Cos[(2 + m) \[Pi] x] + (4 m + m^2 - 
            n (4 + n)) Cot[\[Pi] x] Sin[(2 + m) \[Pi] x]) Sin[(2 + 
           n) \[Pi] x]))
*)

(* Taking limits, subtracting and using a FullSimplify gives the following *)

(1/(2 \[Pi]^2))(-1 + (-1)^(m + n)) Sqrt[1/(3 + 4 m + m^2)] Sqrt[1/(
 3 + 4 n + 
  n^2)] ((4 (2 + m) (2 + n) (6 + m (4 + m) + n (4 + n)))/((m - 
      n)^2 (4 + m + n)^2) + HarmonicNumber[1/2 (-2 + m - n)] - 
   HarmonicNumber[-3 - m/2 - n/2] + HarmonicNumber[1/2 (-2 - m + n)] -
    HarmonicNumber[1/2 (2 + m + n)])

(* Trying for m->n limit and checking the result : *)
Limit[1/(2 \[Pi]^2) (-1 + (-1)^(m + n)) Sqrt[1/(3 + 4 m + m^2)] Sqrt[
  1/(3 + 4 n + 
   n^2)] ((4 (2 + m) (2 + n) (6 + m (4 + m) + n (4 + n)))/((m - 
       n)^2 (4 + m + n)^2) + HarmonicNumber[1/2 (-2 + m - n)] - 
    HarmonicNumber[-3 - m/2 - n/2] + 
    HarmonicNumber[1/2 (-2 - m + n)] - 
    HarmonicNumber[1/2 (2 + m + n)]), m -> n]

(* Output : DirectedInfinity[Sign[-1 + (-1)^(2 n)]/Sqrt[1/
  Sign[3 + 4 n + n^2]]] Sqrt[1/Sign[3 + 4 n + n^2]] *)

With[{n = 2, m = 2}, Integrate[ g[n, x] * g[m, x] *x, {x, 0, 1}]]

(* Output : 1/2 *)

Please help me get rid of the inconsistency.

Edit :

I had asked a related question here. I could make things work using Assumptions as explained in the comments there and then got stuck at the above-mentioned inconsistency.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Nitin
  • 431
  • 2
  • 8
  • 1
    These are hard integrals, especially going brute-force along the indefinite integration route. I would rather post it on Math.SE in a hope the some recursive relations with respect to n and m can be found. – yarchik Jun 07 '20 at 22:35
  • @yarchik I am not set on using indefinite integration route. I just want the result as a function of n,m and don't particularly care about anything else as long as the result is consistent. Also, thanks for the Math.SE suggestion, I was just going to try that! – Nitin Jun 08 '20 at 02:40
  • 1
    @Nitin it might be important to note that (don’t ask me for a reference, I can barely remember having read it haha!) the way Mathematica takes indefinite integrals is to take a definite integral from 0 to the argument, say, x or y or whatever. Perhaps this is causing issues? I’m terrible at math though so this might be useless information :D – CA Trevillian Jun 09 '20 at 09:33
  • @CATrevillian Thanks for that. I will look it up. – Nitin Jun 09 '20 at 14:19

0 Answers0