?

Average Accuracy: 99.8% → 99.9%
Time: 10.8s
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 99.9%

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

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

    [Start]99.9

    \[ \frac{1}{1 + e^{\frac{-x}{s}}} \]

    div-inv [=>]99.9

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

    exp-prod [=>]83.0

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

    neg-mul-1 [=>]83.0

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

    exp-prod [=>]83.0

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

    pow-pow [=>]99.9

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

    div-inv [<=]99.9

    \[ \frac{1}{1 + {\left(e^{-1}\right)}^{\color{blue}{\left(\frac{x}{s}\right)}}} \]
  3. Applied egg-rr99.9%

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

    [Start]99.9

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

    add-exp-log [=>]99.9

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

    log-rec [=>]99.8

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

    log1p-udef [<=]99.9

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

    pow-exp [=>]99.9

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

    associate-*r/ [=>]99.9

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

    neg-mul-1 [<=]99.9

    \[ e^{-\mathsf{log1p}\left(e^{\frac{\color{blue}{-x}}{s}}\right)} \]
  4. Final simplification99.9%

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

Alternatives

Alternative 1
Accuracy99.8%
Cost6752
\[\frac{1}{1 + \frac{1}{{\left(e^{-1}\right)}^{\left(\frac{x}{-s}\right)}}} \]
Alternative 2
Accuracy99.8%
Cost6656
\[\frac{1}{1 + {\left(e^{-1}\right)}^{\left(\frac{x}{s}\right)}} \]
Alternative 3
Accuracy99.8%
Cost3456
\[\frac{1}{e^{\frac{-x}{s}} + 1} \]
Alternative 4
Accuracy76.6%
Cost552
\[\begin{array}{l} t_0 := \frac{-x}{s}\\ \mathbf{if}\;t_0 \leq -4:\\ \;\;\;\;1\\ \mathbf{elif}\;t_0 \leq 2:\\ \;\;\;\;0.5 + \frac{x}{s} \cdot 0.25\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{t_0}\\ \end{array} \]
Alternative 5
Accuracy94.2%
Cost552
\[\begin{array}{l} t_0 := \frac{-x}{s}\\ \mathbf{if}\;t_0 \leq -4:\\ \;\;\;\;1\\ \mathbf{elif}\;t_0 \leq 5:\\ \;\;\;\;0.5 + \frac{x}{s} \cdot 0.25\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(1 + \frac{s}{x}\right)\\ \end{array} \]
Alternative 6
Accuracy97.8%
Cost552
\[\begin{array}{l} t_0 := \frac{-x}{s}\\ \mathbf{if}\;t_0 \leq -4:\\ \;\;\;\;1\\ \mathbf{elif}\;t_0 \leq 2:\\ \;\;\;\;0.5 + \frac{x}{s} \cdot 0.25\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(0 \cdot \frac{s}{x}\right)\\ \end{array} \]
Alternative 7
Accuracy74.4%
Cost520
\[\begin{array}{l} t_0 := \frac{-x}{s}\\ \mathbf{if}\;t_0 \leq -4:\\ \;\;\;\;1\\ \mathbf{elif}\;t_0 \leq 2:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{t_0}\\ \end{array} \]
Alternative 8
Accuracy70.3%
Cost360
\[\begin{array}{l} \mathbf{if}\;-x \leq -9.999999682655225 \cdot 10^{-21}:\\ \;\;\;\;1\\ \mathbf{elif}\;-x \leq 7.999999979801942 \cdot 10^{-6}:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{x}{s}}\\ \end{array} \]
Alternative 9
Accuracy46.0%
Cost228
\[\begin{array}{l} \mathbf{if}\;x \leq -7.999999979801942 \cdot 10^{-6}:\\ \;\;\;\;s \cdot \frac{1}{x}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
Alternative 10
Accuracy69.0%
Cost228
\[\begin{array}{l} \mathbf{if}\;x \leq -7.999999979801942 \cdot 10^{-6}:\\ \;\;\;\;s \cdot \frac{1}{x}\\ \mathbf{elif}\;x \leq 9.999999682655225 \cdot 10^{-21}:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 11
Accuracy46.0%
Cost164
\[\begin{array}{l} \mathbf{if}\;x \leq -7.999999979801942 \cdot 10^{-6}:\\ \;\;\;\;\frac{s}{x}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
Alternative 12
Accuracy34.8%
Cost32
\[0.5 \]

Error

Reproduce?

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