Computing an infinite trigonometric sum $\sum \frac{2}{n^2 \pi^2} \cos(n \pi x)\cos(n \pi y)$ Let $G(x,y) = \sum_{n=1}^\infty \frac{2}{n^2 \pi^2} \cos(n \pi x)\cos(n \pi y)$ 
I'm trying to compute this sum by understanding it as an integral kernel. This question comes from Dym and Mckean Fourier Series and Integrals Ex 1.7.14:  
Consider the cosine basis on $L^2[0,1]$ defined by $f_n(x) = \sqrt 2 \cos(n \pi x)$ for $n \ge 1$ and $f_0 = 1$. Define the operator $F$ by $F f_n = \frac{1}{n^2\pi^2} f_n$ acting only on the subspace $n \ge 1$. 
It turns out that $F f(x) = \int_0^1 G(x, y) f(y) dy$ for $f \in L^2[0,1]$.
Now let $u = f_n''$ for some unspecified $n \ge 1$ .
$$F (f_n'') = -f_n $$ 
$$(F(f_n''))'' = -f_n''$$
$$(F u)'' = -u$$
$$(Fu)'(x) =-\int_0^x u(y)dy + K_1$$
$K_1 = 0$ because $(F u)'(0) = C \sin(0) = 0$
$$(Fu)(x) = -\int_0^x \int_0^y u(z)dz\,dy + K_2$$
$K_2 = \int_0^1\int_0^x \int_0^y u(z)dz\,dy\,dx$ because $\int_0^1 (Fu)(x) dx = \int_0^1 C \cos (2 \pi n x) dx = 0$ 
Now changing order of integration
$$ (Fu)(x) = - \int_0^x (x - z)u(z) dy + K_2$$
$$ = - \int_0^x (x - z)u(z) dy + \int_0^1\int_0^x (x - z)u(z) dz\,dx$$
$$ =... + \int_0^1\int_z^1(x -z)u(z)dx\,dz$$
$$ =... + \int_0^1u(z) [(1 - z^2)/2 - z(1-z)] dz $$
$$ = ... + \int_0^1 u(z) (z - 1)^2/2 dz$$
$$ = - \int_0^x (x - z)u(z) dz + \int_0^1 u(z) (z - 1)^2/2 dz$$
$$ = - \int_0^x (x - z)u(z) dz + \int_0^x u(z) (z - 1)^2/2 dz+ \int_x^1 u(z) (z - 1)^2/2 dz$$
$$ = \int_0^1 T(x,z) u(z) dz$$
where $T(x,y) = (y^2 + 1)/2 - x $ for $y < x$ and $(y-1)^2/2$ for $y > x$ 
and by necessity $T(x,y) = G(x,y)$
Unfortunately, I don't think this is the right function and it doesn't even look symmetric in $x,y$. I am looking for help for the correct derivation which should lead to $G(x,y) = \frac{x^2 - x + y^2 -y - |x-y|}{2} + 1/3$
Edit:
Even though $T(x,y)$ gives rise to the same operator $F$, it may not equal to $G(x,y)$ since they can differ by any function $\Delta(x)$ so that $T(x,y) + \Delta(x) = G(x,y)$, since $\int_0^1\Delta(x) f_n(y) dy = 0$. Since $\int G(x,y) dy = 0$, we should require $\Delta(x) = -\int_0^1T(x,y)dy = -1/6 + x^2/2$ so that $G(x,y) = (y^2 + 1)/2 - x - x^2/2 + 1/6 $ for $y < x$ and $(y-1)^2/2 + x^2/2 + 1/6$ for $y > x$ and this is the book's answer. 
 A: Note:
