Average Error: 0.1 → 0.1
Time: 9.5s
Precision: binary32
Cost: 6656
\[0 \leq s \land s \leq 1.0651631\]
\[\frac{1}{1 + e^{\frac{-x}{s}}} \]
\[\frac{1}{1 + {\left(e^{-1}\right)}^{\left(\frac{x}{s}\right)}} \]
(FPCore (x s) :precision binary32 (/ 1.0 (+ 1.0 (exp (/ (- x) s)))))
(FPCore (x s) :precision binary32 (/ 1.0 (+ 1.0 (pow (exp -1.0) (/ x s)))))
float code(float x, float s) {
	return 1.0f / (1.0f + expf((-x / s)));
}
float code(float x, float s) {
	return 1.0f / (1.0f + powf(expf(-1.0f), (x / s)));
}
real(4) function code(x, s)
    real(4), intent (in) :: x
    real(4), intent (in) :: s
    code = 1.0e0 / (1.0e0 + exp((-x / s)))
end function
real(4) function code(x, s)
    real(4), intent (in) :: x
    real(4), intent (in) :: s
    code = 1.0e0 / (1.0e0 + (exp((-1.0e0)) ** (x / s)))
end function
function code(x, s)
	return Float32(Float32(1.0) / Float32(Float32(1.0) + exp(Float32(Float32(-x) / s))))
end
function code(x, s)
	return Float32(Float32(1.0) / Float32(Float32(1.0) + (exp(Float32(-1.0)) ^ Float32(x / s))))
end
function tmp = code(x, s)
	tmp = single(1.0) / (single(1.0) + exp((-x / s)));
end
function tmp = code(x, s)
	tmp = single(1.0) / (single(1.0) + (exp(single(-1.0)) ^ (x / s)));
end
\frac{1}{1 + e^{\frac{-x}{s}}}
\frac{1}{1 + {\left(e^{-1}\right)}^{\left(\frac{x}{s}\right)}}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.1

    \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
  2. Applied egg-rr0.1

    \[\leadsto \frac{1}{1 + \color{blue}{\frac{\frac{1}{\sqrt{e^{\frac{x}{s}}}}}{\sqrt{e^{\frac{x}{s}}}}}} \]
  3. Applied egg-rr0.1

    \[\leadsto \frac{1}{1 + \color{blue}{{\left(e^{-0.5 \cdot \frac{x}{s}}\right)}^{2}}} \]
  4. Applied egg-rr0.1

    \[\leadsto \frac{1}{1 + {\color{blue}{\left({\left(e^{-0.5}\right)}^{\left(\frac{x}{s}\right)}\right)}}^{2}} \]
  5. Applied egg-rr0.1

    \[\leadsto \frac{1}{1 + \color{blue}{\left({\left(e^{-1}\right)}^{\left(\frac{x}{s}\right)} + 0\right)}} \]
  6. Simplified0.1

    \[\leadsto \frac{1}{1 + \color{blue}{{\left(e^{-1}\right)}^{\left(\frac{x}{s}\right)}}} \]
    Proof

    [Start]0.1

    \[ \frac{1}{1 + \left({\left(e^{-1}\right)}^{\left(\frac{x}{s}\right)} + 0\right)} \]

    +-rgt-identity [=>]0.1

    \[ \frac{1}{1 + \color{blue}{{\left(e^{-1}\right)}^{\left(\frac{x}{s}\right)}}} \]
  7. Final simplification0.1

    \[\leadsto \frac{1}{1 + {\left(e^{-1}\right)}^{\left(\frac{x}{s}\right)}} \]

Alternatives

Alternative 1
Error0.1
Cost3456
\[\frac{1}{1 + e^{-\frac{x}{s}}} \]
Alternative 2
Error10.0
Cost196
\[\begin{array}{l} \mathbf{if}\;-\frac{x}{s} \leq 5:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
Alternative 3
Error20.8
Cost32
\[0.5 \]

Error

Reproduce

herbie shell --seed 2022354 
(FPCore (x s)
  :name "Logistic function"
  :precision binary32
  :pre (and (<= 0.0 s) (<= s 1.0651631))
  (/ 1.0 (+ 1.0 (exp (/ (- x) s)))))