I am looking for a function $f\colon \mathbb{R}\to\mathbb{R}$ such that $$g(x)=\begin{cases} f(x), &\text{if }| x|<k \\ | x|, &\text{otherwise}\end{cases}$$ is $C^2$ or $C^\infty$ (at least twice continuously differenciable).
I also wish that the deviations between $| x|$ and $g(x)$ tends to $0$ as $k\to0$, possibly uniformly, as well as the deviations of the first two derivatives.
If possible, I am looking for a parametric class of symetric functions f for which computations are explicit and do not require heavy numerical procedure. I guess a polynomial class would do it, requiring only a linear solver, but there may be other solutions.
Thank you for your ideas.
It suffices to take $f(x) = a + bx^2 + cx^4$ (with unknown coefficients $a$, $b$, and $c$ depending on $k$ to be determined). The function $g$ is of class $C^2$ if and only if $f(k) = k$, $f'(k) = 1$, and $f''(k) = 0$, and this system is easy to solve. (Evenness of $f$ guarantees the necessary boundary conditions at $-k$.)
Alternatively, the (real-analytic) function $g(x) = \sqrt{x^2 + k^2}$ might be suitable if you don't need $g(x)$ to agree exactly with $|x|$.