?

Average Error: 0.1 → 0.1
Time: 28.4s
Precision: binary32
Cost: 6720

?

\[0 \leq s \land s \leq 1.0651631\]
\[\frac{1}{1 + e^{\frac{-x}{s}}} \]
\[\frac{1}{1 + {\left(e^{x \cdot \frac{-0.5}{s}}\right)}^{2}} \]
(FPCore (x s) :precision binary32 (/ 1.0 (+ 1.0 (exp (/ (- x) s)))))
(FPCore (x s)
 :precision binary32
 (/ 1.0 (+ 1.0 (pow (exp (* x (/ -0.5 s))) 2.0))))
float code(float x, float s) {
	return 1.0f / (1.0f + expf((-x / s)));
}
float code(float x, float s) {
	return 1.0f / (1.0f + powf(expf((x * (-0.5f / s))), 2.0f));
}
real(4) function code(x, s)
    real(4), intent (in) :: x
    real(4), intent (in) :: s
    code = 1.0e0 / (1.0e0 + exp((-x / s)))
end function
real(4) function code(x, s)
    real(4), intent (in) :: x
    real(4), intent (in) :: s
    code = 1.0e0 / (1.0e0 + (exp((x * ((-0.5e0) / s))) ** 2.0e0))
end function
function code(x, s)
	return Float32(Float32(1.0) / Float32(Float32(1.0) + exp(Float32(Float32(-x) / s))))
end
function code(x, s)
	return Float32(Float32(1.0) / Float32(Float32(1.0) + (exp(Float32(x * Float32(Float32(-0.5) / s))) ^ 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 = single(1.0) / (single(1.0) + (exp((x * (single(-0.5) / s))) ^ single(2.0)));
end
\frac{1}{1 + e^{\frac{-x}{s}}}
\frac{1}{1 + {\left(e^{x \cdot \frac{-0.5}{s}}\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}{e^{-0.5 \cdot \frac{x}{s}} \cdot e^{-0.5 \cdot \frac{x}{s}}}} \]
  3. Taylor expanded in x around inf 0.1

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

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

    [Start]0.1

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

    rational_best-simplify-55 [=>]0.1

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

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

Alternatives

Alternative 1
Error0.1
Cost3456
\[\frac{1}{1 + e^{\frac{-x}{s}}} \]
Alternative 2
Error2.6
Cost616
\[\begin{array}{l} \mathbf{if}\;x \leq -0.0005000000237487257:\\ \;\;\;\;-1 + \left(1 - \frac{s}{x}\right)\\ \mathbf{elif}\;x \leq -2.0000000063421537 \cdot 10^{-29}:\\ \;\;\;\;\frac{1}{\frac{\frac{2}{s} - \frac{x}{s \cdot s}}{\frac{1}{s}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{4}{2 + \left(\frac{4}{1 + \frac{x}{s}} - -2\right)}\\ \end{array} \]
Alternative 3
Error3.5
Cost484
\[\begin{array}{l} \mathbf{if}\;x \leq -9.99999983775159 \cdot 10^{-18}:\\ \;\;\;\;\left(-1 - \frac{s}{x}\right) + 1\\ \mathbf{else}:\\ \;\;\;\;\frac{4}{2 + \left(\frac{4}{1 + \frac{x}{s}} - -2\right)}\\ \end{array} \]
Alternative 4
Error3.5
Cost420
\[\begin{array}{l} \mathbf{if}\;x \leq -9.99999983775159 \cdot 10^{-18}:\\ \;\;\;\;\left(-1 - \frac{s}{x}\right) + 1\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 + \frac{1}{1 + \frac{x}{s}}}\\ \end{array} \]
Alternative 5
Error4.9
Cost360
\[\begin{array}{l} t_0 := 1 - \frac{s}{x}\\ \mathbf{if}\;x \leq -9.99999983775159 \cdot 10^{-18}:\\ \;\;\;\;-1 + t_0\\ \mathbf{elif}\;x \leq 1.999999967550318 \cdot 10^{-17}:\\ \;\;\;\;0.5 + \frac{x}{s} \cdot 0.25\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error4.9
Cost360
\[\begin{array}{l} \mathbf{if}\;x \leq -9.99999983775159 \cdot 10^{-18}:\\ \;\;\;\;\left(-1 - \frac{s}{x}\right) + 1\\ \mathbf{elif}\;x \leq 1.999999967550318 \cdot 10^{-17}:\\ \;\;\;\;0.5 + \frac{x}{s} \cdot 0.25\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{s}{x}\\ \end{array} \]
Alternative 7
Error4.9
Cost360
\[\begin{array}{l} \mathbf{if}\;x \leq -9.99999983775159 \cdot 10^{-18}:\\ \;\;\;\;\left(-1 - \frac{s}{x}\right) + 1\\ \mathbf{elif}\;x \leq 9.999999998199587 \cdot 10^{-24}:\\ \;\;\;\;0.5 + \frac{x}{s} \cdot 0.25\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{s}{x} + 1}\\ \end{array} \]
Alternative 8
Error10.4
Cost296
\[\begin{array}{l} \mathbf{if}\;x \leq -9.99999993922529 \cdot 10^{-9}:\\ \;\;\;\;-\frac{s}{x}\\ \mathbf{elif}\;x \leq 1.999999967550318 \cdot 10^{-17}:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{s}{x}\\ \end{array} \]
Alternative 9
Error10.0
Cost296
\[\begin{array}{l} \mathbf{if}\;x \leq -9.99999993922529 \cdot 10^{-9}:\\ \;\;\;\;\frac{-1}{\frac{x}{s}}\\ \mathbf{elif}\;x \leq 1.999999967550318 \cdot 10^{-17}:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{s}{x}\\ \end{array} \]
Alternative 10
Error5.2
Cost296
\[\begin{array}{l} t_0 := 1 - \frac{s}{x}\\ \mathbf{if}\;x \leq -9.99999983775159 \cdot 10^{-18}:\\ \;\;\;\;-1 + t_0\\ \mathbf{elif}\;x \leq 1.999999967550318 \cdot 10^{-17}:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 11
Error17.3
Cost196
\[\begin{array}{l} \mathbf{if}\;x \leq -9.99999993922529 \cdot 10^{-9}:\\ \;\;\;\;-\frac{s}{x}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
Alternative 12
Error20.8
Cost32
\[0.5 \]

Error

Reproduce?

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