?

Average Error: 0.1 → 0.0
Time: 13.7s
Precision: binary32
Cost: 9760

?

\[0 \leq s \land s \leq 1.0651631\]
\[\frac{1}{1 + e^{\frac{-x}{s}}} \]
\[e^{-\mathsf{log1p}\left(e^{\frac{-x}{s}}\right)} \]
(FPCore (x s) :precision binary32 (/ 1.0 (+ 1.0 (exp (/ (- x) s)))))
(FPCore (x s) :precision binary32 (exp (- (log1p (exp (/ (- x) s))))))
float code(float x, float s) {
	return 1.0f / (1.0f + expf((-x / s)));
}
float code(float x, float s) {
	return expf(-log1pf(expf((-x / s))));
}
function code(x, s)
	return Float32(Float32(1.0) / Float32(Float32(1.0) + exp(Float32(Float32(-x) / s))))
end
function code(x, s)
	return exp(Float32(-log1p(exp(Float32(Float32(-x) / s)))))
end
\frac{1}{1 + e^{\frac{-x}{s}}}
e^{-\mathsf{log1p}\left(e^{\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.0

    \[\leadsto \color{blue}{e^{-\mathsf{log1p}\left(e^{-\frac{x}{s}}\right)}} \]
  4. Simplified0.0

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

    [Start]0.0

    \[ e^{-\mathsf{log1p}\left(e^{-\frac{x}{s}}\right)} \]

    distribute-neg-frac [=>]0.0

    \[ e^{-\mathsf{log1p}\left(e^{\color{blue}{\frac{-x}{s}}}\right)} \]
  5. Final simplification0.0

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

Alternatives

Alternative 1
Error0.1
Cost3456
\[\frac{1}{e^{\frac{-x}{s}} + 1} \]
Alternative 2
Error11.7
Cost708
\[\begin{array}{l} \mathbf{if}\;\frac{-x}{s} \leq -2:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(2 + x \cdot \frac{0.5}{s \cdot \frac{s}{x}}\right) - \frac{x}{s}}\\ \end{array} \]
Alternative 3
Error11.9
Cost612
\[\begin{array}{l} \mathbf{if}\;\frac{-x}{s} \leq 20:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2 + \left(x \cdot \frac{x}{s \cdot \left(-s\right)}\right) \cdot -0.5}\\ \end{array} \]
Alternative 4
Error12.5
Cost516
\[\begin{array}{l} \mathbf{if}\;\frac{-x}{s} \leq 1000:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{0.5 \cdot \left(x \cdot x\right)}{s \cdot s}}\\ \end{array} \]
Alternative 5
Error12.5
Cost516
\[\begin{array}{l} \mathbf{if}\;-x \leq 9.999999887266023 \cdot 10^{-27}:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2 + 0.5 \cdot \frac{x \cdot x}{s \cdot s}}\\ \end{array} \]
Alternative 6
Error12.5
Cost516
\[\begin{array}{l} \mathbf{if}\;-x \leq 9.999999887266023 \cdot 10^{-27}:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2 + \frac{\frac{x \cdot x}{2}}{s \cdot s}}\\ \end{array} \]
Alternative 7
Error13.5
Cost452
\[\begin{array}{l} \mathbf{if}\;\frac{-x}{s} \leq 20000000:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(s \cdot \frac{s}{x \cdot x}\right)\\ \end{array} \]
Alternative 8
Error12.6
Cost452
\[\begin{array}{l} \mathbf{if}\;\frac{-x}{s} \leq 1000:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \frac{s \cdot s}{x \cdot x}\\ \end{array} \]
Alternative 9
Error16.2
Cost388
\[\begin{array}{l} \mathbf{if}\;\frac{-x}{s} \leq -2:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2 - \frac{x}{s}}\\ \end{array} \]
Alternative 10
Error16.7
Cost356
\[\begin{array}{l} t_0 := \frac{-x}{s}\\ \mathbf{if}\;t_0 \leq 0.20000000298023224:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{t_0}\\ \end{array} \]
Alternative 11
Error17.2
Cost196
\[\begin{array}{l} \mathbf{if}\;x \leq -4.999999969612645 \cdot 10^{-9}:\\ \;\;\;\;\frac{-s}{x}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
Alternative 12
Error17.2
Cost164
\[\begin{array}{l} \mathbf{if}\;x \leq -4.999999987376214 \cdot 10^{-7}:\\ \;\;\;\;\frac{s}{x}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
Alternative 13
Error20.8
Cost32
\[0.5 \]

Error

Reproduce?

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