Solution (source code)

= Solution

For period two, the <Fourier series> convention is
$$
f(x)=\frac{a_0}{2}+\sum_{n=1}^{\infty}\bigl[a_n\cos(n\pi x)+b_n\sin(n\pi x)\bigr].
$$
Since $f$ is an <even function>, every $b_n$ is zero. Also $a_0=\int_{-1}^1\cosh x\,dx=2\sinh1$. For $n\geq1$, an <antiderivative> useful for the cosine coefficient is
$$
\int\cosh x\cos(n\pi x)\,dx=
\frac{\sinh x\cos(n\pi x)+n\pi\cosh x\sin(n\pi x)}{1+n^2\pi^2}.
$$
Evaluation at $\pm1$ gives $a_n=2(-1)^n\sinh1/(1+n^2\pi^2)$. Thus
$$
\boxed{f(x)=\sinh1\left[1+2\sum_{n=1}^{\infty}\frac{(-1)^n\cos(n\pi x)}{1+n^2\pi^2}\right]}.
$$
The periodic extension is continuous at $x=1$, so its <Fourier series> converges to $\cosh1$ there. Since $\cos(n\pi)=(-1)^n$,
$$
\cosh1=\sinh1\left[1+2\sum_{n=1}^{\infty}\frac1{1+n^2\pi^2}\right].
$$
Therefore $\boxed{p=2,\ q=\pi}$, with $q=-\pi$ giving the same expression because only $q^2$ occurs. This is the $\beta=1$ case of <Fourier series of periodic hyperbolic sine and cosine>.