Help with the visualization of a function

I am trying to make the plot of an specific function through integration from others, but Wolfram-Alpha and Desmos are having problems with it, so I came here to see if someone could help me using Mathematica:

The parent function is: $$f(x) = \begin{cases} 0,\ |x|\geq 1; \\ 1,\ x=0;\\ \dfrac{1}{1+\exp\left(\frac{1-2|x|}{x^2-|x|}\right)},\ \text{otherwise}\end{cases}$$ which is a smooth bump function. Then the function $$g(x) = \int\limits_{-\infty}^x f(t)\ dt$$ should look like a sigmoidal smooth transition function, as it does in Desmos, but taking the integral again got stuck: $$h(x)=\int\limits_{-\infty}^x g(t)\ dt$$

I am expecting something that looks like $$s(x) = \ln(1+e^x)$$ or $$r(x) = \dfrac{x}{1-e^{-2x}}$$

and verify how much it deviates from them, but I have not able to do it yet.

code

f[x_Real]:=Piecewise[{
{0.,RealAbs@x>=1},
{1.,x==0},
{1./(1+E^((1-2RealAbs@x)/(x^2-RealAbs@x))),True}
}];

Plot[
{
NIntegrate[f[t], {u, -Infinity, x}, {t, -Infinity, u}],
Log[1 + Exp@x],
x/(1 - Exp[-2*x])
},
{x, -1, 1},
PlotRange -> {{-1, 1}, {0, 2}},
PlotLegends -> "Expressions"
]



code

g[x_] := NIntegrate[f[t], {u, -Infinity, x}, {t, -Infinity, u}];
g[0]


result

0.138459

• thanks for the answer. Did you have problems while doing it? (like more calculation time than usual)... Can I ask for a zoom on the square $x\in[-1,\ 1]$, $y\in[0,\ 2]$ please? Commented Aug 8 at 2:19
• It did take a lot of time. Commented Aug 8 at 2:21
• @Joako answer updated. Commented Aug 8 at 2:28
• thanks you a lot... is really weird why is so hard since the function is finite from the right... as a last question, Could you share the value at $x=0$? Commented Aug 8 at 2:36
• @Joako because NIntegrate appears in Plot, which will evaluate it's first argument many times. If you want to speed up, using Integrate beforehand to get an explicit representation and put it into Plot. Commented Aug 8 at 2:49
• Or using Newton-Leibniz formula and NDSolve
Clear["Global*"];
f[x_] :=
Piecewise[{{0, Abs[x] >= 1}, {1, x == 0}, {1/(
1 + Exp[(1 - 2 Abs[x])/(x^2 - Abs[x])]), True}}];
g0 = NIntegrate[f[x], {x, -∞, 0}]
sol = NDSolve[{g'[x] == f[x], g[0] == g0}, g, {x, -5, 5}]
Plot[g[x] /. sol, {x, -2, 2}]


• The same way to plot the h[x] which approximate to x/(1 - Exp[-x*65/9]).
h0 = NIntegrate[g[x] /. sol[[1]], {x, -2, 0}];
solh = NDSolve[{h'[x] == g[x] /. sol[[1]], h[0] == h0}, h, {x, -5, 5}];
{Plot[h[x] /. solh[[1]], {x, -2, 2}],
Plot[x/(1 - Exp[-x*65/9]), {x, -2, 2}]}
`

• thanks for the answer, but I am asking about the integral of that function, the one that looks like $\frac{x}{1-e^{-x\ 65/9}}$. Commented Aug 8 at 3:06