Logistic distribution

Percentage Accurate: 99.6% → 99.6%
Time: 14.7s
Alternatives: 23
Speedup: 1.1×

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 23 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.6% 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.6% accurate, 0.8× speedup?

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

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

    \[\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. lift-fabs.f32N/A

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \]
  4. Applied egg-rr99.0%

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

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

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

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

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

      \[\leadsto \frac{1}{\frac{{\left(e^{\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)} + 1\right)}^{2}}{\frac{\color{blue}{{\left(e^{-1}\right)}^{\left(\frac{\left|x\right|}{s}\right)}}}{s}}} \]
    6. lower-exp.f3299.0

      \[\leadsto \frac{1}{\frac{{\left(e^{-\frac{\left|x\right|}{s}} + 1\right)}^{2}}{\frac{{\color{blue}{\left(e^{-1}\right)}}^{\left(\frac{\left|x\right|}{s}\right)}}{s}}} \]
  6. Applied egg-rr99.0%

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

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

Alternative 2: 97.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-\frac{\left|x\right|}{s}}\\ t_1 := 1 + t\_0\\ \mathbf{if}\;\frac{t\_0}{t\_1 \cdot \left(s \cdot t\_1\right)} \leq 4.999999841327613 \cdot 10^{-22}:\\ \;\;\;\;\frac{t\_0}{s}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(x, \frac{x}{s}, s \cdot 4\right)}\\ \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (let* ((t_0 (exp (- (/ (fabs x) s)))) (t_1 (+ 1.0 t_0)))
   (if (<= (/ t_0 (* t_1 (* s t_1))) 4.999999841327613e-22)
     (/ t_0 s)
     (/ 1.0 (fma x (/ x s) (* s 4.0))))))
float code(float x, float s) {
	float t_0 = expf(-(fabsf(x) / s));
	float t_1 = 1.0f + t_0;
	float tmp;
	if ((t_0 / (t_1 * (s * t_1))) <= 4.999999841327613e-22f) {
		tmp = t_0 / s;
	} else {
		tmp = 1.0f / fmaf(x, (x / s), (s * 4.0f));
	}
	return tmp;
}
function code(x, s)
	t_0 = exp(Float32(-Float32(abs(x) / s)))
	t_1 = Float32(Float32(1.0) + t_0)
	tmp = Float32(0.0)
	if (Float32(t_0 / Float32(t_1 * Float32(s * t_1))) <= Float32(4.999999841327613e-22))
		tmp = Float32(t_0 / s);
	else
		tmp = Float32(Float32(1.0) / fma(x, Float32(x / s), Float32(s * Float32(4.0))));
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{-\frac{\left|x\right|}{s}}\\
t_1 := 1 + t\_0\\
\mathbf{if}\;\frac{t\_0}{t\_1 \cdot \left(s \cdot t\_1\right)} \leq 4.999999841327613 \cdot 10^{-22}:\\
\;\;\;\;\frac{t\_0}{s}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(x, \frac{x}{s}, s \cdot 4\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s))))) < 4.9999998e-22

    1. Initial program 99.0%

      \[\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. lift-fabs.f32N/A

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \]
    4. Applied egg-rr99.0%

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

      \[\leadsto \color{blue}{\frac{e^{\mathsf{fma}\left(\mathsf{log1p}\left(e^{\frac{\left|x\right|}{-s}}\right), -2, \frac{\left|x\right|}{-s}\right)}}{s}} \]
    6. Taylor expanded in s around 0

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

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

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

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

        \[\leadsto \frac{e^{\frac{\color{blue}{\left|x\right|}}{\mathsf{neg}\left(s\right)}}}{s} \]
      5. lower-neg.f3299.0

        \[\leadsto \frac{e^{\frac{\left|x\right|}{\color{blue}{-s}}}}{s} \]
    8. Simplified99.0%

      \[\leadsto \frac{e^{\color{blue}{\frac{\left|x\right|}{-s}}}}{s} \]

    if 4.9999998e-22 < (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))))

    1. Initial program 98.7%

      \[\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. lift-fabs.f32N/A

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \]
    4. Applied egg-rr99.1%

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

      \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)}} \]
    6. Step-by-step derivation
      1. lower-*.f32N/A

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

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

        \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}}\right)} \]
      4. unpow2N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{\left|x\right| \cdot \left|x\right|}}{{s}^{2}}\right)} \]
      5. sqr-absN/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
      6. lower-*.f32N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
      7. unpow2N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
      8. lower-*.f3280.3

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
    7. Simplified80.3%

      \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{x \cdot x}{s \cdot s}\right)}} \]
    8. Step-by-step derivation
      1. lift-*.f32N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{s \cdot s}\right)} \]
      2. lift-*.f32N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
      3. lift-/.f32N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{x \cdot x}{s \cdot s}}\right)} \]
      4. +-commutativeN/A

        \[\leadsto \frac{1}{s \cdot \color{blue}{\left(\frac{x \cdot x}{s \cdot s} + 4\right)}} \]
      5. distribute-rgt-inN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x}{s \cdot s} \cdot s + 4 \cdot s}} \]
      6. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{x \cdot x}{s \cdot s} \cdot s + \color{blue}{s \cdot 4}} \]
      7. lift-*.f32N/A

        \[\leadsto \frac{1}{\frac{x \cdot x}{s \cdot s} \cdot s + \color{blue}{s \cdot 4}} \]
      8. lift-/.f32N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x}{s \cdot s}} \cdot s + s \cdot 4} \]
      9. div-invN/A

        \[\leadsto \frac{1}{\color{blue}{\left(\left(x \cdot x\right) \cdot \frac{1}{s \cdot s}\right)} \cdot s + s \cdot 4} \]
      10. associate-*l*N/A

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot x\right) \cdot \left(\frac{1}{s \cdot s} \cdot s\right)} + s \cdot 4} \]
      11. lift-*.f32N/A

        \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot \left(\frac{1}{\color{blue}{s \cdot s}} \cdot s\right) + s \cdot 4} \]
      12. pow2N/A

        \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot \left(\frac{1}{\color{blue}{{s}^{2}}} \cdot s\right) + s \cdot 4} \]
      13. pow-flipN/A

        \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot \left(\color{blue}{{s}^{\left(\mathsf{neg}\left(2\right)\right)}} \cdot s\right) + s \cdot 4} \]
      14. metadata-evalN/A

        \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot \left({s}^{\color{blue}{-2}} \cdot s\right) + s \cdot 4} \]
      15. pow-plusN/A

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

        \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot {s}^{\color{blue}{-1}} + s \cdot 4} \]
      17. inv-powN/A

        \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot \color{blue}{\frac{1}{s}} + s \cdot 4} \]
      18. div-invN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x}{s}} + s \cdot 4} \]
      19. lift-*.f32N/A

        \[\leadsto \frac{1}{\frac{\color{blue}{x \cdot x}}{s} + s \cdot 4} \]
      20. associate-/l*N/A

        \[\leadsto \frac{1}{\color{blue}{x \cdot \frac{x}{s}} + s \cdot 4} \]
      21. lower-fma.f32N/A

        \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(x, \frac{x}{s}, s \cdot 4\right)}} \]
    9. Applied egg-rr94.0%

      \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(x, \frac{x}{s}, s \cdot 4\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{e^{-\frac{\left|x\right|}{s}}}{\left(1 + e^{-\frac{\left|x\right|}{s}}\right) \cdot \left(s \cdot \left(1 + e^{-\frac{\left|x\right|}{s}}\right)\right)} \leq 4.999999841327613 \cdot 10^{-22}:\\ \;\;\;\;\frac{e^{-\frac{\left|x\right|}{s}}}{s}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(x, \frac{x}{s}, s \cdot 4\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 97.6% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-\frac{\left|x\right|}{s}}\\ t_1 := 1 + t\_0\\ \mathbf{if}\;\frac{t\_0}{t\_1 \cdot \left(s \cdot t\_1\right)} \leq 4.999999841327613 \cdot 10^{-22}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(x, \frac{x}{s}, s \cdot 4\right)}\\ \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (let* ((t_0 (exp (- (/ (fabs x) s)))) (t_1 (+ 1.0 t_0)))
   (if (<= (/ t_0 (* t_1 (* s t_1))) 4.999999841327613e-22)
     t_0
     (/ 1.0 (fma x (/ x s) (* s 4.0))))))
float code(float x, float s) {
	float t_0 = expf(-(fabsf(x) / s));
	float t_1 = 1.0f + t_0;
	float tmp;
	if ((t_0 / (t_1 * (s * t_1))) <= 4.999999841327613e-22f) {
		tmp = t_0;
	} else {
		tmp = 1.0f / fmaf(x, (x / s), (s * 4.0f));
	}
	return tmp;
}
function code(x, s)
	t_0 = exp(Float32(-Float32(abs(x) / s)))
	t_1 = Float32(Float32(1.0) + t_0)
	tmp = Float32(0.0)
	if (Float32(t_0 / Float32(t_1 * Float32(s * t_1))) <= Float32(4.999999841327613e-22))
		tmp = t_0;
	else
		tmp = Float32(Float32(1.0) / fma(x, Float32(x / s), Float32(s * Float32(4.0))));
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{-\frac{\left|x\right|}{s}}\\
t_1 := 1 + t\_0\\
\mathbf{if}\;\frac{t\_0}{t\_1 \cdot \left(s \cdot t\_1\right)} \leq 4.999999841327613 \cdot 10^{-22}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(x, \frac{x}{s}, s \cdot 4\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s))))) < 4.9999998e-22

    1. Initial program 99.0%

      \[\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. Applied egg-rr99.7%

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

      \[\leadsto e^{\color{blue}{-1 \cdot \frac{\left|x\right|}{s}}} \]
    5. Step-by-step derivation
      1. neg-mul-1N/A

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

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

        \[\leadsto e^{\mathsf{neg}\left(\color{blue}{\frac{\left|x\right|}{s}}\right)} \]
      4. lower-fabs.f3298.4

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

      \[\leadsto e^{\color{blue}{-\frac{\left|x\right|}{s}}} \]

    if 4.9999998e-22 < (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))))

    1. Initial program 98.7%

      \[\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. lift-fabs.f32N/A

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \]
    4. Applied egg-rr99.1%

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

      \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)}} \]
    6. Step-by-step derivation
      1. lower-*.f32N/A

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

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

        \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}}\right)} \]
      4. unpow2N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{\left|x\right| \cdot \left|x\right|}}{{s}^{2}}\right)} \]
      5. sqr-absN/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
      6. lower-*.f32N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
      7. unpow2N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
      8. lower-*.f3280.3

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
    7. Simplified80.3%

      \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{x \cdot x}{s \cdot s}\right)}} \]
    8. Step-by-step derivation
      1. lift-*.f32N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{s \cdot s}\right)} \]
      2. lift-*.f32N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
      3. lift-/.f32N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{x \cdot x}{s \cdot s}}\right)} \]
      4. +-commutativeN/A

        \[\leadsto \frac{1}{s \cdot \color{blue}{\left(\frac{x \cdot x}{s \cdot s} + 4\right)}} \]
      5. distribute-rgt-inN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x}{s \cdot s} \cdot s + 4 \cdot s}} \]
      6. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{x \cdot x}{s \cdot s} \cdot s + \color{blue}{s \cdot 4}} \]
      7. lift-*.f32N/A

        \[\leadsto \frac{1}{\frac{x \cdot x}{s \cdot s} \cdot s + \color{blue}{s \cdot 4}} \]
      8. lift-/.f32N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x}{s \cdot s}} \cdot s + s \cdot 4} \]
      9. div-invN/A

        \[\leadsto \frac{1}{\color{blue}{\left(\left(x \cdot x\right) \cdot \frac{1}{s \cdot s}\right)} \cdot s + s \cdot 4} \]
      10. associate-*l*N/A

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot x\right) \cdot \left(\frac{1}{s \cdot s} \cdot s\right)} + s \cdot 4} \]
      11. lift-*.f32N/A

        \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot \left(\frac{1}{\color{blue}{s \cdot s}} \cdot s\right) + s \cdot 4} \]
      12. pow2N/A

        \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot \left(\frac{1}{\color{blue}{{s}^{2}}} \cdot s\right) + s \cdot 4} \]
      13. pow-flipN/A

        \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot \left(\color{blue}{{s}^{\left(\mathsf{neg}\left(2\right)\right)}} \cdot s\right) + s \cdot 4} \]
      14. metadata-evalN/A

        \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot \left({s}^{\color{blue}{-2}} \cdot s\right) + s \cdot 4} \]
      15. pow-plusN/A

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

        \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot {s}^{\color{blue}{-1}} + s \cdot 4} \]
      17. inv-powN/A

        \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot \color{blue}{\frac{1}{s}} + s \cdot 4} \]
      18. div-invN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x}{s}} + s \cdot 4} \]
      19. lift-*.f32N/A

        \[\leadsto \frac{1}{\frac{\color{blue}{x \cdot x}}{s} + s \cdot 4} \]
      20. associate-/l*N/A

        \[\leadsto \frac{1}{\color{blue}{x \cdot \frac{x}{s}} + s \cdot 4} \]
      21. lower-fma.f32N/A

        \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(x, \frac{x}{s}, s \cdot 4\right)}} \]
    9. Applied egg-rr94.0%

      \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(x, \frac{x}{s}, s \cdot 4\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{e^{-\frac{\left|x\right|}{s}}}{\left(1 + e^{-\frac{\left|x\right|}{s}}\right) \cdot \left(s \cdot \left(1 + e^{-\frac{\left|x\right|}{s}}\right)\right)} \leq 4.999999841327613 \cdot 10^{-22}:\\ \;\;\;\;e^{-\frac{\left|x\right|}{s}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(x, \frac{x}{s}, s \cdot 4\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 99.6% accurate, 0.8× speedup?

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

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

    \[\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. lift-fabs.f32N/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\color{blue}{\left|x\right|}\right)}{s}}\right)} \]
    11. remove-double-negN/A

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

      \[\leadsto \frac{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\left|x\right|\right)\right)}\right)\right)\right)}{s}}\right)} \]
    13. remove-double-negN/A

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

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

      \[\leadsto \frac{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\color{blue}{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}\right)} \]
  4. Applied egg-rr99.0%

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{{\left(e^{-1}\right)}^{\left(\frac{\left|x\right|}{s}\right)}}}{{\left(e^{\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)} + 1\right)}^{2} \cdot s} \]
    7. lower-exp.f3299.0

      \[\leadsto \frac{{\color{blue}{\left(e^{-1}\right)}}^{\left(\frac{\left|x\right|}{s}\right)}}{{\left(e^{-\frac{\left|x\right|}{s}} + 1\right)}^{2} \cdot s} \]
  6. Applied egg-rr99.0%

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

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

