?

Average Error: 0.1 → 0.1
Time: 8.0s
Precision: binary32
Cost: 3456

?

\[0 \leq s \land s \leq 1.0651631\]
\[\frac{1}{1 + e^{\frac{-x}{s}}} \]
\[\frac{1}{1 + e^{\frac{-x}{s}}} \]
(FPCore (x s) :precision binary32 (/ 1.0 (+ 1.0 (exp (/ (- x) s)))))
(FPCore (x s) :precision binary32 (/ 1.0 (+ 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 1.0f / (1.0f + expf((-x / s)));
}
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 / s)))
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(Float32(-x) / s))))
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 / s)));
end
\frac{1}{1 + e^{\frac{-x}{s}}}
\frac{1}{1 + e^{\frac{-x}{s}}}

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. Final simplification0.1

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

Alternatives

Alternative 1
Error11.8
Cost868
\[\begin{array}{l} t_0 := \frac{1}{2 - \frac{x}{s}}\\ \mathbf{if}\;x \leq 9.999999796611898 \cdot 10^{-32}:\\ \;\;\;\;t_0 \cdot \left(t_0 \cdot \frac{1}{0.5 + 0.25 \cdot \frac{x}{s}}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
Alternative 2
Error11.0
Cost808
\[\begin{array}{l} t_0 := \frac{1}{2 - \frac{x}{s}}\\ \mathbf{if}\;x \leq -4000000000:\\ \;\;\;\;t_0 \cdot \left(t_0 \cdot \left(4 \cdot \frac{s}{x}\right)\right)\\ \mathbf{elif}\;x \leq 9.999999796611898 \cdot 10^{-32}:\\ \;\;\;\;t_0 \cdot \left(-0.5 \cdot \frac{x}{s} + \left(1 + 0.5 \cdot \frac{x}{s}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
Alternative 3
Error12.7
Cost740
\[\begin{array}{l} t_0 := \frac{1}{2 - \frac{x}{s}}\\ \mathbf{if}\;x \leq -4.99999991225835 \cdot 10^{-15}:\\ \;\;\;\;t_0 \cdot \left(t_0 \cdot \left(4 \cdot \frac{s}{x}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
Alternative 4
Error13.2
Cost612
\[\begin{array}{l} t_0 := \frac{1}{2 - \frac{x}{s}}\\ \mathbf{if}\;x \leq -5.0000000900125474 \cdot 10^{-36}:\\ \;\;\;\;t_0 \cdot \left(t_0 \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
Alternative 5
Error13.6
Cost484
\[\begin{array}{l} \mathbf{if}\;x \leq -4.99999991225835 \cdot 10^{-15}:\\ \;\;\;\;\frac{1}{2 - \frac{x}{s}} \cdot \left(-2 \cdot \frac{s}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
Alternative 6
Error16.5
Cost292
\[\begin{array}{l} \mathbf{if}\;x \leq 9.999999796611898 \cdot 10^{-32}:\\ \;\;\;\;\frac{1}{2 - \frac{x}{s}}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
Alternative 7
Error16.8
Cost260
\[\begin{array}{l} \mathbf{if}\;x \leq -0.0010000000474974513:\\ \;\;\;\;\frac{1}{-\frac{x}{s}}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
Alternative 8
Error17.2
Cost196
\[\begin{array}{l} \mathbf{if}\;x \leq -0.0010000000474974513:\\ \;\;\;\;-\frac{s}{x}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
Alternative 9
Error20.7
Cost32
\[0.5 \]

Error

Reproduce?

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