# Question

Why is it difficult to find an elementary function that generally and suitably satisfies the below piecewise function, without reference to conditions, given continuous elementary functions $$f$$ and $$g$$ such that $$f(a)=g(a)$$?

$h:\mathbb{R}\to\mathbb{R}, h(x)=\begin{cases} f(x) & x\geq a \\ g(x) & x\leq a \end{cases}$

# Thoughts

## Formulation?

I mean, this can be formulated in terms of signum (or heaviside function).

\begin{align} h(x) &= \begin{cases} f(x) & x\geq a \\ g(x) & x\leq a \end{cases} \\ &=\begin{cases} f(x) & x> a \\ \frac{f(x)+g(x)}{2} & x=a \\ g(x) & x< a \end{cases} \\ &=\begin{cases} f(x) & x> a \\ \frac{f(x)}{2} & x=a \\ 0 & x< a \end{cases} + \begin{cases} 0 & x> a \\ \frac{g(x)}{2} & x=a \\ g(x) & x< a \end{cases} \\ &=f(x)\begin{cases} 1 & x> a \\ \frac{1}{2} & x=a \\ 0 & x< a \end{cases} + g(x)\begin{cases} 0 & x> a \\ \frac{1}{2} & x=a \\ 1 & x< a \end{cases} \\ &=f(x)\left(\frac{1}{2}+\frac{1}{2}\operatorname{sgn}(x-a)\right) + g(x)\left(\frac{1}{2}-\frac{1}{2}\operatorname{sgn}(x-a)\right) \\ \end{align}

## Goal: Eliminate signum?

I have this little fun brilliant fact for 'simple' signum. That is: Given odd $$f:A\to\mathbb{R}, A=-A, f(x)\operatorname{sgn}(x)=f\left(|x|\right)$$.

This is a quick little way to eliminate signum. So my first thought was - perhaps - if both $$f$$ and $$g$$ were odd functions, then we could simplify it. But we could only apply this when $$a=0$$. And that does work, you end up with a nice $$\frac{1}{2}\left(f(x)+f(|x|)+g(x)-g(|x|)\right)$$.

On our line of thinking with $$a=0$$, my next thought was decomposing the functions - because as it turns out, we can simplify a piecewise equation with $$x^2$$ and $$x$$. That is, let $$f=f_{o}\cdot f_{a}$$ and $$g=g_{o}\cdot g_{a}$$, where $$f_{o}$$ and $$g_{o}$$ are odd function components of $$f$$ and $$g$$ respectively (not necessarily 0 for even functions), and $$f_{a}$$ and $$g_{a}$$ are the respective 'remaining' functions. From here we can actually simplify:

$h(x) = \frac{1}{2}f_{a}(x)\left(f_{o}(x)+f_{o}\left(|x|\right)\right)+\frac{1}{2}g_{a}(x)\left(g_{o}(x)-g_{o}\left(|x|\right)\right)$

Interesting thing to note here is that for all odd functions:

$\frac{1}{2}\left(f_{o}(x)+f_{o}(|x|)\right) = \begin{cases} f_{o}(x) & x\geq 0 \\ 0 & x\leq 0 \end{cases}$

$\frac{1}{2}\left(f_{o}(x)-f_{o}(|x|)\right) = \begin{cases} 0 & x\geq 0 \\ f_{o}(x) & x\leq 0 \end{cases}$

With that being said, it's not clean at all. Hm. Bad line of thinking? Still doesn't answer why it's just so hard to find a nice form. We can't account for every function with this. Weird.

## Signum identities

Also my next thought was - how could we potentially rewrite $$f(x)\operatorname{sgn}(x-a)$$?

Update: Well, $$f(x)\operatorname{sgn}(x-a) = f\left(|x-a|+a\operatorname{sgn}(x-a)\right)$$, given odd $$f$$. Consequently, $$f(x-a)\operatorname{sgn}(x-a) = f(|x-a|)$$. Also interestingly, $$f(x-a)\operatorname{sgn}(x)=f\left(|x|-a\operatorname{sgn}(x)\right)$$.

The latter two facts are consequences of the former fact, which is proven as follows. Suppose $$f$$ is an odd function. Then:

\begin{align} f(x)\operatorname{sgn}(x-a) &= \begin{cases} f(x) & x>a \\ 0 & x=a \\ -f(x) & x< a \end{cases} \\ &= f\left(\begin{cases} x & x>a \\ 0 & x=a \\ -x & x < a \end{cases}\right) \\ &= f\left(\begin{cases} x-a & x>a \\ 0 & x=a \\ -x+a & x < a \end{cases}+\begin{cases} a & x>a \\ 0 & x=a \\ -a & x < a \end{cases}\right) \\ &= f\left(|x-a|+a\operatorname{sgn}(x-a)\right) \\ \end{align}

## New approach

So originally I did a subtitution with $$u=x-a$$ on the original $$h(x)$$ definition to help me focus - led me to this hypothesis: $$h(x)=f(\max(x,a))+g(\min(x,a))-f(a)$$.

Turns out, this is indeed the case.

\begin{align} h(x)&=\begin{cases} f(x) & x\geq a \\ g(x) & x\leq a \end{cases}\\ &=\begin{cases} f(x) & x\geq a \\ 0 & x< a \end{cases}+\begin{cases} 0 & x\geq a \\ g(x) & x< a \end{cases}\\ &=\begin{cases} f(x) & x\geq a \\ f(a) & x< a \end{cases}-\begin{cases} 0 & x\geq a \\ f(a) & x< a \end{cases}+\begin{cases} g(a) & x\geq a \\ g(x) & x< a \end{cases}-\begin{cases} g(a) & x\geq a \\ 0 & x< a \end{cases}\\ &=f\left(\begin{cases} x & x\geq a \\ a & x< a \end{cases}\right)+g\left(\begin{cases} a & x\geq a \\ x & x< a \end{cases}\right)-\begin{cases} g(a) & x\geq a \\ f(a) & x< a \end{cases}\\ &=f\left(\max(x,a)\right)+g\left(\min(x,a)\right)-\begin{cases} f(a) & x\geq a \\ f(a) & x< a \end{cases}\\ &=f\left(\max(x,a)\right)+g\left(\min(x,a)\right)-f(a)\\ &=f\left(\max(x,a)\right)+g\left(\min(x,a)\right)-g(a) \end{align}