# Smooth approximation for non differentiable function

Let $$f(t) = \min(\frac{1}{\lvert t\rvert}, 1)$$. I would like to find a smooth approximating function $$g$$ such that $$f(t) \leq g(t)$$ for all real $$t$$. Is there a nice function $$g$$ out there? Any suggestion appreciated!

• like $\frac{1}{|a| \sqrt{\pi}} e^{- x^2/a^2}$? Jul 18, 2022 at 13:32

$$\newcommand\de\delta$$If the function $$f$$ were convex, then a convolution of $$f$$ with (say) an even positive mollifier would do. However, $$f$$ is not convex.

Yet, it would be quite easy to construct just some smooth approximating function $$g$$ such that $$f\le g$$. The challenge here, as I see it, is to make sure that the approximating function $$g$$ is nice (as requested by the OP) and preferably explicitly given.

Such an explicit construction is as follows:

For $$\de\in(0,1/2)$$ and all real $$t$$, let $$g_\de(t):=\frac12\,\Big[\frac1{\sqrt{t^2+\de}}+\de+1-h_\de\Big(\frac1{\sqrt{t^2+\de}}+\de-1\Big)\Big],$$ where $$h_\de(y):=\frac{y^2}{\sqrt{y^2+\de}}.$$

Then $$g_\de$$ is a smooth function, $$g_\de\ge f$$, and $$g_\de\to f$$ uniformly on $$\mathbb R$$ as $$\de\downarrow0$$ -- as desired.

(Details on this are provided at the end of this answer.)

Here are the graphs $$\{(t,f(t))\colon|t|<2\}$$ (blue) and $$\{(t,g_{1/50}(t))\colon|t|<2\}$$ (golden):

Details: First here, we understand that the definition $$f(t):=\min(\frac1{|t|},1)$$, which can work only for $$t\ne0$$, is complemented by $$f(0):=1$$, by continuity.

Next, take indeed any $$\de\in(0,1/2)$$. Then, for real $$t$$ with $$t^2\ge1-\de$$, $$\begin{equation*} 0\le\frac1{|t|}-\frac1{\sqrt{t^2+\de}}=\frac\de{|t|\sqrt{t^2+\de}\,(|t|+\sqrt{t^2+\de})} \\ \le\frac\de{\sqrt{1-\de}(\sqrt{1-\de}+1)}<\de. \tag{1}\label{1} \end{equation*}$$ So, for real $$t$$, $$\begin{equation*} f(t)\le f_\de(t):=\min(1,x_\de(t)),\quad\text{where}\quad x_\de(t):=\frac1{\sqrt{t^2+\de}}+\de. \tag{2}\label{2} \end{equation*}$$ Moreover, $$f_\de(t)-f(t)\le x_\de(t)-\frac1{|t|}<\de$$ for all real $$t$$. So, $$$$0\le f_\de-f<\de. \tag{2a}\label{2a}$$$$

Next, for all real $$y$$, $$\begin{equation*} h_\de(y)\le|y| \tag{3}\label{3} \end{equation*}$$ and $$\begin{equation*} |y|-h_\de(y)=\frac{|y|\de}{\sqrt{y^2+\de}\,(|y|+\sqrt{y^2+\de})} \le\frac{|y|\de}{y^2+\de}<\sqrt\de, \end{equation*}$$ so that $$\begin{equation*} |y|-h_\de(y)\to0 \tag{4}\label{4} \end{equation*}$$ uniformly in real $$y$$ (as $$\de\downarrow0$$).

Further, for all real $$x$$, $$\begin{equation*} \min(1,x)=\frac{x+1-|x-1|}2\le\frac{x+1-h_\de(x-1)}2, \tag{5}\label{5} \end{equation*}$$ by \eqref{3}. By \eqref{2} and \eqref{5}, for real $$t$$, $$\begin{equation*} f(t)\le f_\de(t)\le\frac{x_\de(t)+1-h_\de(x_\de(t)-1)}2=g_\de(t) \tag{6}\label{6} \end{equation*}$$ and, in view of \eqref{4}, $$\begin{equation*} g_\de(t)-f_\de(t)\to0 \tag{7}\label{7} \end{equation*}$$ uniformly in real $$t$$.

So, by \eqref{2a} and \eqref{7}, $$\begin{equation*} g_\de(t)\to f(t) \tag{8}\label{8} \end{equation*}$$ uniformly in real $$t$$ and, by \eqref{6}, $$g_\de\ge f$$.

Finally, that $$g_\de$$ is smooth is obvious. $$\quad\Box$$

• Is "details will be provided later" like "this will be the subject of future work"? đ Jul 18, 2022 at 15:41
• @LSpice : The details have now been provided. Jul 18, 2022 at 17:18
• Great! I hope that my joke did not offend. Jul 18, 2022 at 17:24
• @LSpice : No, I am fine. Jul 18, 2022 at 17:46

$$\frac{\sqrt{1+(x^{2k+1})^2}}{1+x^{2k}}$$ has an arbitrarily small range with large error:

The reason for the large deviation lies in the points of extremal curvature of $$x^n$$;
better solutions would require functions with monotone curvature.

Taking the monotone curvature argument into account leads to: $$\sqrt{\frac{1+(x^{2k+1})^2}{1+(x^{2k+2})^2}}$$