Can we find a closed form for the following integral (in terms of any known constants, elementary or special functions)? Numerical value obtained by Wolfram Alpha is:
$$I=\int_0^{\pi/2} \frac{x-\sin x}{\tan x-x} dx=0.51235905260998669767\dots$$
The function under the integral is very nice in the range of interest and looks like this:
What we know about the function under the integral:
$$f(x)=\frac{x-\sin x}{\tan x-x} $$
$$f(-x)=f(x)$$
$$\lim_{x \to 0} f(x)=\frac{1}{2}$$
$$\lim_{x \to 0} f'(x)=0$$
$$\lim_{x \to \pi/2} f(x)=0$$
$$\lim_{x \to \pi/2} f'(x)=1-\frac{\pi}{2}$$
The function is very closely approximated by its Taylor series (in the range of interest):
$$f(x)=\frac{1}{2}-\frac{9}{40}x^2+\frac{27}{2800}x^4-\frac{27}{112000}x^6+\cdots$$
This allows us to estimate the integral:
$$\frac{\pi}{4}-\frac{3}{320}\pi^3+\frac{27}{448000}\pi^5-\frac{27}{100352000}\pi^7 < I < \frac{\pi}{4}-\frac{3}{320}\pi^3+\frac{27}{448000}\pi^5$$
Or numerically (with correct digits highlighted):
$$\color{blue}{0.5123}4485141169155 < I < \color{blue}{0.51}315747016517901$$
Provided no closed form exists (which I find likely) can we find a different integral or series expression with general terms expressed in terms of known elementary or special functions?
We can also write:
$$I=\int_0^{\pi/2} \frac{\pi /2-x-\cos x}{\cot x+x-\pi/2} dx$$
Though, in this case I don't see how to use this.
Integrating by parts is hard, because for the obvious choices of $u$, we get divergence at $0$. Choosing the whole integrated function as $u$ makes the expression more complicated:
$$I=\int_0^{\frac{\pi }{2}} \frac{ x \left(1-\cos ^3 x\right)+\sin x \cos 2 x-\frac{1}{2} \sin 2 x}{(x \cos (x)-\sin (x))^2} x\, dx$$
Or maybe contour integration could work here? In this case it will involve logarithms, which I don't know how to deal with.
Putting $e^{i x}=z$ and choosing the contour to be a half of the unit circle (possibly, I'm not sure), we will have:
$$I=\frac{1}{4} \int_{-\pi/2}^{\pi/2} \frac{(2 i x -e^{ix}+e^{-ix})(e^{i x}+e^{-ix})}{e^{ix}-e^{-ix}-ix(e^{ix}+e^{-ix})} dx=\frac{1}{4i} \oint \frac{(2 z \log z-z^2+1)(z^2+1)}{(z^2-1-(z^2+1) \log z)z^2} dz$$
I have no idea what to do with logarithms, and it seems to me as the only singularity the function has inside the contour is at $z=0$.

A short answer regarding the series expansion of the integral.
Let $\,\displaystyle a_{m,n}:=\int_0^{\frac{\pi}{2}}(\cos x)^m \left(\frac{x}{\sin x}\right)^n\,$ with $\,\,m,n\in\mathbb{N}_0\,$.
It’s $\enspace\displaystyle a_{0,0}=\frac{\pi}{2}\enspace$ , $\enspace\displaystyle a_{m,0}=\frac{\sqrt{\pi}}{2}\frac{\Gamma\left(\frac{m-1}{2}\right)}{\Gamma\left(\frac{m}{2}\right)}\enspace$ for $\enspace m>0\,$
and $\enspace\displaystyle a_{0,n}=I_n\enspace$ ( see my answer in Generalised Integral $I_n=\int_0^{\pi/2} \frac{x^n}{\sin ^n x} \ \mathrm{d}x, \quad n\in \mathbb{Z}^+.$ ) .
It's: $$\int\limits_0^{\frac{\pi}{2}}\frac{x-\sin x}{\tan x - x}dx = -\frac{\pi}{2} + \int\limits_0^{\frac{\pi}{2}}\frac{1-\cos x}{1-x\cot x}dx = -\frac{\pi}{2} + \sum\limits_{n=0}^\infty (a_{n,n} – a_{n+1,n}) $$
For $\,n\ge 1\,$ we have:
with the Stirling numbers of the first kind $\begin{bmatrix}n\\k\end{bmatrix}$ defined by $\displaystyle\sum\limits_{k=0}^n\begin{bmatrix}n\\k\end{bmatrix}x^k:=\prod\limits_{k=0}^{n-1}(x+k),$
and $\enspace\beta(s)$ := Dirichlet $\beta$ function, $\enspace\eta(s)$ := Dirichlet $\eta$ function, $\,\,$ and their analytical extensions which also can be read in my answer of the question Generalised Integral $I_n=\int_0^{\pi/2} \frac{x^n}{\sin ^n x} \ \mathrm{d}x, \quad n\in \mathbb{Z}^+.$