I am finally correcting my mistake
pointed out by Mark.
For
$G(x,y) 
= \sum_{n=1}^\infty \frac{2}{n^2 \pi^2} \cos(n \pi x)\cos(n \pi y)
$,
since
(here's where my mistake was:
I had cos-cos
instead of the correct
cos+cos)
$\cos(a)\cos(b)
=\frac12(\cos(a-b)+\cos(a+b))
$,
$\begin{array}\\
G(x,y) 
&= \frac12\sum_{n=1}^\infty \frac{2}{n^2 \pi^2} (\cos(n \pi (x-y))+\cos(n \pi (x+y)))\\
&= \frac1{\pi^2}\left(\sum_{n=1}^\infty \frac{1}{n^2} \cos(n \pi (x-y))
+ \sum_{n=1}^\infty \frac{1}{n^2} \cos(n \pi (x+y))\right)\\
&= g(x-y)+g(x+y)\\
\end{array}
$
where
$g(z)
=\frac1{\pi^2}\sum_{n=1}^\infty \frac{1}{n^2} \cos(n \pi z)
$.
$g'(z)
=-\frac1{\pi}\sum_{n=1}^\infty \frac{1}{n} \sin(n \pi z)
$
and,
getting into areas of dubious convergence,
$\begin{array}\\
g''(z)
&=-\sum_{n=1}^\infty \cos(n \pi z)\\
&=-\Re\sum_{n=1}^\infty \exp(in \pi z)\\
&=-\Re\frac{\exp(i \pi z)}{1-\exp(i \pi z)}\\
&=-\Re\frac{\cos( \pi z)+i\sin( \pi z)}{1-\cos( \pi z)-i\sin( \pi z)}\\
&=-\Re\frac{\cos( \pi z)+i\sin( \pi z)}{1-\cos( \pi z)-i\sin( \pi z)}
\frac{1-\cos( \pi z)+i\sin( \pi z)}{1-\cos( \pi z)+i\sin( \pi z)}\\
&=-\Re\frac{\cos( \pi z)+i\sin( \pi z)}{1-\cos( \pi z)-i\sin( \pi z)}
\frac{1-\cos( \pi z)+i\sin( \pi z)}{1-\cos( \pi z)+i\sin( \pi z)}\\
&=-\Re\frac{(\cos( \pi z)+i\sin( \pi z))(1-\cos( \pi z)+i\sin( \pi z))}{(1-\cos( \pi z))^2+\sin^2( \pi z)}\\
&=-\Re\frac{\cos( \pi z)(1-\cos( \pi z)-\sin^2( \pi z))+i(....)}{2-2\cos( \pi z)}\\
&=-\frac{\cos( \pi z)-\cos^2( \pi z)-\sin^2( \pi z)}{2(1-\cos( \pi z))}\\
&=-\frac{\cos( \pi z)-1}{2(1-\cos( \pi z))}\\
&=\frac12\\
\end{array}
$
This seems to imply that
$g(z)
=\frac14 z^2+az+b
$
for some $a$ and $b$,
which I find quite surprising.
I will continue under 
the assumption that
this is correct.
If $z=0$,
$b
=g(0)
=\frac1{\pi^2}\sum_{n=1}^\infty \frac1{n^2}
=\frac1{\pi^2}\zeta(2)
=\frac{1}{6}
$.
If
$z=1$,
$\begin{array}\\
g(1)
&=\frac14+a+b\\
&=\frac14+a+\frac1{6}\\
&=\frac{5}{12}+a\\
&=\frac1{\pi^2}\sum_{n=1}^\infty \frac1{n^2}\cos(n\pi)\\
&=\frac1{\pi^2}\sum_{n=1}^\infty \frac{(-1)^n}{n^2}\\
&=-\frac1{\pi^2}\frac12\zeta(2)\\
&=-\frac1{12}\\
\end{array}
$
so
$a
=-\frac12
$.
As a check,
if
$z=2$,
$\begin{array}\\
g(2)
&=1+2a+b\\
&=1+2a+\frac1{6}\\
&=\frac{7}{6}+a\\
&=\frac1{\pi^2}\sum_{n=1}^\infty \frac1{n^2}\cos(2n\pi)\\
&=\frac1{\pi^2}\sum_{n=1}^\infty \frac{1}{n^2}\\
&=\frac1{\pi^2}\zeta(2)\\
&=\frac1{6}\\
\end{array}
$
so
$2a+\frac76
=\frac16
$
or
$a=
-\frac12
$.
Therefore
$\begin{array}\\
G(x, y)
&=g(x-y)+g(x+y)\\
&=\frac14((x-y)^2+(x+y)^2))-\frac12((x-y)+(x+y))+2\frac1{6}\\
&=\frac12(x^2+y^2)-x+\frac13\\
\end{array}
$.
A: Marty Cohen is correct in his approach to this $G(x,y)$ but there is the sign error in the trig expressions.  
Defined on the interval $0 < t < P$, it is fairly easy to demonstrate that the function:
\begin{equation}
h(t)=\pi^2 \left[ \left( \frac{t}{P} \right)^2 -\left( \frac{t}{P} \right) + \frac{1}{6} \right]
\end{equation}
has a Fourier series expansion of:
\begin{equation}
h(t) = \sum\limits_{n = 1}^{\infty} 
\frac{
\cos\left( 2 \pi \frac{n}{P} t \right)
}{n^2}
\end{equation}
The polynomial, $h(t)$, is Bernoulli Polynomial, $B_2(\frac{t}{P})$ which has been scaled appropriately.
Using $h(t)$ above and setting $P=2$ the closed form of $g(z)$ above is given by:
\begin{equation}
g(z) = \left[ \left(\frac{z}{2}\right)^2 - \left(\frac{z}{2}\right) + \frac{1}{6} \right]
\end{equation}
This is exactly the same value of $g(z)$ found above, so his exposition on the approch is correct.
Proceeding with the reasoning of Marty Cohen but with the sign correction for $cos(a)cos(b)$:
\begin{align}
G(x,y) &= g(x-y) + g(x+y)
\\
&= \left[ \left( \frac{x-y}{2} \right)^2 - \left( \frac{x-y}{2} \right) + \frac{1}{6} \right]
\\
&+ \left[ \left( \frac{x+y}{2} \right)^2 - \left( \frac{x+y}{2} \right) + \frac{1}{6} \right]
\\
&= \left[ \frac{x^2}{4} - xy + \frac{y^2}{4} - \frac{x-y}{2} + \frac{1}{6} \right]
\\
&+ \left[ \frac{x^2}{4} + xy + \frac{y^2}{4} - \frac{x+y}{2} + \frac{1}{6} \right]
\\
&= \frac{x^2 + y^2}{2} -x +\frac{1}{3}
\end{align}
where the domain for $x$ and $y$ are:


*

*$0 \le (x + y) \le 2$

*$0 \le (x - y) \le 2$


This is different way to answer to the question: "What is G(x,y) in closed form?" It is not in keeping with the the essence of the question posed by the OP so it is not a proper answer.  
None the less, this confirms Marty Cohen's approach (less the sign error) is correct.
