Fourier series $\sum_{k=0}^\infty \frac{(-1)^k}{(2k+1)^2} \cos \left(\pi \left(k+\frac{1}{2} \right)x \right)$ for $x \in (-1,1)$

$$ \begin{align} & \quad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\color{white}{\text{.}} \\ & \text{Let}\quad \color{red}{z=e^{i\,\frac{\pi}{2}x}} \\[4mm] & \cos\left(\pi(k+1/2)x\right) = \frac{1}{2}\left[e^{+i\,\pi(k+1/2)x} + e^{-i\,\pi(k+1/2)x}\right] = \frac{1}{2}\left[e^{+i\,\frac{\pi}{2}x}\,e^{+i\,\pi x k} + e^{-i\,\frac{\pi}{2}x}\,e^{-i\,\pi x k}\right] \\ & \qquad\qquad\qquad\quad\space = \frac{1}{2}\left[e^{+i\,\frac{\pi}{2}x}\left(e^{+i\,\frac{\pi}{2}x}\right)^{2k} + e^{-i\,\frac{\pi}{2}x}\left(e^{-i\,\frac{\pi}{2}x}\right)^{2k}\right] = \frac{1}{2}\left[z^{+1}\,z^{+2k} + z^{-1}\,z^{-2k}\right] \\[4mm] & \Phi(z,s,a) = \sum_{k=0}^{\infty}\frac{z^{k}}{(k+a)^{s}} \quad\&\quad \chi_{s}(z) = 2^{-s}\,z\,\Phi(z^2,s,\small 1/2 \normalsize) = \frac12 \left[\operatorname{Li}_{s}(+z) - \operatorname{Li}_{s}(-z)\right] \end{align} $$ Where $\space\Phi(z,s,a)$, $\chi_{s}(z)$, and $\operatorname{Li}_{s}(z)\space$ are Lerch Phi, and Legendre Chi, Polylogarithm, respectivly.

$$ \begin{align} & \quad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\color{white}{\text{.}} \\ & f_{\color{red}{n}}(x) = \sum_{k=0}^{\infty}(-1)^k\frac{\cos\left(\pi(k+1/2)x\right)}{(2k+1)^{\color{red}{n}}} \\[4mm] & \qquad = \frac{1}{2}\sum_{k=0}^{\infty}(-1)^k\frac{z^{+1}\,z^{+2k} + z^{-1}\,z^{-2k}}{(2k+1)^{n}} = \frac{1}{2\,2^n}\sum_{k=0}^{\infty}\left[z^{+1}\frac{(-z^{+2})^k}{(k+\small 1/2 \normalsize)^{n}} + z^{-1}\frac{(-z^{-2})^k}{(k+\small 1/2 \normalsize)^{n}}\right] \\[4mm] & \qquad = \frac{2^{-n}}{2}\left[z^{+1}\,\Phi(-z^{+2},n,\small 1/2 \normalsize) + z^{-1}\,\Phi(-z^{-2},n,\small 1/2 \normalsize)\right] \\[4mm] & \qquad = -\frac{i}{2}\left[2^{-n}\,(i\,z)\,\Phi\left( (i\,z)^2,n,\small 1/2 \normalsize \right) \, + \, 2^{-n}\,(i/z)\,\Phi\left( (i/z)^2,n,\small 1/2 \normalsize \right)\right] \\[4mm] & \qquad = \color{red}{-\frac{i}{2}\left[\chi_{n}(i\,z) + \chi_{n}(i/z)\right]} \\[4mm] & \qquad = -\frac{i}{4}\left[\operatorname{Li}_{n}(+i\,z) - \operatorname{Li}_{n}(-i\,z) + \operatorname{Li}_{n}(+i/z) - \operatorname{Li}_{n}(-i/z) \right] \\ & \qquad\qquad\quad \small ''+Re\left\{-\frac{i}{2}\left[\operatorname{Li}_{n}(+i\,z) + \operatorname{Li}_{n}(+i/z)\right]\right\} = -Re\left\{-\frac{i}{2}\left[\operatorname{Li}_{n}(-i\,z) + \operatorname{Li}_{n}(-i/z)\right]\right\}'' \quad\text{double} \\ & \qquad\qquad\quad \small ''+Im\left\{-\frac{i}{2}\left[\operatorname{Li}_{n}(+i\,z) + \operatorname{Li}_{n}(+i/z)\right]\right\} = +Im\left\{-\frac{i}{2}\left[\operatorname{Li}_{n}(-i\,z) + \operatorname{Li}_{n}(-i/z)\right]\right\}'' \quad\text{cancel} \\[4mm] & \qquad = Re\left\{-\frac{i}{2}\left[\operatorname{Li}_{n}(i\,z) + \operatorname{Li}_{n}(i/z)\right]\right\} = Im\left\{-\frac{i^2}{2}\left[\operatorname{Li}_{n}(i\,z) + \operatorname{Li}_{n}(i/z)\right]\right\} \quad\Rightarrow \end{align} $$ $$ \boxed{ \quad \color{red}{f_{n}(x)} = \sum_{k=0}^{\infty}(-1)^k\frac{\cos\left(\pi(k+1/2)x\right)}{(2k+1)^n} = \color{red}{\frac12\Im\left[\operatorname{Li}_{n}(i\,z) + \operatorname{Li}_{n}(i/z)\right]} \quad } $$ Where the polylogarithm of positive integer order could be expressed using a Bernoulli polynomial. Unfortunately, unless $z = e^{i \, 2 \pi x}$, the expression will involve powers of complex logarithms. $$ \operatorname {Li}_{n}(z)+(-1)^{n}\,\operatorname{Li}_{n}(1/z)=-{\frac {(2\pi i)^{n}}{n!}}~B_{n}\!\left({\frac {1}{2}}+{\ln(-z) \over {2\pi i}}\right) $$
In special cases, integral representation could give a better approach to calculate the polylogarithm considering the case. Nevertheless, "a broken watch tells the correct time twice a day!". Generally, $\color{red}{\text{It is FALSE to expect a polynomial of degree }n}$ as a representative of $f_n(x)$, even if some cases (like $n=\small1$, $n=\small3$, or else) show similar behavior. $f_n(x)$ is a polylogarithm function. And, for $n=\small2$, the polylogarithm $\operatorname{Li}_{2}(z)$ is known as Dilogarithm, and it has various properties and identities including the case: $$ \operatorname{Li}_{2}(z) + \operatorname{Li}_{2}(1/z) = -\frac{\pi}{6} -\frac{1}{2}\log^{2}(-z) $$ With the difficulties of the power of the logarithm of a complex argument. A good approximation could be utilized by using the Taylor series to expand $f_2(x)$ at the origin $x=\small0$. By doing so: $$ \begin{align} & \quad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\color{white}{\text{.}} \\ & \Im\left[\operatorname{Li}_{2}(i\,z) + \operatorname{Li}_{2}(i/z)\right] = +2\,C -\frac{\pi^2x^2}{8} -\frac{\pi^4x^4}{384} -\frac{\pi^6x^6}{9216} -\frac{61\,\pi^6x^6}{10321920} +\mathcal{O}\left(x^{10}\right) \\ & \qquad = 2\,C -\frac{\pi^2x^2}{2^2\,2!} -\frac{\pi^4x^4}{2^4\,4!} -\frac{5\,\pi^6x^6}{2^6\,6!} -\frac{61\,\pi^6x^6}{2^8\,8!} +\mathcal{O}\left(x^{10}\right) \\ & \qquad \approx 2\,C - \sum_{k=1}^{K}\frac{1}{(2k)!}\left(\frac{\pi}{2}x\right)^{2k} = 2\,C + 1 - \cosh\left(\frac{\pi}{2}x\right) \quad\Rightarrow \end{align} $$ $$ \boxed{ \quad \color{red}{f_{2}(x)} = \sum_{k=0}^{\infty}(-1)^k\frac{\cos\left(\pi(k+1/2)x\right)}{(2k+1)^2} = \frac12\Im\left[\operatorname{Li}_{2}(i\,z) + \operatorname{Li}_{2}(i/z)\right] \approx \color{red}{C + \frac12 - \frac12 \cosh\left(\frac{\pi}{2}x\right)} \quad } $$ As illustrated here, Where $C$ is the Catalan constant.

