Trouble understanding why hypothesis is needed in proving $g(x) = f(x,x)$ is continous Let $a < b$ be real numbers and $f:[a,b] \times [a,b] \to \mathbb{R}$ such that,
1) For each $y \in [a,b],$ $x \mapsto f(x,y)$ is non-increasing and continuous on $[a,b].$
2) For each $x \in [a,b],$ $y \mapsto f(x,y)$ is non-decreasing and continuous on $[a,b].$
Prove $g(x) = f(x,x)$ is continuous on $[a,b]$.

My proof:
Given any $\epsilon > 0,$ it suffices to show that there is a $\delta > 0$ such that when $|x-y| < \delta,$ $|g(x) - g(y)| < \epsilon$ for $x,y \in [a,b].$
Fix an $\epsilon.$ By continuity on a compact set, we know that there is a single $\delta_1$ such that for $x$ fixed, $|f(x,x) - f(x,y)| < \epsilon/2$ whenever $|x-y| < \delta_1.$ Likewise, there is a single $\delta_2$ such that for $y$ fixed, $|x-y| < \delta_2$ implies that $|f(x,y) - f(y,y)| < \epsilon/2.$
Then we see that $|f(x,x) - f(y,y)| \leq |f(x,x) - f(x,y)| + |f(x,y) - f(y,y)| < \epsilon$ when $|x-y| < \min\{\delta_1 , \delta_2\} = \delta.$

I never used the monotonicity hypothesis provided, which makes me feel like this proof is wrong or incomplete.  Can anybody point out errors or provide a stronger proof?
 A: The trouble with this is that $\delta_2$ depends on the choice of $y$. You need, however to choose it, after fixing $x$, uniformly in a $\delta_1$ neighbourhood of $x$. How do you do that?
A: The problem is that the choice of $\delta_2$ actually depends on $y$. That is, for each $y$ so that $|y-x| <\delta_1$, there is $\delta_2(y)$ so that if $|z-y|<\delta_2(y)$, then $|f(z, y) - f(y,y)|<\epsilon/2$. 
Now in order that your argument works, from the inequality
$$|f(x,x) - f(y,y)| \leq |f(x,x) - f(x,y)| + |f(x,y) - f(y,y)|$$
you are requiring that $|x-y|<\delta_2(y)$ for all $y$ so that $|y-x|<\delta_1$. It is not clear why this is true.
To use the condition of $f$. Let $\epsilon >0$. By (2), there is $\delta_1$ so that 
$$ f(x,y) < f(x,x) +\epsilon$$
for $x<y< x+\delta_1$. Using (1), you have 
$$f(y,y) \le f(x,y)< f(x,x)+\epsilon.$$
Similarly, by (1) there is $\delta_2 $ so that 
$$f(x,z) > f(x,x) -\epsilon$$
for all $x<z<x+\delta_2$. By (2) one has 
$$ f(z,z) \ge f(x,z) >  f(x,x) -\epsilon$$
The above two implies 
$$|g(z) - g(x)|<\epsilon$$
if $x<z< x+ \min\{\delta_1,\delta_2\}$. Now do something similar for $z<x$ and you are done. 
