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.
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.