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.
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$ :
Hoping it helped,