Alternative 5: 82.2% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-\frac{\left|x\right|}{s}}\\ t_1 := 1 + t\_0\\ \mathbf{if}\;\frac{t\_0}{t\_1 \cdot \left(s \cdot t\_1\right)} \leq 0:\\ \;\;\;\;\frac{1}{s \cdot \frac{x \cdot x}{s \cdot s}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(x, \frac{x}{s}, s \cdot 4\right)}\\ \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (let* ((t_0 (exp (- (/ (fabs x) s)))) (t_1 (+ 1.0 t_0)))
   (if (<= (/ t_0 (* t_1 (* s t_1))) 0.0)
     (/ 1.0 (* s (/ (* x x) (* s s))))
     (/ 1.0 (fma x (/ x s) (* s 4.0))))))
float code(float x, float s) {
	float t_0 = expf(-(fabsf(x) / s));
	float t_1 = 1.0f + t_0;
	float tmp;
	if ((t_0 / (t_1 * (s * t_1))) <= 0.0f) {
		tmp = 1.0f / (s * ((x * x) / (s * s)));
	} else {
		tmp = 1.0f / fmaf(x, (x / s), (s * 4.0f));
	}
	return tmp;
}
function code(x, s)
	t_0 = exp(Float32(-Float32(abs(x) / s)))
	t_1 = Float32(Float32(1.0) + t_0)
	tmp = Float32(0.0)
	if (Float32(t_0 / Float32(t_1 * Float32(s * t_1))) <= Float32(0.0))
		tmp = Float32(Float32(1.0) / Float32(s * Float32(Float32(x * x) / Float32(s * s))));
	else
		tmp = Float32(Float32(1.0) / fma(x, Float32(x / s), Float32(s * Float32(4.0))));
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{-\frac{\left|x\right|}{s}}\\
t_1 := 1 + t\_0\\
\mathbf{if}\;\frac{t\_0}{t\_1 \cdot \left(s \cdot t\_1\right)} \leq 0:\\
\;\;\;\;\frac{1}{s \cdot \frac{x \cdot x}{s \cdot s}}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(x, \frac{x}{s}, s \cdot 4\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s))))) < 0.0

    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. lift-fabs.f32N/A

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \]
    4. Applied egg-rr99.1%

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

      \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)}} \]
    6. Step-by-step derivation
      1. lower-*.f32N/A

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

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

        \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}}\right)} \]
      4. unpow2N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{\left|x\right| \cdot \left|x\right|}}{{s}^{2}}\right)} \]
      5. sqr-absN/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
      6. lower-*.f32N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
      7. unpow2N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
      8. lower-*.f3277.9

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
    7. Simplified77.9%

      \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{x \cdot x}{s \cdot s}\right)}} \]
    8. Taylor expanded in x around inf

      \[\leadsto \frac{1}{s \cdot \color{blue}{\frac{{x}^{2}}{{s}^{2}}}} \]
    9. Step-by-step derivation
      1. lower-/.f32N/A

        \[\leadsto \frac{1}{s \cdot \color{blue}{\frac{{x}^{2}}{{s}^{2}}}} \]
      2. unpow2N/A

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

        \[\leadsto \frac{1}{s \cdot \frac{\color{blue}{x \cdot x}}{{s}^{2}}} \]
      4. unpow2N/A

        \[\leadsto \frac{1}{s \cdot \frac{x \cdot x}{\color{blue}{s \cdot s}}} \]
      5. lower-*.f3277.9

        \[\leadsto \frac{1}{s \cdot \frac{x \cdot x}{\color{blue}{s \cdot s}}} \]
    10. Simplified77.9%

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

    if 0.0 < (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))))

    1. Initial program 98.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. Step-by-step derivation
      1. lift-fabs.f32N/A

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \]
    4. Applied egg-rr98.8%

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

      \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)}} \]
    6. Step-by-step derivation
      1. lower-*.f32N/A

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

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

        \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}}\right)} \]
      4. unpow2N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{\left|x\right| \cdot \left|x\right|}}{{s}^{2}}\right)} \]
      5. sqr-absN/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
      6. lower-*.f32N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
      7. unpow2N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
      8. lower-*.f3277.9

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
    7. Simplified77.9%

      \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{x \cdot x}{s \cdot s}\right)}} \]
    8. Step-by-step derivation
      1. lift-*.f32N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{s \cdot s}\right)} \]
      2. lift-*.f32N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
      3. lift-/.f32N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{x \cdot x}{s \cdot s}}\right)} \]
      4. +-commutativeN/A

        \[\leadsto \frac{1}{s \cdot \color{blue}{\left(\frac{x \cdot x}{s \cdot s} + 4\right)}} \]
      5. distribute-rgt-inN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x}{s \cdot s} \cdot s + 4 \cdot s}} \]
      6. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{x \cdot x}{s \cdot s} \cdot s + \color{blue}{s \cdot 4}} \]
      7. lift-*.f32N/A

        \[\leadsto \frac{1}{\frac{x \cdot x}{s \cdot s} \cdot s + \color{blue}{s \cdot 4}} \]
      8. lift-/.f32N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x}{s \cdot s}} \cdot s + s \cdot 4} \]
      9. div-invN/A

        \[\leadsto \frac{1}{\color{blue}{\left(\left(x \cdot x\right) \cdot \frac{1}{s \cdot s}\right)} \cdot s + s \cdot 4} \]
      10. associate-*l*N/A

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot x\right) \cdot \left(\frac{1}{s \cdot s} \cdot s\right)} + s \cdot 4} \]
      11. lift-*.f32N/A

        \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot \left(\frac{1}{\color{blue}{s \cdot s}} \cdot s\right) + s \cdot 4} \]
      12. pow2N/A

        \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot \left(\frac{1}{\color{blue}{{s}^{2}}} \cdot s\right) + s \cdot 4} \]
      13. pow-flipN/A

        \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot \left(\color{blue}{{s}^{\left(\mathsf{neg}\left(2\right)\right)}} \cdot s\right) + s \cdot 4} \]
      14. metadata-evalN/A

        \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot \left({s}^{\color{blue}{-2}} \cdot s\right) + s \cdot 4} \]
      15. pow-plusN/A

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

        \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot {s}^{\color{blue}{-1}} + s \cdot 4} \]
      17. inv-powN/A

        \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot \color{blue}{\frac{1}{s}} + s \cdot 4} \]
      18. div-invN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x}{s}} + s \cdot 4} \]
      19. lift-*.f32N/A

        \[\leadsto \frac{1}{\frac{\color{blue}{x \cdot x}}{s} + s \cdot 4} \]
      20. associate-/l*N/A

        \[\leadsto \frac{1}{\color{blue}{x \cdot \frac{x}{s}} + s \cdot 4} \]
      21. lower-fma.f32N/A

        \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(x, \frac{x}{s}, s \cdot 4\right)}} \]
    9. Applied egg-rr91.2%

      \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(x, \frac{x}{s}, s \cdot 4\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification81.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{e^{-\frac{\left|x\right|}{s}}}{\left(1 + e^{-\frac{\left|x\right|}{s}}\right) \cdot \left(s \cdot \left(1 + e^{-\frac{\left|x\right|}{s}}\right)\right)} \leq 0:\\ \;\;\;\;\frac{1}{s \cdot \frac{x \cdot x}{s \cdot s}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(x, \frac{x}{s}, s \cdot 4\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 65.5% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-\frac{\left|x\right|}{s}}\\ t_1 := 1 + t\_0\\ \mathbf{if}\;\frac{t\_0}{t\_1 \cdot \left(s \cdot t\_1\right)} \leq 4.999999841327613 \cdot 10^{-22}:\\ \;\;\;\;\frac{1}{\frac{x}{\frac{s}{x}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25}{s}\\ \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (let* ((t_0 (exp (- (/ (fabs x) s)))) (t_1 (+ 1.0 t_0)))
   (if (<= (/ t_0 (* t_1 (* s t_1))) 4.999999841327613e-22)
     (/ 1.0 (/ x (/ s x)))
     (/ 0.25 s))))
float code(float x, float s) {
	float t_0 = expf(-(fabsf(x) / s));
	float t_1 = 1.0f + t_0;
	float tmp;
	if ((t_0 / (t_1 * (s * t_1))) <= 4.999999841327613e-22f) {
		tmp = 1.0f / (x / (s / x));
	} 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) :: t_0
    real(4) :: t_1
    real(4) :: tmp
    t_0 = exp(-(abs(x) / s))
    t_1 = 1.0e0 + t_0
    if ((t_0 / (t_1 * (s * t_1))) <= 4.999999841327613e-22) then
        tmp = 1.0e0 / (x / (s / x))
    else
        tmp = 0.25e0 / s
    end if
    code = tmp
end function
function code(x, s)
	t_0 = exp(Float32(-Float32(abs(x) / s)))
	t_1 = Float32(Float32(1.0) + t_0)
	tmp = Float32(0.0)
	if (Float32(t_0 / Float32(t_1 * Float32(s * t_1))) <= Float32(4.999999841327613e-22))
		tmp = Float32(Float32(1.0) / Float32(x / Float32(s / x)));
	else
		tmp = Float32(Float32(0.25) / s);
	end
	return tmp
end
function tmp_2 = code(x, s)
	t_0 = exp(-(abs(x) / s));
	t_1 = single(1.0) + t_0;
	tmp = single(0.0);
	if ((t_0 / (t_1 * (s * t_1))) <= single(4.999999841327613e-22))
		tmp = single(1.0) / (x / (s / x));
	else
		tmp = single(0.25) / s;
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{-\frac{\left|x\right|}{s}}\\
t_1 := 1 + t\_0\\
\mathbf{if}\;\frac{t\_0}{t\_1 \cdot \left(s \cdot t\_1\right)} \leq 4.999999841327613 \cdot 10^{-22}:\\
\;\;\;\;\frac{1}{\frac{x}{\frac{s}{x}}}\\

\mathbf{else}:\\
\;\;\;\;\frac{0.25}{s}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s))))) < 4.9999998e-22

    1. Initial program 99.0%

      \[\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. lift-fabs.f32N/A

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \]
    4. Applied egg-rr99.0%

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

      \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)}} \]
    6. Step-by-step derivation
      1. lower-*.f32N/A

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

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

        \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}}\right)} \]
      4. unpow2N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{\left|x\right| \cdot \left|x\right|}}{{s}^{2}}\right)} \]
      5. sqr-absN/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
      6. lower-*.f32N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
      7. unpow2N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
      8. lower-*.f3277.2

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
    7. Simplified77.2%

      \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{x \cdot x}{s \cdot s}\right)}} \]
    8. Taylor expanded in s around 0

      \[\leadsto \color{blue}{\frac{s}{{x}^{2}}} \]
    9. Step-by-step derivation
      1. lower-/.f32N/A

        \[\leadsto \color{blue}{\frac{s}{{x}^{2}}} \]
      2. unpow2N/A

        \[\leadsto \frac{s}{\color{blue}{x \cdot x}} \]
      3. lower-*.f3256.8

        \[\leadsto \frac{s}{\color{blue}{x \cdot x}} \]
    10. Simplified56.8%

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

        \[\leadsto \color{blue}{\frac{\frac{s}{x}}{x}} \]
      2. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{x}{\frac{s}{x}}}} \]
      3. lower-/.f32N/A

        \[\leadsto \color{blue}{\frac{1}{\frac{x}{\frac{s}{x}}}} \]
      4. lower-/.f32N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{x}{\frac{s}{x}}}} \]
      5. lower-/.f3258.4

        \[\leadsto \frac{1}{\frac{x}{\color{blue}{\frac{s}{x}}}} \]
    12. Applied egg-rr58.4%

      \[\leadsto \color{blue}{\frac{1}{\frac{x}{\frac{s}{x}}}} \]

    if 4.9999998e-22 < (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))))

    1. Initial program 98.7%

      \[\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. lower-/.f3291.7

        \[\leadsto \color{blue}{\frac{0.25}{s}} \]
    5. Simplified91.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{e^{-\frac{\left|x\right|}{s}}}{\left(1 + e^{-\frac{\left|x\right|}{s}}\right) \cdot \left(s \cdot \left(1 + e^{-\frac{\left|x\right|}{s}}\right)\right)} \leq 4.999999841327613 \cdot 10^{-22}:\\ \;\;\;\;\frac{1}{\frac{x}{\frac{s}{x}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25}{s}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 65.4% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-\frac{\left|x\right|}{s}}\\ t_1 := 1 + t\_0\\ \mathbf{if}\;\frac{t\_0}{t\_1 \cdot \left(s \cdot t\_1\right)} \leq 4.999999841327613 \cdot 10^{-22}:\\ \;\;\;\;\frac{1}{\frac{x \cdot x}{s}}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25}{s}\\ \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (let* ((t_0 (exp (- (/ (fabs x) s)))) (t_1 (+ 1.0 t_0)))
   (if (<= (/ t_0 (* t_1 (* s t_1))) 4.999999841327613e-22)
     (/ 1.0 (/ (* x x) s))
     (/ 0.25 s))))
