?

Average Error: 0.1 → 0.1
Time: 14.2s
Precision: binary32
Cost: 12992

?

\[0 \leq s \land s \leq 1.0651631\]
\[\frac{1}{1 + e^{\frac{-x}{s}}} \]
\[{\left(\mathsf{hypot}\left(1, {\left(e^{\frac{x}{s}}\right)}^{-0.5}\right)\right)}^{-2} \]
(FPCore (x s) :precision binary32 (/ 1.0 (+ 1.0 (exp (/ (- x) s)))))
(FPCore (x s)
 :precision binary32
 (pow (hypot 1.0 (pow (exp (/ x s)) -0.5)) -2.0))
float code(float x, float s) {
	return 1.0f / (1.0f + expf((-x / s)));
}
float code(float x, float s) {
	return powf(hypotf(1.0f, powf(expf((x / s)), -0.5f)), -2.0f);
}
function code(x, s)
	return Float32(Float32(1.0) / Float32(Float32(1.0) + exp(Float32(Float32(-x) / s))))
end
function code(x, s)
	return hypot(Float32(1.0), (exp(Float32(x / s)) ^ Float32(-0.5))) ^ Float32(-2.0)
end
function tmp = code(x, s)
	tmp = single(1.0) / (single(1.0) + exp((-x / s)));
end
function tmp = code(x, s)
	tmp = hypot(single(1.0), (exp((x / s)) ^ single(-0.5))) ^ single(-2.0);
end
\frac{1}{1 + e^{\frac{-x}{s}}}
{\left(\mathsf{hypot}\left(1, {\left(e^{\frac{x}{s}}\right)}^{-0.5}\right)\right)}^{-2}

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.3

    \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(1, {\left(e^{\frac{x}{s}}\right)}^{-0.5}\right)\right)}^{-1} \cdot {\left(\mathsf{hypot}\left(1, {\left(e^{\frac{x}{s}}\right)}^{-0.5}\right)\right)}^{-1}} \]
  4. Simplified0.1

    \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(1, {\left(e^{\frac{x}{s}}\right)}^{-0.5}\right)\right)}^{-2}} \]
    Proof

    [Start]0.3

    \[ {\left(\mathsf{hypot}\left(1, {\left(e^{\frac{x}{s}}\right)}^{-0.5}\right)\right)}^{-1} \cdot {\left(\mathsf{hypot}\left(1, {\left(e^{\frac{x}{s}}\right)}^{-0.5}\right)\right)}^{-1} \]

    pow-sqr [=>]0.1

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

    metadata-eval [=>]0.1

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

    \[\leadsto {\left(\mathsf{hypot}\left(1, {\left(e^{\frac{x}{s}}\right)}^{-0.5}\right)\right)}^{-2} \]

Alternatives

Alternative 1
Error0.1
Cost9824
\[{\left(\mathsf{hypot}\left(1, e^{x \cdot \frac{-0.5}{s}}\right)\right)}^{-2} \]
Alternative 2
Error0.1
Cost9760
\[e^{-\mathsf{log1p}\left(e^{\frac{-x}{s}}\right)} \]
Alternative 3
Error0.1
Cost3456
\[\frac{1}{1 + e^{\frac{-x}{s}}} \]
Alternative 4
Error2.0
Cost836
\[\begin{array}{l} \mathbf{if}\;\frac{-x}{s} \leq 10:\\ \;\;\;\;\frac{1}{1 + \frac{1}{1 + \left(\frac{x}{s} + 0.5 \cdot \left(x \cdot \frac{\frac{x}{s}}{s}\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;1 + \left(\frac{s}{x} + -1\right)\\ \end{array} \]
Alternative 5
Error8.0
Cost552
\[\begin{array}{l} t_0 := \frac{-x}{s}\\ \mathbf{if}\;t_0 \leq -200:\\ \;\;\;\;1 - \frac{s}{x}\\ \mathbf{elif}\;t_0 \leq 1:\\ \;\;\;\;0.5 + \frac{x}{s} \cdot 0.25\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{t_0}\\ \end{array} \]
Alternative 6
Error2.3
Cost552
\[\begin{array}{l} t_0 := \frac{-x}{s}\\ \mathbf{if}\;t_0 \leq -200:\\ \;\;\;\;1 - \frac{s}{x}\\ \mathbf{elif}\;t_0 \leq 4:\\ \;\;\;\;0.5 + \frac{x}{s} \cdot 0.25\\ \mathbf{else}:\\ \;\;\;\;1 + \left(\frac{s}{x} + -1\right)\\ \end{array} \]
Alternative 7
Error2.3
Cost552
\[\begin{array}{l} t_0 := \frac{-x}{s}\\ \mathbf{if}\;t_0 \leq -200:\\ \;\;\;\;\frac{1}{1 + \frac{s}{x}}\\ \mathbf{elif}\;t_0 \leq 4:\\ \;\;\;\;0.5 + \frac{x}{s} \cdot 0.25\\ \mathbf{else}:\\ \;\;\;\;1 + \left(\frac{s}{x} + -1\right)\\ \end{array} \]
Alternative 8
Error8.6
Cost520
\[\begin{array}{l} t_0 := \frac{-x}{s}\\ \mathbf{if}\;t_0 \leq -2:\\ \;\;\;\;1 - \frac{s}{x}\\ \mathbf{elif}\;t_0 \leq 1:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{t_0}\\ \end{array} \]
Alternative 9
Error2.5
Cost516
\[\begin{array}{l} \mathbf{if}\;\frac{-x}{s} \leq 10:\\ \;\;\;\;\frac{1}{1 + \frac{1}{1 + \frac{x}{s}}}\\ \mathbf{else}:\\ \;\;\;\;1 + \left(\frac{s}{x} + -1\right)\\ \end{array} \]
Alternative 10
Error10.7
Cost296
\[\begin{array}{l} \mathbf{if}\;x \leq -1.9999999949504854 \cdot 10^{-6}:\\ \;\;\;\;s \cdot \frac{-1}{x}\\ \mathbf{elif}\;x \leq 3.999999886872274 \cdot 10^{-9}:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{s}{x}\\ \end{array} \]
Alternative 11
Error17.3
Cost228
\[\begin{array}{l} \mathbf{if}\;x \leq -1.9999999949504854 \cdot 10^{-6}:\\ \;\;\;\;s \cdot \frac{-1}{x}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
Alternative 12
Error17.3
Cost164
\[\begin{array}{l} \mathbf{if}\;x \leq -1.9999999949504854 \cdot 10^{-6}:\\ \;\;\;\;\frac{s}{x}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
Alternative 13
Error20.9
Cost32
\[0.5 \]

Error

Reproduce?

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