Logistic distribution

Percentage Accurate: 99.5% → 99.3%
Time: 20.1s
Alternatives: 17
Speedup: 2.9×

Specification

?
\[0 \leq s \land s \leq 1.0651631\]
\[\begin{array}{l} \\ \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} \end{array} \]
(FPCore (x s)
 :precision binary32
 (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)
    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}

\\
\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}
\end{array}

Sampling outcomes in binary32 precision:

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 17 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?

\[\begin{array}{l} \\ \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} \end{array} \]
(FPCore (x s)
 :precision binary32
 (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)
    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}

\\
\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}
\end{array}

Alternative 1: 99.3% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\frac{\left|x\right|}{s}}{4}\\ \frac{\frac{1}{{\left(e \cdot e^{0.6666666666666666}\right)}^{t\_0} \cdot e^{t\_0 \cdot 0.3333333333333333}} \cdot \frac{\frac{1}{s}}{{e}^{\left(\frac{\left|x\right|}{s \cdot 2}\right)}}}{{\left(1 + e^{\frac{\left|x\right|}{-s}}\right)}^{2}} \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (let* ((t_0 (/ (/ (fabs x) s) 4.0)))
   (/
    (*
     (/
      1.0
      (*
       (pow (* E (exp 0.6666666666666666)) t_0)
       (exp (* t_0 0.3333333333333333))))
     (/ (/ 1.0 s) (pow E (/ (fabs x) (* s 2.0)))))
    (pow (+ 1.0 (exp (/ (fabs x) (- s)))) 2.0))))
float code(float x, float s) {
	float t_0 = (fabsf(x) / s) / 4.0f;
	return ((1.0f / (powf((((float) M_E) * expf(0.6666666666666666f)), t_0) * expf((t_0 * 0.3333333333333333f)))) * ((1.0f / s) / powf(((float) M_E), (fabsf(x) / (s * 2.0f))))) / powf((1.0f + expf((fabsf(x) / -s))), 2.0f);
}
function code(x, s)
	t_0 = Float32(Float32(abs(x) / s) / Float32(4.0))
	return Float32(Float32(Float32(Float32(1.0) / Float32((Float32(Float32(exp(1)) * exp(Float32(0.6666666666666666))) ^ t_0) * exp(Float32(t_0 * Float32(0.3333333333333333))))) * Float32(Float32(Float32(1.0) / s) / (Float32(exp(1)) ^ Float32(abs(x) / Float32(s * Float32(2.0)))))) / (Float32(Float32(1.0) + exp(Float32(abs(x) / Float32(-s)))) ^ Float32(2.0)))
