# Integrate has issues when integrating the general form of a trigonometric integral but not specific instances

I'm trying to solve with Mathematica the following integral for $$m$$ a positive integer

$$s=\int_{0}^{1/2}\frac{\sin^4(\pi\nu m)}{m^2\sin^2(\pi\nu)}\mathrm{d}\nu$$

which should yield $$1/(4m)$$ (I already know the solution but want to practice with Mathematica which I use too sparingly). If I solve any specific instance, I get the right result, e.g.

Integrate[Sin[Pi \[Nu] 128]^4/(128 Sin[Pi \[Nu]])^2, {\[Nu], 0, 1/2}]


yields $$1/512$$. However, if I try to solve the general case with

Integrate[Sin[Pi \[Nu] m]^4/(m Sin[Pi \[Nu]])^2, {\[Nu], 0, 1/2}, Assumptions -> m \[Element] PositiveIntegers]


or with

Integrate[Sin[Pi \[Nu] m]^4/(m Sin[Pi \[Nu]])^2, {\[Nu], -1/2, 1/2}, PrincipalValue->True, Assumptions -> m \[Element] PositiveIntegers]


I get a more convoluted expression that yields infinities when substituting an integer value for $$m$$.

I thought that the problem might be due to the singularity at $$\nu=0$$ and also tried to integrate with a lower limit different from zero and then take the limit afterward, but it didn't work. The same starting from the indefinite integral.

Any tips on how to improve the solution?

• Feb 25 at 11:07

that yields infinities when substituting an integer value for m

You need to use Limit.

integrand = Sin[Pi *v*m]^4/(m*Sin[Pi*v])^2
anti = Integrate[integrand /. m -> 128, {v, 0, 1/2},
Assumptions -> Element[m, PositiveIntegers]]


Compare to

anti = Integrate[integrand, {v, 0, 1/2}, Assumptions -> Element[m, PositiveIntegers]];


 Limit[anti, m -> 128]


If you do not use limit, you get

anti /. m -> 128


• Looking at your and Mariusz's answers it seems that there's no easy way to guide Integrate or Limit to directly yield the solution $1/(4m)$. I always find it hard to understand these Mathematica's idiosyncrasies... Feb 25 at 11:52
• @MassimoOrtolano Mathematica is not a magic box that'll spit out a solution to any problem. Maple 2023 cannot do it, either for general m. Feb 25 at 13:31

Easy way:

S = Table[Integrate[Sin[Pi  \[Nu]  m]^4/(m  Sin[Pi  \[Nu]])^2, {\[Nu], 0, 1/2}], {m, 1, 10}];
FindSequenceFunction[S, m]

(*1/(4 m)*)


Hard way:

S = Integrate[Sin[Pi  \[Nu]  m]^4/(m  Sin[Pi  \[Nu]])^2 // TrigReduce //
Expand, {\[Nu], 0, 1/2}, Assumptions -> m > 0] // FullSimplify

(*(1/(16 m^2 \[Pi]))I E^(-2 I m \[Pi]) (1 -
4 E^(2 I m \[Pi]) m \[Pi] (2 Cot[m \[Pi]] - Cot[2 m \[Pi]]) +
2 m PolyGamma[0, 1/2 - m] - 2 m PolyGamma[0, -m] -
4 E^(I m \[Pi]) (1 + m PolyGamma[0, 1/2 - m/2] -
m PolyGamma[0, -(m/2)]) +
E^(4 I m \[Pi]) (1 + 2 m PolyGamma[0, m] -
2 m PolyGamma[0, 1/2 + m]) -
4 E^(3 I m \[Pi]) (1 + m PolyGamma[0, m/2] -
m PolyGamma[0, (1 + m)/2]))*)

FullSimplify[S, Assumptions -> m \[Element] PositiveIntegers]
(*Indeterminate*)

{Table[Limit[S, m -> w], {w, 1, 10}] // FullSimplify, Table[1/(4 m), {m, 1, 10}]} // TableForm