Turning a Piecewise Function into a Single Continuous Expression I'm trying to construct a function that contains two parts: one, $g(a,b)$, coming into effect when $a\lt b$, and the other, $h(a,b)$, when $b \lt a$.
The problem is that $a=b$ is a valid possibility which I do not know how to handle, even though

if $a=b$,  then $g(a,b)=h(a,b)$ and $g'(a,b)=h'(a,b)$.

So there is a real result at $a=b$, but I don't know how to get it out of the equation. there must be a mathematical way to properly express this.
currently I have
f(a,b) = $$\frac{(a-b)-\sqrt{(a-b)^2}}{2(a-b)}g(a,b) + \frac{\sqrt{(a-b)^2}+(a-b)}{2(a-b)}h(a,b).$$
which clearly doesn't cut it, because at $a=b$ the result is some weird specie of infinity.
And I am still working on figuring out $g(a,b)$ and $h(a,b)$, so I can't provide you with an example at this point.
So to recap: How do you join parts of functions into one continuous arithmetic function? (without input logic)
"you can'd do that" is a valid answer, but I'd like to know why.
 A: Consider the Heaviside step function defined this way (other variants for $H(0)$ exist) :
$$
H(x)=\begin{cases}
x<0&\ 0\\[8pt]
x=0&\frac 12\\[8pt]
x>0&\ 1\\[8pt]
\end{cases}
$$
(you may too write $H$ as a $\rm{sign}$ function : $\ H(x)=\dfrac {1+\rm{sign}(x)}2$) then :
$$\boxed{\displaystyle f(a,b)= g(a,b)\cdot H(b-a)+ h(a,b)\cdot H(a-b)}$$
(with value $\dfrac{g(a,a)+h(a,a)}2$ for $a=b$ of course)
To get a 'smoothed' result you may replace $H$ by a Sigmoid function :
$\ \displaystyle S(x)=\frac 1{1+e^{-x}}\ $ or other variants. 
Since $\ H(x)=\lim_{n->\infty} S(n\cdot x)\ $ you may replace $H(x)$ by something like $S(n\cdot x)$ with any $n \gg 1$ to get a smooth transition!
Let's illustrate this with an example : $x\mapsto x^2$ for negative $x$ and $x\mapsto \cos(10 x)$ for positive $x$ illustrated with $n=1000$ and $n=100$ :
f(t)=t^2/(1+exp(1000*t))+cos(10*t)/(1+exp(-1000*t)


f(t)=t^2/(1+exp(100*t))+cos(10*t)/(1+exp(-100*t)


Hoping it helped,
A: If it is acceptable for you to write
$$g(a,b)=u\left(\frac{a+b}{2}\right)+(b-a)\cdot g_*(a,b)\\
h(a,b)=u\left(\frac{a+b}{2}\right)+(b-a)\cdot h_*(a,b)$$
then you can write
$$f(a,b)=u\left(\frac{a+b}{2}\right)+\frac{(b-a)-|b-a|}{2}\cdot g_*(a,b)+\frac{(b-a)+|b-a|}{2}\cdot h_*(a,b)$$

On the other hand, if you have to consider $g,h$ as opaque functions, it is impossible to find continuous $\varphi,\psi$ such that
$$f(a,b)=\varphi(a,b)g(a,b)+\psi(a,b)h(a,b)$$
(this is because necessarily $\varphi(a,b)=1$ when $a<b$ and $0$ when $a>b$, creating a discontinuity).
In particular, if $\varphi,\psi$ are constructed from constants, the variables $a,b$, operators like $+,-,\times,/$ and continuous functions like $\exp,\log,\sin,\cos,\tan,\sqrt{\cdot},|\cdot|$ (paying attention to their domain of definition), then they are necessarily continuous.