end
function tmp = code(x, s)
	t_0 = (abs(x) / s) / single(4.0);
	tmp = ((single(1.0) / (((single(2.71828182845904523536) * exp(single(0.6666666666666666))) ^ t_0) * exp((t_0 * single(0.3333333333333333))))) * ((single(1.0) / s) / (single(2.71828182845904523536) ^ (abs(x) / (s * single(2.0)))))) / ((single(1.0) + exp((abs(x) / -s))) ^ single(2.0));
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\frac{\left|x\right|}{s}}{4}\\
\frac{\frac{1}{{\left(e \cdot e^{0.6666666666666666}\right)}^{t\_0} \cdot e^{t\_0 \cdot 0.3333333333333333}} \cdot \frac{\frac{1}{s}}{{e}^{\left(\frac{\left|x\right|}{s \cdot 2}\right)}}}{{\left(1 + e^{\frac{\left|x\right|}{-s}}\right)}^{2}}
\end{array}
\end{array}
Derivation
  1. Initial program 99.1%

    \[\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. Add Preprocessing
  3. Step-by-step derivation
    1. associate-*l*N/A

      \[\leadsto \frac{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}{s \cdot \color{blue}{\left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)}} \]
    2. associate-/r*N/A

      \[\leadsto \frac{\frac{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}{s}}{\color{blue}{\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)}} \]
    3. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}{s}\right), \color{blue}{\left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)}\right) \]
    4. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right), s\right), \left(\color{blue}{\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    5. exp-lowering-exp.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\left(\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}\right)\right), s\right), \left(\left(\color{blue}{1} + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    6. distribute-frac-negN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\left(\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    7. distribute-neg-frac2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\left(\frac{\left|x\right|}{\mathsf{neg}\left(s\right)}\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    8. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\left(\left|x\right|\right), \left(\mathsf{neg}\left(s\right)\right)\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    9. fabs-lowering-fabs.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \left(\mathsf{neg}\left(s\right)\right)\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    10. neg-lowering-neg.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    11. pow2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), s\right), \left({\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)}^{\color{blue}{2}}\right)\right) \]
    12. pow-lowering-pow.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), s\right), \mathsf{pow.f32}\left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right), \color{blue}{2}\right)\right) \]
  4. Applied egg-rr99.1%

    \[\leadsto \color{blue}{\frac{\frac{e^{\frac{\left|x\right|}{-s}}}{s}}{{\left(e^{\frac{\left|x\right|}{-s}} + 1\right)}^{2}}} \]
  5. Step-by-step derivation
    1. div-invN/A

      \[\leadsto \mathsf{/.f32}\left(\left(e^{\frac{\left|x\right|}{\mathsf{neg}\left(s\right)}} \cdot \frac{1}{s}\right), \mathsf{pow.f32}\left(\color{blue}{\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right)}, 2\right)\right) \]
    2. distribute-frac-neg2N/A

      \[\leadsto \mathsf{/.f32}\left(\left(e^{\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)} \cdot \frac{1}{s}\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\color{blue}{\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)}\right), 1\right), 2\right)\right) \]
    3. exp-negN/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{1}{e^{\frac{\left|x\right|}{s}}} \cdot \frac{1}{s}\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\color{blue}{\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right)}, 1\right), 2\right)\right) \]
    4. associate-*l/N/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{1 \cdot \frac{1}{s}}{e^{\frac{\left|x\right|}{s}}}\right), \mathsf{pow.f32}\left(\color{blue}{\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right)}, 2\right)\right) \]
    5. *-lft-identityN/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{1 \cdot \frac{1}{s}}{e^{1 \cdot \frac{\left|x\right|}{s}}}\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    6. pow-expN/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{1 \cdot \frac{1}{s}}{{\left(e^{1}\right)}^{\left(\frac{\left|x\right|}{s}\right)}}\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), \color{blue}{1}\right), 2\right)\right) \]
    7. sqr-powN/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{1 \cdot \frac{1}{s}}{{\left(e^{1}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{2}\right)} \cdot {\left(e^{1}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{2}\right)}}\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), \color{blue}{1}\right), 2\right)\right) \]
    8. times-fracN/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{1}{{\left(e^{1}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{2}\right)}} \cdot \frac{\frac{1}{s}}{{\left(e^{1}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{2}\right)}}\right), \mathsf{pow.f32}\left(\color{blue}{\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right)}, 2\right)\right) \]
    9. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\left(\frac{1}{{\left(e^{1}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{2}\right)}}\right), \left(\frac{\frac{1}{s}}{{\left(e^{1}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{2}\right)}}\right)\right), \mathsf{pow.f32}\left(\color{blue}{\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right)}, 2\right)\right) \]
  6. Applied egg-rr99.4%

    \[\leadsto \frac{\color{blue}{\frac{1}{{e}^{\left(\frac{\left|x\right|}{s \cdot 2}\right)}} \cdot \frac{\frac{1}{s}}{{e}^{\left(\frac{\left|x\right|}{s \cdot 2}\right)}}}}{{\left(e^{\frac{\left|x\right|}{-s}} + 1\right)}^{2}} \]
  7. Step-by-step derivation
    1. sqr-powN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(1, \left({\mathsf{E}\left(\right)}^{\left(\frac{\frac{\left|x\right|}{s \cdot 2}}{2}\right)} \cdot {\mathsf{E}\left(\right)}^{\left(\frac{\frac{\left|x\right|}{s \cdot 2}}{2}\right)}\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    2. pow-prod-downN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(1, \left({\left(\mathsf{E}\left(\right) \cdot \mathsf{E}\left(\right)\right)}^{\left(\frac{\frac{\left|x\right|}{s \cdot 2}}{2}\right)}\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    3. add-cube-cbrtN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(1, \left({\left(\mathsf{E}\left(\right) \cdot \left(\left(\sqrt[3]{\mathsf{E}\left(\right)} \cdot \sqrt[3]{\mathsf{E}\left(\right)}\right) \cdot \sqrt[3]{\mathsf{E}\left(\right)}\right)\right)}^{\left(\frac{\frac{\left|x\right|}{s \cdot 2}}{2}\right)}\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    4. associate-*r*N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(1, \left({\left(\left(\mathsf{E}\left(\right) \cdot \left(\sqrt[3]{\mathsf{E}\left(\right)} \cdot \sqrt[3]{\mathsf{E}\left(\right)}\right)\right) \cdot \sqrt[3]{\mathsf{E}\left(\right)}\right)}^{\left(\frac{\frac{\left|x\right|}{s \cdot 2}}{2}\right)}\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    5. unpow-prod-downN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(1, \left({\left(\mathsf{E}\left(\right) \cdot \left(\sqrt[3]{\mathsf{E}\left(\right)} \cdot \sqrt[3]{\mathsf{E}\left(\right)}\right)\right)}^{\left(\frac{\frac{\left|x\right|}{s \cdot 2}}{2}\right)} \cdot {\left(\sqrt[3]{\mathsf{E}\left(\right)}\right)}^{\left(\frac{\frac{\left|x\right|}{s \cdot 2}}{2}\right)}\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    6. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(1, \mathsf{*.f32}\left(\left({\left(\mathsf{E}\left(\right) \cdot \left(\sqrt[3]{\mathsf{E}\left(\right)} \cdot \sqrt[3]{\mathsf{E}\left(\right)}\right)\right)}^{\left(\frac{\frac{\left|x\right|}{s \cdot 2}}{2}\right)}\right), \left({\left(\sqrt[3]{\mathsf{E}\left(\right)}\right)}^{\left(\frac{\frac{\left|x\right|}{s \cdot 2}}{2}\right)}\right)\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
  8. Applied egg-rr99.4%

    \[\leadsto \frac{\frac{1}{\color{blue}{{\left(e \cdot e^{0.6666666666666666}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{4}\right)} \cdot e^{0.3333333333333333 \cdot \frac{\frac{\left|x\right|}{s}}{4}}}} \cdot \frac{\frac{1}{s}}{{e}^{\left(\frac{\left|x\right|}{s \cdot 2}\right)}}}{{\left(e^{\frac{\left|x\right|}{-s}} + 1\right)}^{2}} \]
  9. Final simplification99.4%

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

Alternative 2: 99.3% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \frac{\frac{\frac{1}{s}}{{e}^{\left(\frac{\left|x\right|}{s \cdot 2}\right)}} \cdot \frac{1}{{\left(e \cdot e^{0.6666666666666666}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{4}\right)} \cdot e^{\frac{\left|x\right| \cdot 0.08333333333333333}{s}}}}{{\left(1 + e^{\frac{\left|x\right|}{-s}}\right)}^{2}} \end{array} \]
(FPCore (x s)
 :precision binary32
 (/
  (*
   (/ (/ 1.0 s) (pow E (/ (fabs x) (* s 2.0))))
   (/
    1.0
    (*
     (pow (* E (exp 0.6666666666666666)) (/ (/ (fabs x) s) 4.0))
     (exp (/ (* (fabs x) 0.08333333333333333) s)))))
  (pow (+ 1.0 (exp (/ (fabs x) (- s)))) 2.0)))
float code(float x, float s) {
	return (((1.0f / s) / powf(((float) M_E), (fabsf(x) / (s * 2.0f)))) * (1.0f / (powf((((float) M_E) * expf(0.6666666666666666f)), ((fabsf(x) / s) / 4.0f)) * expf(((fabsf(x) * 0.08333333333333333f) / s))))) / powf((1.0f + expf((fabsf(x) / -s))), 2.0f);
}
function code(x, s)
	return Float32(Float32(Float32(Float32(Float32(1.0) / s) / (Float32(exp(1)) ^ Float32(abs(x) / Float32(s * Float32(2.0))))) * Float32(Float32(1.0) / Float32((Float32(Float32(exp(1)) * exp(Float32(0.6666666666666666))) ^ Float32(Float32(abs(x) / s) / Float32(4.0))) * exp(Float32(Float32(abs(x) * Float32(0.08333333333333333)) / s))))) / (Float32(Float32(1.0) + exp(Float32(abs(x) / Float32(-s)))) ^ Float32(2.0)))
end
function tmp = code(x, s)
	tmp = (((single(1.0) / s) / (single(2.71828182845904523536) ^ (abs(x) / (s * single(2.0))))) * (single(1.0) / (((single(2.71828182845904523536) * exp(single(0.6666666666666666))) ^ ((abs(x) / s) / single(4.0))) * exp(((abs(x) * single(0.08333333333333333)) / s))))) / ((single(1.0) + exp((abs(x) / -s))) ^ single(2.0));
end
\begin{array}{l}

\\
\frac{\frac{\frac{1}{s}}{{e}^{\left(\frac{\left|x\right|}{s \cdot 2}\right)}} \cdot \frac{1}{{\left(e \cdot e^{0.6666666666666666}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{4}\right)} \cdot e^{\frac{\left|x\right| \cdot 0.08333333333333333}{s}}}}{{\left(1 + e^{\frac{\left|x\right|}{-s}}\right)}^{2}}
\end{array}
Derivation
  1. Initial program 99.1%

    \[\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. Add Preprocessing
  3. Step-by-step derivation
    1. associate-*l*N/A

      \[\leadsto \frac{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}{s \cdot \color{blue}{\left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)}} \]
    2. associate-/r*N/A

      \[\leadsto \frac{\frac{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}{s}}{\color{blue}{\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)}} \]
    3. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}{s}\right), \color{blue}{\left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)}\right) \]
    4. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right), s\right), \left(\color{blue}{\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    5. exp-lowering-exp.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\left(\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}\right)\right), s\right), \left(\left(\color{blue}{1} + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    6. distribute-frac-negN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\left(\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    7. distribute-neg-frac2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\left(\frac{\left|x\right|}{\mathsf{neg}\left(s\right)}\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    8. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\left(\left|x\right|\right), \left(\mathsf{neg}\left(s\right)\right)\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    9. fabs-lowering-fabs.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \left(\mathsf{neg}\left(s\right)\right)\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    10. neg-lowering-neg.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    11. pow2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), s\right), \left({\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)}^{\color{blue}{2}}\right)\right) \]
    12. pow-lowering-pow.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), s\right), \mathsf{pow.f32}\left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right), \color{blue}{2}\right)\right) \]
  4. Applied egg-rr99.1%

    \[\leadsto \color{blue}{\frac{\frac{e^{\frac{\left|x\right|}{-s}}}{s}}{{\left(e^{\frac{\left|x\right|}{-s}} + 1\right)}^{2}}} \]
  5. Step-by-step derivation
    1. div-invN/A

      \[\leadsto \mathsf{/.f32}\left(\left(e^{\frac{\left|x\right|}{\mathsf{neg}\left(s\right)}} \cdot \frac{1}{s}\right), \mathsf{pow.f32}\left(\color{blue}{\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right)}, 2\right)\right) \]
    2. distribute-frac-neg2N/A

      \[\leadsto \mathsf{/.f32}\left(\left(e^{\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)} \cdot \frac{1}{s}\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\color{blue}{\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)}\right), 1\right), 2\right)\right) \]
    3. exp-negN/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{1}{e^{\frac{\left|x\right|}{s}}} \cdot \frac{1}{s}\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\color{blue}{\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right)}, 1\right), 2\right)\right) \]
    4. associate-*l/N/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{1 \cdot \frac{1}{s}}{e^{\frac{\left|x\right|}{s}}}\right), \mathsf{pow.f32}\left(\color{blue}{\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right)}, 2\right)\right) \]
    5. *-lft-identityN/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{1 \cdot \frac{1}{s}}{e^{1 \cdot \frac{\left|x\right|}{s}}}\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    6. pow-expN/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{1 \cdot \frac{1}{s}}{{\left(e^{1}\right)}^{\left(\frac{\left|x\right|}{s}\right)}}\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), \color{blue}{1}\right), 2\right)\right) \]
    7. sqr-powN/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{1 \cdot \frac{1}{s}}{{\left(e^{1}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{2}\right)} \cdot {\left(e^{1}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{2}\right)}}\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), \color{blue}{1}\right), 2\right)\right) \]
    8. times-fracN/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{1}{{\left(e^{1}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{2}\right)}} \cdot \frac{\frac{1}{s}}{{\left(e^{1}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{2}\right)}}\right), \mathsf{pow.f32}\left(\color{blue}{\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right)}, 2\right)\right) \]
    9. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\left(\frac{1}{{\left(e^{1}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{2}\right)}}\right), \left(\frac{\frac{1}{s}}{{\left(e^{1}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{2}\right)}}\right)\right), \mathsf{pow.f32}\left(\color{blue}{\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right)}, 2\right)\right) \]
  6. Applied egg-rr99.4%

    \[\leadsto \frac{\color{blue}{\frac{1}{{e}^{\left(\frac{\left|x\right|}{s \cdot 2}\right)}} \cdot \frac{\frac{1}{s}}{{e}^{\left(\frac{\left|x\right|}{s \cdot 2}\right)}}}}{{\left(e^{\frac{\left|x\right|}{-s}} + 1\right)}^{2}} \]
  7. Step-by-step derivation
    1. sqr-powN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(1, \left({\mathsf{E}\left(\right)}^{\left(\frac{\frac{\left|x\right|}{s \cdot 2}}{2}\right)} \cdot {\mathsf{E}\left(\right)}^{\left(\frac{\frac{\left|x\right|}{s \cdot 2}}{2}\right)}\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    2. pow-prod-downN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(1, \left({\left(\mathsf{E}\left(\right) \cdot \mathsf{E}\left(\right)\right)}^{\left(\frac{\frac{\left|x\right|}{s \cdot 2}}{2}\right)}\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    3. add-cube-cbrtN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(1, \left({\left(\mathsf{E}\left(\right) \cdot \left(\left(\sqrt[3]{\mathsf{E}\left(\right)} \cdot \sqrt[3]{\mathsf{E}\left(\right)}\right) \cdot \sqrt[3]{\mathsf{E}\left(\right)}\right)\right)}^{\left(\frac{\frac{\left|x\right|}{s \cdot 2}}{2}\right)}\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    4. associate-*r*N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(1, \left({\left(\left(\mathsf{E}\left(\right) \cdot \left(\sqrt[3]{\mathsf{E}\left(\right)} \cdot \sqrt[3]{\mathsf{E}\left(\right)}\right)\right) \cdot \sqrt[3]{\mathsf{E}\left(\right)}\right)}^{\left(\frac{\frac{\left|x\right|}{s \cdot 2}}{2}\right)}\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    5. unpow-prod-downN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(1, \left({\left(\mathsf{E}\left(\right) \cdot \left(\sqrt[3]{\mathsf{E}\left(\right)} \cdot \sqrt[3]{\mathsf{E}\left(\right)}\right)\right)}^{\left(\frac{\frac{\left|x\right|}{s \cdot 2}}{2}\right)} \cdot {\left(\sqrt[3]{\mathsf{E}\left(\right)}\right)}^{\left(\frac{\frac{\left|x\right|}{s \cdot 2}}{2}\right)}\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    6. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(1, \mathsf{*.f32}\left(\left({\left(\mathsf{E}\left(\right) \cdot \left(\sqrt[3]{\mathsf{E}\left(\right)} \cdot \sqrt[3]{\mathsf{E}\left(\right)}\right)\right)}^{\left(\frac{\frac{\left|x\right|}{s \cdot 2}}{2}\right)}\right), \left({\left(\sqrt[3]{\mathsf{E}\left(\right)}\right)}^{\left(\frac{\frac{\left|x\right|}{s \cdot 2}}{2}\right)}\right)\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
  8. Applied egg-rr99.4%

    \[\leadsto \frac{\frac{1}{\color{blue}{{\left(e \cdot e^{0.6666666666666666}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{4}\right)} \cdot e^{0.3333333333333333 \cdot \frac{\frac{\left|x\right|}{s}}{4}}}} \cdot \frac{\frac{1}{s}}{{e}^{\left(\frac{\left|x\right|}{s \cdot 2}\right)}}}{{\left(e^{\frac{\left|x\right|}{-s}} + 1\right)}^{2}} \]
  9. Taylor expanded in x around 0

    \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(1, \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{exp.f32}\left(\frac{2}{3}\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), s\right), 4\right)\right), \mathsf{exp.f32}\left(\color{blue}{\left(\frac{1}{12} \cdot \frac{\left|x\right|}{s}\right)}\right)\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
  10. Step-by-step derivation
    1. associate-*r/N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(1, \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{exp.f32}\left(\frac{2}{3}\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), s\right), 4\right)\right), \mathsf{exp.f32}\left(\left(\frac{\frac{1}{12} \cdot \left|x\right|}{s}\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    2. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(1, \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{exp.f32}\left(\frac{2}{3}\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), s\right), 4\right)\right), \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\left(\frac{1}{12} \cdot \left|x\right|\right), s\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    3. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(1, \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{exp.f32}\left(\frac{2}{3}\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), s\right), 4\right)\right), \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{12}, \left(\left|x\right|\right)\right), s\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    4. fabs-lowering-fabs.f3299.4%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(1, \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{exp.f32}\left(\frac{2}{3}\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), s\right), 4\right)\right), \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{12}, \mathsf{fabs.f32}\left(x\right)\right), s\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
  11. Simplified99.4%

    \[\leadsto \frac{\frac{1}{{\left(e \cdot e^{0.6666666666666666}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{4}\right)} \cdot e^{\color{blue}{\frac{0.08333333333333333 \cdot \left|x\right|}{s}}}} \cdot \frac{\frac{1}{s}}{{e}^{\left(\frac{\left|x\right|}{s \cdot 2}\right)}}}{{\left(e^{\frac{\left|x\right|}{-s}} + 1\right)}^{2}} \]
  12. Final simplification99.4%

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

Alternative 3: 99.4% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \frac{\frac{\frac{1}{s}}{{e}^{\left(\frac{\left|x\right|}{s \cdot 2}\right)}} \cdot {e}^{\left(\frac{\frac{\left|x\right|}{s}}{-2}\right)}}{{\left(1 + e^{\frac{\left|x\right|}{-s}}\right)}^{2}} \end{array} \]
(FPCore (x s)
 :precision binary32
 (/
  (*
   (/ (/ 1.0 s) (pow E (/ (fabs x) (* s 2.0))))
   (pow E (/ (/ (fabs x) s) -2.0)))
  (pow (+ 1.0 (exp (/ (fabs x) (- s)))) 2.0)))
float code(float x, float s) {
	return (((1.0f / s) / powf(((float) M_E), (fabsf(x) / (s * 2.0f)))) * powf(((float) M_E), ((fabsf(x) / s) / -2.0f))) / powf((1.0f + expf((fabsf(x) / -s))), 2.0f);
}
function code(x, s)
	return Float32(Float32(Float32(Float32(Float32(1.0) / s) / (Float32(exp(1)) ^ Float32(abs(x) / Float32(s * Float32(2.0))))) * (Float32(exp(1)) ^ Float32(Float32(abs(x) / s) / Float32(-2.0)))) / (Float32(Float32(1.0) + exp(Float32(abs(x) / Float32(-s)))) ^ Float32(2.0)))
end
function tmp = code(x, s)
	tmp = (((single(1.0) / s) / (single(2.71828182845904523536) ^ (abs(x) / (s * single(2.0))))) * (single(2.71828182845904523536) ^ ((abs(x) / s) / single(-2.0)))) / ((single(1.0) + exp((abs(x) / -s))) ^ single(2.0));
end
\begin{array}{l}

\\
\frac{\frac{\frac{1}{s}}{{e}^{\left(\frac{\left|x\right|}{s \cdot 2}\right)}} \cdot {e}^{\left(\frac{\frac{\left|x\right|}{s}}{-2}\right)}}{{\left(1 + e^{\frac{\left|x\right|}{-s}}\right)}^{2}}
\end{array}
Derivation
  1. Initial program 99.1%

    \[\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. Add Preprocessing
  3. Step-by-step derivation
    1. associate-*l*N/A

      \[\leadsto \frac{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}{s \cdot \color{blue}{\left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)}} \]
    2. associate-/r*N/A

      \[\leadsto \frac{\frac{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}{s}}{\color{blue}{\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)}} \]
    3. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}{s}\right), \color{blue}{\left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)}\right) \]
    4. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right), s\right), \left(\color{blue}{\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    5. exp-lowering-exp.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\left(\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}\right)\right), s\right), \left(\left(\color{blue}{1} + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    6. distribute-frac-negN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\left(\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    7. distribute-neg-frac2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\left(\frac{\left|x\right|}{\mathsf{neg}\left(s\right)}\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    8. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\left(\left|x\right|\right), \left(\mathsf{neg}\left(s\right)\right)\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    9. fabs-lowering-fabs.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \left(\mathsf{neg}\left(s\right)\right)\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    10. neg-lowering-neg.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    11. pow2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), s\right), \left({\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)}^{\color{blue}{2}}\right)\right) \]
    12. pow-lowering-pow.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), s\right), \mathsf{pow.f32}\left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right), \color{blue}{2}\right)\right) \]
  4. Applied egg-rr99.1%

    \[\leadsto \color{blue}{\frac{\frac{e^{\frac{\left|x\right|}{-s}}}{s}}{{\left(e^{\frac{\left|x\right|}{-s}} + 1\right)}^{2}}} \]
  5. Step-by-step derivation
    1. div-invN/A

      \[\leadsto \mathsf{/.f32}\left(\left(e^{\frac{\left|x\right|}{\mathsf{neg}\left(s\right)}} \cdot \frac{1}{s}\right), \mathsf{pow.f32}\left(\color{blue}{\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right)}, 2\right)\right) \]
    2. distribute-frac-neg2N/A

      \[\leadsto \mathsf{/.f32}\left(\left(e^{\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)} \cdot \frac{1}{s}\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\color{blue}{\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)}\right), 1\right), 2\right)\right) \]
    3. exp-negN/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{1}{e^{\frac{\left|x\right|}{s}}} \cdot \frac{1}{s}\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\color{blue}{\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right)}, 1\right), 2\right)\right) \]
    4. associate-*l/N/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{1 \cdot \frac{1}{s}}{e^{\frac{\left|x\right|}{s}}}\right), \mathsf{pow.f32}\left(\color{blue}{\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right)}, 2\right)\right) \]
    5. *-lft-identityN/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{1 \cdot \frac{1}{s}}{e^{1 \cdot \frac{\left|x\right|}{s}}}\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    6. pow-expN/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{1 \cdot \frac{1}{s}}{{\left(e^{1}\right)}^{\left(\frac{\left|x\right|}{s}\right)}}\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), \color{blue}{1}\right), 2\right)\right) \]
    7. sqr-powN/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{1 \cdot \frac{1}{s}}{{\left(e^{1}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{2}\right)} \cdot {\left(e^{1}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{2}\right)}}\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), \color{blue}{1}\right), 2\right)\right) \]
    8. times-fracN/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{1}{{\left(e^{1}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{2}\right)}} \cdot \frac{\frac{1}{s}}{{\left(e^{1}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{2}\right)}}\right), \mathsf{pow.f32}\left(\color{blue}{\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right)}, 2\right)\right) \]
    9. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\left(\frac{1}{{\left(e^{1}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{2}\right)}}\right), \left(\frac{\frac{1}{s}}{{\left(e^{1}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{2}\right)}}\right)\right), \mathsf{pow.f32}\left(\color{blue}{\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right)}, 2\right)\right) \]
  6. Applied egg-rr99.4%

    \[\leadsto \frac{\color{blue}{\frac{1}{{e}^{\left(\frac{\left|x\right|}{s \cdot 2}\right)}} \cdot \frac{\frac{1}{s}}{{e}^{\left(\frac{\left|x\right|}{s \cdot 2}\right)}}}}{{\left(e^{\frac{\left|x\right|}{-s}} + 1\right)}^{2}} \]
  7. Step-by-step derivation
    1. pow-flipN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\left({\mathsf{E}\left(\right)}^{\left(\mathsf{neg}\left(\frac{\left|x\right|}{s \cdot 2}\right)\right)}\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\color{blue}{\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right)}, 1\right), 2\right)\right) \]
    2. associate-/r*N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\left({\mathsf{E}\left(\right)}^{\left(\mathsf{neg}\left(\frac{\frac{\left|x\right|}{s}}{2}\right)\right)}\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    3. distribute-frac-negN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\left({\mathsf{E}\left(\right)}^{\left(\frac{\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)}{2}\right)}\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    4. distribute-frac-neg2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\left({\mathsf{E}\left(\right)}^{\left(\frac{\frac{\left|x\right|}{\mathsf{neg}\left(s\right)}}{2}\right)}\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    5. pow-lowering-pow.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{E}\left(\right), \left(\frac{\frac{\left|x\right|}{\mathsf{neg}\left(s\right)}}{2}\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\color{blue}{\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right)}, 1\right), 2\right)\right) \]
    6. E-lowering-E.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \left(\frac{\frac{\left|x\right|}{\mathsf{neg}\left(s\right)}}{2}\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\color{blue}{\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)}\right), 1\right), 2\right)\right) \]
    7. distribute-frac-neg2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \left(\frac{\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)}{2}\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    8. distribute-frac-negN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \left(\mathsf{neg}\left(\frac{\frac{\left|x\right|}{s}}{2}\right)\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    9. distribute-neg-frac2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \left(\frac{\frac{\left|x\right|}{s}}{\mathsf{neg}\left(2\right)}\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    10. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\left(\frac{\left|x\right|}{s}\right), \left(\mathsf{neg}\left(2\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    11. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(\left|x\right|\right), s\right), \left(\mathsf{neg}\left(2\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    12. fabs-lowering-fabs.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), s\right), \left(\mathsf{neg}\left(2\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    13. metadata-eval99.4%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), s\right), -2\right)\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
  8. Applied egg-rr99.4%

    \[\leadsto \frac{\color{blue}{{e}^{\left(\frac{\frac{\left|x\right|}{s}}{-2}\right)}} \cdot \frac{\frac{1}{s}}{{e}^{\left(\frac{\left|x\right|}{s \cdot 2}\right)}}}{{\left(e^{\frac{\left|x\right|}{-s}} + 1\right)}^{2}} \]
  9. Final simplification99.4%

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

Alternative 4: 99.6% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \frac{\frac{1}{{e}^{\left(\frac{\left|x\right|}{s \cdot 2}\right)}} \cdot \frac{e^{\frac{\frac{\left|x\right|}{s}}{-2}}}{s}}{{\left(1 + e^{\frac{\left|x\right|}{-s}}\right)}^{2}} \end{array} \]
(FPCore (x s)
 :precision binary32
 (/
  (*
   (/ 1.0 (pow E (/ (fabs x) (* s 2.0))))
   (/ (exp (/ (/ (fabs x) s) -2.0)) s))
  (pow (+ 1.0 (exp (/ (fabs x) (- s)))) 2.0)))
float code(float x, float s) {
	return ((1.0f / powf(((float) M_E), (fabsf(x) / (s * 2.0f)))) * (expf(((fabsf(x) / s) / -2.0f)) / s)) / powf((1.0f + expf((fabsf(x) / -s))), 2.0f);
}
function code(x, s)
	return Float32(Float32(Float32(Float32(1.0) / (Float32(exp(1)) ^ Float32(abs(x) / Float32(s * Float32(2.0))))) * Float32(exp(Float32(Float32(abs(x) / s) / Float32(-2.0))) / s)) / (Float32(Float32(1.0) + exp(Float32(abs(x) / Float32(-s)))) ^ Float32(2.0)))
end
function tmp = code(x, s)
	tmp = ((single(1.0) / (single(2.71828182845904523536) ^ (abs(x) / (s * single(2.0))))) * (exp(((abs(x) / s) / single(-2.0))) / s)) / ((single(1.0) + exp((abs(x) / -s))) ^ single(2.0));
end
\begin{array}{l}

\\
\frac{\frac{1}{{e}^{\left(\frac{\left|x\right|}{s \cdot 2}\right)}} \cdot \frac{e^{\frac{\frac{\left|x\right|}{s}}{-2}}}{s}}{{\left(1 + e^{\frac{\left|x\right|}{-s}}\right)}^{2}}
\end{array}
Derivation
  1. Initial program 99.1%

    \[\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. Add Preprocessing
  3. Step-by-step derivation
    1. associate-*l*N/A

      \[\leadsto \frac{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}{s \cdot \color{blue}{\left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)}} \]
    2. associate-/r*N/A

      \[\leadsto \frac{\frac{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}{s}}{\color{blue}{\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)}} \]
    3. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}{s}\right), \color{blue}{\left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)}\right) \]
    4. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right), s\right), \left(\color{blue}{\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    5. exp-lowering-exp.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\left(\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}\right)\right), s\right), \left(\left(\color{blue}{1} + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    6. distribute-frac-negN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\left(\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    7. distribute-neg-frac2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\left(\frac{\left|x\right|}{\mathsf{neg}\left(s\right)}\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    8. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\left(\left|x\right|\right), \left(\mathsf{neg}\left(s\right)\right)\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    9. fabs-lowering-fabs.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \left(\mathsf{neg}\left(s\right)\right)\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    10. neg-lowering-neg.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    11. pow2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), s\right), \left({\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)}^{\color{blue}{2}}\right)\right) \]
    12. pow-lowering-pow.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), s\right), \mathsf{pow.f32}\left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right), \color{blue}{2}\right)\right) \]
  4. Applied egg-rr99.1%

    \[\leadsto \color{blue}{\frac{\frac{e^{\frac{\left|x\right|}{-s}}}{s}}{{\left(e^{\frac{\left|x\right|}{-s}} + 1\right)}^{2}}} \]
  5. Step-by-step derivation
    1. div-invN/A

      \[\leadsto \mathsf{/.f32}\left(\left(e^{\frac{\left|x\right|}{\mathsf{neg}\left(s\right)}} \cdot \frac{1}{s}\right), \mathsf{pow.f32}\left(\color{blue}{\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right)}, 2\right)\right) \]
    2. distribute-frac-neg2N/A

      \[\leadsto \mathsf{/.f32}\left(\left(e^{\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)} \cdot \frac{1}{s}\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\color{blue}{\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)}\right), 1\right), 2\right)\right) \]
    3. exp-negN/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{1}{e^{\frac{\left|x\right|}{s}}} \cdot \frac{1}{s}\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\color{blue}{\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right)}, 1\right), 2\right)\right) \]
    4. associate-*l/N/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{1 \cdot \frac{1}{s}}{e^{\frac{\left|x\right|}{s}}}\right), \mathsf{pow.f32}\left(\color{blue}{\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right)}, 2\right)\right) \]
    5. *-lft-identityN/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{1 \cdot \frac{1}{s}}{e^{1 \cdot \frac{\left|x\right|}{s}}}\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    6. pow-expN/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{1 \cdot \frac{1}{s}}{{\left(e^{1}\right)}^{\left(\frac{\left|x\right|}{s}\right)}}\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), \color{blue}{1}\right), 2\right)\right) \]
    7. sqr-powN/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{1 \cdot \frac{1}{s}}{{\left(e^{1}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{2}\right)} \cdot {\left(e^{1}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{2}\right)}}\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), \color{blue}{1}\right), 2\right)\right) \]
    8. times-fracN/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{1}{{\left(e^{1}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{2}\right)}} \cdot \frac{\frac{1}{s}}{{\left(e^{1}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{2}\right)}}\right), \mathsf{pow.f32}\left(\color{blue}{\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right)}, 2\right)\right) \]
    9. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\left(\frac{1}{{\left(e^{1}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{2}\right)}}\right), \left(\frac{\frac{1}{s}}{{\left(e^{1}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{2}\right)}}\right)\right), \mathsf{pow.f32}\left(\color{blue}{\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right)}, 2\right)\right) \]
  6. Applied egg-rr99.4%

    \[\leadsto \frac{\color{blue}{\frac{1}{{e}^{\left(\frac{\left|x\right|}{s \cdot 2}\right)}} \cdot \frac{\frac{1}{s}}{{e}^{\left(\frac{\left|x\right|}{s \cdot 2}\right)}}}}{{\left(e^{\frac{\left|x\right|}{-s}} + 1\right)}^{2}} \]
  7. Step-by-step derivation
    1. associate-/l/N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(1, \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right), \left(\frac{1}{{\mathsf{E}\left(\right)}^{\left(\frac{\left|x\right|}{s \cdot 2}\right)} \cdot s}\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), \color{blue}{1}\right), 2\right)\right) \]
    2. associate-/r*N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(1, \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right), \left(\frac{\frac{1}{{\mathsf{E}\left(\right)}^{\left(\frac{\left|x\right|}{s \cdot 2}\right)}}}{s}\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), \color{blue}{1}\right), 2\right)\right) \]
    3. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(1, \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right), \mathsf{/.f32}\left(\left(\frac{1}{{\mathsf{E}\left(\right)}^{\left(\frac{\left|x\right|}{s \cdot 2}\right)}}\right), s\right)\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), \color{blue}{1}\right), 2\right)\right) \]
  8. Applied egg-rr99.4%

    \[\leadsto \frac{\frac{1}{{e}^{\left(\frac{\left|x\right|}{s \cdot 2}\right)}} \cdot \color{blue}{\frac{e^{\frac{\frac{\left|x\right|}{s}}{-2}}}{s}}}{{\left(e^{\frac{\left|x\right|}{-s}} + 1\right)}^{2}} \]
  9. Final simplification99.4%

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

