Two Variable Function with Specific Properties (Challenging) I am looking for a two variable function (a surface), $g(x,b)$, with the following properties:
$$g:\ [0,\pi] \times (0,\pi) \to[0,\pi] $$
$$g(0,b)=0$$
$$g(\pi,b)=\pi$$
$$g(b,b)=\frac{\pi}{2}$$
$$g\left( x,\frac{\pi}{2}\right)=x$$
Where $x\in[0,\pi]$ and $b\in(0,\pi)$.
Can you define such a $g$?  I have been looking for a while and am unable to find one.  If you cannot define one, does such a $g$ even exist?
 A: Something like
$$ g(x,b) = \begin{cases} 0 & x=0\\ \arctan\bigl(\tan(x-\tfrac\pi2)-\tan(b-\tfrac\pi2)\bigr)+\tfrac\pi2 & 0<x<\pi \\ \pi & x=\pi \end{cases} $$
ought to work relatively smoothly, but this version with hyperbolic functions behaves nicer in some respects:
$$ g(x,b) = \begin{cases} 0 & x=0\\ \tfrac\pi2 \Bigl(\tanh\bigl(\operatorname{arctanh}(2x/\pi -1)-\operatorname{arctanh}(2b/\pi-1)\bigr)+1\Bigr) & 0<x<\pi \\ \pi & x=\pi \end{cases} $$
"Nicer" is in the eye of the beholder, of course. These proposals both have the general form
$$ g(x,b) = \begin{cases} 0 & x=0\\ h^{-1}\bigl(h(x)-h(b)\bigr) & 0<x<\pi \\ \pi & x=\pi \end{cases} $$
where $h$ is an increasing bijection $(0,\pi)\to\mathbb R$ with $h(\pi/2)=0$. This immediately guarantees the properties you specify, as well as continuity in your domain. Furthermore the function is increasing in $x$ and $b$ for fixed $b$ and $x$.
The $\tan$ version has the property that at each fixed $b$ we have $g(\varepsilon, b)\approx\varepsilon$ for small enough $\varepsilon$ (and similarly at the other three edges of the domain, mutatis mutandis). This probably is not what you want, but since I don't know what you want it for it could be exactly what you need.
On the other hand $\operatorname{arctanh}$ gives the nice property that if you graph $g$ for constant $x$ or $b$, there are no inflection points. One would probably usually find that desirable.
For a purely algebraic option you might try $h(x)=\frac{1}{\pi-x}-\frac{1}{x} $, which ought to behave more or less like the tangent option.
A: $$g(x,y)=2\arctan\frac{\tan(x/2)}{\tan (y/2)}$$
I've started from $g(b,b)=\frac\pi2$. That means that somehow $g$ depends either on the difference $(x-y)$, or some ratio of similar functions for the coordinates $f(x)/f(y)$. The second form was hinted from the fact that $y$ is on an open interval, so $f(0),f(\pi)\in[0,\pm\infty]$. The fact that $g(0,b)=0$ means $f(0)=0$. But $g(\pi,y)=\pi$ means that I need to scale $f(\pi)=\infty$ back to $\pi$ (that's where the ideas of $\tan$ and $\arctan$ functions came from). If $f(\pi/2)=1$ you have $\arctan \tan x=x$.
Note: following the comment from @HenningMakholm, I can rewrite this in a more accurate way:
$$g(x,y)=\lim_{u\to x}2\arctan\frac{\tan(u/2)}{\tan(y/2)}$$
