2

I am dealing with a piecewise affine function $f$ defined as follows: $f(x)=0$ if $x<1$, $f(x)=1-x$ if $x\in [1,2]$ and $f(x)=-1$ otherwise. enter image description here I want to make it smooth. I looked at sigmoid functions of the form: $$ g_{a,b}(x)=\frac{1}{1+e^{-a(x-b)}}, $$ but I think that these functions are useful only when dealing with indicator functions. I thought of adding a circle arc to make smooth the corners: enter image description here

But I am stuck on how to parametrize them so I get a smooth function $g_{\epsilon}$ that converges to $f$ when $\epsilon$ goes to zero.

daw
  • 54,637
  • 2
  • 44
  • 85
hanava331
  • 169
  • 1
    Would this help you? https://math.stackexchange.com/q/1508257/1104384 – Bruno B Jun 05 '24 at 11:37
  • @BrunoB thanks for the answer, but I could not find a "smooth partition of unity": function that is equal to 1 over [-a/2,a/2] and 0 over [-a,a] and smooth in between – hanava331 Jun 05 '24 at 14:41
  • Try looking up the keyword "mollifier", you will find a function that satisfies these prerequisites on the Wikipedia page for example. – Bruno B Jun 05 '24 at 14:48

1 Answers1

0

If the curvature starts at $x=1$ it would not be possible to match the slope of $1-x$, so the smooth approximation should start a bit earlier.

If with smooth you mean a function class $C^\infty$, modifying what is said here I did the following approximation: $$s(x)=\begin{cases} 0,\ x\leq \frac58;\\ -1,\ x\geq \frac{19}{8};\\ \dfrac{1}{1+\exp\left(\frac{56\sqrt{3}(3-2x)}{(8x-19)(8x-5)}\right)}-1,\ \frac58<x<\frac{19}{8};\end{cases}$$ which correspond to the function from the source translated and scaled by $\hat{x}\equiv \frac{x-5/8}{7/4}$.

I found it visually by trial and error so surely it could be improved.

You can check its plot in Desmos.

approximation

Joako
  • 1,957