Alternative 5: 99.5% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \frac{\frac{{\left(e \cdot e\right)}^{\left(\frac{\left|x\right|}{0 - s \cdot 2}\right)}}{s}}{{\left(1 + e^{\frac{\left|x\right|}{-s}}\right)}^{2}} \end{array} \]
(FPCore (x s)
 :precision binary32
 (/
  (/ (pow (* E E) (/ (fabs x) (- 0.0 (* s 2.0)))) s)
  (pow (+ 1.0 (exp (/ (fabs x) (- s)))) 2.0)))
float code(float x, float s) {
	return (powf((((float) M_E) * ((float) M_E)), (fabsf(x) / (0.0f - (s * 2.0f)))) / s) / powf((1.0f + expf((fabsf(x) / -s))), 2.0f);
}
function code(x, s)
	return Float32(Float32((Float32(Float32(exp(1)) * Float32(exp(1))) ^ Float32(abs(x) / Float32(Float32(0.0) - Float32(s * Float32(2.0))))) / s) / (Float32(Float32(1.0) + exp(Float32(abs(x) / Float32(-s)))) ^ Float32(2.0)))
end
function tmp = code(x, s)
	tmp = (((single(2.71828182845904523536) * single(2.71828182845904523536)) ^ (abs(x) / (single(0.0) - (s * single(2.0))))) / s) / ((single(1.0) + exp((abs(x) / -s))) ^ single(2.0));
end
\begin{array}{l}

