Average Error: 0.1 → 0.1
Time: 7.6s
Precision: binary32
\[0 \leq s \land s \leq 1.0651631\]
\[\frac{1}{1 + e^{\frac{-x}{s}}} \]
\[\begin{array}{l} t_0 := e^{-\frac{x}{s}}\\ \sqrt[3]{e^{\mathsf{log1p}\left(t_0\right) \cdot -2} \cdot \frac{1}{t_0 + 1}} \end{array} \]
\frac{1}{1 + e^{\frac{-x}{s}}}
\begin{array}{l}
t_0 := e^{-\frac{x}{s}}\\
\sqrt[3]{e^{\mathsf{log1p}\left(t_0\right) \cdot -2} \cdot \frac{1}{t_0 + 1}}
\end{array}
(FPCore (x s) :precision binary32 (/ 1.0 (+ 1.0 (exp (/ (- x) s)))))
(FPCore (x s)
 :precision binary32
 (let* ((t_0 (exp (- (/ x s)))))
   (cbrt (* (exp (* (log1p t_0) -2.0)) (/ 1.0 (+ t_0 1.0))))))
float code(float x, float s) {
	return 1.0f / (1.0f + expf(-x / s));
}
float code(float x, float s) {
	float t_0 = expf(-(x / s));
	return cbrtf(expf(log1pf(t_0) * -2.0f) * (1.0f / (t_0 + 1.0f)));
}

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. Applied add-cbrt-cube_binary320.2

    \[\leadsto \frac{1}{\color{blue}{\sqrt[3]{\left(\left(1 + e^{\frac{-x}{s}}\right) \cdot \left(1 + e^{\frac{-x}{s}}\right)\right) \cdot \left(1 + e^{\frac{-x}{s}}\right)}}} \]
  3. Applied add-cbrt-cube_binary320.2

    \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(1 \cdot 1\right) \cdot 1}}}{\sqrt[3]{\left(\left(1 + e^{\frac{-x}{s}}\right) \cdot \left(1 + e^{\frac{-x}{s}}\right)\right) \cdot \left(1 + e^{\frac{-x}{s}}\right)}} \]
  4. Applied cbrt-undiv_binary320.2

    \[\leadsto \color{blue}{\sqrt[3]{\frac{\left(1 \cdot 1\right) \cdot 1}{\left(\left(1 + e^{\frac{-x}{s}}\right) \cdot \left(1 + e^{\frac{-x}{s}}\right)\right) \cdot \left(1 + e^{\frac{-x}{s}}\right)}}} \]
  5. Applied add-exp-log_binary320.2

    \[\leadsto \sqrt[3]{\frac{\left(1 \cdot 1\right) \cdot 1}{\left(\left(1 + e^{\frac{-x}{s}}\right) \cdot \left(1 + e^{\frac{-x}{s}}\right)\right) \cdot \color{blue}{e^{\log \left(1 + e^{\frac{-x}{s}}\right)}}}} \]
  6. Applied add-exp-log_binary320.2

    \[\leadsto \sqrt[3]{\frac{\left(1 \cdot 1\right) \cdot 1}{\left(\left(1 + e^{\frac{-x}{s}}\right) \cdot \color{blue}{e^{\log \left(1 + e^{\frac{-x}{s}}\right)}}\right) \cdot e^{\log \left(1 + e^{\frac{-x}{s}}\right)}}} \]
  7. Applied add-exp-log_binary320.2

    \[\leadsto \sqrt[3]{\frac{\left(1 \cdot 1\right) \cdot 1}{\left(\color{blue}{e^{\log \left(1 + e^{\frac{-x}{s}}\right)}} \cdot e^{\log \left(1 + e^{\frac{-x}{s}}\right)}\right) \cdot e^{\log \left(1 + e^{\frac{-x}{s}}\right)}}} \]
  8. Applied prod-exp_binary320.2

    \[\leadsto \sqrt[3]{\frac{\left(1 \cdot 1\right) \cdot 1}{\color{blue}{e^{\log \left(1 + e^{\frac{-x}{s}}\right) + \log \left(1 + e^{\frac{-x}{s}}\right)}} \cdot e^{\log \left(1 + e^{\frac{-x}{s}}\right)}}} \]
  9. Applied prod-exp_binary320.2

    \[\leadsto \sqrt[3]{\frac{\left(1 \cdot 1\right) \cdot 1}{\color{blue}{e^{\left(\log \left(1 + e^{\frac{-x}{s}}\right) + \log \left(1 + e^{\frac{-x}{s}}\right)\right) + \log \left(1 + e^{\frac{-x}{s}}\right)}}}} \]
  10. Simplified0.2

    \[\leadsto \sqrt[3]{\frac{\left(1 \cdot 1\right) \cdot 1}{e^{\color{blue}{3 \cdot \mathsf{log1p}\left(e^{-\frac{x}{s}}\right)}}}} \]
  11. Applied add-cube-cbrt_binary320.2

    \[\leadsto \sqrt[3]{\frac{\left(1 \cdot 1\right) \cdot 1}{\color{blue}{\left(\sqrt[3]{e^{3 \cdot \mathsf{log1p}\left(e^{-\frac{x}{s}}\right)}} \cdot \sqrt[3]{e^{3 \cdot \mathsf{log1p}\left(e^{-\frac{x}{s}}\right)}}\right) \cdot \sqrt[3]{e^{3 \cdot \mathsf{log1p}\left(e^{-\frac{x}{s}}\right)}}}}} \]
  12. Applied times-frac_binary320.2

    \[\leadsto \sqrt[3]{\color{blue}{\frac{1 \cdot 1}{\sqrt[3]{e^{3 \cdot \mathsf{log1p}\left(e^{-\frac{x}{s}}\right)}} \cdot \sqrt[3]{e^{3 \cdot \mathsf{log1p}\left(e^{-\frac{x}{s}}\right)}}} \cdot \frac{1}{\sqrt[3]{e^{3 \cdot \mathsf{log1p}\left(e^{-\frac{x}{s}}\right)}}}}} \]
  13. Simplified0.2

    \[\leadsto \sqrt[3]{\color{blue}{e^{\mathsf{log1p}\left(e^{-\frac{x}{s}}\right) \cdot -2}} \cdot \frac{1}{\sqrt[3]{e^{3 \cdot \mathsf{log1p}\left(e^{-\frac{x}{s}}\right)}}}} \]
  14. Simplified0.1

    \[\leadsto \sqrt[3]{e^{\mathsf{log1p}\left(e^{-\frac{x}{s}}\right) \cdot -2} \cdot \color{blue}{\frac{1}{1 + e^{-\frac{x}{s}}}}} \]
  15. Final simplification0.1

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

Reproduce

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