Transforming this serie to a definite integral. Basically i need to simplify the following summation: $$\sum_{n=0}^\infty \frac{cos(nx)}{n^2}$$
As far as i know this summation is equal to 
$$\frac{x^2}{2}-\frac{\pi x}{4}+\frac{\pi ^2}{6}$$ when $[0\le x \le 2\pi]$. Now for the project I'm trying to calculate this for the value of $x$ is never included in such interval. So, given that $cos(x) = cos(x +2\pi k)$ i can actually solve this equation by changing the variable to $y=x-2\pi k$ and simplifying with this. But the resulting equation is an equation with 2 variables, $x$ and $k$, that ain't the result i was looking for (i know as well that $k$ is technically not a variable since you can actually find her, but to do so you need to use modulo which has no math equation and therefore is not the thing i was looking for).
So the alternative i have is to convert such summation in a definite integral, i guess. I've spent few hours looking for an actual method to do so without any result (since I'm a computer engineer, not a mathematician, and I've never had to study deeply calculus). I was wondering if you guys can actually point me to the right direction on this. To actually give you more infos about that my summation is in the form $$2\sum_{n=0}^\infty \frac{cos(nxm)}{n^2 m^2}$$ where $m$ is a generic multiplication factor. 
Ultimately I apologize for my English but understand it's not my first language. 
 A: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
\begin{align}
\sum_{n = \color{red}{1}}^{\infty}{\cos\pars{nx} \over n^{2}} & =
\Re\sum_{n = \color{red}{1}}^{\infty}{\pars{\expo{\ic x}}^{n} \over n^{2}} =
\Re\mrm{Li}_{2}\pars{\expo{\ic x}}
\\[5mm] & =
{1 \over 2}\pars{\mrm{Li}_{2}\pars{\expo{2\pi\ic\braces{x/\bracks{2\pi}}}} +
\mrm{Li}_{2}\pars{\expo{-2\pi\ic\braces{x/\bracks{2\pi}}}}}
\\[5mm] & =
{1 \over 2}\bracks{-\,{\pars{2\pi\ic}^{2} \over 2!}
\,\mrm{B}_{2}\pars{x \over 2\pi}}\,,\qquad\qquad
\left\{\begin{array}{rcl}
\ds{{x \over 2\pi} \in \left[0,1\right)} & \mbox{if} & \ds{\Im\pars{x} \geq 0}
\\[2mm]
\ds{{x \over 2\pi} \in \left(0,1\right]} & \mbox{if} & \ds{\Im\pars{x} < 0}
\end{array}\right.
\end{align}

See this link.
  $\ds{\mrm{B}_{n}}$ is a Bernoulli Polynomial.
  Note that
  $\ds{\mrm{B}_{2}\pars{z} = z^{2} - z + {1 \over 6}}$.

Then,
\begin{align}
\sum_{n = \color{red}{1}}^{\infty}{\cos\pars{nx} \over n^{2}} & =
\pi^{2}\bracks{\pars{x \over 2\pi}^{2} - {x \over 2\pi} + {1 \over 6}} =
\bbx{{1 \over 4}\,x^{2} - {\pi \over 2}\,x + {\pi^{2} \over 6}}
\end{align}
A: Addressing the content of your first paragraph...
Let $x = \hat{x}+2\pi k$ for $k$ an integer.  In your sum, $n$ is also an integer.  Then \begin{align*}
\cos(nx) &= \cos(n(\hat{x}+2\pi k))  \\
    &= \cos(n\hat{x}+2\pi k n)  \\
    &= \cos(n\hat{x})  \text{,}
\end{align*}
because $kn$, the product of two integers, is also an integer.  Consequently, the value of $k$ has no effect on the sum of your series.