\\
\frac{\frac{{\left(e \cdot e\right)}^{\left(\frac{\left|x\right|}{0 - s \cdot 2}\right)}}{s}}{{\left(1 + e^{\frac{\left|x\right|}{-s}}\right)}^{2}}
\end{array}
Derivation
  1. Initial program 99.1%

    \[\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. Add Preprocessing
  3. Step-by-step derivation
    1. associate-*l*N/A

      \[\leadsto \frac{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}{s \cdot \color{blue}{\left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)}} \]
    2. associate-/r*N/A

      \[\leadsto \frac{\frac{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}{s}}{\color{blue}{\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)}} \]
    3. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}{s}\right), \color{blue}{\left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)}\right) \]
    4. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right), s\right), \left(\color{blue}{\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    5. exp-lowering-exp.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\left(\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}\right)\right), s\right), \left(\left(\color{blue}{1} + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    6. distribute-frac-negN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\left(\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    7. distribute-neg-frac2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\left(\frac{\left|x\right|}{\mathsf{neg}\left(s\right)}\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    8. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\left(\left|x\right|\right), \left(\mathsf{neg}\left(s\right)\right)\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    9. fabs-lowering-fabs.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \left(\mathsf{neg}\left(s\right)\right)\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    10. neg-lowering-neg.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    11. pow2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), s\right), \left({\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)}^{\color{blue}{2}}\right)\right) \]
    12. pow-lowering-pow.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), s\right), \mathsf{pow.f32}\left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right), \color{blue}{2}\right)\right) \]
  4. Applied egg-rr99.1%

    \[\leadsto \color{blue}{\frac{\frac{e^{\frac{\left|x\right|}{-s}}}{s}}{{\left(e^{\frac{\left|x\right|}{-s}} + 1\right)}^{2}}} \]
  5. Step-by-step derivation
    1. distribute-frac-neg2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(e^{\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)}\right), s\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\color{blue}{\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)}\right), 1\right), 2\right)\right) \]
    2. exp-negN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(\frac{1}{e^{\frac{\left|x\right|}{s}}}\right), s\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\color{blue}{\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right)}, 1\right), 2\right)\right) \]
    3. *-lft-identityN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(\frac{1}{e^{1 \cdot \frac{\left|x\right|}{s}}}\right), s\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    4. pow-expN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(\frac{1}{{\left(e^{1}\right)}^{\left(\frac{\left|x\right|}{s}\right)}}\right), s\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    5. sqr-powN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(\frac{1}{{\left(e^{1}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{2}\right)} \cdot {\left(e^{1}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{2}\right)}}\right), s\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    6. pow-prod-downN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(\frac{1}{{\left(e^{1} \cdot e^{1}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{2}\right)}}\right), s\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    7. pow-flipN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left({\left(e^{1} \cdot e^{1}\right)}^{\left(\mathsf{neg}\left(\frac{\frac{\left|x\right|}{s}}{2}\right)\right)}\right), s\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\color{blue}{\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right)}, 1\right), 2\right)\right) \]
    8. pow-lowering-pow.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{pow.f32}\left(\left(e^{1} \cdot e^{1}\right), \left(\mathsf{neg}\left(\frac{\frac{\left|x\right|}{s}}{2}\right)\right)\right), s\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\color{blue}{\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right)}, 1\right), 2\right)\right) \]
    9. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(\left(e^{1}\right), \left(e^{1}\right)\right), \left(\mathsf{neg}\left(\frac{\frac{\left|x\right|}{s}}{2}\right)\right)\right), s\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\color{blue}{\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)}\right), 1\right), 2\right)\right) \]
    10. exp-1-eN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(\mathsf{E}\left(\right), \left(e^{1}\right)\right), \left(\mathsf{neg}\left(\frac{\frac{\left|x\right|}{s}}{2}\right)\right)\right), s\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\color{blue}{\mathsf{fabs.f32}\left(x\right)}, \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    11. E-lowering-E.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(\mathsf{E.f32}\left(\right), \left(e^{1}\right)\right), \left(\mathsf{neg}\left(\frac{\frac{\left|x\right|}{s}}{2}\right)\right)\right), s\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\color{blue}{\mathsf{fabs.f32}\left(x\right)}, \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    12. exp-1-eN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{E}\left(\right)\right), \left(\mathsf{neg}\left(\frac{\frac{\left|x\right|}{s}}{2}\right)\right)\right), s\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \color{blue}{\mathsf{neg.f32}\left(s\right)}\right)\right), 1\right), 2\right)\right) \]
    13. E-lowering-E.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{E.f32}\left(\right)\right), \left(\mathsf{neg}\left(\frac{\frac{\left|x\right|}{s}}{2}\right)\right)\right), s\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \color{blue}{\mathsf{neg.f32}\left(s\right)}\right)\right), 1\right), 2\right)\right) \]
    14. neg-lowering-neg.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{E.f32}\left(\right)\right), \mathsf{neg.f32}\left(\left(\frac{\frac{\left|x\right|}{s}}{2}\right)\right)\right), s\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    15. associate-/l/N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{E.f32}\left(\right)\right), \mathsf{neg.f32}\left(\left(\frac{\left|x\right|}{2 \cdot s}\right)\right)\right), s\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    16. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{E.f32}\left(\right)\right), \mathsf{neg.f32}\left(\mathsf{/.f32}\left(\left(\left|x\right|\right), \left(2 \cdot s\right)\right)\right)\right), s\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    17. fabs-lowering-fabs.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{E.f32}\left(\right)\right), \mathsf{neg.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \left(2 \cdot s\right)\right)\right)\right), s\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    18. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{E.f32}\left(\right)\right), \mathsf{neg.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \left(s \cdot 2\right)\right)\right)\right), s\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
    19. *-lowering-*.f3299.2%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{E.f32}\left(\right)\right), \mathsf{neg.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{*.f32}\left(s, 2\right)\right)\right)\right), s\right), \mathsf{pow.f32}\left(\mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 1\right), 2\right)\right) \]
  6. Applied egg-rr99.2%

    \[\leadsto \frac{\frac{\color{blue}{{\left(e \cdot e\right)}^{\left(-\frac{\left|x\right|}{s \cdot 2}\right)}}}{s}}{{\left(e^{\frac{\left|x\right|}{-s}} + 1\right)}^{2}} \]
  7. Final simplification99.2%

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

Alternative 6: 99.5% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\frac{\left|x\right|}{-s}}\\ \frac{\frac{t\_0}{s}}{{\left(1 + t\_0\right)}^{2}} \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (let* ((t_0 (exp (/ (fabs x) (- s))))) (/ (/ t_0 s) (pow (+ 1.0 t_0) 2.0))))
float code(float x, float s) {
	float t_0 = expf((fabsf(x) / -s));
	return (t_0 / s) / powf((1.0f + t_0), 2.0f);
}
real(4) function code(x, s)
    real(4), intent (in) :: x
    real(4), intent (in) :: s
    real(4) :: t_0
    t_0 = exp((abs(x) / -s))
    code = (t_0 / s) / ((1.0e0 + t_0) ** 2.0e0)
end function
function code(x, s)
	t_0 = exp(Float32(abs(x) / Float32(-s)))
	return Float32(Float32(t_0 / s) / (Float32(Float32(1.0) + t_0) ^ Float32(2.0)))
end
function tmp = code(x, s)
	t_0 = exp((abs(x) / -s));
	tmp = (t_0 / s) / ((single(1.0) + t_0) ^ single(2.0));
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{\frac{\left|x\right|}{-s}}\\
\frac{\frac{t\_0}{s}}{{\left(1 + t\_0\right)}^{2}}
\end{array}
\end{array}
Derivation
  1. Initial program 99.1%

    \[\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. Add Preprocessing
  3. Step-by-step derivation
    1. associate-*l*N/A

      \[\leadsto \frac{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}{s \cdot \color{blue}{\left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)}} \]
    2. associate-/r*N/A

      \[\leadsto \frac{\frac{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}{s}}{\color{blue}{\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)}} \]
    3. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}{s}\right), \color{blue}{\left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)}\right) \]
    4. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right), s\right), \left(\color{blue}{\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    5. exp-lowering-exp.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\left(\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}\right)\right), s\right), \left(\left(\color{blue}{1} + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    6. distribute-frac-negN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\left(\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    7. distribute-neg-frac2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\left(\frac{\left|x\right|}{\mathsf{neg}\left(s\right)}\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    8. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\left(\left|x\right|\right), \left(\mathsf{neg}\left(s\right)\right)\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    9. fabs-lowering-fabs.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \left(\mathsf{neg}\left(s\right)\right)\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    10. neg-lowering-neg.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), s\right), \left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right)\right) \]
    11. pow2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), s\right), \left({\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)}^{\color{blue}{2}}\right)\right) \]
    12. pow-lowering-pow.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), s\right), \mathsf{pow.f32}\left(\left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right), \color{blue}{2}\right)\right) \]
  4. Applied egg-rr99.1%

    \[\leadsto \color{blue}{\frac{\frac{e^{\frac{\left|x\right|}{-s}}}{s}}{{\left(e^{\frac{\left|x\right|}{-s}} + 1\right)}^{2}}} \]
  5. Final simplification99.1%

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

Alternative 7: 99.5% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \frac{1}{s \cdot \left(2 + 2 \cdot \cosh \left(\frac{\left|x\right|}{s}\right)\right)} \end{array} \]
(FPCore (x s)
 :precision binary32
 (/ 1.0 (* s (+ 2.0 (* 2.0 (cosh (/ (fabs x) s)))))))
float code(float x, float s) {
	return 1.0f / (s * (2.0f + (2.0f * coshf((fabsf(x) / s)))));
}
real(4) function code(x, s)
    real(4), intent (in) :: x
    real(4), intent (in) :: s
    code = 1.0e0 / (s * (2.0e0 + (2.0e0 * cosh((abs(x) / s)))))
end function
function code(x, s)
	return Float32(Float32(1.0) / Float32(s * Float32(Float32(2.0) + Float32(Float32(2.0) * cosh(Float32(abs(x) / s))))))
end
function tmp = code(x, s)
	tmp = single(1.0) / (s * (single(2.0) + (single(2.0) * cosh((abs(x) / s)))));
end
\begin{array}{l}

\\
\frac{1}{s \cdot \left(2 + 2 \cdot \cosh \left(\frac{\left|x\right|}{s}\right)\right)}
\end{array}
Derivation
  1. Initial program 99.1%

    \[\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. Simplified98.9%

    \[\leadsto \color{blue}{\frac{\frac{1}{e^{-\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{s}} + 2\right)}}{s}} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. associate-/l/N/A

      \[\leadsto \frac{1}{\color{blue}{s \cdot \left(e^{\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)} + \left(e^{\frac{\left|x\right|}{s}} + 2\right)\right)}} \]
    2. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(1, \color{blue}{\left(s \cdot \left(e^{\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)} + \left(e^{\frac{\left|x\right|}{s}} + 2\right)\right)\right)}\right) \]
    3. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{*.f32}\left(s, \color{blue}{\left(e^{\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)} + \left(e^{\frac{\left|x\right|}{s}} + 2\right)\right)}\right)\right) \]
    4. associate-+r+N/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{*.f32}\left(s, \left(\left(e^{\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)} + e^{\frac{\left|x\right|}{s}}\right) + \color{blue}{2}\right)\right)\right) \]
    5. +-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{*.f32}\left(s, \left(2 + \color{blue}{\left(e^{\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)} + e^{\frac{\left|x\right|}{s}}\right)}\right)\right)\right) \]
    6. +-lowering-+.f32N/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{*.f32}\left(s, \mathsf{+.f32}\left(2, \color{blue}{\left(e^{\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)} + e^{\frac{\left|x\right|}{s}}\right)}\right)\right)\right) \]
    7. distribute-frac-negN/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{*.f32}\left(s, \mathsf{+.f32}\left(2, \left(e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}} + e^{\frac{\color{blue}{\left|x\right|}}{s}}\right)\right)\right)\right) \]
    8. +-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{*.f32}\left(s, \mathsf{+.f32}\left(2, \left(e^{\frac{\left|x\right|}{s}} + \color{blue}{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}\right)\right)\right)\right) \]
    9. distribute-frac-negN/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{*.f32}\left(s, \mathsf{+.f32}\left(2, \left(e^{\frac{\left|x\right|}{s}} + e^{\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)}\right)\right)\right)\right) \]
    10. cosh-undefN/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{*.f32}\left(s, \mathsf{+.f32}\left(2, \left(2 \cdot \color{blue}{\cosh \left(\frac{\left|x\right|}{s}\right)}\right)\right)\right)\right) \]
    11. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{*.f32}\left(s, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(2, \color{blue}{\cosh \left(\frac{\left|x\right|}{s}\right)}\right)\right)\right)\right) \]
    12. cosh-lowering-cosh.f32N/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{*.f32}\left(s, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(2, \mathsf{cosh.f32}\left(\left(\frac{\left|x\right|}{s}\right)\right)\right)\right)\right)\right) \]
    13. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{*.f32}\left(s, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(2, \mathsf{cosh.f32}\left(\mathsf{/.f32}\left(\left(\left|x\right|\right), s\right)\right)\right)\right)\right)\right) \]
    14. fabs-lowering-fabs.f3299.0%

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{*.f32}\left(s, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(2, \mathsf{cosh.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), s\right)\right)\right)\right)\right)\right) \]
  5. Applied egg-rr99.0%

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

Alternative 8: 95.7% accurate, 3.0× speedup?

\[\begin{array}{l} \\ \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + 3} \end{array} \]
(FPCore (x s) :precision binary32 (/ (/ 1.0 s) (+ (exp (/ (fabs x) s)) 3.0)))
float code(float x, float s) {
	return (1.0f / s) / (expf((fabsf(x) / s)) + 3.0f);
}
real(4) function code(x, s)
    real(4), intent (in) :: x
    real(4), intent (in) :: s
    code = (1.0e0 / s) / (exp((abs(x) / s)) + 3.0e0)
