I am sure this is an easy question. Although I am new in mathematica. I want to integrate a function that has some (removable) singularities. $ f_h(x) = -x\cot{h\pi x} - \frac{1}{\pi h}\sum_{j=1}^{h} \frac{j}{j-hx}$ I want to compute $\int_{0}^{1}f_h(x)\,dx.$ I executed the following code

f = -x*cot (Pi*x) - 1/(Pi*(1 - x)); Integrate[f, {x, 0, 1}]

Integrate::idiv: "Integral of 1/([Pi](-1+x))-cot [Pi] x^2 does not converge on {0,1}."

Although the answer is $-\frac{\ln{2\pi}}{\pi}.$ How to fix my code to work for general h?


h = 4; 
g = 1/(h*Pi)* Sum[(i/(i - h*x)), {i, h}]; 
F = - x*Cot[h*Pi*x] - g;
Integrate[F, {x, 0, 1}]

we get

$-\frac{Log[192 \pi^2]}{8\pi}$


closed as off-topic by Daniel Lichtblau, happy fish, m_goldberg, Mr.Wizard Apr 23 at 23:09

This question appears to be off-topic. The users who voted to close gave these specific reasons:

  • "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – Mr.Wizard
  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Daniel Lichtblau, happy fish, m_goldberg
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Try Pi not pi and Cot[Pi*x] not cot (pi*x). $\endgroup$ – Mariusz Iwaniuk Apr 23 at 19:05
  • $\begingroup$ ok. I got the same answer, $\endgroup$ – 111 Apr 23 at 19:06
  • 1
    $\begingroup$ In version 10.1 the input f = -x*Cot[Pi*x] - 1/(Pi*(1 - x)); Integrate[f, {x, 0, 1}] gives the output -(Log[2 Pi]/Pi). Are you seeing something else? $\endgroup$ – Mr.Wizard Apr 23 at 23:09
  • $\begingroup$ my bad. When I changed cot(Pix) with Cot[Pix] I got the right result. $\endgroup$ – 111 Apr 24 at 0:24

Include the option PrincipalValue -> True:

Integrate[-x Cot[π x] -1/(π (1-x)), {x, 0, 1}, PrincipalValue->True]

-(Log[2 π]/π)

  • $\begingroup$ @111 I don't think there's a principal value for $h>1$, since the pole at $x=1$ doesn't cancel. $\endgroup$ – Carl Woll Apr 23 at 22:34

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