I would like to approximate a piece-wise function. The aim is to get a function as $f(x) \approx ...$ without piece-wise definition (only one expression, not depending of $x \leq 1$ or $x \geq 1$), and if possible composed of well-known functions (polynomials, exponentials, ...).
Here it is : $f:x\mapsto \left\{ \begin{array}{c l}1-x & x \geq 1 \\ -\ln(x)& x \leq 1 \end{array} \right.\qquad x \in [\frac{1}{2};2]$
I thought of Taylor Series but I don't know how to do it with a function defined by parts.
I also tried to interpolate a function with the points $(0.5,\ln(2))$, $(1,0)$ and $(2,-1)$, resulting in $f(x) \approx 0.2575296\cdot x^2-1.772589\cdot x+1.515059$ . But I think it is not good enough (cf function curves) : in red is my interpolation, in blue the log part and in black the linear part.
Can you help me ? Thanks.


My approach would be:
$$f(x)=-\ln(x)(1-H(x-1))+(1-x)H(x-1)=-\ln(x)+(1-x+\ln(x))H(x-1)$$ where $H(x)$ is the Heaviside step function.
There are many analytical approximations of $H(x)$, my favorite one is $$H(x)=\lim_{k\to \infty}\frac{\tanh(kx)+1}2$$.
Thus, $$f(x)\approx -\ln(x)+(1-x+\ln(x)) \frac{\tanh(k(x-1))+1}2$$ for large $k$.