Function Repository Resource:

ExponentialSmoothStep

Source Notebook

Evaluate a smooth step function based on exponentials

Contributed by: Ted Ersek

ResourceFunction["ExponentialSmoothStep"][x]

is a smooth monotonic function that is 0 for x0 and 1 for x1.

Details

Mathematical function, suitable for both symbolic and numerical manipulation.
ResourceFunction["ExponentialSmoothStep"][x] is C(i.e. is differentiable for all degrees of differentiation over the real numbers).
All derivatives of ResourceFunction["ExponentialSmoothStep"][x] are zero at x=0 and x=1.
ResourceFunction["ExponentialSmoothStep"][z] returns $Failed when z has a Complex numeric value.
ResourceFunction["ExponentialSmoothStep"][x] can be evaluated to arbitrary numerical precision.
ResourceFunction["ExponentialSmoothStep"] automatically threads over lists.

Examples

Basic Examples (2) 

Plot the exponential smooth step and see the function is smooth and monotonic:

In[1]:=
Plot[ResourceFunction["ExponentialSmoothStep"][x], {x, -0.5, 1.5}]
Out[1]=

ExponentialSmoothStep[x] returns a Piecewise function:

In[2]:=
ResourceFunction["ExponentialSmoothStep"][x]
Out[2]=

Scope (5) 

ExponentialSmoothStep is automatically threaded over a list of values:

In[3]:=
ResourceFunction[
 "ExponentialSmoothStep"][{-2, -0.2, 0.2, 1/E, 0.6, 2, E^3}]
Out[3]=

Compute ExponentialSmoothStep at an arbitrary precision number:

