Average Error: 0.1 → 0.1
Time: 6.1s
Precision: binary32
\[0 \leq s \land s \leq 1.0651631\]
\[\frac{1}{1 + e^{\frac{-x}{s}}}\]
\[e^{-\log \left(1 + e^{-\frac{x}{s}}\right)}\]
\frac{1}{1 + e^{\frac{-x}{s}}}
e^{-\log \left(1 + e^{-\frac{x}{s}}\right)}
(FPCore (x s) :precision binary32 (/ 1.0 (+ 1.0 (exp (/ (- x) s)))))
(FPCore (x s) :precision binary32 (exp (- (log (+ 1.0 (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(-logf(1.0f + expf(-(x / s))));
}

Error

Bits error versus x

Bits error versus s

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. Using strategy rm
  3. Applied add-exp-log_binary320.1

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

    \[\leadsto \frac{\color{blue}{e^{0}}}{e^{\log \left(1 + e^{\frac{-x}{s}}\right)}}\]
  5. Applied div-exp_binary320.1

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

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

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

Reproduce

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