Skip to content
Oakfield Operator Calculus Function Reference Site

Soft Clamping Functions

For bounds a<ba < b, slope parameter β>0\beta > 0, and center x0x_0, define

softclamp(x)=a+(ba)σ ⁣(β(xx0)),σ(z)=11+ez\operatorname{softclamp}(x) = a + (b-a)\,\sigma\!\big(\beta(x - x_0)\big), \qquad \sigma(z) = \frac{1}{1+e^{-z}}

For real inputs, softclamp:R(a,b)\operatorname{softclamp}:\mathbb{R}\to(a,b), with softclamp(x)a\operatorname{softclamp}(x)\to a as xx\to-\infty and softclamp(x)b\operatorname{softclamp}(x)\to b as x+x\to+\infty.


Monotone and CC^\infty; derivative

softclamp(x)=(ba)βσ(β(xx0))(1σ(β(xx0)))\operatorname{softclamp}'(x) = (b-a)\,\beta\,\sigma(\beta(x-x_0))\big(1-\sigma(\beta(x-x_0))\big)

peaks at x=x0x = x_0. Limits: limxsoftclamp(x)=a\lim_{x\to -\infty}\operatorname{softclamp}(x) = a, limxsoftclamp(x)=b\lim_{x\to\infty}\operatorname{softclamp}(x) = b.


  • β\beta\to\infty approaches a hard clamp centered at x0x_0.
  • a=0a=0, b=1b=1, x0=0x_0=0 reduces to the logistic sigmoid σ(βx)\sigma(\beta x).

Hyperbolic tangent provides a symmetric clamp to (1,1)(-1,1); smooth saturation functions generalize bounded responses with alternative profiles.


Oakfield uses soft clamping primarily in the thermostat/regulation path:

  • Thermostat operator supports smooth min/max limiting of its regulated parameters via a softplus-style clamp (controlled by softplus_k), avoiding hard discontinuities when enforcing bounds.
  • Other parts of the engine also provide hard clamps (e.g. continuity clamp ranges), but the explicit “soft clamp” behavior is concentrated in the thermostat’s smooth clamp logic.

Logistic-style transitions provide smooth approximations to step functions and clamps, enabling bounded mappings with controllable transition sharpness.

Soft clamps are standard tools when boundedness is required but differentiability must be preserved for gradient-based methods.


  • Boyd & Vandenberghe, Convex Optimization
  • NIST Digital Library of Mathematical Functions (DLMF), §4