# Calculus: Integral of a function [duplicate]

For all $$-1, I'm trying to solve the following integral: $$\int_{-\infty}^\infty z\frac{e^{z(k+1)}}{(1+e^z)^2}dz.$$ My firt attempt was to use change of variables: $$t=e^z\implies z=\ln(t)\implies dz/dt=1/t$$. Hence, $$$$\int_{-\infty}^\infty z\frac{e^{z(k+1)}}{(1+e^z)^2}dz=\int_{0}^\infty \ln(t)\frac{t^{k}}{(1+t)^2}dt. \quad (1)$$$$ But the expression on the RHS of $$(1)$$ is not easy to solve. WolframAlpha asserts that $$$$\int_{0}^\infty \ln(t)\frac{t^{k}}{(1+t)^2}dt=\pi(1-\pi k \cot(\pi k))\csc(\pi k), \quad (2)$$$$ which I'm unable to show.

Can someone help me with the steps to show that $$(2)$$ is valid?

• Just a hunch, maybe some residues may be useful, as I see cotangents and cosecants of certain angles. Commented yesterday

There's something really clever at play here using the beta function. Using the second formula as seen in the Wikipedia article (which uses the substitution $$t \mapsto \frac{t}{1+t}$$; see, e.g. here, we can write

$$B(p, q) = \int_0 ^1 t^{p-1} (1-t)^{q-1} \ dt = \int_0 ^\infty \frac{t^{p+q-1}}{(1+t)^{p+q}} \ dt.$$

Set $$p = k+1$$ and $$q = 1-k.$$ We have the related integral

$$B(k+1, 1-k) = \int_0 ^\infty \frac{t^k}{(1+t)^2} \ dt$$

which is very close to the desired integral. Now, as $$\frac{\partial}{\partial k} t^k = t^k \ln t$$ we'll follow the trick from Svyatoslav so we obtain

$$\frac{\partial B(k+1, 1-k)}{\partial k} = \int_0 ^\infty \ln t \frac{t^k}{(1+t)^2} \ dt.$$

Now by using properties of the beta and gamma functions,

\begin{align*} B(k+1, 1-k) &= \frac{\Gamma(k+1) \Gamma(1-k)}{\Gamma(2)} \\ &= k\Gamma(k) \Gamma(1-k) \\ &= \frac{k\pi}{\sin k \pi}. \end{align*}

Taking the derivative now gives

$$\frac{d}{dk} \left( \frac{k\pi}{\sin k \pi} \right) = \pi \csc k\pi \left( 1 - k\pi \cot k\pi \right)$$

as desired.

• What did you use to ensure the interchange between improper integral and differentiation? Commented 20 hours ago
• Note that $t^k$ is continuous for $k \in (-1, 1)$ as well as its derivative. Commented 20 hours ago

Let’s start with $$\int_{-\infty}^{\infty} \frac{z e^{z(k+1)}}{\left(1+e^z\right)^2} d y \stackrel{t=e^z}{=} \int_0^{\infty} \frac{t^k \ln t}{(1+t)^2} d t=I’(k)$$ where the parametrised integral $$I(a)=\int_0^{\infty} \frac{t^a}{(1+t)^2} d t.$$ Let $$y=\frac{1}{1+t}$$, then \begin{aligned} I(a) & =\int_0^1\left(\frac{1}{y}-1\right)^a d y \\ & =\int_0^1 y^{-a}(1-y)^a d y \\ & =B(1-a, 1+a) \\ & =\frac{\Gamma(1-a) \Gamma(1+a)}{\Gamma(2)} \\ & =a \Gamma(1-a) \Gamma(a) \\ & =a \pi \csc (\pi a) \end{aligned} Differentiating $$I(a)$$ w.r.t. $$a$$ at $$a=k$$ yields $$\boxed{\int_{-\infty}^{\infty} \frac{z e^{z(k+1)}}{\left(1+e^z\right)^2} d y = I^{\prime}(k)=\csc (\pi k)(1-k \pi \cot (\pi k))}$$