float code(float x, float s) {
	float t_0 = expf(-(fabsf(x) / s));
	float t_1 = 1.0f + t_0;
	float tmp;
	if ((t_0 / (t_1 * (s * t_1))) <= 4.999999841327613e-22f) {
		tmp = 1.0f / ((x * x) / 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) :: t_0
    real(4) :: t_1
    real(4) :: tmp
    t_0 = exp(-(abs(x) / s))
    t_1 = 1.0e0 + t_0
    if ((t_0 / (t_1 * (s * t_1))) <= 4.999999841327613e-22) then
        tmp = 1.0e0 / ((x * x) / s)
    else
        tmp = 0.25e0 / s
    end if
    code = tmp
end function
function code(x, s)
	t_0 = exp(Float32(-Float32(abs(x) / s)))
	t_1 = Float32(Float32(1.0) + t_0)
	tmp = Float32(0.0)
	if (Float32(t_0 / Float32(t_1 * Float32(s * t_1))) <= Float32(4.999999841327613e-22))
		tmp = Float32(Float32(1.0) / Float32(Float32(x * x) / s));
	else
		tmp = Float32(Float32(0.25) / s);
	end
	return tmp
end
function tmp_2 = code(x, s)
	t_0 = exp(-(abs(x) / s));
	t_1 = single(1.0) + t_0;
	tmp = single(0.0);
	if ((t_0 / (t_1 * (s * t_1))) <= single(4.999999841327613e-22))
		tmp = single(1.0) / ((x * x) / s);
	else
		tmp = single(0.25) / s;
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{-\frac{\left|x\right|}{s}}\\
t_1 := 1 + t\_0\\
\mathbf{if}\;\frac{t\_0}{t\_1 \cdot \left(s \cdot t\_1\right)} \leq 4.999999841327613 \cdot 10^{-22}:\\
\;\;\;\;\frac{1}{\frac{x \cdot x}{s}}\\

\mathbf{else}:\\
\;\;\;\;\frac{0.25}{s}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s))))) < 4.9999998e-22

    1. Initial program 99.0%

      \[\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. lift-fabs.f32N/A

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \]
    4. Applied egg-rr99.0%

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

      \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)}} \]
    6. Step-by-step derivation
      1. lower-*.f32N/A

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

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

        \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}}\right)} \]
      4. unpow2N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{\left|x\right| \cdot \left|x\right|}}{{s}^{2}}\right)} \]
      5. sqr-absN/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
      6. lower-*.f32N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
      7. unpow2N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
      8. lower-*.f3277.2

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
    7. Simplified77.2%

      \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{x \cdot x}{s \cdot s}\right)}} \]
    8. Taylor expanded in s around 0

      \[\leadsto \frac{1}{\color{blue}{\frac{{x}^{2}}{s}}} \]
    9. Step-by-step derivation
      1. lower-/.f32N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{{x}^{2}}{s}}} \]
      2. unpow2N/A

        \[\leadsto \frac{1}{\frac{\color{blue}{x \cdot x}}{s}} \]
      3. lower-*.f3258.4

        \[\leadsto \frac{1}{\frac{\color{blue}{x \cdot x}}{s}} \]
    10. Simplified58.4%

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

    if 4.9999998e-22 < (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))))

    1. Initial program 98.7%

      \[\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. lower-/.f3291.7

        \[\leadsto \color{blue}{\frac{0.25}{s}} \]
    5. Simplified91.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{e^{-\frac{\left|x\right|}{s}}}{\left(1 + e^{-\frac{\left|x\right|}{s}}\right) \cdot \left(s \cdot \left(1 + e^{-\frac{\left|x\right|}{s}}\right)\right)} \leq 4.999999841327613 \cdot 10^{-22}:\\ \;\;\;\;\frac{1}{\frac{x \cdot x}{s}}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25}{s}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 64.0% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-\frac{\left|x\right|}{s}}\\ t_1 := 1 + t\_0\\ \mathbf{if}\;\frac{t\_0}{t\_1 \cdot \left(s \cdot t\_1\right)} \leq 4.999999841327613 \cdot 10^{-22}:\\ \;\;\;\;\frac{s}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25}{s}\\ \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (let* ((t_0 (exp (- (/ (fabs x) s)))) (t_1 (+ 1.0 t_0)))
   (if (<= (/ t_0 (* t_1 (* s t_1))) 4.999999841327613e-22)
     (/ s (* x x))
     (/ 0.25 s))))
float code(float x, float s) {
	float t_0 = expf(-(fabsf(x) / s));
	float t_1 = 1.0f + t_0;
	float tmp;
	if ((t_0 / (t_1 * (s * t_1))) <= 4.999999841327613e-22f) {
		tmp = s / (x * x);
	} 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) :: t_0
    real(4) :: t_1
    real(4) :: tmp
    t_0 = exp(-(abs(x) / s))
    t_1 = 1.0e0 + t_0
    if ((t_0 / (t_1 * (s * t_1))) <= 4.999999841327613e-22) then
        tmp = s / (x * x)
    else
        tmp = 0.25e0 / s
    end if
    code = tmp
end function
function code(x, s)
	t_0 = exp(Float32(-Float32(abs(x) / s)))
	t_1 = Float32(Float32(1.0) + t_0)
	tmp = Float32(0.0)
	if (Float32(t_0 / Float32(t_1 * Float32(s * t_1))) <= Float32(4.999999841327613e-22))
		tmp = Float32(s / Float32(x * x));
	else
		tmp = Float32(Float32(0.25) / s);
	end
	return tmp
end
function tmp_2 = code(x, s)
	t_0 = exp(-(abs(x) / s));
	t_1 = single(1.0) + t_0;
	tmp = single(0.0);
	if ((t_0 / (t_1 * (s * t_1))) <= single(4.999999841327613e-22))
		tmp = s / (x * x);
	else
		tmp = single(0.25) / s;
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{-\frac{\left|x\right|}{s}}\\
t_1 := 1 + t\_0\\
\mathbf{if}\;\frac{t\_0}{t\_1 \cdot \left(s \cdot t\_1\right)} \leq 4.999999841327613 \cdot 10^{-22}:\\
\;\;\;\;\frac{s}{x \cdot x}\\

\mathbf{else}:\\
\;\;\;\;\frac{0.25}{s}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s))))) < 4.9999998e-22

    1. Initial program 99.0%

      \[\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. lift-fabs.f32N/A

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \]
    4. Applied egg-rr99.0%

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

      \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)}} \]
    6. Step-by-step derivation
      1. lower-*.f32N/A

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

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

        \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}}\right)} \]
      4. unpow2N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{\left|x\right| \cdot \left|x\right|}}{{s}^{2}}\right)} \]
      5. sqr-absN/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
      6. lower-*.f32N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
      7. unpow2N/A

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
      8. lower-*.f3277.2

        \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
    7. Simplified77.2%

      \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{x \cdot x}{s \cdot s}\right)}} \]
    8. Taylor expanded in s around 0

      \[\leadsto \color{blue}{\frac{s}{{x}^{2}}} \]
    9. Step-by-step derivation
      1. lower-/.f32N/A

        \[\leadsto \color{blue}{\frac{s}{{x}^{2}}} \]
      2. unpow2N/A

        \[\leadsto \frac{s}{\color{blue}{x \cdot x}} \]
      3. lower-*.f3256.8

        \[\leadsto \frac{s}{\color{blue}{x \cdot x}} \]
    10. Simplified56.8%

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

    if 4.9999998e-22 < (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))))

    1. Initial program 98.7%

      \[\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. lower-/.f3291.7

        \[\leadsto \color{blue}{\frac{0.25}{s}} \]
    5. Simplified91.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{e^{-\frac{\left|x\right|}{s}}}{\left(1 + e^{-\frac{\left|x\right|}{s}}\right) \cdot \left(s \cdot \left(1 + e^{-\frac{\left|x\right|}{s}}\right)\right)} \leq 4.999999841327613 \cdot 10^{-22}:\\ \;\;\;\;\frac{s}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25}{s}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 99.6% accurate, 1.0× speedup?

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

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

    \[\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. lift-fabs.f32N/A

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \]
  4. Applied egg-rr99.0%

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

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

Alternative 10: 99.6% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -\frac{\left|x\right|}{s}\\ \frac{e^{\mathsf{fma}\left(\mathsf{log1p}\left(e^{t\_0}\right), -2, t\_0\right)}}{s} \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (let* ((t_0 (- (/ (fabs x) s))))
   (/ (exp (fma (log1p (exp t_0)) -2.0 t_0)) s)))
