Weighted sum of cosines Consider $$f(x) = \sum_{k=1}^\infty \cos(kx) k^\alpha.$$ The first question is: does this have a name (Mathematica gives it as a sum of polylogs of complex arguments, but this seems unnatural). Also, does the logarithmic derivative have a name and/or nice properties? (The exponent $\alpha$ in my applications is a negative real number, but I will take what I can get...)
 A: We  treat the  case $\alpha  = -4$ because even  $\alpha$  yields maximal
cancelation in the residue computation that follows.
(Gamma function poles.)
The sum term  $$S(x) = \sum_{n\ge 1} \frac{\cos(nx)}{n^4}$$
is harmonic and may be evaluated by inverting its Mellin transform.
Recall the harmonic sum identity
$$\mathfrak{M}\left(\sum_{k\ge 1} \lambda_k g(\mu_k x);s\right) =
\left(\sum_{k\ge 1} \frac{\lambda_k}{\mu_k^s} \right) g^*(s)$$
where $g^*(s)$ is the Mellin transform of $g(x).$
In the present case we have
$$\lambda_k = \frac{1}{k^4}, \quad \mu_k = k \quad \text{and} \quad
g(x) = \cos(x).$$
We need the Mellin transform $g^*(s)$ of $g(x) = \cos(x)$
which was computed at this 
MSE link 
and found to be
$$g^*(s) = \Gamma(s) \cos(\pi s/2)$$
with fundamental strip $\langle 0,1 \rangle.$

Hence the Mellin transform $Q(s)$ of $S(x)$ is given by
$$ Q(s) = \Gamma(s) \cos(\pi s/2) \zeta(s+4)
\quad\text{because}\quad
\sum_{k\ge 1} \frac{\lambda_k}{\mu_k^s} = \zeta(s+4)$$
where $\Re(s+4) > 1$ or $\Re(s) > -5$.

Intersecting the  fundamental strip and  the half-plane from  the zeta
function  term we  find  that  the Mellin  inversion  integral for  an
expansion about zero is
$$\frac{1}{2\pi i} \int_{1/2-i\infty}^{1/2+i\infty} Q(s)/x^s ds$$
which we evaluate in the left half-plane $\Re(s)<1/2.$
The cosine  term cancels the poles  of the gamma function  term at odd
negative  integers  and the  zeta  function  term  the poles  at  even
negative integers. We are left with just four poles.
$$\begin{align}
\mathrm{Res}(Q(s)/x^s; s=0) & = \frac{\pi^4}{90} \\
\mathrm{Res}(Q(s)/x^s; s=-2) & = - \frac{\pi^2}{12} x^2 \\
\mathrm{Res}(Q(s)/x^s; s=-3) & = \frac{\pi}{12} x^3  \quad\text{and}\\
\mathrm{Res}(Q(s)/x^s; s=-4) & = -\frac{1}{48} x^4
\end{align}$$
Hence in a neighborhood of zero,
$$S(x) = 
\frac{\pi^4}{90}
- \frac{\pi^2}{12} x^2
+ \frac{\pi}{12} x^3
-\frac{1}{48} x^4.$$

We will now show  that this is exact for $x\in(0,2\pi).$
Put  $s= \sigma + it$ with $\sigma \le -9/2$
where we seek to evaluate
$$\frac{1}{2\pi i} \int_{-9/2-i\infty}^{-9/2+i\infty} Q(s)/x^s ds.$$
Recall that with $\sigma > 1$  and for $|t|\to\infty$ we have
$$|\zeta(\sigma+it)| \in \mathcal{O}(1).$$

Furthermore recall the functional equation 
of the Riemann Zeta function
$$\zeta(1-s) = \frac{2}{2^s\pi^s} 
\cos\left(\frac{\pi s}{2}\right) \Gamma(s) \zeta(s)$$
which we re-parameterize like so
$$\zeta(s+4) = 2\times (2\pi)^{s+3}
\cos\left(-\frac{\pi (s+3)}{2}\right) \Gamma(-s-3) \zeta(-s-3)$$
which is
$$\zeta(s+4) = 2\times (2\pi)^{s+3}
\sin(\pi s/2) \frac{\Gamma(1-s)}{s(s+1)(s+2)(s+3)} \zeta(-s-3).$$
Substitute this into $Q(s)$ to obtain
$$\Gamma(s) \cos(\pi s/2) \times
2 \times (2\pi)^{s+3} \sin(\pi s/2) 
\frac{\Gamma(1-s)}{s(s+1)(s+2)(s+3)} \zeta(-s-3).$$
Use the reflection formula for the Gamma function to obtain
$$\cos(\pi s/2) \times
2 \times (2\pi)^{s+3} \sin(\pi s/2) \times
\frac{\pi}{\sin(\pi s)}
\frac{1}{s(s+1)(s+2)(s+3)} \zeta(-s-3),$$
in other words we have
$$Q(s) = \pi(2\pi)^{s+3} \frac{\zeta(-s-3)}{s(s+1)(s+2)(s+3)}.$$
This finally implies (with $\sigma< -9/2$ we have $\Re(-s-1) > 7/2$)
$$|Q(s)/x^s|\sim
8\pi^4 (2\pi)^{\sigma} x^{-\sigma} |t|^{-4}.$$
or 
$$|Q(s)/x^s|\sim
8\pi^4 (x/2/\pi)^{-\sigma} |t|^{-4}.$$
We see from the term in $|t|$ that the integral obviously converges.
(This much we knew already.)
Moreover, when $x\in(0,2\pi)$ we have $(x/2/\pi)^{-\sigma}\to 0$ as 
$\sigma\to -\infty.$ 
The term  in $x$ does not depend  on the variable $t$  of the integral
and may be brought to the front.
This means that the contribution from the left side of the rectangular
contour that we employ as we  shift to the left vanishes in the limit,
proving the exactness of the formula for $S(x)$ in the interval $(0,2\pi)$ 
obtained earlier.

As I have  mentioned elsewhere there is a  theorem hiding here, namely
that certain Fourier series can be evaluated by inverting their Mellin
transforms which  is not terribly  surprising and which the  reader is
invited to state and prove.
