Logistic distribution

Percentage Accurate: 99.5% → 99.5%
Time: 3.5s
Alternatives: 9
Speedup: N/A×

Specification

?
\[0 \leq s \land s \leq 1.0651631\]
\[\begin{array}{l} t_0 := e^{\frac{-\left|x\right|}{s}}\\ t_1 := 1 + t\_0\\ \frac{t\_0}{\left(s \cdot t\_1\right) \cdot t\_1} \end{array} \]
(FPCore (x s)
  :precision binary32
  :pre (and (<= 0.0 s) (<= s 1.0651631))
  (let* ((t_0 (exp (/ (- (fabs x)) s))) (t_1 (+ 1.0 t_0)))
  (/ t_0 (* (* s t_1) t_1))))
float code(float x, float s) {
	float t_0 = expf((-fabsf(x) / s));
	float t_1 = 1.0f + t_0;
	return t_0 / ((s * t_1) * t_1);
}
real(4) function code(x, s)
use fmin_fmax_functions
    real(4), intent (in) :: x
    real(4), intent (in) :: s
    real(4) :: t_0
    real(4) :: t_1
    t_0 = exp((-abs(x) / s))
    t_1 = 1.0e0 + t_0
    code = t_0 / ((s * t_1) * t_1)
end function
function code(x, s)
	t_0 = exp(Float32(Float32(-abs(x)) / s))
	t_1 = Float32(Float32(1.0) + t_0)
	return Float32(t_0 / Float32(Float32(s * t_1) * t_1))
end
function tmp = code(x, s)
	t_0 = exp((-abs(x) / s));
	t_1 = single(1.0) + t_0;
	tmp = t_0 / ((s * t_1) * t_1);
end
\begin{array}{l}
t_0 := e^{\frac{-\left|x\right|}{s}}\\
t_1 := 1 + t\_0\\
\frac{t\_0}{\left(s \cdot t\_1\right) \cdot t\_1}
\end{array}

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 9 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.5% accurate, 1.0× speedup?

\[0 \leq s \land s \leq 1.0651631\]
\[\begin{array}{l} t_0 := e^{\frac{-\left|x\right|}{s}}\\ t_1 := 1 + t\_0\\ \frac{t\_0}{\left(s \cdot t\_1\right) \cdot t\_1} \end{array} \]
(FPCore (x s)
  :precision binary32
  :pre (and (<= 0.0 s) (<= s 1.0651631))
  (let* ((t_0 (exp (/ (- (fabs x)) s))) (t_1 (+ 1.0 t_0)))
  (/ t_0 (* (* s t_1) t_1))))
float code(float x, float s) {
	float t_0 = expf((-fabsf(x) / s));
	float t_1 = 1.0f + t_0;
	return t_0 / ((s * t_1) * t_1);
}
real(4) function code(x, s)
use fmin_fmax_functions
    real(4), intent (in) :: x
    real(4), intent (in) :: s
    real(4) :: t_0
    real(4) :: t_1
    t_0 = exp((-abs(x) / s))
    t_1 = 1.0e0 + t_0
    code = t_0 / ((s * t_1) * t_1)
end function
function code(x, s)
	t_0 = exp(Float32(Float32(-abs(x)) / s))
	t_1 = Float32(Float32(1.0) + t_0)
	return Float32(t_0 / Float32(Float32(s * t_1) * t_1))
end
function tmp = code(x, s)
	t_0 = exp((-abs(x) / s));
	t_1 = single(1.0) + t_0;
	tmp = t_0 / ((s * t_1) * t_1);
end
\begin{array}{l}
t_0 := e^{\frac{-\left|x\right|}{s}}\\
t_1 := 1 + t\_0\\
\frac{t\_0}{\left(s \cdot t\_1\right) \cdot t\_1}
\end{array}

Alternative 1: 99.5% accurate, 0.9× speedup?

\[0 \leq s \land s \leq 1.0651631\]
\[\begin{array}{l} t_0 := \frac{1}{e^{\frac{\left|x\right|}{s}}}\\ t_1 := 1 + t\_0\\ \frac{t\_0}{\left(s \cdot t\_1\right) \cdot t\_1} \end{array} \]
(FPCore (x s)
  :precision binary32
  :pre (and (<= 0.0 s) (<= s 1.0651631))
  (let* ((t_0 (/ 1.0 (exp (/ (fabs x) s)))) (t_1 (+ 1.0 t_0)))
  (/ t_0 (* (* s t_1) t_1))))