end function
function code(x, s)
	return Float32(Float32(Float32(1.0) / s) / Float32(exp(Float32(abs(x) / s)) + Float32(3.0)))
end
function tmp = code(x, s)
	tmp = (single(1.0) / s) / (exp((abs(x) / s)) + single(3.0));
end
\begin{array}{l}

\\
\frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + 3}
\end{array}
Derivation
  1. Initial program 99.1%

    \[\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. Simplified98.9%

    \[\leadsto \color{blue}{\frac{\frac{1}{e^{-\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{s}} + 2\right)}}{s}} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. *-lft-identityN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{neg.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), s\right)\right)\right), \mathsf{+.f32}\left(\left(e^{1 \cdot \frac{\left|x\right|}{s}}\right), 2\right)\right)\right), s\right) \]
    2. exp-prodN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{neg.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), s\right)\right)\right), \mathsf{+.f32}\left(\left({\left(e^{1}\right)}^{\left(\frac{\left|x\right|}{s}\right)}\right), 2\right)\right)\right), s\right) \]
    3. pow-lowering-pow.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{neg.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), s\right)\right)\right), \mathsf{+.f32}\left(\mathsf{pow.f32}\left(\left(e^{1}\right), \left(\frac{\left|x\right|}{s}\right)\right), 2\right)\right)\right), s\right) \]
    4. exp-lowering-exp.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{neg.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), s\right)\right)\right), \mathsf{+.f32}\left(\mathsf{pow.f32}\left(\mathsf{exp.f32}\left(1\right), \left(\frac{\left|x\right|}{s}\right)\right), 2\right)\right)\right), s\right) \]
    5. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{neg.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), s\right)\right)\right), \mathsf{+.f32}\left(\mathsf{pow.f32}\left(\mathsf{exp.f32}\left(1\right), \mathsf{/.f32}\left(\left(\left|x\right|\right), s\right)\right), 2\right)\right)\right), s\right) \]
    6. fabs-lowering-fabs.f3298.9%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{neg.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), s\right)\right)\right), \mathsf{+.f32}\left(\mathsf{pow.f32}\left(\mathsf{exp.f32}\left(1\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), s\right)\right), 2\right)\right)\right), s\right) \]
  5. Applied egg-rr98.9%

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

    \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\color{blue}{1}, \mathsf{+.f32}\left(\mathsf{pow.f32}\left(\mathsf{exp.f32}\left(1\right), \mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), s\right)\right), 2\right)\right)\right), s\right) \]
  7. Step-by-step derivation
    1. Simplified94.1%

      \[\leadsto \frac{\frac{1}{\color{blue}{1} + \left({\left(e^{1}\right)}^{\left(\frac{\left|x\right|}{s}\right)} + 2\right)}}{s} \]
    2. Step-by-step derivation
      1. associate-/l/N/A

        \[\leadsto \frac{1}{\color{blue}{s \cdot \left(1 + \left({\left(e^{1}\right)}^{\left(\frac{\left|x\right|}{s}\right)} + 2\right)\right)}} \]
      2. associate-/r*N/A

        \[\leadsto \frac{\frac{1}{s}}{\color{blue}{1 + \left({\left(e^{1}\right)}^{\left(\frac{\left|x\right|}{s}\right)} + 2\right)}} \]
      3. /-lowering-/.f32N/A

        \[\leadsto \mathsf{/.f32}\left(\left(\frac{1}{s}\right), \color{blue}{\left(1 + \left({\left(e^{1}\right)}^{\left(\frac{\left|x\right|}{s}\right)} + 2\right)\right)}\right) \]
      4. /-lowering-/.f32N/A

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \left(\color{blue}{1} + \left({\left(e^{1}\right)}^{\left(\frac{\left|x\right|}{s}\right)} + 2\right)\right)\right) \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \left(\left({\left(e^{1}\right)}^{\left(\frac{\left|x\right|}{s}\right)} + 2\right) + \color{blue}{1}\right)\right) \]
      6. associate-+l+N/A

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \left({\left(e^{1}\right)}^{\left(\frac{\left|x\right|}{s}\right)} + \color{blue}{\left(2 + 1\right)}\right)\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \left({\left(e^{1}\right)}^{\left(\frac{\left|x\right|}{s}\right)} + 3\right)\right) \]
      8. +-lowering-+.f32N/A

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{+.f32}\left(\left({\left(e^{1}\right)}^{\left(\frac{\left|x\right|}{s}\right)}\right), \color{blue}{3}\right)\right) \]
      9. pow-expN/A

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{+.f32}\left(\left(e^{1 \cdot \frac{\left|x\right|}{s}}\right), 3\right)\right) \]
      10. *-lft-identityN/A

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{+.f32}\left(\left(e^{\frac{\left|x\right|}{s}}\right), 3\right)\right) \]
      11. exp-lowering-exp.f32N/A

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\left(\frac{\left|x\right|}{s}\right)\right), 3\right)\right) \]
      12. /-lowering-/.f32N/A

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\left(\left|x\right|\right), s\right)\right), 3\right)\right) \]
      13. fabs-lowering-fabs.f3294.1%

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{+.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), s\right)\right), 3\right)\right) \]
    3. Applied egg-rr94.1%

      \[\leadsto \color{blue}{\frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + 3}} \]
    4. Add Preprocessing

    Alternative 9: 94.5% accurate, 3.0× speedup?

    \[\begin{array}{l} \\ \frac{\frac{e^{\frac{\left|x\right|}{-s}}}{4}}{s} \end{array} \]
    (FPCore (x s) :precision binary32 (/ (/ (exp (/ (fabs x) (- s))) 4.0) s))
    float code(float x, float s) {
    	return (expf((fabsf(x) / -s)) / 4.0f) / s;
    }
    
    real(4) function code(x, s)
        real(4), intent (in) :: x
        real(4), intent (in) :: s
        code = (exp((abs(x) / -s)) / 4.0e0) / s
    end function
    
    function code(x, s)
    	return Float32(Float32(exp(Float32(abs(x) / Float32(-s))) / Float32(4.0)) / s)
    end
    
    function tmp = code(x, s)
    	tmp = (exp((abs(x) / -s)) / single(4.0)) / s;
    end
    
    \begin{array}{l}
    
    \\
    \frac{\frac{e^{\frac{\left|x\right|}{-s}}}{4}}{s}
    \end{array}
    
    Derivation
    1. Initial program 99.1%

      \[\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. Add Preprocessing
    3. Taylor expanded in s around inf

      \[\leadsto \mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{neg.f32}\left(\mathsf{fabs.f32}\left(x\right)\right), s\right)\right), \color{blue}{\left(4 \cdot s\right)}\right) \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{neg.f32}\left(\mathsf{fabs.f32}\left(x\right)\right), s\right)\right), \left(s \cdot \color{blue}{4}\right)\right) \]
      2. *-lowering-*.f3291.9%

        \[\leadsto \mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{neg.f32}\left(\mathsf{fabs.f32}\left(x\right)\right), s\right)\right), \mathsf{*.f32}\left(s, \color{blue}{4}\right)\right) \]
    5. Simplified91.9%

      \[\leadsto \frac{e^{\frac{-\left|x\right|}{s}}}{\color{blue}{s \cdot 4}} \]
    6. Step-by-step derivation
      1. distribute-frac-negN/A

        \[\leadsto \frac{e^{\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)}}{s \cdot 4} \]
      2. distribute-frac-neg2N/A

        \[\leadsto \frac{e^{\frac{\left|x\right|}{\mathsf{neg}\left(s\right)}}}{s \cdot 4} \]
      3. *-commutativeN/A

        \[\leadsto \frac{e^{\frac{\left|x\right|}{\mathsf{neg}\left(s\right)}}}{4 \cdot \color{blue}{s}} \]
      4. associate-/r*N/A

        \[\leadsto \frac{\frac{e^{\frac{\left|x\right|}{\mathsf{neg}\left(s\right)}}}{4}}{\color{blue}{s}} \]
      5. /-lowering-/.f32N/A

        \[\leadsto \mathsf{/.f32}\left(\left(\frac{e^{\frac{\left|x\right|}{\mathsf{neg}\left(s\right)}}}{4}\right), \color{blue}{s}\right) \]
      6. /-lowering-/.f32N/A

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(e^{\frac{\left|x\right|}{\mathsf{neg}\left(s\right)}}\right), 4\right), s\right) \]
      7. distribute-frac-neg2N/A

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(e^{\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)}\right), 4\right), s\right) \]
      8. distribute-frac-negN/A

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right), 4\right), s\right) \]
      9. exp-lowering-exp.f32N/A

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\left(\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}\right)\right), 4\right), s\right) \]
      10. distribute-frac-negN/A

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\left(\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)\right)\right), 4\right), s\right) \]
      11. distribute-frac-neg2N/A

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\left(\frac{\left|x\right|}{\mathsf{neg}\left(s\right)}\right)\right), 4\right), s\right) \]
      12. /-lowering-/.f32N/A

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\left(\left|x\right|\right), \left(\mathsf{neg}\left(s\right)\right)\right)\right), 4\right), s\right) \]
      13. fabs-lowering-fabs.f32N/A

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \left(\mathsf{neg}\left(s\right)\right)\right)\right), 4\right), s\right) \]
      14. neg-lowering-neg.f3291.9%

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), \mathsf{neg.f32}\left(s\right)\right)\right), 4\right), s\right) \]
    7. Applied egg-rr91.9%

      \[\leadsto \color{blue}{\frac{\frac{e^{\frac{\left|x\right|}{-s}}}{4}}{s}} \]
    8. Add Preprocessing

    Alternative 10: 94.5% accurate, 3.0× speedup?

    \[\begin{array}{l} \\ \frac{e^{\frac{\left|x\right|}{-s}}}{s \cdot 4} \end{array} \]
    (FPCore (x s) :precision binary32 (/ (exp (/ (fabs x) (- s))) (* s 4.0)))
    float code(float x, float s) {
    	return expf((fabsf(x) / -s)) / (s * 4.0f);
    }
    
    real(4) function code(x, s)
        real(4), intent (in) :: x
        real(4), intent (in) :: s
        code = exp((abs(x) / -s)) / (s * 4.0e0)
    end function
    
    function code(x, s)
    	return Float32(exp(Float32(abs(x) / Float32(-s))) / Float32(s * Float32(4.0)))
    end
    
    function tmp = code(x, s)
    	tmp = exp((abs(x) / -s)) / (s * single(4.0));
    end
    
    \begin{array}{l}
    
    \\
    \frac{e^{\frac{\left|x\right|}{-s}}}{s \cdot 4}
    \end{array}
    
    Derivation
    1. Initial program 99.1%

      \[\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. Add Preprocessing
    3. Taylor expanded in s around inf

      \[\leadsto \mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{neg.f32}\left(\mathsf{fabs.f32}\left(x\right)\right), s\right)\right), \color{blue}{\left(4 \cdot s\right)}\right) \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{neg.f32}\left(\mathsf{fabs.f32}\left(x\right)\right), s\right)\right), \left(s \cdot \color{blue}{4}\right)\right) \]
      2. *-lowering-*.f3291.9%

        \[\leadsto \mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{neg.f32}\left(\mathsf{fabs.f32}\left(x\right)\right), s\right)\right), \mathsf{*.f32}\left(s, \color{blue}{4}\right)\right) \]
    5. Simplified91.9%

      \[\leadsto \frac{e^{\frac{-\left|x\right|}{s}}}{\color{blue}{s \cdot 4}} \]
    6. Final simplification91.9%

      \[\leadsto \frac{e^{\frac{\left|x\right|}{-s}}}{s \cdot 4} \]
    7. Add Preprocessing

    Alternative 11: 94.5% accurate, 3.0× speedup?

    \[\begin{array}{l} \\ \frac{\frac{0.25}{e^{\frac{\left|x\right|}{s}}}}{s} \end{array} \]
    (FPCore (x s) :precision binary32 (/ (/ 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)
        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(Float32(0.25) / exp(Float32(abs(x) / s))) / s)
    end
    
    function tmp = code(x, s)
    	tmp = (single(0.25) / exp((abs(x) / s))) / s;
    end
    
    \begin{array}{l}
    
    \\
    \frac{\frac{0.25}{e^{\frac{\left|x\right|}{s}}}}{s}
    \end{array}
    
    Derivation
    1. Initial program 99.1%

      \[\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. Add Preprocessing
    3. Taylor expanded in s around inf

      \[\leadsto \mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{neg.f32}\left(\mathsf{fabs.f32}\left(x\right)\right), s\right)\right), \color{blue}{\left(4 \cdot s\right)}\right) \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{neg.f32}\left(\mathsf{fabs.f32}\left(x\right)\right), s\right)\right), \left(s \cdot \color{blue}{4}\right)\right) \]
      2. *-lowering-*.f3291.9%

        \[\leadsto \mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{neg.f32}\left(\mathsf{fabs.f32}\left(x\right)\right), s\right)\right), \mathsf{*.f32}\left(s, \color{blue}{4}\right)\right) \]
    5. Simplified91.9%

      \[\leadsto \frac{e^{\frac{-\left|x\right|}{s}}}{\color{blue}{s \cdot 4}} \]
    6. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{1}{4} \cdot \frac{e^{-1 \cdot \frac{\left|x\right|}{s}}}{s}} \]
    7. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{\frac{1}{4} \cdot e^{-1 \cdot \frac{\left|x\right|}{s}}}{\color{blue}{s}} \]
      2. /-lowering-/.f32N/A

        \[\leadsto \mathsf{/.f32}\left(\left(\frac{1}{4} \cdot e^{-1 \cdot \frac{\left|x\right|}{s}}\right), \color{blue}{s}\right) \]
      3. neg-mul-1N/A

        \[\leadsto \mathsf{/.f32}\left(\left(\frac{1}{4} \cdot e^{\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)}\right), s\right) \]
      4. rec-expN/A

        \[\leadsto \mathsf{/.f32}\left(\left(\frac{1}{4} \cdot \frac{1}{e^{\frac{\left|x\right|}{s}}}\right), s\right) \]
      5. associate-*r/N/A

        \[\leadsto \mathsf{/.f32}\left(\left(\frac{\frac{1}{4} \cdot 1}{e^{\frac{\left|x\right|}{s}}}\right), s\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{/.f32}\left(\left(\frac{\frac{1}{4}}{e^{\frac{\left|x\right|}{s}}}\right), s\right) \]
      7. /-lowering-/.f32N/A

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{1}{4}, \left(e^{\frac{\left|x\right|}{s}}\right)\right), s\right) \]
      8. exp-lowering-exp.f32N/A

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{1}{4}, \mathsf{exp.f32}\left(\left(\frac{\left|x\right|}{s}\right)\right)\right), s\right) \]
      9. /-lowering-/.f32N/A

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{1}{4}, \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\left(\left|x\right|\right), s\right)\right)\right), s\right) \]
      10. fabs-lowering-fabs.f3291.8%

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{1}{4}, \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), s\right)\right)\right), s\right) \]
    8. Simplified91.8%

      \[\leadsto \color{blue}{\frac{\frac{0.25}{e^{\frac{\left|x\right|}{s}}}}{s}} \]
    9. Add Preprocessing

    Alternative 12: 94.5% accurate, 3.0× speedup?

    \[\begin{array}{l} \\ \frac{0.25}{s \cdot e^{\frac{\left|x\right|}{s}}} \end{array} \]
    (FPCore (x s) :precision binary32 (/ 0.25 (* s (exp (/ (fabs x) s)))))
    float code(float x, float s) {
    	return 0.25f / (s * expf((fabsf(x) / s)));
    }
    
    real(4) function code(x, s)
        real(4), intent (in) :: x
        real(4), intent (in) :: s
        code = 0.25e0 / (s * exp((abs(x) / s)))
    end function
    
    function code(x, s)
    	return Float32(Float32(0.25) / Float32(s * exp(Float32(abs(x) / s))))
    end
    
    function tmp = code(x, s)
    	tmp = single(0.25) / (s * exp((abs(x) / s)));
    end
    
    \begin{array}{l}
    
    \\
    \frac{0.25}{s \cdot e^{\frac{\left|x\right|}{s}}}
    \end{array}
    
    Derivation
    1. Initial program 99.1%

      \[\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. Add Preprocessing
    3. Taylor expanded in s around inf

      \[\leadsto \mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{neg.f32}\left(\mathsf{fabs.f32}\left(x\right)\right), s\right)\right), \color{blue}{\left(4 \cdot s\right)}\right) \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{neg.f32}\left(\mathsf{fabs.f32}\left(x\right)\right), s\right)\right), \left(s \cdot \color{blue}{4}\right)\right) \]
      2. *-lowering-*.f3291.9%

        \[\leadsto \mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{neg.f32}\left(\mathsf{fabs.f32}\left(x\right)\right), s\right)\right), \mathsf{*.f32}\left(s, \color{blue}{4}\right)\right) \]
    5. Simplified91.9%

      \[\leadsto \frac{e^{\frac{-\left|x\right|}{s}}}{\color{blue}{s \cdot 4}} \]
    6. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{1}{4} \cdot \frac{e^{-1 \cdot \frac{\left|x\right|}{s}}}{s}} \]
    7. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{\frac{1}{4} \cdot e^{-1 \cdot \frac{\left|x\right|}{s}}}{\color{blue}{s}} \]
      2. /-lowering-/.f32N/A

        \[\leadsto \mathsf{/.f32}\left(\left(\frac{1}{4} \cdot e^{-1 \cdot \frac{\left|x\right|}{s}}\right), \color{blue}{s}\right) \]
      3. neg-mul-1N/A

        \[\leadsto \mathsf{/.f32}\left(\left(\frac{1}{4} \cdot e^{\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)}\right), s\right) \]
      4. rec-expN/A

        \[\leadsto \mathsf{/.f32}\left(\left(\frac{1}{4} \cdot \frac{1}{e^{\frac{\left|x\right|}{s}}}\right), s\right) \]
      5. associate-*r/N/A

        \[\leadsto \mathsf{/.f32}\left(\left(\frac{\frac{1}{4} \cdot 1}{e^{\frac{\left|x\right|}{s}}}\right), s\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{/.f32}\left(\left(\frac{\frac{1}{4}}{e^{\frac{\left|x\right|}{s}}}\right), s\right) \]
      7. /-lowering-/.f32N/A

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{1}{4}, \left(e^{\frac{\left|x\right|}{s}}\right)\right), s\right) \]
      8. exp-lowering-exp.f32N/A

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{1}{4}, \mathsf{exp.f32}\left(\left(\frac{\left|x\right|}{s}\right)\right)\right), s\right) \]
      9. /-lowering-/.f32N/A

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{1}{4}, \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\left(\left|x\right|\right), s\right)\right)\right), s\right) \]
      10. fabs-lowering-fabs.f3291.8%

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{1}{4}, \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), s\right)\right)\right), s\right) \]
    8. Simplified91.8%

      \[\leadsto \color{blue}{\frac{\frac{0.25}{e^{\frac{\left|x\right|}{s}}}}{s}} \]
    9. Step-by-step derivation
      1. associate-/l/N/A

        \[\leadsto \frac{\frac{1}{4}}{\color{blue}{s \cdot e^{\frac{\left|x\right|}{s}}}} \]
      2. /-lowering-/.f32N/A

        \[\leadsto \mathsf{/.f32}\left(\frac{1}{4}, \color{blue}{\left(s \cdot e^{\frac{\left|x\right|}{s}}\right)}\right) \]
      3. *-lft-identityN/A

        \[\leadsto \mathsf{/.f32}\left(\frac{1}{4}, \left(s \cdot e^{1 \cdot \frac{\left|x\right|}{s}}\right)\right) \]
      4. pow-expN/A

        \[\leadsto \mathsf{/.f32}\left(\frac{1}{4}, \left(s \cdot {\left(e^{1}\right)}^{\color{blue}{\left(\frac{\left|x\right|}{s}\right)}}\right)\right) \]
      5. *-lowering-*.f32N/A

        \[\leadsto \mathsf{/.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(s, \color{blue}{\left({\left(e^{1}\right)}^{\left(\frac{\left|x\right|}{s}\right)}\right)}\right)\right) \]
      6. pow-expN/A

        \[\leadsto \mathsf{/.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(s, \left(e^{1 \cdot \frac{\left|x\right|}{s}}\right)\right)\right) \]
      7. *-lft-identityN/A

        \[\leadsto \mathsf{/.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(s, \left(e^{\frac{\left|x\right|}{s}}\right)\right)\right) \]
      8. exp-lowering-exp.f32N/A

        \[\leadsto \mathsf{/.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(s, \mathsf{exp.f32}\left(\left(\frac{\left|x\right|}{s}\right)\right)\right)\right) \]
      9. /-lowering-/.f32N/A

        \[\leadsto \mathsf{/.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(s, \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\left(\left|x\right|\right), s\right)\right)\right)\right) \]
      10. fabs-lowering-fabs.f3291.8%

        \[\leadsto \mathsf{/.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(s, \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{fabs.f32}\left(x\right), s\right)\right)\right)\right) \]
    10. Applied egg-rr91.8%

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

    Alternative 13: 81.9% accurate, 5.3× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|x\right| \leq 1.5000000786160286 \cdot 10^{-23}:\\ \;\;\;\;\frac{0.25 - \frac{x}{s} \cdot \frac{x \cdot 0.0625}{s}}{s}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{4 + \frac{x \cdot x}{s \cdot s}}}{s}\\ \end{array} \end{array} \]
    (FPCore (x s)
     :precision binary32
     (if (<= (fabs x) 1.5000000786160286e-23)
       (/ (- 0.25 (* (/ x s) (/ (* x 0.0625) s))) s)
       (/ (/ 1.0 (+ 4.0 (/ (* x x) (* s s)))) s)))
    float code(float x, float s) {
    	float tmp;
    	if (fabsf(x) <= 1.5000000786160286e-23f) {
    		tmp = (0.25f - ((x / s) * ((x * 0.0625f) / s))) / s;
    	} else {
    		tmp = (1.0f / (4.0f + ((x * x) / (s * s)))) / s;
    	}
    	return tmp;
    }
    
    real(4) function code(x, s)
        real(4), intent (in) :: x
        real(4), intent (in) :: s
        real(4) :: tmp
        if (abs(x) <= 1.5000000786160286e-23) then
            tmp = (0.25e0 - ((x / s) * ((x * 0.0625e0) / s))) / s
        else
            tmp = (1.0e0 / (4.0e0 + ((x * x) / (s * s)))) / s
        end if
        code = tmp
    end function
    
    function code(x, s)
    	tmp = Float32(0.0)
    	if (abs(x) <= Float32(1.5000000786160286e-23))
    		tmp = Float32(Float32(Float32(0.25) - Float32(Float32(x / s) * Float32(Float32(x * Float32(0.0625)) / s))) / s);
    	else
    		tmp = Float32(Float32(Float32(1.0) / Float32(Float32(4.0) + Float32(Float32(x * x) / Float32(s * s)))) / s);
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, s)
    	tmp = single(0.0);
    	if (abs(x) <= single(1.5000000786160286e-23))
    		tmp = (single(0.25) - ((x / s) * ((x * single(0.0625)) / s))) / s;
    	else
    		tmp = (single(1.0) / (single(4.0) + ((x * x) / (s * s)))) / s;
    	end
    	tmp_2 = tmp;
    end
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;\left|x\right| \leq 1.5000000786160286 \cdot 10^{-23}:\\
    \;\;\;\;\frac{0.25 - \frac{x}{s} \cdot \frac{x \cdot 0.0625}{s}}{s}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\frac{1}{4 + \frac{x \cdot x}{s \cdot s}}}{s}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (fabs.f32 x) < 1.50000008e-23

      1. Initial program 97.4%

        \[\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. Simplified96.7%

        \[\leadsto \color{blue}{\frac{\frac{1}{e^{-\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{s}} + 2\right)}}{s}} \]
      3. Add Preprocessing
      4. Taylor expanded in s around inf

        \[\leadsto \color{blue}{\frac{\left(\frac{1}{4} + -1 \cdot \frac{\frac{-1}{64} \cdot {\left(\left|x\right| + -1 \cdot \left|x\right|\right)}^{2} + \frac{1}{16} \cdot {\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right) - \frac{1}{16} \cdot \frac{\left|x\right| + -1 \cdot \left|x\right|}{s}}{s}} \]
      5. Simplified47.6%

        \[\leadsto \color{blue}{\frac{0.25 - \frac{\left(x \cdot x\right) \cdot 0.0625}{s \cdot s}}{s}} \]
      6. Step-by-step derivation
        1. associate-*l*N/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\frac{1}{4}, \left(\frac{x \cdot \left(x \cdot \frac{1}{16}\right)}{s \cdot s}\right)\right), s\right) \]
        2. times-fracN/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\frac{1}{4}, \left(\frac{x}{s} \cdot \frac{x \cdot \frac{1}{16}}{s}\right)\right), s\right) \]
        3. *-lowering-*.f32N/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(\left(\frac{x}{s}\right), \left(\frac{x \cdot \frac{1}{16}}{s}\right)\right)\right), s\right) \]
        4. /-lowering-/.f32N/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(\mathsf{/.f32}\left(x, s\right), \left(\frac{x \cdot \frac{1}{16}}{s}\right)\right)\right), s\right) \]
        5. /-lowering-/.f32N/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(\mathsf{/.f32}\left(x, s\right), \mathsf{/.f32}\left(\left(x \cdot \frac{1}{16}\right), s\right)\right)\right), s\right) \]
        6. *-lowering-*.f3266.3%

          \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(\mathsf{/.f32}\left(x, s\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(x, \frac{1}{16}\right), s\right)\right)\right), s\right) \]
      7. Applied egg-rr66.3%

        \[\leadsto \frac{0.25 - \color{blue}{\frac{x}{s} \cdot \frac{x \cdot 0.0625}{s}}}{s} \]

      if 1.50000008e-23 < (fabs.f32 x)

      1. Initial program 99.6%

        \[\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. Simplified99.7%

        \[\leadsto \color{blue}{\frac{\frac{1}{e^{-\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{s}} + 2\right)}}{s}} \]
      3. Add Preprocessing
      4. Taylor expanded in s around inf

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, \color{blue}{\left(4 + \left(-1 \cdot \frac{\left|x\right|}{s} + \left(\frac{\left|x\right|}{s} + \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)\right)\right)}\right), s\right) \]
      5. Step-by-step derivation
        1. associate-+r+N/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, \left(4 + \left(\left(-1 \cdot \frac{\left|x\right|}{s} + \frac{\left|x\right|}{s}\right) + \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)\right)\right), s\right) \]
        2. distribute-lft1-inN/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, \left(4 + \left(\left(-1 + 1\right) \cdot \frac{\left|x\right|}{s} + \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)\right)\right), s\right) \]
        3. metadata-evalN/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, \left(4 + \left(0 \cdot \frac{\left|x\right|}{s} + \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)\right)\right), s\right) \]
        4. mul0-lftN/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, \left(4 + \left(0 + \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)\right)\right), s\right) \]
        5. associate-+r+N/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, \left(\left(4 + 0\right) + \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)\right), s\right) \]
        6. metadata-evalN/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, \left(4 + \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)\right), s\right) \]
        7. +-lowering-+.f32N/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(4, \left(\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)\right)\right), s\right) \]
        8. /-lowering-/.f32N/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(4, \mathsf{/.f32}\left(\left({\left(\left|x\right|\right)}^{2}\right), \left({s}^{2}\right)\right)\right)\right), s\right) \]
        9. unpow2N/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(4, \mathsf{/.f32}\left(\left(\left|x\right| \cdot \left|x\right|\right), \left({s}^{2}\right)\right)\right)\right), s\right) \]
        10. sqr-absN/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(4, \mathsf{/.f32}\left(\left(x \cdot x\right), \left({s}^{2}\right)\right)\right)\right), s\right) \]
        11. *-lowering-*.f32N/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(4, \mathsf{/.f32}\left(\mathsf{*.f32}\left(x, x\right), \left({s}^{2}\right)\right)\right)\right), s\right) \]
        12. unpow2N/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(4, \mathsf{/.f32}\left(\mathsf{*.f32}\left(x, x\right), \left(s \cdot s\right)\right)\right)\right), s\right) \]
        13. *-lowering-*.f3283.6%

          \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(4, \mathsf{/.f32}\left(\mathsf{*.f32}\left(x, x\right), \mathsf{*.f32}\left(s, s\right)\right)\right)\right), s\right) \]
      6. Simplified83.6%

        \[\leadsto \frac{\frac{1}{\color{blue}{4 + \frac{x \cdot x}{s \cdot s}}}}{s} \]
    3. Recombined 2 regimes into one program.
    4. Add Preprocessing

    Alternative 14: 27.9% accurate, 34.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;s \leq 4.0000001089808046 \cdot 10^{-27}:\\ \;\;\;\;\frac{\frac{\frac{\left(x \cdot x\right) \cdot -0.0625}{s}}{s}}{s}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25 - \frac{x}{s} \cdot \frac{x \cdot 0.0625}{s}}{s}\\ \end{array} \end{array} \]
    (FPCore (x s)
     :precision binary32
     (if (<= s 4.0000001089808046e-27)
       (/ (/ (/ (* (* x x) -0.0625) s) s) s)
       (/ (- 0.25 (* (/ x s) (/ (* x 0.0625) s))) s)))
    float code(float x, float s) {
    	float tmp;
    	if (s <= 4.0000001089808046e-27f) {
    		tmp = ((((x * x) * -0.0625f) / s) / s) / s;
    	} else {
    		tmp = (0.25f - ((x / s) * ((x * 0.0625f) / s))) / s;
    	}
    	return tmp;
    }
    
    real(4) function code(x, s)
        real(4), intent (in) :: x
        real(4), intent (in) :: s
        real(4) :: tmp
        if (s <= 4.0000001089808046e-27) then
            tmp = ((((x * x) * (-0.0625e0)) / s) / s) / s
        else
            tmp = (0.25e0 - ((x / s) * ((x * 0.0625e0) / s))) / s
        end if
        code = tmp
    end function
    
    function code(x, s)
    	tmp = Float32(0.0)
    	if (s <= Float32(4.0000001089808046e-27))
    		tmp = Float32(Float32(Float32(Float32(Float32(x * x) * Float32(-0.0625)) / s) / s) / s);
    	else
    		tmp = Float32(Float32(Float32(0.25) - Float32(Float32(x / s) * Float32(Float32(x * Float32(0.0625)) / s))) / s);
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, s)
    	tmp = single(0.0);
    	if (s <= single(4.0000001089808046e-27))
    		tmp = ((((x * x) * single(-0.0625)) / s) / s) / s;
    	else
    		tmp = (single(0.25) - ((x / s) * ((x * single(0.0625)) / s))) / s;
    	end
    	tmp_2 = tmp;
    end
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;s \leq 4.0000001089808046 \cdot 10^{-27}:\\
    \;\;\;\;\frac{\frac{\frac{\left(x \cdot x\right) \cdot -0.0625}{s}}{s}}{s}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{0.25 - \frac{x}{s} \cdot \frac{x \cdot 0.0625}{s}}{s}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if s < 4.00000011e-27

      1. Initial program 98.2%

        \[\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. Simplified97.7%

        \[\leadsto \color{blue}{\frac{\frac{1}{e^{-\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{s}} + 2\right)}}{s}} \]
      3. Add Preprocessing
      4. Taylor expanded in s around inf

        \[\leadsto \color{blue}{\frac{\left(\frac{1}{4} + -1 \cdot \frac{\frac{-1}{64} \cdot {\left(\left|x\right| + -1 \cdot \left|x\right|\right)}^{2} + \frac{1}{16} \cdot {\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right) - \frac{1}{16} \cdot \frac{\left|x\right| + -1 \cdot \left|x\right|}{s}}{s}} \]
      5. Simplified2.1%

        \[\leadsto \color{blue}{\frac{0.25 - \frac{\left(x \cdot x\right) \cdot 0.0625}{s \cdot s}}{s}} \]
      6. Taylor expanded in x around inf

        \[\leadsto \color{blue}{\frac{-1}{16} \cdot \frac{{x}^{2}}{{s}^{3}}} \]
      7. Step-by-step derivation
        1. associate-*r/N/A

          \[\leadsto \frac{\frac{-1}{16} \cdot {x}^{2}}{\color{blue}{{s}^{3}}} \]
        2. unpow3N/A

          \[\leadsto \frac{\frac{-1}{16} \cdot {x}^{2}}{\left(s \cdot s\right) \cdot \color{blue}{s}} \]
        3. unpow2N/A

          \[\leadsto \frac{\frac{-1}{16} \cdot {x}^{2}}{{s}^{2} \cdot s} \]
        4. associate-/r*N/A

          \[\leadsto \frac{\frac{\frac{-1}{16} \cdot {x}^{2}}{{s}^{2}}}{\color{blue}{s}} \]
        5. *-commutativeN/A

          \[\leadsto \frac{\frac{{x}^{2} \cdot \frac{-1}{16}}{{s}^{2}}}{s} \]
        6. unpow2N/A

          \[\leadsto \frac{\frac{\left(x \cdot x\right) \cdot \frac{-1}{16}}{{s}^{2}}}{s} \]
        7. sqr-absN/A

          \[\leadsto \frac{\frac{\left(\left|x\right| \cdot \left|x\right|\right) \cdot \frac{-1}{16}}{{s}^{2}}}{s} \]
        8. unpow2N/A

          \[\leadsto \frac{\frac{{\left(\left|x\right|\right)}^{2} \cdot \frac{-1}{16}}{{s}^{2}}}{s} \]
        9. associate-*l/N/A

          \[\leadsto \frac{\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}} \cdot \frac{-1}{16}}{s} \]
        10. *-commutativeN/A

          \[\leadsto \frac{\frac{-1}{16} \cdot \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}}{s} \]
        11. metadata-evalN/A

          \[\leadsto \frac{\left(\mathsf{neg}\left(\frac{1}{16}\right)\right) \cdot \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}}{s} \]
        12. distribute-lft-neg-inN/A

          \[\leadsto \frac{\mathsf{neg}\left(\frac{1}{16} \cdot \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)}{s} \]
        13. /-lowering-/.f32N/A

          \[\leadsto \mathsf{/.f32}\left(\left(\mathsf{neg}\left(\frac{1}{16} \cdot \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)\right), \color{blue}{s}\right) \]
      8. Simplified21.4%

        \[\leadsto \color{blue}{\frac{-0.0625 \cdot \frac{\frac{x \cdot x}{s}}{s}}{s}} \]
      9. Step-by-step derivation
        1. associate-*r/N/A

          \[\leadsto \mathsf{/.f32}\left(\left(\frac{\frac{-1}{16} \cdot \frac{x \cdot x}{s}}{s}\right), s\right) \]
        2. /-lowering-/.f32N/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(\frac{-1}{16} \cdot \frac{x \cdot x}{s}\right), s\right), s\right) \]
        3. associate-*r/N/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(\frac{\frac{-1}{16} \cdot \left(x \cdot x\right)}{s}\right), s\right), s\right) \]
        4. /-lowering-/.f32N/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(\frac{-1}{16} \cdot \left(x \cdot x\right)\right), s\right), s\right), s\right) \]
        5. *-lowering-*.f32N/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{-1}{16}, \left(x \cdot x\right)\right), s\right), s\right), s\right) \]
        6. *-lowering-*.f3222.6%

          \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{-1}{16}, \mathsf{*.f32}\left(x, x\right)\right), s\right), s\right), s\right) \]
      10. Applied egg-rr22.6%

        \[\leadsto \frac{\color{blue}{\frac{\frac{-0.0625 \cdot \left(x \cdot x\right)}{s}}{s}}}{s} \]

      if 4.00000011e-27 < s

      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. Simplified99.6%

        \[\leadsto \color{blue}{\frac{\frac{1}{e^{-\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{s}} + 2\right)}}{s}} \]
      3. Add Preprocessing
      4. Taylor expanded in s around inf

        \[\leadsto \color{blue}{\frac{\left(\frac{1}{4} + -1 \cdot \frac{\frac{-1}{64} \cdot {\left(\left|x\right| + -1 \cdot \left|x\right|\right)}^{2} + \frac{1}{16} \cdot {\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right) - \frac{1}{16} \cdot \frac{\left|x\right| + -1 \cdot \left|x\right|}{s}}{s}} \]
      5. Simplified35.7%

        \[\leadsto \color{blue}{\frac{0.25 - \frac{\left(x \cdot x\right) \cdot 0.0625}{s \cdot s}}{s}} \]
      6. Step-by-step derivation
        1. associate-*l*N/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\frac{1}{4}, \left(\frac{x \cdot \left(x \cdot \frac{1}{16}\right)}{s \cdot s}\right)\right), s\right) \]
        2. times-fracN/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\frac{1}{4}, \left(\frac{x}{s} \cdot \frac{x \cdot \frac{1}{16}}{s}\right)\right), s\right) \]
        3. *-lowering-*.f32N/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(\left(\frac{x}{s}\right), \left(\frac{x \cdot \frac{1}{16}}{s}\right)\right)\right), s\right) \]
        4. /-lowering-/.f32N/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(\mathsf{/.f32}\left(x, s\right), \left(\frac{x \cdot \frac{1}{16}}{s}\right)\right)\right), s\right) \]
        5. /-lowering-/.f32N/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(\mathsf{/.f32}\left(x, s\right), \mathsf{/.f32}\left(\left(x \cdot \frac{1}{16}\right), s\right)\right)\right), s\right) \]
        6. *-lowering-*.f3237.8%

          \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(\mathsf{/.f32}\left(x, s\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(x, \frac{1}{16}\right), s\right)\right)\right), s\right) \]
      7. Applied egg-rr37.8%

        \[\leadsto \frac{0.25 - \color{blue}{\frac{x}{s} \cdot \frac{x \cdot 0.0625}{s}}}{s} \]
    3. Recombined 2 regimes into one program.
    4. Final simplification32.7%

      \[\leadsto \begin{array}{l} \mathbf{if}\;s \leq 4.0000001089808046 \cdot 10^{-27}:\\ \;\;\;\;\frac{\frac{\frac{\left(x \cdot x\right) \cdot -0.0625}{s}}{s}}{s}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25 - \frac{x}{s} \cdot \frac{x \cdot 0.0625}{s}}{s}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 15: 28.6% accurate, 38.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;s \leq 2.0000000063421537 \cdot 10^{-28}:\\ \;\;\;\;\frac{\frac{\frac{\left(x \cdot x\right) \cdot -0.0625}{s}}{s}}{s}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25}{s}\\ \end{array} \end{array} \]
    (FPCore (x s)
     :precision binary32
     (if (<= s 2.0000000063421537e-28)
       (/ (/ (/ (* (* x x) -0.0625) s) s) s)
       (/ 0.25 s)))
    float code(float x, float s) {
    	float tmp;
    	if (s <= 2.0000000063421537e-28f) {
    		tmp = ((((x * x) * -0.0625f) / s) / s) / s;
    	} else {
    		tmp = 0.25f / s;
    	}
    	return tmp;
    }
    
    real(4) function code(x, s)
        real(4), intent (in) :: x
        real(4), intent (in) :: s
        real(4) :: tmp
        if (s <= 2.0000000063421537e-28) then
            tmp = ((((x * x) * (-0.0625e0)) / s) / s) / s
        else
            tmp = 0.25e0 / s
        end if
        code = tmp
    end function
    
    function code(x, s)
    	tmp = Float32(0.0)
    	if (s <= Float32(2.0000000063421537e-28))
    		tmp = Float32(Float32(Float32(Float32(Float32(x * x) * Float32(-0.0625)) / s) / s) / s);
    	else
    		tmp = Float32(Float32(0.25) / s);
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, s)
    	tmp = single(0.0);
    	if (s <= single(2.0000000063421537e-28))
    		tmp = ((((x * x) * single(-0.0625)) / s) / s) / s;
    	else
    		tmp = single(0.25) / s;
    	end
    	tmp_2 = tmp;
    end
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;s \leq 2.0000000063421537 \cdot 10^{-28}:\\
    \;\;\;\;\frac{\frac{\frac{\left(x \cdot x\right) \cdot -0.0625}{s}}{s}}{s}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{0.25}{s}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if s < 2.00000001e-28

      1. Initial program 98.2%

        \[\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. Simplified97.5%

        \[\leadsto \color{blue}{\frac{\frac{1}{e^{-\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{s}} + 2\right)}}{s}} \]
      3. Add Preprocessing
      4. Taylor expanded in s around inf

        \[\leadsto \color{blue}{\frac{\left(\frac{1}{4} + -1 \cdot \frac{\frac{-1}{64} \cdot {\left(\left|x\right| + -1 \cdot \left|x\right|\right)}^{2} + \frac{1}{16} \cdot {\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right) - \frac{1}{16} \cdot \frac{\left|x\right| + -1 \cdot \left|x\right|}{s}}{s}} \]
      5. Simplified2.1%

        \[\leadsto \color{blue}{\frac{0.25 - \frac{\left(x \cdot x\right) \cdot 0.0625}{s \cdot s}}{s}} \]
      6. Taylor expanded in x around inf

        \[\leadsto \color{blue}{\frac{-1}{16} \cdot \frac{{x}^{2}}{{s}^{3}}} \]
      7. Step-by-step derivation
        1. associate-*r/N/A

          \[\leadsto \frac{\frac{-1}{16} \cdot {x}^{2}}{\color{blue}{{s}^{3}}} \]
        2. unpow3N/A

          \[\leadsto \frac{\frac{-1}{16} \cdot {x}^{2}}{\left(s \cdot s\right) \cdot \color{blue}{s}} \]
        3. unpow2N/A

          \[\leadsto \frac{\frac{-1}{16} \cdot {x}^{2}}{{s}^{2} \cdot s} \]
        4. associate-/r*N/A

          \[\leadsto \frac{\frac{\frac{-1}{16} \cdot {x}^{2}}{{s}^{2}}}{\color{blue}{s}} \]
        5. *-commutativeN/A

          \[\leadsto \frac{\frac{{x}^{2} \cdot \frac{-1}{16}}{{s}^{2}}}{s} \]
        6. unpow2N/A

          \[\leadsto \frac{\frac{\left(x \cdot x\right) \cdot \frac{-1}{16}}{{s}^{2}}}{s} \]
        7. sqr-absN/A

          \[\leadsto \frac{\frac{\left(\left|x\right| \cdot \left|x\right|\right) \cdot \frac{-1}{16}}{{s}^{2}}}{s} \]
        8. unpow2N/A

          \[\leadsto \frac{\frac{{\left(\left|x\right|\right)}^{2} \cdot \frac{-1}{16}}{{s}^{2}}}{s} \]
        9. associate-*l/N/A

          \[\leadsto \frac{\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}} \cdot \frac{-1}{16}}{s} \]
        10. *-commutativeN/A

          \[\leadsto \frac{\frac{-1}{16} \cdot \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}}{s} \]
        11. metadata-evalN/A

          \[\leadsto \frac{\left(\mathsf{neg}\left(\frac{1}{16}\right)\right) \cdot \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}}{s} \]
        12. distribute-lft-neg-inN/A

          \[\leadsto \frac{\mathsf{neg}\left(\frac{1}{16} \cdot \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)}{s} \]
        13. /-lowering-/.f32N/A

          \[\leadsto \mathsf{/.f32}\left(\left(\mathsf{neg}\left(\frac{1}{16} \cdot \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)\right), \color{blue}{s}\right) \]
      8. Simplified21.8%

        \[\leadsto \color{blue}{\frac{-0.0625 \cdot \frac{\frac{x \cdot x}{s}}{s}}{s}} \]
      9. Step-by-step derivation
        1. associate-*r/N/A

          \[\leadsto \mathsf{/.f32}\left(\left(\frac{\frac{-1}{16} \cdot \frac{x \cdot x}{s}}{s}\right), s\right) \]
        2. /-lowering-/.f32N/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(\frac{-1}{16} \cdot \frac{x \cdot x}{s}\right), s\right), s\right) \]
        3. associate-*r/N/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(\frac{\frac{-1}{16} \cdot \left(x \cdot x\right)}{s}\right), s\right), s\right) \]
        4. /-lowering-/.f32N/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(\frac{-1}{16} \cdot \left(x \cdot x\right)\right), s\right), s\right), s\right) \]
        5. *-lowering-*.f32N/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{-1}{16}, \left(x \cdot x\right)\right), s\right), s\right), s\right) \]
        6. *-lowering-*.f3223.0%

          \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{-1}{16}, \mathsf{*.f32}\left(x, x\right)\right), s\right), s\right), s\right) \]
      10. Applied egg-rr23.0%

        \[\leadsto \frac{\color{blue}{\frac{\frac{-0.0625 \cdot \left(x \cdot x\right)}{s}}{s}}}{s} \]

      if 2.00000001e-28 < s

      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. Add Preprocessing
      3. Taylor expanded in s around inf

        \[\leadsto \color{blue}{\frac{\frac{1}{4}}{s}} \]
      4. Step-by-step derivation
        1. /-lowering-/.f3236.9%

          \[\leadsto \mathsf{/.f32}\left(\frac{1}{4}, \color{blue}{s}\right) \]
      5. Simplified36.9%

        \[\leadsto \color{blue}{\frac{0.25}{s}} \]
    3. Recombined 2 regimes into one program.
    4. Final simplification32.6%

      \[\leadsto \begin{array}{l} \mathbf{if}\;s \leq 2.0000000063421537 \cdot 10^{-28}:\\ \;\;\;\;\frac{\frac{\frac{\left(x \cdot x\right) \cdot -0.0625}{s}}{s}}{s}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25}{s}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 16: 28.3% accurate, 38.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;s \leq 2.0000000063421537 \cdot 10^{-28}:\\ \;\;\;\;\frac{-0.0625 \cdot \frac{\frac{x \cdot x}{s}}{s}}{s}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25}{s}\\ \end{array} \end{array} \]
    (FPCore (x s)
     :precision binary32
     (if (<= s 2.0000000063421537e-28)
       (/ (* -0.0625 (/ (/ (* x x) s) s)) s)
       (/ 0.25 s)))
    float code(float x, float s) {
    	float tmp;
    	if (s <= 2.0000000063421537e-28f) {
    		tmp = (-0.0625f * (((x * x) / s) / s)) / s;
    	} else {
    		tmp = 0.25f / s;
    	}
    	return tmp;
    }
    
    real(4) function code(x, s)
        real(4), intent (in) :: x
        real(4), intent (in) :: s
        real(4) :: tmp
        if (s <= 2.0000000063421537e-28) then
            tmp = ((-0.0625e0) * (((x * x) / s) / s)) / s
        else
            tmp = 0.25e0 / s
        end if
        code = tmp
    end function
    
    function code(x, s)
    	tmp = Float32(0.0)
    	if (s <= Float32(2.0000000063421537e-28))
    		tmp = Float32(Float32(Float32(-0.0625) * Float32(Float32(Float32(x * x) / s) / s)) / s);
    	else
    		tmp = Float32(Float32(0.25) / s);
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, s)
    	tmp = single(0.0);
    	if (s <= single(2.0000000063421537e-28))
    		tmp = (single(-0.0625) * (((x * x) / s) / s)) / s;
    	else
    		tmp = single(0.25) / s;
    	end
    	tmp_2 = tmp;
    end
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;s \leq 2.0000000063421537 \cdot 10^{-28}:\\
    \;\;\;\;\frac{-0.0625 \cdot \frac{\frac{x \cdot x}{s}}{s}}{s}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{0.25}{s}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if s < 2.00000001e-28

      1. Initial program 98.2%

        \[\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. Simplified97.5%

        \[\leadsto \color{blue}{\frac{\frac{1}{e^{-\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{s}} + 2\right)}}{s}} \]
      3. Add Preprocessing
      4. Taylor expanded in s around inf

        \[\leadsto \color{blue}{\frac{\left(\frac{1}{4} + -1 \cdot \frac{\frac{-1}{64} \cdot {\left(\left|x\right| + -1 \cdot \left|x\right|\right)}^{2} + \frac{1}{16} \cdot {\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right) - \frac{1}{16} \cdot \frac{\left|x\right| + -1 \cdot \left|x\right|}{s}}{s}} \]
      5. Simplified2.1%

        \[\leadsto \color{blue}{\frac{0.25 - \frac{\left(x \cdot x\right) \cdot 0.0625}{s \cdot s}}{s}} \]
      6. Taylor expanded in x around inf

        \[\leadsto \color{blue}{\frac{-1}{16} \cdot \frac{{x}^{2}}{{s}^{3}}} \]
      7. Step-by-step derivation
        1. associate-*r/N/A

          \[\leadsto \frac{\frac{-1}{16} \cdot {x}^{2}}{\color{blue}{{s}^{3}}} \]
        2. unpow3N/A

          \[\leadsto \frac{\frac{-1}{16} \cdot {x}^{2}}{\left(s \cdot s\right) \cdot \color{blue}{s}} \]
        3. unpow2N/A

          \[\leadsto \frac{\frac{-1}{16} \cdot {x}^{2}}{{s}^{2} \cdot s} \]
        4. associate-/r*N/A

          \[\leadsto \frac{\frac{\frac{-1}{16} \cdot {x}^{2}}{{s}^{2}}}{\color{blue}{s}} \]
        5. *-commutativeN/A

          \[\leadsto \frac{\frac{{x}^{2} \cdot \frac{-1}{16}}{{s}^{2}}}{s} \]
        6. unpow2N/A

          \[\leadsto \frac{\frac{\left(x \cdot x\right) \cdot \frac{-1}{16}}{{s}^{2}}}{s} \]
        7. sqr-absN/A

          \[\leadsto \frac{\frac{\left(\left|x\right| \cdot \left|x\right|\right) \cdot \frac{-1}{16}}{{s}^{2}}}{s} \]
        8. unpow2N/A

          \[\leadsto \frac{\frac{{\left(\left|x\right|\right)}^{2} \cdot \frac{-1}{16}}{{s}^{2}}}{s} \]
        9. associate-*l/N/A

          \[\leadsto \frac{\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}} \cdot \frac{-1}{16}}{s} \]
        10. *-commutativeN/A

          \[\leadsto \frac{\frac{-1}{16} \cdot \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}}{s} \]
        11. metadata-evalN/A

          \[\leadsto \frac{\left(\mathsf{neg}\left(\frac{1}{16}\right)\right) \cdot \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}}{s} \]
        12. distribute-lft-neg-inN/A

          \[\leadsto \frac{\mathsf{neg}\left(\frac{1}{16} \cdot \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)}{s} \]
        13. /-lowering-/.f32N/A

          \[\leadsto \mathsf{/.f32}\left(\left(\mathsf{neg}\left(\frac{1}{16} \cdot \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)\right), \color{blue}{s}\right) \]
      8. Simplified21.8%

        \[\leadsto \color{blue}{\frac{-0.0625 \cdot \frac{\frac{x \cdot x}{s}}{s}}{s}} \]

      if 2.00000001e-28 < s

      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. Add Preprocessing
      3. Taylor expanded in s around inf

        \[\leadsto \color{blue}{\frac{\frac{1}{4}}{s}} \]
      4. Step-by-step derivation
        1. /-lowering-/.f3236.9%

          \[\leadsto \mathsf{/.f32}\left(\frac{1}{4}, \color{blue}{s}\right) \]
      5. Simplified36.9%

        \[\leadsto \color{blue}{\frac{0.25}{s}} \]
    3. Recombined 2 regimes into one program.
    4. Add Preprocessing

    Alternative 17: 27.1% accurate, 206.7× speedup?

    \[\begin{array}{l} \\ \frac{0.25}{s} \end{array} \]
    (FPCore (x s) :precision binary32 (/ 0.25 s))
    float code(float x, float s) {
    	return 0.25f / s;
    }
    
    real(4) function code(x, s)
        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
    
    \begin{array}{l}
    
    \\
    \frac{0.25}{s}
    \end{array}
    
    Derivation
    1. Initial program 99.1%

      \[\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. Add Preprocessing
    3. Taylor expanded in s around inf

      \[\leadsto \color{blue}{\frac{\frac{1}{4}}{s}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f3228.7%

        \[\leadsto \mathsf{/.f32}\left(\frac{1}{4}, \color{blue}{s}\right) \]
    5. Simplified28.7%

      \[\leadsto \color{blue}{\frac{0.25}{s}} \]
    6. Add Preprocessing

    Reproduce

    ?
    herbie shell --seed 2024161 
    (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))))))