enter image description here


$f_1(x)$ is a "square wave" function and $f_3(x)$ is a "parabolic wave" function.

But we cannot expect that $f_2(x)$ be "sawtooth wave" function because it is a different series with $\sin$ instead of $\cos$.

The idea behind to find a "sawtooth wave" or a "triangle wave" as an intermediate between "square wave" and "parabolic wave" is interesting. But this cannot be done only with the change of power of $(2k+1)$. In fact, this is the degree of derivation, or integration which provides the expected result.

If you want to obtain a "triangle wave", either integrate $f_1(x)$ or differentiate $f_3(x)$ : Of course the power of $(2k+1)$ changes as suggested, but also the $\cos$ changes to $\sin$ and the expected result is obtained.

It is easy to express $f_2(x)$ in terms of Lerch function as already pointed out.

One cannot expect a simpler answer with the integral form (below) :

enter image description here


I am not sure that this is what you are looking for:

We have $$ \frac{1}{1+x^2}=\sum_{k=0}^\infty(-1)^kx^{2k} $$ and $$ \tan^{-1}x=\int_0^x\frac{dt}{1+t^2}=\sum_{k=0}^\infty \frac{(-1)^k}{2k+1}x^{2k+1} $$ and thus $$ \frac{\tan^{-1}x}{x}=\sum_{k=0}^\infty \frac{(-1)^k}{2k+1}x^{2k} $$ and finally $$ \int_0^x\frac{\tan^{-1}t\,dt}{t}=\sum_{k=0}^\infty \frac{(-1)^k}{(2k+1)^2}x^{2k+1} $$ This holds, in the place of $x$, for every complex number $z$, with $|z|\le 1$.

Set $w=\exp(i\pi x/2)$, then $$ \sum_{k=0}^\infty \frac{(-1)^k\sin\big(\pi(2k+1)x/2\big)}{(2k+1)^2}=\mathrm{Im}\int_0^w\frac{\tan^{-1}z\,dz}{z}=\mathrm{Im}\int_0^1\frac{\tan^{-1}(rw)\,w\,dr}{rw}\\ =\mathrm{Im} \int_0^1\frac{\tan^{-1}(rw)\,dr}{r}. $$ Note that $$ \int_0^w\frac{\tan^{-1}z\,dz}{z}=\mathrm{T}i_2(w) =\frac{1}{2i}\big(\mathrm{L}i_2(iw)-\mathrm{L}i_2(-iw)\big), $$ where $\mathrm{L}i_2(z)=z\Phi(z,2,1)$, and $$ \Phi(z,2,1)=\sum_{n=0}^\infty\frac{z^n}{(n+1)^2}. $$