float code(float x, float s) {
	float t_0 = 1.0f / expf((fabsf(x) / s));
	float t_1 = 1.0f + t_0;
	return t_0 / ((s * t_1) * t_1);
}
real(4) function code(x, s)
use fmin_fmax_functions
    real(4), intent (in) :: x
    real(4), intent (in) :: s
    real(4) :: t_0
    real(4) :: t_1
    t_0 = 1.0e0 / exp((abs(x) / s))
    t_1 = 1.0e0 + t_0
    code = t_0 / ((s * t_1) * t_1)
end function
function code(x, s)
	t_0 = Float32(Float32(1.0) / exp(Float32(abs(x) / s)))
	t_1 = Float32(Float32(1.0) + t_0)
	return Float32(t_0 / Float32(Float32(s * t_1) * t_1))
end
function tmp = code(x, s)
	t_0 = single(1.0) / exp((abs(x) / s));
	t_1 = single(1.0) + t_0;
	tmp = t_0 / ((s * t_1) * t_1);
end
\begin{array}{l}
t_0 := \frac{1}{e^{\frac{\left|x\right|}{s}}}\\
t_1 := 1 + t\_0\\
\frac{t\_0}{\left(s \cdot t\_1\right) \cdot t\_1}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\frac{e^{\frac{-\left|x\right|}{s}}}{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)} \]
  2. Step-by-step derivation
    1. Applied rewrites99.5%

      \[\leadsto \frac{\frac{1}{e^{\frac{\left|x\right|}{s}}}}{\left(s \cdot \left(1 + \frac{1}{e^{\frac{\left|x\right|}{s}}}\right)\right) \cdot \left(1 + \frac{1}{e^{\frac{\left|x\right|}{s}}}\right)} \]
    2. Add Preprocessing

    Alternative 2: 99.5% accurate, 1.3× speedup?

    \[0 \leq s \land s \leq 1.0651631\]
    \[\begin{array}{l} t_0 := e^{\frac{\left|x\right|}{s}}\\ \frac{1}{s \cdot \left(\left(1 + t\_0\right) \cdot \left(1 + \frac{1}{t\_0}\right)\right)} \end{array} \]
    (FPCore (x s)
      :precision binary32
      :pre (and (<= 0.0 s) (<= s 1.0651631))
      (let* ((t_0 (exp (/ (fabs x) s))))
      (/ 1.0 (* s (* (+ 1.0 t_0) (+ 1.0 (/ 1.0 t_0)))))))
    float code(float x, float s) {
    	float t_0 = expf((fabsf(x) / s));
    	return 1.0f / (s * ((1.0f + t_0) * (1.0f + (1.0f / t_0))));
    }
    
    real(4) function code(x, s)
    use fmin_fmax_functions
        real(4), intent (in) :: x
        real(4), intent (in) :: s
        real(4) :: t_0
        t_0 = exp((abs(x) / s))
        code = 1.0e0 / (s * ((1.0e0 + t_0) * (1.0e0 + (1.0e0 / t_0))))
    end function
    
    function code(x, s)
    	t_0 = exp(Float32(abs(x) / s))
    	return Float32(Float32(1.0) / Float32(s * Float32(Float32(Float32(1.0) + t_0) * Float32(Float32(1.0) + Float32(Float32(1.0) / t_0)))))
    end
    
    function tmp = code(x, s)
    	t_0 = exp((abs(x) / s));
    	tmp = single(1.0) / (s * ((single(1.0) + t_0) * (single(1.0) + (single(1.0) / t_0))));
    end
    
    \begin{array}{l}
    t_0 := e^{\frac{\left|x\right|}{s}}\\
    \frac{1}{s \cdot \left(\left(1 + t\_0\right) \cdot \left(1 + \frac{1}{t\_0}\right)\right)}
    \end{array}
    
    Derivation
    1. Initial program 99.5%

      \[\frac{e^{\frac{-\left|x\right|}{s}}}{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)} \]
    2. Step-by-step derivation
      1. Applied rewrites99.5%

        \[\leadsto \frac{\frac{1}{e^{\frac{\left|x\right|}{s}}}}{\left(s \cdot \left(1 + \frac{1}{e^{\frac{\left|x\right|}{s}}}\right)\right) \cdot \left(1 + \frac{1}{e^{\frac{\left|x\right|}{s}}}\right)} \]
      2. Taylor expanded in s around inf

        \[\leadsto \frac{\frac{1}{1 + \frac{\left|x\right|}{s}}}{\left(s \cdot \left(1 + \frac{1}{1 + \frac{\left|x\right|}{s}}\right)\right) \cdot \left(1 + \frac{1}{1 + \frac{\left|x\right|}{s}}\right)} \]
      3. Step-by-step derivation
        1. Applied rewrites53.3%

          \[\leadsto \frac{\frac{1}{1 + \frac{\left|x\right|}{s}}}{\left(s \cdot \left(1 + \frac{1}{1 + \frac{\left|x\right|}{s}}\right)\right) \cdot \left(1 + \frac{1}{1 + \frac{\left|x\right|}{s}}\right)} \]
        2. Step-by-step derivation
          1. Applied rewrites35.6%

            \[\leadsto \frac{\frac{1}{\frac{s + \left|x\right|}{s} \cdot \left(\frac{s}{\frac{s + \left|x\right|}{s}} + s\right)}}{\frac{s + \left|x\right|}{s} - -1} \cdot \frac{s + \left|x\right|}{s} \]
          2. Taylor expanded in s around 0

            \[\leadsto \frac{1}{s \cdot \left(\left(1 + e^{\frac{\left|x\right|}{s}}\right) \cdot \left(1 + \frac{1}{e^{\frac{\left|x\right|}{s}}}\right)\right)} \]
          3. Step-by-step derivation
            1. Applied rewrites99.5%

              \[\leadsto \frac{1}{s \cdot \left(\left(1 + e^{\frac{\left|x\right|}{s}}\right) \cdot \left(1 + \frac{1}{e^{\frac{\left|x\right|}{s}}}\right)\right)} \]
            2. Add Preprocessing

            Alternative 3: 99.5% accurate, 1.4× speedup?

            \[0 \leq s \land s \leq 1.0651631\]
            \[\begin{array}{l} t_0 := e^{\frac{\left|x\right|}{s}}\\ \frac{1}{\left(1 + t\_0\right) \cdot \left(s + \frac{s}{t\_0}\right)} \end{array} \]
            (FPCore (x s)
              :precision binary32
              :pre (and (<= 0.0 s) (<= s 1.0651631))
              (let* ((t_0 (exp (/ (fabs x) s))))
              (/ 1.0 (* (+ 1.0 t_0) (+ s (/ s t_0))))))
            float code(float x, float s) {
            	float t_0 = expf((fabsf(x) / s));
            	return 1.0f / ((1.0f + t_0) * (s + (s / t_0)));
            }
            
            real(4) function code(x, s)
            use fmin_fmax_functions
                real(4), intent (in) :: x
                real(4), intent (in) :: s
                real(4) :: t_0
                t_0 = exp((abs(x) / s))
                code = 1.0e0 / ((1.0e0 + t_0) * (s + (s / t_0)))
            end function
            
            function code(x, s)
            	t_0 = exp(Float32(abs(x) / s))
            	return Float32(Float32(1.0) / Float32(Float32(Float32(1.0) + t_0) * Float32(s + Float32(s / t_0))))
            end
            
            function tmp = code(x, s)
            	t_0 = exp((abs(x) / s));
            	tmp = single(1.0) / ((single(1.0) + t_0) * (s + (s / t_0)));
            end
            
            \begin{array}{l}
            t_0 := e^{\frac{\left|x\right|}{s}}\\
            \frac{1}{\left(1 + t\_0\right) \cdot \left(s + \frac{s}{t\_0}\right)}
            \end{array}
            
            Derivation
            1. Initial program 99.5%

              \[\frac{e^{\frac{-\left|x\right|}{s}}}{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)} \]
            2. Step-by-step derivation
              1. Applied rewrites99.5%

                \[\leadsto \frac{\frac{1}{e^{\frac{\left|x\right|}{s}}}}{\left(s \cdot \left(1 + \frac{1}{e^{\frac{\left|x\right|}{s}}}\right)\right) \cdot \left(1 + \frac{1}{e^{\frac{\left|x\right|}{s}}}\right)} \]
              2. Taylor expanded in s around inf

                \[\leadsto \frac{\frac{1}{1 + \frac{\left|x\right|}{s}}}{\left(s \cdot \left(1 + \frac{1}{1 + \frac{\left|x\right|}{s}}\right)\right) \cdot \left(1 + \frac{1}{1 + \frac{\left|x\right|}{s}}\right)} \]
              3. Step-by-step derivation
                1. Applied rewrites53.3%

                  \[\leadsto \frac{\frac{1}{1 + \frac{\left|x\right|}{s}}}{\left(s \cdot \left(1 + \frac{1}{1 + \frac{\left|x\right|}{s}}\right)\right) \cdot \left(1 + \frac{1}{1 + \frac{\left|x\right|}{s}}\right)} \]
                2. Step-by-step derivation
                  1. Applied rewrites35.6%

                    \[\leadsto \frac{\frac{1}{\frac{s + \left|x\right|}{s} \cdot \left(\frac{s}{\frac{s + \left|x\right|}{s}} + s\right)}}{\frac{s + \left|x\right|}{s} - -1} \cdot \frac{s + \left|x\right|}{s} \]
                  2. Taylor expanded in x around 0

                    \[\leadsto \frac{1}{\left(1 + e^{\frac{\left|x\right|}{s}}\right) \cdot \left(s + \frac{s}{e^{\frac{\left|x\right|}{s}}}\right)} \]
                  3. Step-by-step derivation
                    1. Applied rewrites99.5%

                      \[\leadsto \frac{1}{\left(1 + e^{\frac{\left|x\right|}{s}}\right) \cdot \left(s + \frac{s}{e^{\frac{\left|x\right|}{s}}}\right)} \]
                    2. Add Preprocessing

                    Alternative 4: 96.0% accurate, 1.4× speedup?

                    \[0 \leq s \land s \leq 1.0651631\]
                    \[\begin{array}{l} t_0 := 2 + -1 \cdot \frac{\left|x\right|}{s}\\ \frac{e^{\frac{-\left|x\right|}{s}}}{\left(s \cdot t\_0\right) \cdot t\_0} \end{array} \]
                    (FPCore (x s)
                      :precision binary32
                      :pre (and (<= 0.0 s) (<= s 1.0651631))
                      (let* ((t_0 (+ 2.0 (* -1.0 (/ (fabs x) s)))))
                      (/ (exp (/ (- (fabs x)) s)) (* (* s t_0) t_0))))
                    float code(float x, float s) {
                    	float t_0 = 2.0f + (-1.0f * (fabsf(x) / s));
                    	return expf((-fabsf(x) / s)) / ((s * t_0) * t_0);
                    }
                    
                    real(4) function code(x, s)
                    use fmin_fmax_functions
                        real(4), intent (in) :: x
                        real(4), intent (in) :: s
                        real(4) :: t_0
                        t_0 = 2.0e0 + ((-1.0e0) * (abs(x) / s))
                        code = exp((-abs(x) / s)) / ((s * t_0) * t_0)
                    end function
                    
                    function code(x, s)
                    	t_0 = Float32(Float32(2.0) + Float32(Float32(-1.0) * Float32(abs(x) / s)))
                    	return Float32(exp(Float32(Float32(-abs(x)) / s)) / Float32(Float32(s * t_0) * t_0))
                    end
                    
                    function tmp = code(x, s)
                    	t_0 = single(2.0) + (single(-1.0) * (abs(x) / s));
                    	tmp = exp((-abs(x) / s)) / ((s * t_0) * t_0);
                    end
                    
                    \begin{array}{l}
                    t_0 := 2 + -1 \cdot \frac{\left|x\right|}{s}\\
                    \frac{e^{\frac{-\left|x\right|}{s}}}{\left(s \cdot t\_0\right) \cdot t\_0}
                    \end{array}
                    
                    Derivation
                    1. Initial program 99.5%

                      \[\frac{e^{\frac{-\left|x\right|}{s}}}{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)} \]
                    2. Taylor expanded in s around inf

                      \[\leadsto \frac{e^{\frac{-\left|x\right|}{s}}}{\left(s \cdot \left(2 + -1 \cdot \frac{\left|x\right|}{s}\right)\right) \cdot \left(2 + -1 \cdot \frac{\left|x\right|}{s}\right)} \]
                    3. Step-by-step derivation
                      1. Applied rewrites96.0%

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

                      Alternative 5: 94.9% accurate, 1.4× speedup?

                      \[0 \leq s \land s \leq 1.0651631\]
                      \[\begin{array}{l} t_0 := e^{\frac{-\left|x\right|}{s}}\\ \frac{t\_0}{\left(s + s\right) \cdot \left(1 + t\_0\right)} \end{array} \]
                      (FPCore (x s)
                        :precision binary32
                        :pre (and (<= 0.0 s) (<= s 1.0651631))
                        (let* ((t_0 (exp (/ (- (fabs x)) s))))
                        (/ t_0 (* (+ s s) (+ 1.0 t_0)))))
                      float code(float x, float s) {
                      	float t_0 = expf((-fabsf(x) / s));
                      	return t_0 / ((s + s) * (1.0f + t_0));
                      }
                      
                      real(4) function code(x, s)
                      use fmin_fmax_functions
                          real(4), intent (in) :: x
                          real(4), intent (in) :: s
                          real(4) :: t_0
                          t_0 = exp((-abs(x) / s))
                          code = t_0 / ((s + s) * (1.0e0 + t_0))
                      end function
                      
                      function code(x, s)
                      	t_0 = exp(Float32(Float32(-abs(x)) / s))
                      	return Float32(t_0 / Float32(Float32(s + s) * Float32(Float32(1.0) + t_0)))
                      end
                      
                      function tmp = code(x, s)
                      	t_0 = exp((-abs(x) / s));
                      	tmp = t_0 / ((s + s) * (single(1.0) + t_0));
                      end
                      
                      \begin{array}{l}
                      t_0 := e^{\frac{-\left|x\right|}{s}}\\
                      \frac{t\_0}{\left(s + s\right) \cdot \left(1 + t\_0\right)}
                      \end{array}
                      
                      Derivation
                      1. Initial program 99.5%

                        \[\frac{e^{\frac{-\left|x\right|}{s}}}{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)} \]
                      2. Taylor expanded in s around inf

                        \[\leadsto \frac{e^{\frac{-\left|x\right|}{s}}}{\left(2 \cdot s\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)} \]
                      3. Step-by-step derivation
                        1. Applied rewrites94.9%

                          \[\leadsto \frac{e^{\frac{-\left|x\right|}{s}}}{\left(2 \cdot s\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)} \]
                        2. Applied rewrites94.9%

                          \[\leadsto \frac{e^{\frac{-\left|x\right|}{s}}}{\left(s + s\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)} \]
                        3. Add Preprocessing

                        Alternative 6: 94.6% accurate, 2.2× speedup?

                        \[0 \leq s \land s \leq 1.0651631\]
                        \[\frac{0.25}{{e}^{\left(\frac{\left|x\right|}{s}\right)} \cdot s} \]
                        (FPCore (x s)
                          :precision binary32
                          :pre (and (<= 0.0 s) (<= s 1.0651631))
                          (/ 0.25 (* (pow E (/ (fabs x) s)) s)))
                        float code(float x, float s) {
                        	return 0.25f / (powf(((float) M_E), (fabsf(x) / s)) * s);
                        }
                        
                        function code(x, s)
                        	return Float32(Float32(0.25) / Float32((Float32(exp(1)) ^ Float32(abs(x) / s)) * s))
                        end
                        
                        function tmp = code(x, s)
                        	tmp = single(0.25) / ((single(2.71828182845904523536) ^ (abs(x) / s)) * s);
                        end
                        
                        \frac{0.25}{{e}^{\left(\frac{\left|x\right|}{s}\right)} \cdot s}
                        
                        Derivation
                        1. Initial program 99.5%

                          \[\frac{e^{\frac{-\left|x\right|}{s}}}{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)} \]
                        2. Step-by-step derivation
                          1. Applied rewrites99.5%

                            \[\leadsto \frac{e^{\frac{-\left|x\right|}{s}}}{{\left(1 + e^{\frac{-\left|x\right|}{s}}\right)}^{2} \cdot s} \]
                          2. Step-by-step derivation
                            1. Applied rewrites99.5%

                              \[\leadsto \frac{{\left(-1 - e^{\frac{-\left|x\right|}{s}}\right)}^{-2}}{e^{\frac{\left|x\right|}{s}} \cdot s} \]
                            2. Taylor expanded in s around inf

                              \[\leadsto \frac{\frac{1}{4}}{e^{\frac{\left|x\right|}{s}} \cdot s} \]
                            3. Step-by-step derivation
                              1. Applied rewrites94.6%

                                \[\leadsto \frac{0.25}{e^{\frac{\left|x\right|}{s}} \cdot s} \]
                              2. Step-by-step derivation
                                1. Applied rewrites94.6%

                                  \[\leadsto \frac{0.25}{{e}^{\left(\frac{\left|x\right|}{s}\right)} \cdot s} \]
                                2. Add Preprocessing

                                Alternative 7: 94.6% accurate, 2.8× speedup?

                                \[0 \leq s \land s \leq 1.0651631\]
                                \[\frac{0.25}{e^{\frac{\left|x\right|}{s}} \cdot s} \]
                                (FPCore (x s)
                                  :precision binary32
                                  :pre (and (<= 0.0 s) (<= s 1.0651631))
                                  (/ 0.25 (* (exp (/ (fabs x) s)) s)))
                                float code(float x, float s) {
                                	return 0.25f / (expf((fabsf(x) / s)) * s);
                                }
                                
                                real(4) function code(x, s)
                                use fmin_fmax_functions
                                    real(4), intent (in) :: x
                                    real(4), intent (in) :: s
                                    code = 0.25e0 / (exp((abs(x) / s)) * s)
                                end function
                                
                                function code(x, s)
                                	return Float32(Float32(0.25) / Float32(exp(Float32(abs(x) / s)) * s))
                                end
                                
                                function tmp = code(x, s)
                                	tmp = single(0.25) / (exp((abs(x) / s)) * s);
                                end
                                
                                \frac{0.25}{e^{\frac{\left|x\right|}{s}} \cdot s}
                                
                                Derivation
                                1. Initial program 99.5%

                                  \[\frac{e^{\frac{-\left|x\right|}{s}}}{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)} \]
                                2. Step-by-step derivation
                                  1. Applied rewrites99.5%

                                    \[\leadsto \frac{e^{\frac{-\left|x\right|}{s}}}{{\left(1 + e^{\frac{-\left|x\right|}{s}}\right)}^{2} \cdot s} \]
                                  2. Step-by-step derivation
                                    1. Applied rewrites99.5%

                                      \[\leadsto \frac{{\left(-1 - e^{\frac{-\left|x\right|}{s}}\right)}^{-2}}{e^{\frac{\left|x\right|}{s}} \cdot s} \]
                                    2. Taylor expanded in s around inf

                                      \[\leadsto \frac{\frac{1}{4}}{e^{\frac{\left|x\right|}{s}} \cdot s} \]
                                    3. Step-by-step derivation
                                      1. Applied rewrites94.6%

                                        \[\leadsto \frac{0.25}{e^{\frac{\left|x\right|}{s}} \cdot s} \]
                                      2. Add Preprocessing

                                      Alternative 8: 51.2% accurate, 4.4× speedup?

                                      \[0 \leq s \land s \leq 1.0651631\]
                                      \[\frac{0.25}{\left(1 + \frac{\left|x\right|}{s}\right) \cdot s} \]
                                      (FPCore (x s)
                                        :precision binary32
                                        :pre (and (<= 0.0 s) (<= s 1.0651631))
                                        (/ 0.25 (* (+ 1.0 (/ (fabs x) s)) s)))
                                      float code(float x, float s) {
                                      	return 0.25f / ((1.0f + (fabsf(x) / s)) * s);
                                      }
                                      
                                      real(4) function code(x, s)
                                      use fmin_fmax_functions
                                          real(4), intent (in) :: x
                                          real(4), intent (in) :: s
                                          code = 0.25e0 / ((1.0e0 + (abs(x) / s)) * s)
                                      end function
                                      
                                      function code(x, s)
                                      	return Float32(Float32(0.25) / Float32(Float32(Float32(1.0) + Float32(abs(x) / s)) * s))
                                      end
                                      
                                      function tmp = code(x, s)
                                      	tmp = single(0.25) / ((single(1.0) + (abs(x) / s)) * s);
                                      end
                                      
                                      \frac{0.25}{\left(1 + \frac{\left|x\right|}{s}\right) \cdot s}
                                      
                                      Derivation
                                      1. Initial program 99.5%

                                        \[\frac{e^{\frac{-\left|x\right|}{s}}}{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)} \]
                                      2. Step-by-step derivation
                                        1. Applied rewrites99.5%

                                          \[\leadsto \frac{e^{\frac{-\left|x\right|}{s}}}{{\left(1 + e^{\frac{-\left|x\right|}{s}}\right)}^{2} \cdot s} \]
                                        2. Step-by-step derivation
                                          1. Applied rewrites99.5%

                                            \[\leadsto \frac{{\left(-1 - e^{\frac{-\left|x\right|}{s}}\right)}^{-2}}{e^{\frac{\left|x\right|}{s}} \cdot s} \]
                                          2. Taylor expanded in s around inf

                                            \[\leadsto \frac{\frac{1}{4}}{e^{\frac{\left|x\right|}{s}} \cdot s} \]
                                          3. Step-by-step derivation
                                            1. Applied rewrites94.6%

                                              \[\leadsto \frac{0.25}{e^{\frac{\left|x\right|}{s}} \cdot s} \]
                                            2. Taylor expanded in s around inf

                                              \[\leadsto \frac{0.25}{\left(1 + \frac{\left|x\right|}{s}\right) \cdot s} \]
                                            3. Step-by-step derivation
                                              1. Applied rewrites51.2%

                                                \[\leadsto \frac{0.25}{\left(1 + \frac{\left|x\right|}{s}\right) \cdot s} \]
                                              2. Add Preprocessing

                                              Alternative 9: 27.5% accurate, 13.8× speedup?

                                              \[0 \leq s \land s \leq 1.0651631\]
                                              \[\frac{0.25}{s} \]
                                              (FPCore (x s)
                                                :precision binary32
                                                :pre (and (<= 0.0 s) (<= s 1.0651631))
                                                (/ 0.25 s))
                                              float code(float x, float s) {
                                              	return 0.25f / s;
                                              }
                                              
                                              real(4) function code(x, s)
                                              use fmin_fmax_functions
                                                  real(4), intent (in) :: x
                                                  real(4), intent (in) :: s
                                                  code = 0.25e0 / s
                                              end function
                                              
                                              function code(x, s)
                                              	return Float32(Float32(0.25) / s)
                                              end
                                              
                                              function tmp = code(x, s)
                                              	tmp = single(0.25) / s;
                                              end
                                              
                                              \frac{0.25}{s}
                                              
                                              Derivation
                                              1. Initial program 99.5%

                                                \[\frac{e^{\frac{-\left|x\right|}{s}}}{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)} \]
                                              2. Taylor expanded in s around inf

                                                \[\leadsto \frac{\frac{1}{4}}{s} \]
                                              3. Step-by-step derivation
                                                1. Applied rewrites27.5%

                                                  \[\leadsto \frac{0.25}{s} \]
                                                2. Add Preprocessing

                                                Reproduce

                                                ?
                                                herbie shell --seed 2026086 
                                                (FPCore (x s)
                                                  :name "Logistic distribution"
                                                  :precision binary32
                                                  :pre (and (<= 0.0 s) (<= s 1.0651631))
                                                  (/ (exp (/ (- (fabs x)) s)) (* (* s (+ 1.0 (exp (/ (- (fabs x)) s)))) (+ 1.0 (exp (/ (- (fabs x)) s))))))