Calculate $\sum_{k=1}^{\infty}\frac{|\sin(k x)|}{1+k^2}$
Solution 1:
Some first results
In order not to spoil the fun of those who wish to find solutions be themselves I provide here only the answers to some question (1) without deriving the results.
$$a(\frac{\pi}{2}) = \frac{1}{4} i \left(H_{-\frac{1}{2}-\frac{i}{2}}-H_{-\frac{1}{2}+\frac{i}{2}}\right)\simeq 0.72033 \tag{1a}$$
$$a(\frac{\pi}{2}) =\frac{1}{4} \pi \tanh \left(\frac{\pi }{2}\right)\tag{1b}$$
Here $H_z$ is the harmonic number of the (complex) argument $z$
$$\begin{align} a(\frac{\pi}{3})=\frac{i}{4 \sqrt{3}} \left(-H_{-\frac{1}{3}+\frac{i}{3}}-H_{-\frac{2}{3}+\frac{i}{3}}+H_{-\frac{1}{3}-\frac{i}{3}}+H_{-\frac{2}{3}-\frac{i}{3}}\right)\simeq 0.784626 \end{align}\tag{2a}$$
$$a(\frac{\pi}{3})=\frac{\pi \sinh \left(\frac{2 \pi }{3}\right)}{\sqrt{3} \left(1+2 \cosh \left(\frac{2 \pi }{3}\right)\right)}\tag{2b}$$
These results show an interesting relation of $s(x)$ to the harmonic numbers and - less obviously - to explicit functions via contour integrals and residues.
General solution to question (1)
With a nudge from @NN2's solution I have found, using Cauchy's theorem and residues, the following simple finite sum for the case of a rational argument
$$a(x=\pi \;\frac{p}{q}) = a_{Q}(p,q): = \frac{\pi}{2 q}\sum _{j=1}^{q-1} | \sin \left(\pi \frac{ p }{q} j\right)| \frac{ \sinh \left(\frac{2 \pi }{q}\right)}{ \cosh \left(\frac{2 \pi }{q}\right)-\cos \left(\frac{2 \pi j}{q}\right)}\tag{s.1}$$
This formula is the full answer to problem part (1) of the OP, and thus generalizes the special results of the initial post in the second form of the equations (i.e. $(1.b)$ and $(2.b)$ ).
Derivation
We have to consider the sum
$$a_Q(p,q) = \sum_{k=1}^{\infty} \frac{| \sin\left(\pi (\frac{p}{q}) k\right)|}{1+k^2}\tag{s.2}$$
In order to simplfy the sum, we start with the observation that the numerator of the summmand has period $q$ in $k$ to split the summation over $k$ into chunks of length $q$ writing
$$k= m q + j\tag{s.3a}$$
with the index ranges
$$m=0,1,...\tag{s.3b}$$ $$j=1,2,...,q-1\tag{s.3c}$$
notice that the $j$ needs to run only up to $q-1$ because the $\sin$-factor vanishes.
Hence our sum becomes the double sum
$$a_{Q}(p,q) = \sum_{j=1}^{q-1} \sum_{m=0}^{\infty}\frac{|\sin(\pi (\frac{p}{q}) j)|}{1+(m q + j)^2}\tag{s.4}$$
Let us now calculate the $m$-sum (designating it following @NN2)
$$u(q,j) = \sum_{m=0}^{\infty}\frac{1}{1+(m q + j)^2}\tag{s.5}$$
Partial fraction decomposition, shifting the summation index $m\to n-1$ and extracting a factor $\frac{1}{q}$ leads to
$$\begin{align} u(q,j) &= \sum_{m=0}^{\infty}\frac{1}{2 i} \left(\frac{1}{-i+m q + j}-\frac{1}{+i+m q + j}\right) \\ &=\frac{1}{2 i q} \sum_{n=1}^{\infty} \left(\frac{1}{n-1 +\frac{-i+j}{q}}-\frac{1}{n-1 +\frac{ i+j}{q}}\right) \\ &=\frac{1}{2 i q} \sum_{n=1}^{\infty} \left(\left(\frac{1}{n}-\frac{1}{n-1 +\frac{+i+j}{q}}\right)-\left(\frac{1}{n}-\frac{1}{n-1 +\frac{-i+j}{q}}\right)\right) \end{align} \tag{s.6}$$
Here, in order to obtain two summands with convergent sums, we have added and subtracted a term $\frac{1}{n}$.
Using the definition of the harmonic number for a general argument $z$
$$H_{z}=H(z) = \sum_{m=1}^{\infty}(\frac{1}{m}-\frac{1}{m+z})\tag{s.7}$$
we can write
$$\begin{align} u(q,j) &=\frac{1}{2 i q} \left(H(\frac{+i+j}{q}-1)-H(\frac{-i+j}{q}-1)\right)\\ &=\frac{1}{q}\Im(H(\frac{+i+j}{q}-1)) \end{align} \tag{s.8}$$
We can also easily find an integral representation of $u$ as follows. Writing the summand as
$$\begin{align} \frac{1}{1+(m q+j)^2}&=\Im \left(\frac{-1}{i+m q + j}\right)=-\Im(\int_{0}^{\infty}e^{-(i+m q + j)}\,dt )\\ &=\int_{0}^{\infty}\sin{t}\;e^{-(m q + j)}\,dt \end{align} \tag{s.9}$$
and performing the sum over $m$ gives finally
$$u(q,j) =\int_0^{\infty } \frac{e^{-j\; t} \sin (t)}{1-e^{-q\; t}} \, dt \tag{s.10}$$
A similar formula was first given in the answer of @NN2 (https://math.stackexchange.com/a/4024768/198592).
Summarizing up to this point, we have obtained for the infinite sum $a_{Q}(p,q)$ a finite sum over $(q-1)$ summands which however contain the more awkward harmonic functions of a complex argument, or, equivalently, a non elementary integral.
Luckily, formula $(s.1)$ shows that there is a similar sum containing more elementary functions.
The key to its derivation is extending the one-sided sum over $m$ into a two-sided sum. It turns out that this is possible if we work under the $j$-sum and take into account the specific numerator.
Derivation A)
Consider, under the sum over $j$ from $1$ to $q-1$,
$$\begin{align} &\sum_{m=-\infty}^{\infty}\frac{|\sin(\pi (\frac{p}{q}) j)|}{1+(m q + j)^2}\\ &= \sum_{m=-\infty}^{-1}\frac{|\sin(\pi (\frac{p}{q}) j)|}{1+(m q + j)^2}+\sum_{m=0}^{\infty}\frac{|\sin(\pi (\frac{p}{q}) j)|}{1+(m q + j)^2} \end{align} \tag{s.11} $$
and the first sum can be transformed as follows
$$\begin{align} &\sum_{m=-\infty}^{-1}\frac{|\sin(\pi (\frac{p}{q}) j)|}{1+(m q + j)^2}=\sum_{m=1}^{\infty}\frac{|\sin(\pi (\frac{p}{q}) j)|}{1+(-m q + j)^2}\\ &=\sum_{m=1}^{\infty}\frac{|\sin(\pi (\frac{p}{q}) j)|}{1+(m q - j)^2} \overset{j\to q-i}=\sum_{m=1}^{\infty}\frac{|\sin(\pi (\frac{p}{q}) (q-i))|}{1+(m q - q+i)^2}\\ &=\sum_{m=1}^{\infty}\frac{|\sin(\pi (\frac{p}{q}) i)|}{1+((m-1) q - +i)^2}=\sum_{m=0}^{\infty}\frac{|\sin(\pi (\frac{p}{q}) i)|}{1+(m q +i)^2} \end{align} \tag{s.12}$$
Hence we can write (with a factor $\frac{1}{2}$)
$$a_{Q}(p,q) = \frac{1}{2} \sum_{j=1}^{q-1} |\sin(\pi (\frac{p}{q}) j)| \sum_{m=-\infty}^{\infty}\frac{1}{1+(m q + j)^2}\tag{s.13}$$
Derivation B)
Let
$$\begin{align} S_1 = \sum_{j=1}^{q-1} | \sin(\pi \frac{p}{q} j) | \sum_{m \ge 0} \frac{1}{1+(q m+j)^2 }=\frac{1}{2}(S_1+S_2) \end{align} \tag{s.14}$$
where $S_2$ has the same values as $S_1$ and differs only in the direction of the summation index $j$.
We proceed with $S_2$ as follows
$$\begin{align} S_2 &= \sum_{j=q-1}^{1} | \sin(\pi \frac{p}{q} j)| \sum_{m \ge 0} \frac{1}{1+(q m+j)^2 }\\ &\overset{j\to q-i}= \sum_{i=1}^{q-1} | \sin(\pi \frac{p}{q}(q- i)) | \sum_{m \ge 0} \frac{1}{1+(q m+q-i)^2 }\\ &=\sum_{i=1}^{q-1} \left|\sin(\pi \frac{p}{q} i) \right| \sum_{m \ge 0} \frac{1}{1+(q(m+1)-i)^2 }\\ &=\sum_{i=1}^{q-1} \left|\sin(\pi \frac{p}{q} i) \right| \sum_{m \ge 0} \frac{1}{1+(-q(m+1)+i)^2 }\\ &\overset{m+1\to n}=\sum_{i=1}^{q-1} \left| \sin(\pi \frac{p}{q} i) \right| \sum_{n=-1}^{-\infty} \frac{1}{1+(q n+i)^2 } \end{align}\tag{s.15} $$
hence from $(s.14)$ follows
$$S_1 =\frac{1}{2} \sum_{j=1}^{q-1} \left| \sin(\pi \frac{p}{q} j) \right| \left( \sum_{m =-1}^{-\infty} + \sum_{m =0}^{\infty} \right) \frac{1}{1+(q m+j)^2}\tag{s.16}$$
hence the two sums add up to a double-sided sum:
$$\begin{align} a_{Q}(p,q) = S_1=\frac{1}{2}\sum_{j=1}^{q-1} | \sin(\pi \frac{p}{q} j)| \sum_{m =-\infty}^{\infty} \frac{1}{1+(q m+j)^2 } \end{align}\tag{s.17}$$
Now the double-sided sum
$$v(q,j) = \sum_{m=-\infty}^{\infty}\frac{1}{1+(m q + j)^2}\tag{s.18}$$
can be calculated by evaluating the contour integral
$$\int_C (\pi \cot(\pi m) \frac{1}{q} \frac{1}{1+(m q +j)^2}\, dm\tag{s.19}$$
over a circle of radius $R$ concentric around the origin in the complex $m$-plane. In the limit of $R \to \infty$ the integral vanishes so that $v$ is given by the sum of the residues at the two poles of $\frac{1}{1+(m q +j)^2}$ which are at $m = \frac { \pm i - j} {q}$
This leads for $1 \le j \le q-1$ to
$$v(q,j) = \frac{\pi \left(\coth \left(\frac{\pi +i \pi j}{q}\right)+\coth \left(\frac{\pi -i \pi j}{q}\right)\right)}{2 q}\tag{s.20}$$
This can be simplified to
$$v(q,j) = \frac{\pi \sinh \left(\frac{2 \pi }{q}\right)}{q \left(\cosh \left(\frac{2 \pi }{q}\right)-\cos \left(\frac{2 \pi j}{q}\right)\right)}\tag{s.21}$$
which completes the derivation of $(s.1)$.
Afterwards I noticed that Mathematica can do the two-sided sum immediately and afterwards can be used to complete the simplification.
Remark: the fact that the values of the two sums for $a_{Q}$ (i.e. using either $u$ or $v$) with the "weight factor" $|\sin(\pi \frac{p}{q}j)|$ are the same might lead at first sight to the conjecture that $v$ is the solution of the integral $(s.10)$ for $u$. But this is not the case: $u$ and $v$ are different.
Plot
Here is a discrete plot of $a_{Q}(p,q)$
The graph is gratifying as is comes very close to the origial graph for real $x$ presented in the OP.
Notice that $a_Q$ can not serve as the general solution for real $x$. We compare the two graphs in the discussion.
Discussion
§d.1
It is interesting to compare the graphs for the function $a_Q(x\in \mathbb{Q})$ if taken at discrete values (as it is intended) and for continuous values $a_Q(x\in \mathbb{R})$. What emerges looks to me like the stalactites hanging of the ceiling of a cave
The function $a_Q(x)$ with $x\in \mathbb{R}$ creates the "ceiling", and its minima (downwards peaks) are the values at the discrete argument $x\in \mathbb{Q}$.
Notice as the main result that the function $a_{Q}(x \in \mathbb{R})$ is different from the original function $a(x)$ almost everywhere (i.e. except for a countable number of points).
§d.2
Type of curve of $a(x)$
For the sake of definiteness we consider the partial sum
$$a(x,n) = \sum_{k=1}^{n} \frac{|\sin(x k)|}{(1+k^2)}$$
For fixed $n$ this is a continuous function of $x$.
The first and second derivatives are calculated from the corresponding expression for $|\sin(k x)|$, i.e.
$$\frac{d}{dx} |\sin(k x)| = \frac{d}{dx} \sqrt{\sin(k x)^2}=\frac{k \sin (k x) \cos (k x)}{\sqrt{\sin ^2(k x)}}\tag{d.1a}$$
$$\left(\frac{d}{dx}\right)^2 |\sin(k x)| = -k^2 \sqrt{\sin ^2(k x)}=-k^2 |\sin(k x)|\tag{d.1b}$$
The first derivative is discontinuous at the points where the sin vanishes, i.e. at $x = \pi \frac{m}{k}$, i.e. it has the value $-k$ for $x$ coming from below and $+k$ for $x$ coming from above. Hence $|\sin(k x)|$ and has a jump of size $2k$.
The second derivative of $|\sin(k x)|$ is continuous.
This reflects in the corresponding expressions for the partial sum which are show in the next picture
Summing up we find that the first derivative of $a(x)$ is discontinuous in all $x$ which are rational multiples of $\pi$. Without mentioning it, these were exactly the points for which $a$ had to be calculated in the OP. Hence the graph of $a'(x)$ is a sawtooth at any scale, probably even self-similar, we could call it a "rough" curve.
Casual question (1): what is the length of the graph of $a'(x)$?
Casual question (ii): what is the first derivative of $a(x)$ at $x=\frac{1}{e}$?
§d.3
I have tried to understand the sum over $j$ in the expression $(s.1)$ in the limit $q\to\infty$ as a Riemann integral, but with no avail.
Replacement of $|\sin(x)|$
I don't know if this leads to something useful but we can write
$$\begin{align}|\sin(x)| = \sin(x)\times \text{sgn}(\sin(x)) \\ =\sin (x) \; \Im\left(\frac{4}{\pi}\text{arctanh}\left(e^{i x}\right)\right)\\ = \sin (x) \; \Re\left(\frac{4}{\pi }\text{arctan}\left(e^{i \left(x-\frac{\pi }{2}\right)}\right)\right) \end{align} \tag{3} $$
here
$$\begin{align} \text{arctanh}(z) = \frac{1}{2} \left(\log(1+z)-\log(1-z) \right)\\ \text{arctan}(z) = \frac{1}{2 i} \left(\log(1+i z)-\log(1-i z) \right)\end{align}\tag{4}$$
Solution 2:
Here I provide a "semi-closed" form expression for $a(x)$ in case of $x\in \mathbb{Q}$ (rational numbers). Perhaps from it, we can obtain the closed form expression for $a(x)$ for $x\in \mathbb{R}$.
As $a(x)$ is a periodic function, it suffices to calculate $a(x)$ for $x\in (0,\pi)$.
Suppose $x\in \mathbb{Q}$, then $x=\frac{p}{q}\pi$ with $p,q\in \mathbb{N}$, $p<q$ and $(p,q)=1$. \begin{align} a(x) &= \sum_{k=1}^{\infty}\frac{|\sin(k x)|}{1+k^2} \\ &= \sum_{k=1}^{\infty}\frac{|\sin(k\frac{p}{q}\pi)|}{1+k^2} \\ &= \sum_{k=1}^q \left(\left|\sin \left(k\frac{p}{q}\pi \right)\right| \sum_{n=0}^{\infty}\frac{1}{1+(k+nq)^2} \right) \tag{1} \\ \end{align} Denote $$u(k,q)=\sum_{n=0}^{\infty}\frac{1}{1+(k+nq)^2}$$ We have \begin{align} u(k,q) &=\frac{i}{2q} \sum_{n=0}^{\infty}\frac{-2\frac{i}{q}}{(n+\frac{k}{q})^2+\frac{1}{q^2}} \\ &=\frac{i}{2q} \sum_{n=0}^{\infty} \left(\frac{1}{n+\frac{k}{q}+\frac{i}{q}}-\frac{1}{n+\frac{k}{q}-\frac{i}{q}} \right) \tag{1} \\ \end{align}
We know that the digamma function for complex number is calculated as $$\psi(z)=-\gamma + \sum_{n=0}^{\infty}\frac{1}{n} - \sum_{n=0}^{\infty}\frac{2}{n+z}=\int_0^{+\infty} \left( \frac{e^{-t}}{t} -\frac{e^{-zt}}{1-e^{-t}} \right)dt \tag{3}$$
From (2) and (3), we can easily deduce
$$u(k,q)=\int_0^{+\infty} \frac{e^{-\frac{k}{q}t}}{1-e^{-t}}\frac{\sin \left( \frac{t}{q} \right)}{q}dt$$
Hence, from (1) we have \begin{align} a(x) &=\sum_{k=1}^q \left(\left|\sin \left(k\frac{p}{q}\pi \right) \right| \int_0^{+\infty} \frac{e^{-\frac{k}{q}t}}{1-e^{-t}}\frac{\sin \left( \frac{t}{q} \right)}{q}dt\right) \tag{4} \\ \end{align}
The formulas (4) can be considered to be the "semi-closed form expression" for $a(x)$ in case of $x\in \mathbb{Q}$ (rational numbers).
Find the closed-form expression for $a(x)$ in general case ($x\in \mathbb{R}$) is equivalent to find the closed-form expression of $a(\frac{p}{q}\pi)$
We have this identity from Fourier transform (link) $$\left|\sin x\right| = \frac{2}{\pi}-\sum_{j = 1}^\infty \frac{4}{\pi(4j^2-1)}\cos(2j x)$$
Then \begin{align} a \left(\frac{p}{q}\pi \right)&=\sum_{k=1}^q \left(\left(\frac{2}{\pi}-\sum_{j = 1}^\infty \frac{4}{\pi(4j^2-1)}\cos \left(2j k\frac{p}{q}\pi\right) \right) \int_0^{+\infty} \frac{e^{-\frac{k}{q}t}}{1-e^{-t}}\frac{\sin \left( \frac{t}{q} \right)}{q}dt\right) \tag{5}\\ \end{align}
Remark: It's possible that from (5), we can transform $a(x)$ to a function $f\left(\frac{p}{q}\right)$. If the function $f\left(\frac{p}{q}\right)$ exists, it suffices then replace $\frac{p}{q}$ by $r \in \Bbb R$.
We can use the formula $(5)$ by noticing that $\sin(x)\cos(y) =\frac{1}{2}(\sin(x+y)+\sin(x-y))$ and
$$\sum_{i=1}^n \sin(nx) = \frac{\sin\left(\frac{nx}{2}\right)\sin\left(\frac{(n+1)x}{2}\right)}{\cos\left(\frac{x}{2}\right)}$$
We have
\begin{align}
a \left(\frac{p}{q}\pi \right)&=\sum_{k=1}^q \left(\left(\frac{2}{\pi}-\sum_{j = 1}^\infty \frac{4}{\pi(4j^2-1)}\cos \left(2j k\frac{p}{q}\pi\right) \right) \int_0^{+\infty} \frac{e^{-\frac{k}{q}t}}{1-e^{-t}}\frac{\sin \left( \frac{t}{q} \right)}{q}dt\right) \\
&=\frac{2}{\pi}\sum_{k=1}^q \int_0^{+\infty} \frac{e^{-\frac{k}{q}t}}{1-e^{-t}}\frac{\sin \left( \frac{t}{q} \right)}{q}dt - \sum_{j = 1}^\infty \left( \frac{4}{\pi(4j^2-1)} \int_0^{+\infty} \frac{\sum_{k=1}^q e^{-\frac{k}{q}t}\cos \left(2j k\frac{p}{q}\pi \right) \sin \left( \frac{t}{q} \right)}{(1-e^{-t})q}dt \right)\\
&= I_1 - I_2 \\
\end{align}
The first term $I_1$ is equal to
$$I_1 = \frac{2}{\pi} \int_0^{+\infty} \frac{\sin \left( \frac{t}{q} \right)}{q(e^{\frac{t}{q}}-1)}dt = \frac{2}{\pi} \int_0^{+\infty} \frac{\sin (t)}{e^t-1}dt$$
The second term $I_2$ is equal to
\begin{align}
I_2 &=\sum_{j = 1}^\infty \left( \frac{4}{\pi(4j^2-1)} \int_0^{+\infty} \frac{\sum_{k=1}^q e^{-\frac{k}{q}t}\cos \left(2j k\frac{p}{q}\pi \right) \sin \left( \frac{t}{q} \right)}{(1-e^{-t})q}dt \right)\\
&=\sum_{j = 1}^\infty \left( \frac{4}{\pi(4j^2-1)} \int_0^{+\infty}
\frac{
\sin(\frac{t}{q})(-e^{-t}+\cos(2jpt)+e^{t+\frac{t}{q}}\cos(2j\frac{p}{q}t)-e^{\frac{t}{q}}\cos(2j(\frac{p}{q}+p)t))}{q(e^t-1)(1+e^{\frac{2t}{q}} -2e^{\frac{t}{q}}\cos(2j\frac{p}{q}t))
}
\right)\\
\end{align}
Denote $r = \frac{p}{q}$ \begin{align} I_2 &=\sum_{j = 1}^\infty \left( \frac{4}{\pi(4j^2-1)} \int_0^{+\infty} \frac{ \sin(\frac{t}{q})(-e^{-t}+\cos(2jrqt)+e^{t+\frac{t}{q}}\cos(2jrt)-e^{\frac{t}{q}}\cos(2jr(1+q)t))}{q(e^t-1)(1+e^{\frac{2t}{q}}+-2e^{\frac{t}{q}}\cos(2jrt)) } \right)\\ \end{align}
We can transform the integrand into a function depended on only $r$ and $t$. But it's too calculating. I must stop here.