Average Error: 0.1 → 0.1
Time: 8.0s
Precision: binary32
Cost: 6720
\[0 \leq s \land s \leq 1.0651631\]
\[\frac{1}{1 + e^{\frac{-x}{s}}} \]
\[\frac{1}{1 + {\left(e^{2}\right)}^{\left(-0.5 \cdot \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 2.0) (* -0.5 (/ 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(2.0f), (-0.5f * (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(2.0e0) ** ((-0.5e0) * (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(2.0)) ^ Float32(Float32(-0.5) * 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(2.0)) ^ (single(-0.5) * (x / s))));
end
\frac{1}{1 + e^{\frac{-x}{s}}}
\frac{1}{1 + {\left(e^{2}\right)}^{\left(-0.5 \cdot \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{1}{e^{\frac{x}{s}}}}} \]
  3. Applied egg-rr0.1

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

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

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

Alternatives

Alternative 1
Error0.1
Cost3456
\[\frac{1}{1 + e^{\frac{-x}{s}}} \]
Alternative 2
Error0.9
Cost836
\[\begin{array}{l} \mathbf{if}\;\frac{-x}{s} \leq 20:\\ \;\;\;\;\frac{1}{1 + \frac{1}{\left(1 + \frac{x}{s}\right) + \frac{x}{s} \cdot \frac{x \cdot 0.5}{s}}}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
Alternative 3
Error0.7
Cost552
\[\begin{array}{l} t_0 := \frac{-x}{s}\\ \mathbf{if}\;t_0 \leq -2:\\ \;\;\;\;1\\ \mathbf{elif}\;t_0 \leq 2:\\ \;\;\;\;0.5 + \frac{x \cdot 0.25}{s}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
Alternative 4
Error1.3
Cost516
\[\begin{array}{l} \mathbf{if}\;\frac{-x}{s} \leq 20:\\ \;\;\;\;\frac{1}{1 + \frac{1}{1 + \frac{x}{s}}}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
Alternative 5
Error1.3
Cost360
\[\begin{array}{l} t_0 := \frac{-x}{s}\\ \mathbf{if}\;t_0 \leq -2:\\ \;\;\;\;1\\ \mathbf{elif}\;t_0 \leq 20:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
Alternative 6
Error13.7
Cost100
\[\begin{array}{l} \mathbf{if}\;x \leq 4.999999980020986 \cdot 10^{-13}:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 7
Error20.9
Cost32
\[0.5 \]

Error

Reproduce

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