float code(float x, float s) {
	float t_0 = -(fabsf(x) / s);
	return expf(fmaf(log1pf(expf(t_0)), -2.0f, t_0)) / s;
}
function code(x, s)
	t_0 = Float32(-Float32(abs(x) / s))
	return Float32(exp(fma(log1p(exp(t_0)), Float32(-2.0), t_0)) / s)
end
\begin{array}{l}

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

    \[\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. lift-fabs.f32N/A

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \]
  4. Applied egg-rr99.0%

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

    \[\leadsto \color{blue}{\frac{e^{\mathsf{fma}\left(\mathsf{log1p}\left(e^{\frac{\left|x\right|}{-s}}\right), -2, \frac{\left|x\right|}{-s}\right)}}{s}} \]
  6. Final simplification99.0%

    \[\leadsto \frac{e^{\mathsf{fma}\left(\mathsf{log1p}\left(e^{-\frac{\left|x\right|}{s}}\right), -2, -\frac{\left|x\right|}{s}\right)}}{s} \]
  7. Add Preprocessing

Alternative 11: 96.6% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\left|x\right|}{s}\\ \frac{e^{-t\_0}}{s \cdot {\left(2 - t\_0\right)}^{2}} \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (let* ((t_0 (/ (fabs x) s))) (/ (exp (- t_0)) (* s (pow (- 2.0 t_0) 2.0)))))
float code(float x, float s) {
	float t_0 = fabsf(x) / s;
	return expf(-t_0) / (s * powf((2.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 = abs(x) / s
    code = exp(-t_0) / (s * ((2.0e0 - t_0) ** 2.0e0))
end function
function code(x, s)
	t_0 = Float32(abs(x) / s)
	return Float32(exp(Float32(-t_0)) / Float32(s * (Float32(Float32(2.0) - t_0) ^ Float32(2.0))))
end
function tmp = code(x, s)
	t_0 = abs(x) / s;
	tmp = exp(-t_0) / (s * ((single(2.0) - t_0) ^ single(2.0)));
end
\begin{array}{l}

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

    \[\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. lift-fabs.f32N/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\color{blue}{\left|x\right|}\right)}{s}}\right)} \]
    11. remove-double-negN/A

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

      \[\leadsto \frac{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\left|x\right|\right)\right)}\right)\right)\right)}{s}}\right)} \]
    13. remove-double-negN/A

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

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

      \[\leadsto \frac{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\color{blue}{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}\right)} \]
  4. Applied egg-rr99.0%

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

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

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

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

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

      \[\leadsto \frac{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}{{\left(2 - \color{blue}{\frac{\left|x\right|}{s}}\right)}^{2} \cdot s} \]
    5. lower-fabs.f3296.7

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

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

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

Alternative 12: 95.1% accurate, 1.5× speedup?

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

