1
$\begingroup$

I have a function defined like :

g[n_, x_] := ((n + 2)*Cos[π*(n + 2)*x] - Cot[π*x] *Sin[(n + 2)*π*x])

and I want to do the following :

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

But this results in the error :

Integrate::idiv: Integral of x ((2+m) Cos[(2+m) π x]-Cot[π x] Sin[(2+m) π x]) ((2+n) Cos[(2+n) π x]-Cot[π x] Sin[(2+n) π x]) does not converge on {0,1}.

On the other hand, if I specify values of n and m it gives me a numerical output, as desired. Experimenting with the numbers, I have been able to determine that whenever m = n + odd#, where odd# is any odd number > 1, the integral is zero within machine precision.

Table[Integrate[x*g[n, x]*g[n + i, x], {x, 0, 1}], {n, 3}, {i, 3}]

Results in :

{{-(6656/(735*Pi^2)), 0, -(2816/(2835*Pi^2))}, {-(15872/(945*Pi^2)), 0, -(72704/(38115*Pi^2))}, {-(1013504/(38115*Pi^2)), 0, -(1801216/(585585*Pi^2))}}

Considering the above, can someone please guide me how I can obtain the output of Integrate as a function of n or n and m? One way I can think of is to find the relation between coefficients of my output but I can't figure out how to do that by hand or by any code.

Edit : Inspired from comments I tried the following to check for specific cases of n and m values. Here I take m=n+3 which I have verified works for n upto 10 (atleast).

Integrate[x*g[n, x]*g[n + 3, x], {x, 0, 1}, 
 Assumptions -> {n \[Element] {1, 2, 3}}] (* Fails *)

Integrate[x*g[n, x]*g[n + 3, x], {x, 0, 1}] /. n -> 1 (* Works *)
Integrate[x*g[n, x]*g[n + 3, x], {x, 0, 1}] /. n -> 2 (* Works *)
Integrate[x*g[n, x]*g[n + 3, x], {x, 0, 1}] /. n -> 3 (* Works *)

```
$\endgroup$
6
  • 1
    $\begingroup$ Assumptions or Assuming is the way to go. See e.g. 1, 2 or 3. $\endgroup$
    – Artes
    May 4 '20 at 21:39
  • $\begingroup$ @Artes I tried Integrate[x*g[n, x]*g[n, x], {x, 0, 1}, Assumptions -> {n \[Element] Integers}] which provided me with output Integrate::idiv: Integral of x ((2+n) Cos[(2+n) \[Pi] x]-Cot[\[Pi] x] Sin[(2+n) \[Pi] x])^2 does not converge on {0,1}. Could you please look into this more? I am also trying to read all the discussion on the links you provided. $\endgroup$
    – Nitin
    May 4 '20 at 22:50
  • $\begingroup$ This integral is divergent because you have Cot[Pi x] in g which diverges when x goes to 0 and when it goes to 1. $\endgroup$
    – Artes
    May 4 '20 at 23:11
  • $\begingroup$ @Artes Then Mathematica shouldn't provide a finite value when I specify the value of n and m, right? But it does as can be seen from the question I posted. $\endgroup$
    – Nitin
    May 4 '20 at 23:12
  • 1
    $\begingroup$ When you specify n and m Integrate can calculate specified case, in general seems it cannot. Try to rewrite your integrand to get rid of Cot putting e.g. Cos/Sin. Perhaps you should also try the PrincipalValue option in Integrate. $\endgroup$
    – Artes
    May 4 '20 at 23:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.