In[4]:=
ResourceFunction["ExponentialSmoothStep"][0.25`40]
Out[4]=

The definition of ExponentialSmoothStep[x] is extended to ±∞:

In[5]:=
{ResourceFunction["ExponentialSmoothStep"][-\[Infinity]], ResourceFunction["ExponentialSmoothStep"][\[Infinity]]}
Out[5]=

The definition of ExponentialSmoothStep[expr] is used when expr is a real number in some cases:

In[6]:=
ResourceFunction["ExponentialSmoothStep"][Log[x]]
Out[6]=

ExponentialSmoothStep[z] returns $Failed for a complex numeric value:

In[7]:=
ResourceFunction["ExponentialSmoothStep"][E^(2 I)]
Out[7]=

Properties and Relations (5) 

ExponentialSmoothStep[{x,n}] is a C function (i.e. differentiable for all degrees of differentiation over the real numbers). Here we see the third derivative is continuous over the interval plotted:

In[8]:=
D[ResourceFunction["ExponentialSmoothStep"][x], {x, 3}];
Plot[%, {x, -0.5, 1.5}, PlotRange -> All, WorkingPrecision -> 16]
Out[9]=

The resource function RationalSmoothStep is also a C function. However, ExponentialSmoothStep[x] has the special property that all derivatives are exactly 0 at x=0 and at x=1. As a result only ExponentialSmoothStep[x] is nearly 0 for x slightly larger than 0:

In[10]:=
Plot[{ResourceFunction["ExponentialSmoothStep"][x], ResourceFunction[
ResourceObject[<|"Name" -> "RationalSmoothStep", "ShortName" -> "RationalSmoothStep", "UUID" -> "8a2f16d3-753f-411e-b8fa-88e556b38ec0", "ResourceType" -> "Function", "Version" -> "1.0.1", "Description" -> "A sigmoidal interpolating rational function", "RepositoryLocation" -> URL[
       "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"],
       "SymbolName" -> "FunctionRepository`$2425d99a97ec4b9a8c3911e574c1701d`RationalSmoothStep"|>, ResourceSystemBase -> Automatic]][x]}, {x, 0, 0.17}, PlotLegends -> "Expressions"]
Out[10]=

Likewise ExponentialSmoothStep[x] is nearly 1 for x slightly less than 1:

In[11]:=
Plot[{ResourceFunction["ExponentialSmoothStep"][x], ResourceFunction[
ResourceObject[<|"Name" -> "RationalSmoothStep", "ShortName" -> "RationalSmoothStep", "UUID" -> "8a2f16d3-753f-411e-b8fa-88e556b38ec0", "ResourceType" -> "Function", "Version" -> "1.0.1", "Description" -> "A sigmoidal interpolating rational function", "RepositoryLocation" -> URL[
       "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"],
       "SymbolName" -> "FunctionRepository`$2425d99a97ec4b9a8c3911e574c1701d`RationalSmoothStep"|>, ResourceSystemBase -> Automatic]][x]}, {x, 0.83, 1}, PlotLegends -> "Expressions"]
Out[11]=

Unlike ExponentialSmoothStep[x], the second derivative of [x] is discontinuous at x=0 and x=1:

In[12]:=
Plot[Evaluate[D[ResourceFunction[
ResourceObject[<|"Name" -> "SmoothStep", "ShortName" -> "SmoothStep", "UUID" -> "45eab264-322e-4fa1-a68b-e14d5c3c2fb2", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "A sigmoidal interpolation function", "RepositoryLocation" -> URL[
        "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"], "SymbolName" -> "FunctionRepository`$5bdb301af09e480fb7519af95b8e76e8`SmoothStep", "FunctionLocation" -> CloudObject[
        "https://www.wolframcloud.com/obj/01916f57-cb2f-4c8d-9d24-751ea20d2da6"]|>, ResourceSystemBase -> Automatic]][x], {x, 2}]], {x, -1, 2}, PlotRange -> All]
Out[12]=

Unlike ExponentialSmoothStep[x], the third derivative of [x] is discontinuous at x=0 and x=1:

In[13]:=
Plot[Evaluate[D[ResourceFunction[
ResourceObject[<|"Name" -> "SmootherStep", "ShortName" -> "SmootherStep", "UUID" -> "75926152-853d-40e3-a10a-12bd6801dbbe", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "An improved sigmoidal interpolation function", "RepositoryLocation" -> URL[
        "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"], "SymbolName" -> "FunctionRepository`$432987f2200646f1a523468832987cef`SmootherStep", "FunctionLocation" -> CloudObject[
        "https://www.wolframcloud.com/obj/1e1ee94c-5bc3-4146-a0cd-d5bb5862c71e"]|>, ResourceSystemBase -> Automatic]][x], {x, 3}]], {x, -1, 2}, PlotRange -> All]
Out[13]=

Unlike ExponentialSmoothStep[x], the fifth order derivative of ResourceFunction["GeneralizedSmoothStep"][x,4] is discontinuous at x=0 and x=1:

In[14]:=
Plot[Evaluate[D[ResourceFunction[
ResourceObject[<|"Name" -> "GeneralizedSmoothStep", "ShortName" -> "GeneralizedSmoothStep", "UUID" -> "5521a09d-dc25-47aa-b425-4b036ec85f69", "ResourceType" -> "Function", "Version" -> "2.0.0", "Description" -> "A generalized sigmoidal interpolating polynomial", "RepositoryLocation" -> URL[
        "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"], "SymbolName" -> "FunctionRepository`$83c6ea6ca0fa4786ae01e242a99a27ab`GeneralizedSmoothStep", "FunctionLocation" -> CloudObject[
        "https://www.wolframcloud.com/obj/1e356f15-b066-4942-8023-35e9e62e0a73"]|>, ResourceSystemBase -> Automatic]][4, x], {x, 5}]], {x, -0.3, 1.3}, PlotRange -> All]
Out[14]=

Possible Issues (1) 

Directly computing a high order derivative ExponentialSmoothStep[x] leads to a very complicated result. Working with such expressions may require a long time and a lot of memory:

In[15]:=
Table[LeafCount[
  D[ResourceFunction["ExponentialSmoothStep"][x], {x, n}]], {n, 0, 8}]
Out[15]=

Publisher

Ted Ersek

Requirements

Wolfram Language 14.0 (January 2024) or above

Version History

  • 1.0.0 – 09 October 2024

Related Resources

License Information