\\
\frac{1}{\frac{4}{\frac{{\left(e^{-1}\right)}^{\left(\frac{\left|x\right|}{s}\right)}}{s}}}
\end{array}
Derivation
  1. Initial program 98.9%

    \[\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. lift-fabs.f32N/A

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \]
  4. Applied egg-rr99.0%

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

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

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

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

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

      \[\leadsto \frac{1}{\frac{{\left(e^{\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)} + 1\right)}^{2}}{\frac{\color{blue}{{\left(e^{-1}\right)}^{\left(\frac{\left|x\right|}{s}\right)}}}{s}}} \]
    6. lower-exp.f3299.0

      \[\leadsto \frac{1}{\frac{{\left(e^{-\frac{\left|x\right|}{s}} + 1\right)}^{2}}{\frac{{\color{blue}{\left(e^{-1}\right)}}^{\left(\frac{\left|x\right|}{s}\right)}}{s}}} \]
  6. Applied egg-rr99.0%

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

    \[\leadsto \frac{1}{\frac{\color{blue}{4}}{\frac{{\left(e^{-1}\right)}^{\left(\frac{\left|x\right|}{s}\right)}}{s}}} \]
  8. Step-by-step derivation
    1. Simplified95.4%

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

    Alternative 13: 95.1% accurate, 2.5× speedup?

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

      \[\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. lift-fabs.f32N/A

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \]
    4. Applied egg-rr99.0%

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

      \[\leadsto \frac{1}{\frac{\color{blue}{4}}{\frac{e^{\mathsf{neg}\left(\frac{\left|x\right|}{s}\right)}}{s}}} \]
    6. Step-by-step derivation
      1. Simplified95.4%

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

      Alternative 14: 95.1% accurate, 2.8× 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(-Float32(abs(x) / 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 98.9%

        \[\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 \frac{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}{\color{blue}{4 \cdot s}} \]
      4. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \frac{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}{\color{blue}{s \cdot 4}} \]
        2. lower-*.f3295.4

          \[\leadsto \frac{e^{\frac{-\left|x\right|}{s}}}{\color{blue}{s \cdot 4}} \]
      5. Simplified95.4%

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

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

      Alternative 15: 85.9% accurate, 4.4× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|x\right| \leq 1.9999999996399175 \cdot 10^{-23}:\\ \;\;\;\;\frac{\frac{1}{s}}{\mathsf{fma}\left(\frac{\frac{\left|x\right|}{s}}{s}, \frac{1}{\frac{1}{\left|x\right|}}, 4\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{s \cdot \mathsf{fma}\left(\frac{1}{s \cdot s}, x \cdot x, 4\right)}\\ \end{array} \end{array} \]
      (FPCore (x s)
       :precision binary32
       (if (<= (fabs x) 1.9999999996399175e-23)
         (/ (/ 1.0 s) (fma (/ (/ (fabs x) s) s) (/ 1.0 (/ 1.0 (fabs x))) 4.0))
         (/ 1.0 (* s (fma (/ 1.0 (* s s)) (* x x) 4.0)))))
      float code(float x, float s) {
      	float tmp;
      	if (fabsf(x) <= 1.9999999996399175e-23f) {
      		tmp = (1.0f / s) / fmaf(((fabsf(x) / s) / s), (1.0f / (1.0f / fabsf(x))), 4.0f);
      	} else {
      		tmp = 1.0f / (s * fmaf((1.0f / (s * s)), (x * x), 4.0f));
      	}
      	return tmp;
      }
      
      function code(x, s)
      	tmp = Float32(0.0)
      	if (abs(x) <= Float32(1.9999999996399175e-23))
      		tmp = Float32(Float32(Float32(1.0) / s) / fma(Float32(Float32(abs(x) / s) / s), Float32(Float32(1.0) / Float32(Float32(1.0) / abs(x))), Float32(4.0)));
      	else
      		tmp = Float32(Float32(1.0) / Float32(s * fma(Float32(Float32(1.0) / Float32(s * s)), Float32(x * x), Float32(4.0))));
      	end
      	return tmp
      end
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;\left|x\right| \leq 1.9999999996399175 \cdot 10^{-23}:\\
      \;\;\;\;\frac{\frac{1}{s}}{\mathsf{fma}\left(\frac{\frac{\left|x\right|}{s}}{s}, \frac{1}{\frac{1}{\left|x\right|}}, 4\right)}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{1}{s \cdot \mathsf{fma}\left(\frac{1}{s \cdot s}, x \cdot x, 4\right)}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (fabs.f32 x) < 2e-23

        1. Initial program 97.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. lift-fabs.f32N/A

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

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

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

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

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

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

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

            \[\leadsto \frac{\color{blue}{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \]
        4. Applied egg-rr97.2%

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

          \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)}} \]
        6. Step-by-step derivation
          1. lower-*.f32N/A

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

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

            \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}}\right)} \]
          4. unpow2N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{\left|x\right| \cdot \left|x\right|}}{{s}^{2}}\right)} \]
          5. sqr-absN/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
          6. lower-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
          7. unpow2N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
          8. lower-*.f3261.9

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
        7. Simplified61.9%

          \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{x \cdot x}{s \cdot s}\right)}} \]
        8. Step-by-step derivation
          1. lift-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{s \cdot s}\right)} \]
          2. lift-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
          3. lift-/.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{x \cdot x}{s \cdot s}}\right)} \]
          4. lift-+.f32N/A

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

            \[\leadsto \color{blue}{\frac{\frac{1}{s}}{4 + \frac{x \cdot x}{s \cdot s}}} \]
          6. lower-/.f32N/A

            \[\leadsto \color{blue}{\frac{\frac{1}{s}}{4 + \frac{x \cdot x}{s \cdot s}}} \]
          7. lower-/.f3261.9

            \[\leadsto \frac{\color{blue}{\frac{1}{s}}}{4 + \frac{x \cdot x}{s \cdot s}} \]
          8. lift-+.f32N/A

            \[\leadsto \frac{\frac{1}{s}}{\color{blue}{4 + \frac{x \cdot x}{s \cdot s}}} \]
          9. +-commutativeN/A

            \[\leadsto \frac{\frac{1}{s}}{\color{blue}{\frac{x \cdot x}{s \cdot s} + 4}} \]
          10. lift-/.f32N/A

            \[\leadsto \frac{\frac{1}{s}}{\color{blue}{\frac{x \cdot x}{s \cdot s}} + 4} \]
          11. lift-*.f32N/A

            \[\leadsto \frac{\frac{1}{s}}{\frac{\color{blue}{x \cdot x}}{s \cdot s} + 4} \]
          12. associate-/l*N/A

            \[\leadsto \frac{\frac{1}{s}}{\color{blue}{x \cdot \frac{x}{s \cdot s}} + 4} \]
          13. lower-fma.f32N/A

            \[\leadsto \frac{\frac{1}{s}}{\color{blue}{\mathsf{fma}\left(x, \frac{x}{s \cdot s}, 4\right)}} \]
          14. lower-/.f3275.1

            \[\leadsto \frac{\frac{1}{s}}{\mathsf{fma}\left(x, \color{blue}{\frac{x}{s \cdot s}}, 4\right)} \]
        9. Applied egg-rr75.1%

          \[\leadsto \color{blue}{\frac{\frac{1}{s}}{\mathsf{fma}\left(x, \frac{x}{s \cdot s}, 4\right)}} \]
        10. Step-by-step derivation
          1. lift-*.f32N/A

            \[\leadsto \frac{\frac{1}{s}}{x \cdot \frac{x}{\color{blue}{s \cdot s}} + 4} \]
          2. lift-/.f32N/A

            \[\leadsto \frac{\frac{1}{s}}{x \cdot \color{blue}{\frac{x}{s \cdot s}} + 4} \]
          3. lift-/.f32N/A

            \[\leadsto \frac{\frac{1}{s}}{x \cdot \color{blue}{\frac{x}{s \cdot s}} + 4} \]
          4. associate-*r/N/A

            \[\leadsto \frac{\frac{1}{s}}{\color{blue}{\frac{x \cdot x}{s \cdot s}} + 4} \]
          5. sqr-absN/A

            \[\leadsto \frac{\frac{1}{s}}{\frac{\color{blue}{\left|x\right| \cdot \left|x\right|}}{s \cdot s} + 4} \]
          6. lift-fabs.f32N/A

            \[\leadsto \frac{\frac{1}{s}}{\frac{\color{blue}{\left|x\right|} \cdot \left|x\right|}{s \cdot s} + 4} \]
          7. lift-fabs.f32N/A

            \[\leadsto \frac{\frac{1}{s}}{\frac{\left|x\right| \cdot \color{blue}{\left|x\right|}}{s \cdot s} + 4} \]
          8. lift-*.f32N/A

            \[\leadsto \frac{\frac{1}{s}}{\frac{\left|x\right| \cdot \left|x\right|}{\color{blue}{s \cdot s}} + 4} \]
          9. frac-timesN/A

            \[\leadsto \frac{\frac{1}{s}}{\color{blue}{\frac{\left|x\right|}{s} \cdot \frac{\left|x\right|}{s}} + 4} \]
          10. lift-/.f32N/A

            \[\leadsto \frac{\frac{1}{s}}{\color{blue}{\frac{\left|x\right|}{s}} \cdot \frac{\left|x\right|}{s} + 4} \]
          11. clear-numN/A

            \[\leadsto \frac{\frac{1}{s}}{\frac{\left|x\right|}{s} \cdot \color{blue}{\frac{1}{\frac{s}{\left|x\right|}}} + 4} \]
          12. associate-*r/N/A

            \[\leadsto \frac{\frac{1}{s}}{\color{blue}{\frac{\frac{\left|x\right|}{s} \cdot 1}{\frac{s}{\left|x\right|}}} + 4} \]
          13. div-invN/A

            \[\leadsto \frac{\frac{1}{s}}{\frac{\frac{\left|x\right|}{s} \cdot 1}{\color{blue}{s \cdot \frac{1}{\left|x\right|}}} + 4} \]
          14. times-fracN/A

            \[\leadsto \frac{\frac{1}{s}}{\color{blue}{\frac{\frac{\left|x\right|}{s}}{s} \cdot \frac{1}{\frac{1}{\left|x\right|}}} + 4} \]
          15. lower-fma.f32N/A

            \[\leadsto \frac{\frac{1}{s}}{\color{blue}{\mathsf{fma}\left(\frac{\frac{\left|x\right|}{s}}{s}, \frac{1}{\frac{1}{\left|x\right|}}, 4\right)}} \]
          16. lower-/.f32N/A

            \[\leadsto \frac{\frac{1}{s}}{\mathsf{fma}\left(\color{blue}{\frac{\frac{\left|x\right|}{s}}{s}}, \frac{1}{\frac{1}{\left|x\right|}}, 4\right)} \]
          17. lower-/.f32N/A

            \[\leadsto \frac{\frac{1}{s}}{\mathsf{fma}\left(\frac{\frac{\left|x\right|}{s}}{s}, \color{blue}{\frac{1}{\frac{1}{\left|x\right|}}}, 4\right)} \]
          18. lower-/.f3292.9

            \[\leadsto \frac{\frac{1}{s}}{\mathsf{fma}\left(\frac{\frac{\left|x\right|}{s}}{s}, \frac{1}{\color{blue}{\frac{1}{\left|x\right|}}}, 4\right)} \]
        11. Applied egg-rr92.9%

          \[\leadsto \frac{\frac{1}{s}}{\color{blue}{\mathsf{fma}\left(\frac{\frac{\left|x\right|}{s}}{s}, \frac{1}{\frac{1}{\left|x\right|}}, 4\right)}} \]

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

        1. Initial program 99.3%

          \[\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. lift-fabs.f32N/A

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

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

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

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

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

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

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

            \[\leadsto \frac{\color{blue}{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \]
        4. Applied egg-rr99.4%

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

          \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)}} \]
        6. Step-by-step derivation
          1. lower-*.f32N/A

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

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

            \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}}\right)} \]
          4. unpow2N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{\left|x\right| \cdot \left|x\right|}}{{s}^{2}}\right)} \]
          5. sqr-absN/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
          6. lower-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
          7. unpow2N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
          8. lower-*.f3281.1

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
        7. Simplified81.1%

          \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{x \cdot x}{s \cdot s}\right)}} \]
        8. Step-by-step derivation
          1. lift-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{s \cdot s}\right)} \]
          2. lift-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
          3. lift-/.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{x \cdot x}{s \cdot s}}\right)} \]
          4. +-commutativeN/A

            \[\leadsto \frac{1}{s \cdot \color{blue}{\left(\frac{x \cdot x}{s \cdot s} + 4\right)}} \]
          5. lift-/.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(\color{blue}{\frac{x \cdot x}{s \cdot s}} + 4\right)} \]
          6. clear-numN/A

            \[\leadsto \frac{1}{s \cdot \left(\color{blue}{\frac{1}{\frac{s \cdot s}{x \cdot x}}} + 4\right)} \]
          7. associate-/r/N/A

            \[\leadsto \frac{1}{s \cdot \left(\color{blue}{\frac{1}{s \cdot s} \cdot \left(x \cdot x\right)} + 4\right)} \]
          8. lower-fma.f32N/A

            \[\leadsto \frac{1}{s \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{s \cdot s}, x \cdot x, 4\right)}} \]
          9. lower-/.f3285.9

            \[\leadsto \frac{1}{s \cdot \mathsf{fma}\left(\color{blue}{\frac{1}{s \cdot s}}, x \cdot x, 4\right)} \]
        9. Applied egg-rr85.9%

          \[\leadsto \frac{1}{s \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{s \cdot s}, x \cdot x, 4\right)}} \]
      3. Recombined 2 regimes into one program.
      4. Add Preprocessing

      Alternative 16: 85.9% accurate, 5.8× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|x\right| \leq 1.9999999996399175 \cdot 10^{-23}:\\ \;\;\;\;\frac{\frac{1}{s}}{\mathsf{fma}\left(x, \frac{1}{s \cdot \frac{s}{x}}, 4\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{s \cdot \mathsf{fma}\left(\frac{1}{s \cdot s}, x \cdot x, 4\right)}\\ \end{array} \end{array} \]
      (FPCore (x s)
       :precision binary32
       (if (<= (fabs x) 1.9999999996399175e-23)
         (/ (/ 1.0 s) (fma x (/ 1.0 (* s (/ s x))) 4.0))
         (/ 1.0 (* s (fma (/ 1.0 (* s s)) (* x x) 4.0)))))
      float code(float x, float s) {
      	float tmp;
      	if (fabsf(x) <= 1.9999999996399175e-23f) {
      		tmp = (1.0f / s) / fmaf(x, (1.0f / (s * (s / x))), 4.0f);
      	} else {
      		tmp = 1.0f / (s * fmaf((1.0f / (s * s)), (x * x), 4.0f));
      	}
      	return tmp;
      }
      
      function code(x, s)
      	tmp = Float32(0.0)
      	if (abs(x) <= Float32(1.9999999996399175e-23))
      		tmp = Float32(Float32(Float32(1.0) / s) / fma(x, Float32(Float32(1.0) / Float32(s * Float32(s / x))), Float32(4.0)));
      	else
      		tmp = Float32(Float32(1.0) / Float32(s * fma(Float32(Float32(1.0) / Float32(s * s)), Float32(x * x), Float32(4.0))));
      	end
      	return tmp
      end
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;\left|x\right| \leq 1.9999999996399175 \cdot 10^{-23}:\\
      \;\;\;\;\frac{\frac{1}{s}}{\mathsf{fma}\left(x, \frac{1}{s \cdot \frac{s}{x}}, 4\right)}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{1}{s \cdot \mathsf{fma}\left(\frac{1}{s \cdot s}, x \cdot x, 4\right)}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (fabs.f32 x) < 2e-23

        1. Initial program 97.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. lift-fabs.f32N/A

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

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

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

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

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

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

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

            \[\leadsto \frac{\color{blue}{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \]
        4. Applied egg-rr97.2%

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

          \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)}} \]
        6. Step-by-step derivation
          1. lower-*.f32N/A

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

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

            \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}}\right)} \]
          4. unpow2N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{\left|x\right| \cdot \left|x\right|}}{{s}^{2}}\right)} \]
          5. sqr-absN/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
          6. lower-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
          7. unpow2N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
          8. lower-*.f3261.9

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
        7. Simplified61.9%

          \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{x \cdot x}{s \cdot s}\right)}} \]
        8. Step-by-step derivation
          1. lift-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{s \cdot s}\right)} \]
          2. lift-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
          3. lift-/.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{x \cdot x}{s \cdot s}}\right)} \]
          4. lift-+.f32N/A

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

            \[\leadsto \color{blue}{\frac{\frac{1}{s}}{4 + \frac{x \cdot x}{s \cdot s}}} \]
          6. lower-/.f32N/A

            \[\leadsto \color{blue}{\frac{\frac{1}{s}}{4 + \frac{x \cdot x}{s \cdot s}}} \]
          7. lower-/.f3261.9

            \[\leadsto \frac{\color{blue}{\frac{1}{s}}}{4 + \frac{x \cdot x}{s \cdot s}} \]
          8. lift-+.f32N/A

            \[\leadsto \frac{\frac{1}{s}}{\color{blue}{4 + \frac{x \cdot x}{s \cdot s}}} \]
          9. +-commutativeN/A

            \[\leadsto \frac{\frac{1}{s}}{\color{blue}{\frac{x \cdot x}{s \cdot s} + 4}} \]
          10. lift-/.f32N/A

            \[\leadsto \frac{\frac{1}{s}}{\color{blue}{\frac{x \cdot x}{s \cdot s}} + 4} \]
          11. lift-*.f32N/A

            \[\leadsto \frac{\frac{1}{s}}{\frac{\color{blue}{x \cdot x}}{s \cdot s} + 4} \]
          12. associate-/l*N/A

            \[\leadsto \frac{\frac{1}{s}}{\color{blue}{x \cdot \frac{x}{s \cdot s}} + 4} \]
          13. lower-fma.f32N/A

            \[\leadsto \frac{\frac{1}{s}}{\color{blue}{\mathsf{fma}\left(x, \frac{x}{s \cdot s}, 4\right)}} \]
          14. lower-/.f3275.1

            \[\leadsto \frac{\frac{1}{s}}{\mathsf{fma}\left(x, \color{blue}{\frac{x}{s \cdot s}}, 4\right)} \]
        9. Applied egg-rr75.1%

          \[\leadsto \color{blue}{\frac{\frac{1}{s}}{\mathsf{fma}\left(x, \frac{x}{s \cdot s}, 4\right)}} \]
        10. Step-by-step derivation
          1. associate-/r*N/A

            \[\leadsto \frac{\frac{1}{s}}{\mathsf{fma}\left(x, \color{blue}{\frac{\frac{x}{s}}{s}}, 4\right)} \]
          2. clear-numN/A

            \[\leadsto \frac{\frac{1}{s}}{\mathsf{fma}\left(x, \color{blue}{\frac{1}{\frac{s}{\frac{x}{s}}}}, 4\right)} \]
          3. lower-/.f32N/A

            \[\leadsto \frac{\frac{1}{s}}{\mathsf{fma}\left(x, \color{blue}{\frac{1}{\frac{s}{\frac{x}{s}}}}, 4\right)} \]
          4. /-rgt-identityN/A

            \[\leadsto \frac{\frac{1}{s}}{\mathsf{fma}\left(x, \frac{1}{\frac{\color{blue}{\frac{s}{1}}}{\frac{x}{s}}}, 4\right)} \]
          5. div-invN/A

            \[\leadsto \frac{\frac{1}{s}}{\mathsf{fma}\left(x, \frac{1}{\frac{\color{blue}{s \cdot \frac{1}{1}}}{\frac{x}{s}}}, 4\right)} \]
          6. metadata-evalN/A

            \[\leadsto \frac{\frac{1}{s}}{\mathsf{fma}\left(x, \frac{1}{\frac{s \cdot \color{blue}{1}}{\frac{x}{s}}}, 4\right)} \]
          7. div-invN/A

            \[\leadsto \frac{\frac{1}{s}}{\mathsf{fma}\left(x, \frac{1}{\frac{s \cdot 1}{\color{blue}{x \cdot \frac{1}{s}}}}, 4\right)} \]
          8. lift-/.f32N/A

            \[\leadsto \frac{\frac{1}{s}}{\mathsf{fma}\left(x, \frac{1}{\frac{s \cdot 1}{x \cdot \color{blue}{\frac{1}{s}}}}, 4\right)} \]
          9. times-fracN/A

            \[\leadsto \frac{\frac{1}{s}}{\mathsf{fma}\left(x, \frac{1}{\color{blue}{\frac{s}{x} \cdot \frac{1}{\frac{1}{s}}}}, 4\right)} \]
          10. lift-/.f32N/A

            \[\leadsto \frac{\frac{1}{s}}{\mathsf{fma}\left(x, \frac{1}{\frac{s}{x} \cdot \frac{1}{\color{blue}{\frac{1}{s}}}}, 4\right)} \]
          11. clear-numN/A

            \[\leadsto \frac{\frac{1}{s}}{\mathsf{fma}\left(x, \frac{1}{\frac{s}{x} \cdot \color{blue}{\frac{s}{1}}}, 4\right)} \]
          12. /-rgt-identityN/A

            \[\leadsto \frac{\frac{1}{s}}{\mathsf{fma}\left(x, \frac{1}{\frac{s}{x} \cdot \color{blue}{s}}, 4\right)} \]
          13. lower-*.f32N/A

            \[\leadsto \frac{\frac{1}{s}}{\mathsf{fma}\left(x, \frac{1}{\color{blue}{\frac{s}{x} \cdot s}}, 4\right)} \]
          14. lower-/.f3292.9

            \[\leadsto \frac{\frac{1}{s}}{\mathsf{fma}\left(x, \frac{1}{\color{blue}{\frac{s}{x}} \cdot s}, 4\right)} \]
        11. Applied egg-rr92.9%

          \[\leadsto \frac{\frac{1}{s}}{\mathsf{fma}\left(x, \color{blue}{\frac{1}{\frac{s}{x} \cdot s}}, 4\right)} \]

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

        1. Initial program 99.3%

          \[\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. lift-fabs.f32N/A

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

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

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

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

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

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

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

            \[\leadsto \frac{\color{blue}{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \]
        4. Applied egg-rr99.4%

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

          \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)}} \]
        6. Step-by-step derivation
          1. lower-*.f32N/A

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

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

            \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}}\right)} \]
          4. unpow2N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{\left|x\right| \cdot \left|x\right|}}{{s}^{2}}\right)} \]
          5. sqr-absN/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
          6. lower-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
          7. unpow2N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
          8. lower-*.f3281.1

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
        7. Simplified81.1%

          \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{x \cdot x}{s \cdot s}\right)}} \]
        8. Step-by-step derivation
          1. lift-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{s \cdot s}\right)} \]
          2. lift-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
          3. lift-/.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{x \cdot x}{s \cdot s}}\right)} \]
          4. +-commutativeN/A

            \[\leadsto \frac{1}{s \cdot \color{blue}{\left(\frac{x \cdot x}{s \cdot s} + 4\right)}} \]
          5. lift-/.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(\color{blue}{\frac{x \cdot x}{s \cdot s}} + 4\right)} \]
          6. clear-numN/A

            \[\leadsto \frac{1}{s \cdot \left(\color{blue}{\frac{1}{\frac{s \cdot s}{x \cdot x}}} + 4\right)} \]
          7. associate-/r/N/A

            \[\leadsto \frac{1}{s \cdot \left(\color{blue}{\frac{1}{s \cdot s} \cdot \left(x \cdot x\right)} + 4\right)} \]
          8. lower-fma.f32N/A

            \[\leadsto \frac{1}{s \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{s \cdot s}, x \cdot x, 4\right)}} \]
          9. lower-/.f3285.9

            \[\leadsto \frac{1}{s \cdot \mathsf{fma}\left(\color{blue}{\frac{1}{s \cdot s}}, x \cdot x, 4\right)} \]
        9. Applied egg-rr85.9%

          \[\leadsto \frac{1}{s \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{s \cdot s}, x \cdot x, 4\right)}} \]
      3. Recombined 2 regimes into one program.
      4. Final simplification87.1%

        \[\leadsto \begin{array}{l} \mathbf{if}\;\left|x\right| \leq 1.9999999996399175 \cdot 10^{-23}:\\ \;\;\;\;\frac{\frac{1}{s}}{\mathsf{fma}\left(x, \frac{1}{s \cdot \frac{s}{x}}, 4\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{s \cdot \mathsf{fma}\left(\frac{1}{s \cdot s}, x \cdot x, 4\right)}\\ \end{array} \]
      5. Add Preprocessing

      Alternative 17: 84.5% accurate, 6.3× speedup?

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

        1. Initial program 97.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. lift-fabs.f32N/A

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

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

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

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

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

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

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

            \[\leadsto \frac{\color{blue}{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \]
        4. Applied egg-rr97.2%

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

          \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)}} \]
        6. Step-by-step derivation
          1. lower-*.f32N/A

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

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

            \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}}\right)} \]
          4. unpow2N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{\left|x\right| \cdot \left|x\right|}}{{s}^{2}}\right)} \]
          5. sqr-absN/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
          6. lower-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
          7. unpow2N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
          8. lower-*.f3261.9

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
        7. Simplified61.9%

          \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{x \cdot x}{s \cdot s}\right)}} \]
        8. Step-by-step derivation
          1. sqr-absN/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{\left|x\right| \cdot \left|x\right|}}{s \cdot s}\right)} \]
          2. lift-fabs.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{\left|x\right|} \cdot \left|x\right|}{s \cdot s}\right)} \]
          3. lift-fabs.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\left|x\right| \cdot \color{blue}{\left|x\right|}}{s \cdot s}\right)} \]
          4. frac-timesN/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{\left|x\right|}{s} \cdot \frac{\left|x\right|}{s}}\right)} \]
          5. clear-numN/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{1}{\frac{s}{\left|x\right|}}} \cdot \frac{\left|x\right|}{s}\right)} \]
          6. frac-timesN/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{1 \cdot \left|x\right|}{\frac{s}{\left|x\right|} \cdot s}}\right)} \]
          7. metadata-evalN/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{\left(\mathsf{neg}\left(-1\right)\right)} \cdot \left|x\right|}{\frac{s}{\left|x\right|} \cdot s}\right)} \]
          8. distribute-lft-neg-inN/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{\mathsf{neg}\left(-1 \cdot \left|x\right|\right)}}{\frac{s}{\left|x\right|} \cdot s}\right)} \]
          9. neg-mul-1N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\left|x\right|\right)\right)}\right)}{\frac{s}{\left|x\right|} \cdot s}\right)} \]
          10. remove-double-negN/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{\left|x\right|}}{\frac{s}{\left|x\right|} \cdot s}\right)} \]
          11. lower-/.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{\left|x\right|}{\frac{s}{\left|x\right|} \cdot s}}\right)} \]
          12. lower-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\left|x\right|}{\color{blue}{\frac{s}{\left|x\right|} \cdot s}}\right)} \]
          13. lower-/.f3283.8

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\left|x\right|}{\color{blue}{\frac{s}{\left|x\right|}} \cdot s}\right)} \]
        9. Applied egg-rr83.8%

          \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{\left|x\right|}{\frac{s}{\left|x\right|} \cdot s}}\right)} \]

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

        1. Initial program 99.3%

          \[\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. lift-fabs.f32N/A

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

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

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

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

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

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

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

            \[\leadsto \frac{\color{blue}{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \]
        4. Applied egg-rr99.4%

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

          \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)}} \]
        6. Step-by-step derivation
          1. lower-*.f32N/A

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

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

            \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}}\right)} \]
          4. unpow2N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{\left|x\right| \cdot \left|x\right|}}{{s}^{2}}\right)} \]
          5. sqr-absN/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
          6. lower-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
          7. unpow2N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
          8. lower-*.f3281.1

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
        7. Simplified81.1%

          \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{x \cdot x}{s \cdot s}\right)}} \]
        8. Step-by-step derivation
          1. lift-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{s \cdot s}\right)} \]
          2. lift-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
          3. lift-/.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{x \cdot x}{s \cdot s}}\right)} \]
          4. +-commutativeN/A

            \[\leadsto \frac{1}{s \cdot \color{blue}{\left(\frac{x \cdot x}{s \cdot s} + 4\right)}} \]
          5. lift-/.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(\color{blue}{\frac{x \cdot x}{s \cdot s}} + 4\right)} \]
          6. clear-numN/A

            \[\leadsto \frac{1}{s \cdot \left(\color{blue}{\frac{1}{\frac{s \cdot s}{x \cdot x}}} + 4\right)} \]
          7. associate-/r/N/A

            \[\leadsto \frac{1}{s \cdot \left(\color{blue}{\frac{1}{s \cdot s} \cdot \left(x \cdot x\right)} + 4\right)} \]
          8. lower-fma.f32N/A

            \[\leadsto \frac{1}{s \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{s \cdot s}, x \cdot x, 4\right)}} \]
          9. lower-/.f3285.9

            \[\leadsto \frac{1}{s \cdot \mathsf{fma}\left(\color{blue}{\frac{1}{s \cdot s}}, x \cdot x, 4\right)} \]
        9. Applied egg-rr85.9%

          \[\leadsto \frac{1}{s \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{s \cdot s}, x \cdot x, 4\right)}} \]
      3. Recombined 2 regimes into one program.
      4. Final simplification85.6%

        \[\leadsto \begin{array}{l} \mathbf{if}\;\left|x\right| \leq 1.9999999996399175 \cdot 10^{-23}:\\ \;\;\;\;\frac{1}{s \cdot \left(4 + \frac{\left|x\right|}{s \cdot \frac{s}{\left|x\right|}}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{s \cdot \mathsf{fma}\left(\frac{1}{s \cdot s}, x \cdot x, 4\right)}\\ \end{array} \]
      5. Add Preprocessing

      Alternative 18: 83.9% accurate, 7.0× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|x\right| \leq 1.9999999996399175 \cdot 10^{-23}:\\ \;\;\;\;\frac{1}{s \cdot \mathsf{fma}\left(\frac{x}{s}, \frac{x}{s}, 4\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{s \cdot \mathsf{fma}\left(\frac{1}{s \cdot s}, x \cdot x, 4\right)}\\ \end{array} \end{array} \]
      (FPCore (x s)
       :precision binary32
       (if (<= (fabs x) 1.9999999996399175e-23)
         (/ 1.0 (* s (fma (/ x s) (/ x s) 4.0)))
         (/ 1.0 (* s (fma (/ 1.0 (* s s)) (* x x) 4.0)))))
      float code(float x, float s) {
      	float tmp;
      	if (fabsf(x) <= 1.9999999996399175e-23f) {
      		tmp = 1.0f / (s * fmaf((x / s), (x / s), 4.0f));
      	} else {
      		tmp = 1.0f / (s * fmaf((1.0f / (s * s)), (x * x), 4.0f));
      	}
      	return tmp;
      }
      
      function code(x, s)
      	tmp = Float32(0.0)
      	if (abs(x) <= Float32(1.9999999996399175e-23))
      		tmp = Float32(Float32(1.0) / Float32(s * fma(Float32(x / s), Float32(x / s), Float32(4.0))));
      	else
      		tmp = Float32(Float32(1.0) / Float32(s * fma(Float32(Float32(1.0) / Float32(s * s)), Float32(x * x), Float32(4.0))));
      	end
      	return tmp
      end
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;\left|x\right| \leq 1.9999999996399175 \cdot 10^{-23}:\\
      \;\;\;\;\frac{1}{s \cdot \mathsf{fma}\left(\frac{x}{s}, \frac{x}{s}, 4\right)}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{1}{s \cdot \mathsf{fma}\left(\frac{1}{s \cdot s}, x \cdot x, 4\right)}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (fabs.f32 x) < 2e-23

        1. Initial program 97.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. lift-fabs.f32N/A

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

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

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

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

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

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

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

            \[\leadsto \frac{\color{blue}{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \]
        4. Applied egg-rr97.2%

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

          \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)}} \]
        6. Step-by-step derivation
          1. lower-*.f32N/A

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

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

            \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}}\right)} \]
          4. unpow2N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{\left|x\right| \cdot \left|x\right|}}{{s}^{2}}\right)} \]
          5. sqr-absN/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
          6. lower-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
          7. unpow2N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
          8. lower-*.f3261.9

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
        7. Simplified61.9%

          \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{x \cdot x}{s \cdot s}\right)}} \]
        8. Step-by-step derivation
          1. lift-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{s \cdot s}\right)} \]
          2. lift-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
          3. lift-/.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{x \cdot x}{s \cdot s}}\right)} \]
          4. +-commutativeN/A

            \[\leadsto \frac{1}{s \cdot \color{blue}{\left(\frac{x \cdot x}{s \cdot s} + 4\right)}} \]
          5. lift-/.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(\color{blue}{\frac{x \cdot x}{s \cdot s}} + 4\right)} \]
          6. lift-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(\frac{\color{blue}{x \cdot x}}{s \cdot s} + 4\right)} \]
          7. lift-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(\frac{x \cdot x}{\color{blue}{s \cdot s}} + 4\right)} \]
          8. times-fracN/A

            \[\leadsto \frac{1}{s \cdot \left(\color{blue}{\frac{x}{s} \cdot \frac{x}{s}} + 4\right)} \]
          9. lower-fma.f32N/A

            \[\leadsto \frac{1}{s \cdot \color{blue}{\mathsf{fma}\left(\frac{x}{s}, \frac{x}{s}, 4\right)}} \]
          10. lower-/.f32N/A

            \[\leadsto \frac{1}{s \cdot \mathsf{fma}\left(\color{blue}{\frac{x}{s}}, \frac{x}{s}, 4\right)} \]
          11. lower-/.f3281.6

            \[\leadsto \frac{1}{s \cdot \mathsf{fma}\left(\frac{x}{s}, \color{blue}{\frac{x}{s}}, 4\right)} \]
        9. Applied egg-rr81.6%

          \[\leadsto \frac{1}{s \cdot \color{blue}{\mathsf{fma}\left(\frac{x}{s}, \frac{x}{s}, 4\right)}} \]

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

        1. Initial program 99.3%

          \[\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. lift-fabs.f32N/A

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

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

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

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

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

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

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

            \[\leadsto \frac{\color{blue}{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \]
        4. Applied egg-rr99.4%

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

          \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)}} \]
        6. Step-by-step derivation
          1. lower-*.f32N/A

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

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

            \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}}\right)} \]
          4. unpow2N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{\left|x\right| \cdot \left|x\right|}}{{s}^{2}}\right)} \]
          5. sqr-absN/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
          6. lower-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
          7. unpow2N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
          8. lower-*.f3281.1

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
        7. Simplified81.1%

          \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{x \cdot x}{s \cdot s}\right)}} \]
        8. Step-by-step derivation
          1. lift-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{s \cdot s}\right)} \]
          2. lift-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
          3. lift-/.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{x \cdot x}{s \cdot s}}\right)} \]
          4. +-commutativeN/A

            \[\leadsto \frac{1}{s \cdot \color{blue}{\left(\frac{x \cdot x}{s \cdot s} + 4\right)}} \]
          5. lift-/.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(\color{blue}{\frac{x \cdot x}{s \cdot s}} + 4\right)} \]
          6. clear-numN/A

            \[\leadsto \frac{1}{s \cdot \left(\color{blue}{\frac{1}{\frac{s \cdot s}{x \cdot x}}} + 4\right)} \]
          7. associate-/r/N/A

            \[\leadsto \frac{1}{s \cdot \left(\color{blue}{\frac{1}{s \cdot s} \cdot \left(x \cdot x\right)} + 4\right)} \]
          8. lower-fma.f32N/A

            \[\leadsto \frac{1}{s \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{s \cdot s}, x \cdot x, 4\right)}} \]
          9. lower-/.f3285.9

            \[\leadsto \frac{1}{s \cdot \mathsf{fma}\left(\color{blue}{\frac{1}{s \cdot s}}, x \cdot x, 4\right)} \]
        9. Applied egg-rr85.9%

          \[\leadsto \frac{1}{s \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{s \cdot s}, x \cdot x, 4\right)}} \]
      3. Recombined 2 regimes into one program.
      4. Add Preprocessing

      Alternative 19: 83.9% accurate, 7.2× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|x\right| \leq 1.9999999996399175 \cdot 10^{-23}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(x, \frac{x}{s}, s \cdot 4\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{s \cdot \mathsf{fma}\left(\frac{1}{s \cdot s}, x \cdot x, 4\right)}\\ \end{array} \end{array} \]
      (FPCore (x s)
       :precision binary32
       (if (<= (fabs x) 1.9999999996399175e-23)
         (/ 1.0 (fma x (/ x s) (* s 4.0)))
         (/ 1.0 (* s (fma (/ 1.0 (* s s)) (* x x) 4.0)))))
      float code(float x, float s) {
      	float tmp;
      	if (fabsf(x) <= 1.9999999996399175e-23f) {
      		tmp = 1.0f / fmaf(x, (x / s), (s * 4.0f));
      	} else {
      		tmp = 1.0f / (s * fmaf((1.0f / (s * s)), (x * x), 4.0f));
      	}
      	return tmp;
      }
      
      function code(x, s)
      	tmp = Float32(0.0)
      	if (abs(x) <= Float32(1.9999999996399175e-23))
      		tmp = Float32(Float32(1.0) / fma(x, Float32(x / s), Float32(s * Float32(4.0))));
      	else
      		tmp = Float32(Float32(1.0) / Float32(s * fma(Float32(Float32(1.0) / Float32(s * s)), Float32(x * x), Float32(4.0))));
      	end
      	return tmp
      end
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;\left|x\right| \leq 1.9999999996399175 \cdot 10^{-23}:\\
      \;\;\;\;\frac{1}{\mathsf{fma}\left(x, \frac{x}{s}, s \cdot 4\right)}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{1}{s \cdot \mathsf{fma}\left(\frac{1}{s \cdot s}, x \cdot x, 4\right)}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (fabs.f32 x) < 2e-23

        1. Initial program 97.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. lift-fabs.f32N/A

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

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

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

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

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

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

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

            \[\leadsto \frac{\color{blue}{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \]
        4. Applied egg-rr97.2%

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

          \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)}} \]
        6. Step-by-step derivation
          1. lower-*.f32N/A

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

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

            \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}}\right)} \]
          4. unpow2N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{\left|x\right| \cdot \left|x\right|}}{{s}^{2}}\right)} \]
          5. sqr-absN/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
          6. lower-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
          7. unpow2N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
          8. lower-*.f3261.9

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
        7. Simplified61.9%

          \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{x \cdot x}{s \cdot s}\right)}} \]
        8. Step-by-step derivation
          1. lift-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{s \cdot s}\right)} \]
          2. lift-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
          3. lift-/.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{x \cdot x}{s \cdot s}}\right)} \]
          4. +-commutativeN/A

            \[\leadsto \frac{1}{s \cdot \color{blue}{\left(\frac{x \cdot x}{s \cdot s} + 4\right)}} \]
          5. distribute-rgt-inN/A

            \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x}{s \cdot s} \cdot s + 4 \cdot s}} \]
          6. *-commutativeN/A

            \[\leadsto \frac{1}{\frac{x \cdot x}{s \cdot s} \cdot s + \color{blue}{s \cdot 4}} \]
          7. lift-*.f32N/A

            \[\leadsto \frac{1}{\frac{x \cdot x}{s \cdot s} \cdot s + \color{blue}{s \cdot 4}} \]
          8. lift-/.f32N/A

            \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x}{s \cdot s}} \cdot s + s \cdot 4} \]
          9. div-invN/A

            \[\leadsto \frac{1}{\color{blue}{\left(\left(x \cdot x\right) \cdot \frac{1}{s \cdot s}\right)} \cdot s + s \cdot 4} \]
          10. associate-*l*N/A

            \[\leadsto \frac{1}{\color{blue}{\left(x \cdot x\right) \cdot \left(\frac{1}{s \cdot s} \cdot s\right)} + s \cdot 4} \]
          11. lift-*.f32N/A

            \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot \left(\frac{1}{\color{blue}{s \cdot s}} \cdot s\right) + s \cdot 4} \]
          12. pow2N/A

            \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot \left(\frac{1}{\color{blue}{{s}^{2}}} \cdot s\right) + s \cdot 4} \]
          13. pow-flipN/A

            \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot \left(\color{blue}{{s}^{\left(\mathsf{neg}\left(2\right)\right)}} \cdot s\right) + s \cdot 4} \]
          14. metadata-evalN/A

            \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot \left({s}^{\color{blue}{-2}} \cdot s\right) + s \cdot 4} \]
          15. pow-plusN/A

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

            \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot {s}^{\color{blue}{-1}} + s \cdot 4} \]
          17. inv-powN/A

            \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot \color{blue}{\frac{1}{s}} + s \cdot 4} \]
          18. div-invN/A

            \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x}{s}} + s \cdot 4} \]
          19. lift-*.f32N/A

            \[\leadsto \frac{1}{\frac{\color{blue}{x \cdot x}}{s} + s \cdot 4} \]
          20. associate-/l*N/A

            \[\leadsto \frac{1}{\color{blue}{x \cdot \frac{x}{s}} + s \cdot 4} \]
          21. lower-fma.f32N/A

            \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(x, \frac{x}{s}, s \cdot 4\right)}} \]
        9. Applied egg-rr81.6%

          \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(x, \frac{x}{s}, s \cdot 4\right)}} \]

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

        1. Initial program 99.3%

          \[\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. lift-fabs.f32N/A

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

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

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

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

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

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

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

            \[\leadsto \frac{\color{blue}{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \]
        4. Applied egg-rr99.4%

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

          \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)}} \]
        6. Step-by-step derivation
          1. lower-*.f32N/A

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

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

            \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}}\right)} \]
          4. unpow2N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{\left|x\right| \cdot \left|x\right|}}{{s}^{2}}\right)} \]
          5. sqr-absN/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
          6. lower-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
          7. unpow2N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
          8. lower-*.f3281.1

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
        7. Simplified81.1%

          \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{x \cdot x}{s \cdot s}\right)}} \]
        8. Step-by-step derivation
          1. lift-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{s \cdot s}\right)} \]
          2. lift-*.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
          3. lift-/.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{x \cdot x}{s \cdot s}}\right)} \]
          4. +-commutativeN/A

            \[\leadsto \frac{1}{s \cdot \color{blue}{\left(\frac{x \cdot x}{s \cdot s} + 4\right)}} \]
          5. lift-/.f32N/A

            \[\leadsto \frac{1}{s \cdot \left(\color{blue}{\frac{x \cdot x}{s \cdot s}} + 4\right)} \]
          6. clear-numN/A

            \[\leadsto \frac{1}{s \cdot \left(\color{blue}{\frac{1}{\frac{s \cdot s}{x \cdot x}}} + 4\right)} \]
          7. associate-/r/N/A

            \[\leadsto \frac{1}{s \cdot \left(\color{blue}{\frac{1}{s \cdot s} \cdot \left(x \cdot x\right)} + 4\right)} \]
          8. lower-fma.f32N/A

            \[\leadsto \frac{1}{s \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{s \cdot s}, x \cdot x, 4\right)}} \]
          9. lower-/.f3285.9

            \[\leadsto \frac{1}{s \cdot \mathsf{fma}\left(\color{blue}{\frac{1}{s \cdot s}}, x \cdot x, 4\right)} \]
        9. Applied egg-rr85.9%

          \[\leadsto \frac{1}{s \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{s \cdot s}, x \cdot x, 4\right)}} \]
      3. Recombined 2 regimes into one program.
      4. Add Preprocessing

      Alternative 20: 81.6% accurate, 9.6× speedup?

      \[\begin{array}{l} \\ \frac{1}{s \cdot \mathsf{fma}\left(x, \frac{x}{s \cdot s}, 4\right)} \end{array} \]
      (FPCore (x s) :precision binary32 (/ 1.0 (* s (fma x (/ x (* s s)) 4.0))))
      float code(float x, float s) {
      	return 1.0f / (s * fmaf(x, (x / (s * s)), 4.0f));
      }
      
      function code(x, s)
      	return Float32(Float32(1.0) / Float32(s * fma(x, Float32(x / Float32(s * s)), Float32(4.0))))
      end
      
      \begin{array}{l}
      
      \\
      \frac{1}{s \cdot \mathsf{fma}\left(x, \frac{x}{s \cdot s}, 4\right)}
      \end{array}
      
      Derivation
      1. Initial program 98.9%

        \[\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. lift-fabs.f32N/A

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

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

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

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

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

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

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

          \[\leadsto \frac{\color{blue}{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \]
      4. Applied egg-rr99.0%

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

        \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)}} \]
      6. Step-by-step derivation
        1. lower-*.f32N/A

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

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

          \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}}\right)} \]
        4. unpow2N/A

          \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{\left|x\right| \cdot \left|x\right|}}{{s}^{2}}\right)} \]
        5. sqr-absN/A

          \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
        6. lower-*.f32N/A

          \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
        7. unpow2N/A

          \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
        8. lower-*.f3277.9

          \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
      7. Simplified77.9%

        \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{x \cdot x}{s \cdot s}\right)}} \]
      8. Step-by-step derivation
        1. lift-*.f32N/A

          \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{s \cdot s}\right)} \]
        2. lift-*.f32N/A

          \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
        3. lift-/.f32N/A

          \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{x \cdot x}{s \cdot s}}\right)} \]
        4. lift-+.f32N/A

          \[\leadsto \frac{1}{s \cdot \color{blue}{\left(4 + \frac{x \cdot x}{s \cdot s}\right)}} \]
        5. *-commutativeN/A

          \[\leadsto \frac{1}{\color{blue}{\left(4 + \frac{x \cdot x}{s \cdot s}\right) \cdot s}} \]
        6. lower-*.f3277.9

          \[\leadsto \frac{1}{\color{blue}{\left(4 + \frac{x \cdot x}{s \cdot s}\right) \cdot s}} \]
        7. lift-+.f32N/A

          \[\leadsto \frac{1}{\color{blue}{\left(4 + \frac{x \cdot x}{s \cdot s}\right)} \cdot s} \]
        8. +-commutativeN/A

          \[\leadsto \frac{1}{\color{blue}{\left(\frac{x \cdot x}{s \cdot s} + 4\right)} \cdot s} \]
        9. lift-/.f32N/A

          \[\leadsto \frac{1}{\left(\color{blue}{\frac{x \cdot x}{s \cdot s}} + 4\right) \cdot s} \]
        10. lift-*.f32N/A

          \[\leadsto \frac{1}{\left(\frac{\color{blue}{x \cdot x}}{s \cdot s} + 4\right) \cdot s} \]
        11. associate-/l*N/A

          \[\leadsto \frac{1}{\left(\color{blue}{x \cdot \frac{x}{s \cdot s}} + 4\right) \cdot s} \]
        12. lower-fma.f32N/A

          \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(x, \frac{x}{s \cdot s}, 4\right)} \cdot s} \]
        13. lower-/.f3280.5

          \[\leadsto \frac{1}{\mathsf{fma}\left(x, \color{blue}{\frac{x}{s \cdot s}}, 4\right) \cdot s} \]
      9. Applied egg-rr80.5%

        \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(x, \frac{x}{s \cdot s}, 4\right) \cdot s}} \]
      10. Final simplification80.5%

        \[\leadsto \frac{1}{s \cdot \mathsf{fma}\left(x, \frac{x}{s \cdot s}, 4\right)} \]
      11. Add Preprocessing

      Alternative 21: 66.4% accurate, 11.0× speedup?

      \[\begin{array}{l} \\ \frac{1}{\mathsf{fma}\left(x, \frac{x}{s}, s \cdot 4\right)} \end{array} \]
      (FPCore (x s) :precision binary32 (/ 1.0 (fma x (/ x s) (* s 4.0))))
      float code(float x, float s) {
      	return 1.0f / fmaf(x, (x / s), (s * 4.0f));
      }
      
      function code(x, s)
      	return Float32(Float32(1.0) / fma(x, Float32(x / s), Float32(s * Float32(4.0))))
      end
      
      \begin{array}{l}
      
      \\
      \frac{1}{\mathsf{fma}\left(x, \frac{x}{s}, s \cdot 4\right)}
      \end{array}
      
      Derivation
      1. Initial program 98.9%

        \[\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. lift-fabs.f32N/A

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

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

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

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

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

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

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

          \[\leadsto \frac{\color{blue}{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \]
      4. Applied egg-rr99.0%

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

        \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)}} \]
      6. Step-by-step derivation
        1. lower-*.f32N/A

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

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

          \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}}\right)} \]
        4. unpow2N/A

          \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{\left|x\right| \cdot \left|x\right|}}{{s}^{2}}\right)} \]
        5. sqr-absN/A

          \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
        6. lower-*.f32N/A

          \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
        7. unpow2N/A

          \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
        8. lower-*.f3277.9

          \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
      7. Simplified77.9%

        \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{x \cdot x}{s \cdot s}\right)}} \]
      8. Step-by-step derivation
        1. lift-*.f32N/A

          \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{s \cdot s}\right)} \]
        2. lift-*.f32N/A

          \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
        3. lift-/.f32N/A

          \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{x \cdot x}{s \cdot s}}\right)} \]
        4. +-commutativeN/A

          \[\leadsto \frac{1}{s \cdot \color{blue}{\left(\frac{x \cdot x}{s \cdot s} + 4\right)}} \]
        5. distribute-rgt-inN/A

          \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x}{s \cdot s} \cdot s + 4 \cdot s}} \]
        6. *-commutativeN/A

          \[\leadsto \frac{1}{\frac{x \cdot x}{s \cdot s} \cdot s + \color{blue}{s \cdot 4}} \]
        7. lift-*.f32N/A

          \[\leadsto \frac{1}{\frac{x \cdot x}{s \cdot s} \cdot s + \color{blue}{s \cdot 4}} \]
        8. lift-/.f32N/A

          \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x}{s \cdot s}} \cdot s + s \cdot 4} \]
        9. div-invN/A

          \[\leadsto \frac{1}{\color{blue}{\left(\left(x \cdot x\right) \cdot \frac{1}{s \cdot s}\right)} \cdot s + s \cdot 4} \]
        10. associate-*l*N/A

          \[\leadsto \frac{1}{\color{blue}{\left(x \cdot x\right) \cdot \left(\frac{1}{s \cdot s} \cdot s\right)} + s \cdot 4} \]
        11. lift-*.f32N/A

          \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot \left(\frac{1}{\color{blue}{s \cdot s}} \cdot s\right) + s \cdot 4} \]
        12. pow2N/A

          \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot \left(\frac{1}{\color{blue}{{s}^{2}}} \cdot s\right) + s \cdot 4} \]
        13. pow-flipN/A

          \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot \left(\color{blue}{{s}^{\left(\mathsf{neg}\left(2\right)\right)}} \cdot s\right) + s \cdot 4} \]
        14. metadata-evalN/A

          \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot \left({s}^{\color{blue}{-2}} \cdot s\right) + s \cdot 4} \]
        15. pow-plusN/A

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

          \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot {s}^{\color{blue}{-1}} + s \cdot 4} \]
        17. inv-powN/A

          \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot \color{blue}{\frac{1}{s}} + s \cdot 4} \]
        18. div-invN/A

          \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x}{s}} + s \cdot 4} \]
        19. lift-*.f32N/A

          \[\leadsto \frac{1}{\frac{\color{blue}{x \cdot x}}{s} + s \cdot 4} \]
        20. associate-/l*N/A

          \[\leadsto \frac{1}{\color{blue}{x \cdot \frac{x}{s}} + s \cdot 4} \]
        21. lower-fma.f32N/A

          \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(x, \frac{x}{s}, s \cdot 4\right)}} \]
      9. Applied egg-rr66.6%

        \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(x, \frac{x}{s}, s \cdot 4\right)}} \]
      10. Add Preprocessing

      Alternative 22: 66.0% accurate, 11.0× speedup?

      \[\begin{array}{l} \\ \frac{1}{\mathsf{fma}\left(s, 4, \frac{x \cdot x}{s}\right)} \end{array} \]
      (FPCore (x s) :precision binary32 (/ 1.0 (fma s 4.0 (/ (* x x) s))))
      float code(float x, float s) {
      	return 1.0f / fmaf(s, 4.0f, ((x * x) / s));
      }
      
      function code(x, s)
      	return Float32(Float32(1.0) / fma(s, Float32(4.0), Float32(Float32(x * x) / s)))
      end
      
      \begin{array}{l}
      
      \\
      \frac{1}{\mathsf{fma}\left(s, 4, \frac{x \cdot x}{s}\right)}
      \end{array}
      
      Derivation
      1. Initial program 98.9%

        \[\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. lift-fabs.f32N/A

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

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

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

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

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

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

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

          \[\leadsto \frac{\color{blue}{e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}}}{\left(s \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)\right) \cdot \left(1 + e^{\frac{\mathsf{neg}\left(\left|x\right|\right)}{s}}\right)} \]
      4. Applied egg-rr99.0%

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

        \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}\right)}} \]
      6. Step-by-step derivation
        1. lower-*.f32N/A

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

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

          \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}}}\right)} \]
        4. unpow2N/A

          \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{\left|x\right| \cdot \left|x\right|}}{{s}^{2}}\right)} \]
        5. sqr-absN/A

          \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
        6. lower-*.f32N/A

          \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{{s}^{2}}\right)} \]
        7. unpow2N/A

          \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
        8. lower-*.f3277.9

          \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
      7. Simplified77.9%

        \[\leadsto \frac{1}{\color{blue}{s \cdot \left(4 + \frac{x \cdot x}{s \cdot s}\right)}} \]
      8. Step-by-step derivation
        1. lift-*.f32N/A

          \[\leadsto \frac{1}{s \cdot \left(4 + \frac{\color{blue}{x \cdot x}}{s \cdot s}\right)} \]
        2. lift-*.f32N/A

          \[\leadsto \frac{1}{s \cdot \left(4 + \frac{x \cdot x}{\color{blue}{s \cdot s}}\right)} \]
        3. lift-/.f32N/A

          \[\leadsto \frac{1}{s \cdot \left(4 + \color{blue}{\frac{x \cdot x}{s \cdot s}}\right)} \]
        4. distribute-rgt-inN/A

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

          \[\leadsto \frac{1}{\color{blue}{s \cdot 4} + \frac{x \cdot x}{s \cdot s} \cdot s} \]
        6. lift-/.f32N/A

          \[\leadsto \frac{1}{s \cdot 4 + \color{blue}{\frac{x \cdot x}{s \cdot s}} \cdot s} \]
        7. div-invN/A

          \[\leadsto \frac{1}{s \cdot 4 + \color{blue}{\left(\left(x \cdot x\right) \cdot \frac{1}{s \cdot s}\right)} \cdot s} \]
        8. associate-*l*N/A

          \[\leadsto \frac{1}{s \cdot 4 + \color{blue}{\left(x \cdot x\right) \cdot \left(\frac{1}{s \cdot s} \cdot s\right)}} \]
        9. lift-*.f32N/A

          \[\leadsto \frac{1}{s \cdot 4 + \left(x \cdot x\right) \cdot \left(\frac{1}{\color{blue}{s \cdot s}} \cdot s\right)} \]
        10. pow2N/A

          \[\leadsto \frac{1}{s \cdot 4 + \left(x \cdot x\right) \cdot \left(\frac{1}{\color{blue}{{s}^{2}}} \cdot s\right)} \]
        11. pow-flipN/A

          \[\leadsto \frac{1}{s \cdot 4 + \left(x \cdot x\right) \cdot \left(\color{blue}{{s}^{\left(\mathsf{neg}\left(2\right)\right)}} \cdot s\right)} \]
        12. metadata-evalN/A

          \[\leadsto \frac{1}{s \cdot 4 + \left(x \cdot x\right) \cdot \left({s}^{\color{blue}{-2}} \cdot s\right)} \]
        13. pow-plusN/A

          \[\leadsto \frac{1}{s \cdot 4 + \left(x \cdot x\right) \cdot \color{blue}{{s}^{\left(-2 + 1\right)}}} \]
        14. metadata-evalN/A

          \[\leadsto \frac{1}{s \cdot 4 + \left(x \cdot x\right) \cdot {s}^{\color{blue}{-1}}} \]
        15. inv-powN/A

          \[\leadsto \frac{1}{s \cdot 4 + \left(x \cdot x\right) \cdot \color{blue}{\frac{1}{s}}} \]
        16. div-invN/A

          \[\leadsto \frac{1}{s \cdot 4 + \color{blue}{\frac{x \cdot x}{s}}} \]
        17. lower-fma.f32N/A

          \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(s, 4, \frac{x \cdot x}{s}\right)}} \]
        18. lower-/.f3266.2

          \[\leadsto \frac{1}{\mathsf{fma}\left(s, 4, \color{blue}{\frac{x \cdot x}{s}}\right)} \]
      9. Applied egg-rr66.2%

        \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(s, 4, \frac{x \cdot x}{s}\right)}} \]
      10. Add Preprocessing

      Alternative 23: 27.6% accurate, 31.1× 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 98.9%

        \[\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. lower-/.f3224.6

          \[\leadsto \color{blue}{\frac{0.25}{s}} \]
      5. Simplified24.6%

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

      Reproduce

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