Logistic distribution

Percentage Accurate: 99.6% → 99.6%
Time: 11.5s
Alternatives: 16
Speedup: 1.2×

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 16 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, 1.2× speedup?

\[\begin{array}{l} \\ \frac{1}{\left(1 + e^{\frac{\left|x\right|}{-s}}\right) \cdot \mathsf{fma}\left(s, e^{\frac{\left|x\right|}{s}}, s\right)} \end{array} \]
(FPCore (x s)
 :precision binary32
 (/ 1.0 (* (+ 1.0 (exp (/ (fabs x) (- s)))) (fma s (exp (/ (fabs x) s)) s))))
float code(float x, float s) {
	return 1.0f / ((1.0f + expf((fabsf(x) / -s))) * fmaf(s, expf((fabsf(x) / s)), s));
}
function code(x, s)
	return Float32(Float32(1.0) / Float32(Float32(Float32(1.0) + exp(Float32(abs(x) / Float32(-s)))) * fma(s, exp(Float32(abs(x) / s)), s)))
end
\begin{array}{l}

\\
\frac{1}{\left(1 + e^{\frac{\left|x\right|}{-s}}\right) \cdot \mathsf{fma}\left(s, e^{\frac{\left|x\right|}{s}}, s\right)}
\end{array}
Derivation
  1. Initial program 99.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. Step-by-step derivation
    1. *-lft-identity99.7%

      \[\leadsto \color{blue}{1 \cdot \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. associate-*r/99.7%

      \[\leadsto \color{blue}{\frac{1 \cdot 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)}} \]
    3. associate-/l*99.7%

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

      \[\leadsto \frac{1}{\frac{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}{e^{\color{blue}{-\frac{\left|x\right|}{s}}}}} \]
    5. exp-neg99.8%

      \[\leadsto \frac{1}{\frac{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}{\color{blue}{\frac{1}{e^{\frac{\left|x\right|}{s}}}}}} \]
    6. associate-/r/99.8%

      \[\leadsto \frac{1}{\color{blue}{\frac{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}{1} \cdot e^{\frac{\left|x\right|}{s}}}} \]
    7. /-rgt-identity99.8%

      \[\leadsto \frac{1}{\color{blue}{\left(\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right)} \cdot e^{\frac{\left|x\right|}{s}}} \]
    8. associate-*l*99.8%

      \[\leadsto \frac{1}{\color{blue}{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(\left(1 + e^{\frac{-\left|x\right|}{s}}\right) \cdot e^{\frac{\left|x\right|}{s}}\right)}} \]
  3. Simplified99.8%

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

    \[\leadsto \frac{1}{\left(1 + e^{\frac{\left|x\right|}{-s}}\right) \cdot \mathsf{fma}\left(s, e^{\frac{\left|x\right|}{s}}, s\right)} \]

Alternative 2: 99.4% accurate, 1.5× speedup?

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

\\
\frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{-s}} + 2\right)}
\end{array}
Derivation
  1. Initial program 99.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. Step-by-step derivation
    1. *-lft-identity99.7%

      \[\leadsto \color{blue}{1 \cdot \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. associate-*r/99.7%

      \[\leadsto \color{blue}{\frac{1 \cdot 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)}} \]
    3. associate-*l*99.8%

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{s} \cdot e^{\frac{-\left|x\right|}{s}}}{\left(1 + e^{\frac{-\left|x\right|}{s}}\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}} \]
    6. associate-/l*98.9%

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

      \[\leadsto \frac{\frac{1}{s}}{\frac{\left(1 + e^{\frac{-\left|x\right|}{s}}\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}{e^{\color{blue}{-\frac{\left|x\right|}{s}}}}} \]
    8. exp-neg99.0%

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

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

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

Alternative 3: 97.0% accurate, 2.0× speedup?

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

\\
\frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(2 + e^{\frac{x}{s}}\right)}
\end{array}
Derivation
  1. Initial program 99.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. Step-by-step derivation
    1. *-lft-identity99.7%

      \[\leadsto \color{blue}{1 \cdot \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. associate-*r/99.7%

      \[\leadsto \color{blue}{\frac{1 \cdot 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)}} \]
    3. associate-*l*99.8%

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{s} \cdot e^{\frac{-\left|x\right|}{s}}}{\left(1 + e^{\frac{-\left|x\right|}{s}}\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}} \]
    6. associate-/l*98.9%

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

      \[\leadsto \frac{\frac{1}{s}}{\frac{\left(1 + e^{\frac{-\left|x\right|}{s}}\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}{e^{\color{blue}{-\frac{\left|x\right|}{s}}}}} \]
    8. exp-neg99.0%

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

    \[\leadsto \color{blue}{\frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{-s}} + 2\right)}} \]
  4. Step-by-step derivation
    1. expm1-log1p-u99.1%

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(e^{\frac{\left|x\right|}{-s}}\right)\right)} + 2\right)} \]
    2. expm1-udef99.1%

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\color{blue}{\left(e^{\mathsf{log1p}\left(e^{\frac{\left|x\right|}{-s}}\right)} - 1\right)} + 2\right)} \]
    3. log1p-udef99.1%

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

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\color{blue}{\left(e^{\frac{\left|x\right|}{-s}} + 1\right)} - 1\right) + 2\right)} \]
    6. add-sqr-sqrt53.1%

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\left(e^{\frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{-s}} + 1\right) - 1\right) + 2\right)} \]
    8. add-sqr-sqrt97.2%

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\left(e^{\frac{\color{blue}{x}}{-s}} + 1\right) - 1\right) + 2\right)} \]
    9. add-sqr-sqrt-0.0%

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\left(e^{\frac{x}{\color{blue}{\sqrt{\left(-s\right) \cdot \left(-s\right)}}}} + 1\right) - 1\right) + 2\right)} \]
    11. sqr-neg94.5%

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\left(e^{\frac{x}{\color{blue}{\sqrt{s} \cdot \sqrt{s}}}} + 1\right) - 1\right) + 2\right)} \]
    13. add-sqr-sqrt97.2%

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

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

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

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

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

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

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

Alternative 4: 95.6% accurate, 3.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\frac{x}{s}}\\ \mathbf{if}\;x \leq -1.000000023742228 \cdot 10^{-33}:\\ \;\;\;\;{\left(\frac{s \cdot 4}{t_0}\right)}^{-1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{s \cdot \left(t_0 + 3\right)}\\ \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (let* ((t_0 (exp (/ x s))))
   (if (<= x -1.000000023742228e-33)
     (pow (/ (* s 4.0) t_0) -1.0)
     (/ 1.0 (* s (+ t_0 3.0))))))
float code(float x, float s) {
	float t_0 = expf((x / s));
	float tmp;
	if (x <= -1.000000023742228e-33f) {
		tmp = powf(((s * 4.0f) / t_0), -1.0f);
	} else {
		tmp = 1.0f / (s * (t_0 + 3.0f));
	}
	return tmp;
}
real(4) function code(x, s)
    real(4), intent (in) :: x
    real(4), intent (in) :: s
    real(4) :: t_0
    real(4) :: tmp
    t_0 = exp((x / s))
    if (x <= (-1.000000023742228e-33)) then
        tmp = ((s * 4.0e0) / t_0) ** (-1.0e0)
    else
        tmp = 1.0e0 / (s * (t_0 + 3.0e0))
    end if
    code = tmp
end function
function code(x, s)
	t_0 = exp(Float32(x / s))
	tmp = Float32(0.0)
	if (x <= Float32(-1.000000023742228e-33))
		tmp = Float32(Float32(s * Float32(4.0)) / t_0) ^ Float32(-1.0);
	else
		tmp = Float32(Float32(1.0) / Float32(s * Float32(t_0 + Float32(3.0))));
	end
	return tmp
end
function tmp_2 = code(x, s)
	t_0 = exp((x / s));
	tmp = single(0.0);
	if (x <= single(-1.000000023742228e-33))
		tmp = ((s * single(4.0)) / t_0) ^ single(-1.0);
	else
		tmp = single(1.0) / (s * (t_0 + single(3.0)));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{\frac{x}{s}}\\
\mathbf{if}\;x \leq -1.000000023742228 \cdot 10^{-33}:\\
\;\;\;\;{\left(\frac{s \cdot 4}{t_0}\right)}^{-1}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{s \cdot \left(t_0 + 3\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.00000002e-33

    1. Initial program 99.6%

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

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

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

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

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

    if -1.00000002e-33 < x

    1. Initial program 99.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. Step-by-step derivation
      1. *-lft-identity99.9%

        \[\leadsto \color{blue}{1 \cdot \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. associate-*r/99.9%

        \[\leadsto \color{blue}{\frac{1 \cdot 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)}} \]
      3. associate-*l*99.8%

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{s} \cdot e^{\frac{-\left|x\right|}{s}}}{\left(1 + e^{\frac{-\left|x\right|}{s}}\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}} \]
      6. associate-/l*99.1%

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{-s}} + 2\right)}} \]
    4. Step-by-step derivation
      1. expm1-log1p-u99.3%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(e^{\frac{\left|x\right|}{-s}}\right)\right)} + 2\right)} \]
      2. expm1-udef99.2%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\color{blue}{\left(e^{\mathsf{log1p}\left(e^{\frac{\left|x\right|}{-s}}\right)} - 1\right)} + 2\right)} \]
      3. log1p-udef99.3%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(e^{\color{blue}{\log \left(1 + e^{\frac{\left|x\right|}{-s}}\right)}} - 1\right) + 2\right)} \]
      4. +-commutative99.3%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(e^{\log \color{blue}{\left(e^{\frac{\left|x\right|}{-s}} + 1\right)}} - 1\right) + 2\right)} \]
      5. add-exp-log99.3%

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

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

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\left(e^{\frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{-s}} + 1\right) - 1\right) + 2\right)} \]
      8. add-sqr-sqrt99.0%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\left(e^{\frac{\color{blue}{x}}{-s}} + 1\right) - 1\right) + 2\right)} \]
      9. add-sqr-sqrt-0.0%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\left(e^{\frac{x}{\color{blue}{\sqrt{-s} \cdot \sqrt{-s}}}} + 1\right) - 1\right) + 2\right)} \]
      10. sqrt-unprod91.3%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\left(e^{\frac{x}{\color{blue}{\sqrt{\left(-s\right) \cdot \left(-s\right)}}}} + 1\right) - 1\right) + 2\right)} \]
      11. sqr-neg91.3%

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

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\left(e^{\frac{x}{\color{blue}{\sqrt{s} \cdot \sqrt{s}}}} + 1\right) - 1\right) + 2\right)} \]
      13. add-sqr-sqrt96.0%

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\color{blue}{e^{\frac{x}{s}}} + 2\right)} \]
    8. Taylor expanded in x around 0 96.7%

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

        \[\leadsto \frac{1}{s \cdot \color{blue}{\left(e^{\frac{\left|x\right|}{s}} + 3\right)}} \]
    10. Simplified96.7%

      \[\leadsto \color{blue}{\frac{1}{s \cdot \left(e^{\frac{\left|x\right|}{s}} + 3\right)}} \]
    11. Step-by-step derivation
      1. distribute-lft-in96.7%

        \[\leadsto \frac{1}{\color{blue}{s \cdot e^{\frac{\left|x\right|}{s}} + s \cdot 3}} \]
      2. div-inv96.7%

        \[\leadsto \frac{1}{s \cdot e^{\color{blue}{\left|x\right| \cdot \frac{1}{s}}} + s \cdot 3} \]
      3. exp-prod81.5%

        \[\leadsto \frac{1}{s \cdot \color{blue}{{\left(e^{\left|x\right|}\right)}^{\left(\frac{1}{s}\right)}} + s \cdot 3} \]
      4. add-sqr-sqrt74.8%

        \[\leadsto \frac{1}{s \cdot {\left(e^{\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right|}\right)}^{\left(\frac{1}{s}\right)} + s \cdot 3} \]
      5. fabs-sqr74.8%

        \[\leadsto \frac{1}{s \cdot {\left(e^{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}\right)}^{\left(\frac{1}{s}\right)} + s \cdot 3} \]
      6. add-sqr-sqrt81.5%

        \[\leadsto \frac{1}{s \cdot {\left(e^{\color{blue}{x}}\right)}^{\left(\frac{1}{s}\right)} + s \cdot 3} \]
      7. exp-prod96.7%

        \[\leadsto \frac{1}{s \cdot \color{blue}{e^{x \cdot \frac{1}{s}}} + s \cdot 3} \]
      8. div-inv96.7%

        \[\leadsto \frac{1}{s \cdot e^{\color{blue}{\frac{x}{s}}} + s \cdot 3} \]
    12. Applied egg-rr96.7%

      \[\leadsto \frac{1}{\color{blue}{s \cdot e^{\frac{x}{s}} + s \cdot 3}} \]
    13. Step-by-step derivation
      1. distribute-lft-in96.7%

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

        \[\leadsto \frac{1}{s \cdot \color{blue}{\left(3 + e^{\frac{x}{s}}\right)}} \]
    14. Simplified96.7%

      \[\leadsto \frac{1}{\color{blue}{s \cdot \left(3 + e^{\frac{x}{s}}\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification96.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.000000023742228 \cdot 10^{-33}:\\ \;\;\;\;{\left(\frac{s \cdot 4}{e^{\frac{x}{s}}}\right)}^{-1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{s \cdot \left(e^{\frac{x}{s}} + 3\right)}\\ \end{array} \]

Alternative 5: 89.2% accurate, 3.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.9999998795923744 \cdot 10^{-13}:\\ \;\;\;\;\frac{1}{\mathsf{log1p}\left(\mathsf{expm1}\left(x \cdot \frac{x}{s}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{s \cdot \left(e^{\frac{x}{s}} + 3\right)}\\ \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (if (<= x -2.9999998795923744e-13)
   (/ 1.0 (log1p (expm1 (* x (/ x s)))))
   (/ 1.0 (* s (+ (exp (/ x s)) 3.0)))))
float code(float x, float s) {
	float tmp;
	if (x <= -2.9999998795923744e-13f) {
		tmp = 1.0f / log1pf(expm1f((x * (x / s))));
	} else {
		tmp = 1.0f / (s * (expf((x / s)) + 3.0f));
	}
	return tmp;
}
function code(x, s)
	tmp = Float32(0.0)
	if (x <= Float32(-2.9999998795923744e-13))
		tmp = Float32(Float32(1.0) / log1p(expm1(Float32(x * Float32(x / s)))));
	else
		tmp = Float32(Float32(1.0) / Float32(s * Float32(exp(Float32(x / s)) + Float32(3.0))));
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.9999998795923744 \cdot 10^{-13}:\\
\;\;\;\;\frac{1}{\mathsf{log1p}\left(\mathsf{expm1}\left(x \cdot \frac{x}{s}\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{s \cdot \left(e^{\frac{x}{s}} + 3\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.99999988e-13

    1. Initial program 99.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. Step-by-step derivation
      1. *-lft-identity99.9%

        \[\leadsto \color{blue}{1 \cdot \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. associate-*r/99.9%

        \[\leadsto \color{blue}{\frac{1 \cdot 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)}} \]
      3. associate-/l*99.9%

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

        \[\leadsto \frac{1}{\frac{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}{e^{\color{blue}{-\frac{\left|x\right|}{s}}}}} \]
      5. exp-neg99.9%

        \[\leadsto \frac{1}{\frac{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}{\color{blue}{\frac{1}{e^{\frac{\left|x\right|}{s}}}}}} \]
      6. associate-/r/99.9%

        \[\leadsto \frac{1}{\color{blue}{\frac{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}{1} \cdot e^{\frac{\left|x\right|}{s}}}} \]
      7. /-rgt-identity99.9%

        \[\leadsto \frac{1}{\color{blue}{\left(\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right)} \cdot e^{\frac{\left|x\right|}{s}}} \]
      8. associate-*l*99.9%

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

      \[\leadsto \color{blue}{\frac{1}{\left(e^{\frac{\left|x\right|}{-s}} + 1\right) \cdot \mathsf{fma}\left(s, e^{\frac{\left|x\right|}{s}}, s\right)}} \]
    4. Taylor expanded in s around inf 6.1%

      \[\leadsto \frac{1}{\color{blue}{2 \cdot \left|x\right| + \left(-2 \cdot \left|x\right| + \left(2 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s} + \left(4 \cdot s + -1 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s}\right)\right)\right)}} \]
    5. Step-by-step derivation
      1. associate-+r+6.1%

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

        \[\leadsto \frac{1}{\left(2 \cdot \left|x\right| + -2 \cdot \left|x\right|\right) + \color{blue}{\left(\left(4 \cdot s + -1 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s}\right) + 2 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s}\right)}} \]
      3. associate-+r+6.1%

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

      \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(2, \frac{x \cdot x}{s}, s \cdot 4\right) - \frac{x \cdot x}{s}}} \]
    7. Taylor expanded in x around inf 59.6%

      \[\leadsto \frac{1}{\color{blue}{\frac{{x}^{2}}{s}}} \]
    8. Step-by-step derivation
      1. unpow259.6%

        \[\leadsto \frac{1}{\frac{\color{blue}{x \cdot x}}{s}} \]
      2. associate-/l*59.6%

        \[\leadsto \frac{1}{\color{blue}{\frac{x}{\frac{s}{x}}}} \]
    9. Simplified59.6%

      \[\leadsto \frac{1}{\color{blue}{\frac{x}{\frac{s}{x}}}} \]
    10. Step-by-step derivation
      1. associate-/l*59.6%

        \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x}{s}}} \]
      2. add-sqr-sqrt59.6%

        \[\leadsto \frac{1}{\color{blue}{\sqrt{\frac{x \cdot x}{s}} \cdot \sqrt{\frac{x \cdot x}{s}}}} \]
      3. fabs-sqr59.6%

        \[\leadsto \frac{1}{\color{blue}{\left|\sqrt{\frac{x \cdot x}{s}} \cdot \sqrt{\frac{x \cdot x}{s}}\right|}} \]
      4. add-sqr-sqrt59.6%

        \[\leadsto \frac{1}{\left|\color{blue}{\frac{x \cdot x}{s}}\right|} \]
      5. associate-/l*59.6%

        \[\leadsto \frac{1}{\left|\color{blue}{\frac{x}{\frac{s}{x}}}\right|} \]
      6. log1p-expm1-u93.9%

        \[\leadsto \frac{1}{\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\left|\frac{x}{\frac{s}{x}}\right|\right)\right)}} \]
      7. associate-/l*93.9%

        \[\leadsto \frac{1}{\mathsf{log1p}\left(\mathsf{expm1}\left(\left|\color{blue}{\frac{x \cdot x}{s}}\right|\right)\right)} \]
      8. add-sqr-sqrt93.9%

        \[\leadsto \frac{1}{\mathsf{log1p}\left(\mathsf{expm1}\left(\left|\color{blue}{\sqrt{\frac{x \cdot x}{s}} \cdot \sqrt{\frac{x \cdot x}{s}}}\right|\right)\right)} \]
      9. fabs-sqr93.9%

        \[\leadsto \frac{1}{\mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\sqrt{\frac{x \cdot x}{s}} \cdot \sqrt{\frac{x \cdot x}{s}}}\right)\right)} \]
      10. add-sqr-sqrt93.9%

        \[\leadsto \frac{1}{\mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\frac{x \cdot x}{s}}\right)\right)} \]
      11. associate-*r/93.9%

        \[\leadsto \frac{1}{\mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{x \cdot \frac{x}{s}}\right)\right)} \]
    11. Applied egg-rr93.9%

      \[\leadsto \frac{1}{\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(x \cdot \frac{x}{s}\right)\right)}} \]

    if -2.99999988e-13 < x

    1. Initial program 99.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. Step-by-step derivation
      1. *-lft-identity99.7%

        \[\leadsto \color{blue}{1 \cdot \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. associate-*r/99.7%

        \[\leadsto \color{blue}{\frac{1 \cdot 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)}} \]
      3. associate-*l*99.7%

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{s} \cdot e^{\frac{-\left|x\right|}{s}}}{\left(1 + e^{\frac{-\left|x\right|}{s}}\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}} \]
      6. associate-/l*99.1%

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{-s}} + 2\right)}} \]
    4. Step-by-step derivation
      1. expm1-log1p-u99.3%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(e^{\frac{\left|x\right|}{-s}}\right)\right)} + 2\right)} \]
      2. expm1-udef99.3%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\color{blue}{\left(e^{\mathsf{log1p}\left(e^{\frac{\left|x\right|}{-s}}\right)} - 1\right)} + 2\right)} \]
      3. log1p-udef99.3%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(e^{\color{blue}{\log \left(1 + e^{\frac{\left|x\right|}{-s}}\right)}} - 1\right) + 2\right)} \]
      4. +-commutative99.3%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(e^{\log \color{blue}{\left(e^{\frac{\left|x\right|}{-s}} + 1\right)}} - 1\right) + 2\right)} \]
      5. add-exp-log99.3%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\color{blue}{\left(e^{\frac{\left|x\right|}{-s}} + 1\right)} - 1\right) + 2\right)} \]
      6. add-sqr-sqrt74.7%

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

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\left(e^{\frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{-s}} + 1\right) - 1\right) + 2\right)} \]
      8. add-sqr-sqrt97.3%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\left(e^{\frac{\color{blue}{x}}{-s}} + 1\right) - 1\right) + 2\right)} \]
      9. add-sqr-sqrt-0.0%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\left(e^{\frac{x}{\color{blue}{\sqrt{-s} \cdot \sqrt{-s}}}} + 1\right) - 1\right) + 2\right)} \]
      10. sqrt-unprod92.8%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\left(e^{\frac{x}{\color{blue}{\sqrt{\left(-s\right) \cdot \left(-s\right)}}}} + 1\right) - 1\right) + 2\right)} \]
      11. sqr-neg92.8%

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

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\left(e^{\frac{x}{\color{blue}{\sqrt{s} \cdot \sqrt{s}}}} + 1\right) - 1\right) + 2\right)} \]
      13. add-sqr-sqrt96.7%

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\color{blue}{e^{\frac{x}{s}}} + 2\right)} \]
    8. Taylor expanded in x around 0 96.4%

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

        \[\leadsto \frac{1}{s \cdot \color{blue}{\left(e^{\frac{\left|x\right|}{s}} + 3\right)}} \]
    10. Simplified96.4%

      \[\leadsto \color{blue}{\frac{1}{s \cdot \left(e^{\frac{\left|x\right|}{s}} + 3\right)}} \]
    11. Step-by-step derivation
      1. distribute-lft-in96.4%

        \[\leadsto \frac{1}{\color{blue}{s \cdot e^{\frac{\left|x\right|}{s}} + s \cdot 3}} \]
      2. div-inv96.4%

        \[\leadsto \frac{1}{s \cdot e^{\color{blue}{\left|x\right| \cdot \frac{1}{s}}} + s \cdot 3} \]
      3. exp-prod77.8%

        \[\leadsto \frac{1}{s \cdot \color{blue}{{\left(e^{\left|x\right|}\right)}^{\left(\frac{1}{s}\right)}} + s \cdot 3} \]
      4. add-sqr-sqrt60.4%

        \[\leadsto \frac{1}{s \cdot {\left(e^{\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right|}\right)}^{\left(\frac{1}{s}\right)} + s \cdot 3} \]
      5. fabs-sqr60.4%

        \[\leadsto \frac{1}{s \cdot {\left(e^{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}\right)}^{\left(\frac{1}{s}\right)} + s \cdot 3} \]
      6. add-sqr-sqrt77.8%

        \[\leadsto \frac{1}{s \cdot {\left(e^{\color{blue}{x}}\right)}^{\left(\frac{1}{s}\right)} + s \cdot 3} \]
      7. exp-prod89.5%

        \[\leadsto \frac{1}{s \cdot \color{blue}{e^{x \cdot \frac{1}{s}}} + s \cdot 3} \]
      8. div-inv89.5%

        \[\leadsto \frac{1}{s \cdot e^{\color{blue}{\frac{x}{s}}} + s \cdot 3} \]
    12. Applied egg-rr89.5%

      \[\leadsto \frac{1}{\color{blue}{s \cdot e^{\frac{x}{s}} + s \cdot 3}} \]
    13. Step-by-step derivation
      1. distribute-lft-in89.5%

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

        \[\leadsto \frac{1}{s \cdot \color{blue}{\left(3 + e^{\frac{x}{s}}\right)}} \]
    14. Simplified89.5%

      \[\leadsto \frac{1}{\color{blue}{s \cdot \left(3 + e^{\frac{x}{s}}\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification90.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.9999998795923744 \cdot 10^{-13}:\\ \;\;\;\;\frac{1}{\mathsf{log1p}\left(\mathsf{expm1}\left(x \cdot \frac{x}{s}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{s \cdot \left(e^{\frac{x}{s}} + 3\right)}\\ \end{array} \]

Alternative 6: 96.3% accurate, 3.0× speedup?

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

\\
\frac{1}{s \cdot \left(e^{\frac{\left|x\right|}{s}} + 3\right)}
\end{array}
Derivation
  1. Initial program 99.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. Step-by-step derivation
    1. *-lft-identity99.7%

      \[\leadsto \color{blue}{1 \cdot \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. associate-*r/99.7%

      \[\leadsto \color{blue}{\frac{1 \cdot 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)}} \]
    3. associate-*l*99.8%

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{s} \cdot e^{\frac{-\left|x\right|}{s}}}{\left(1 + e^{\frac{-\left|x\right|}{s}}\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}} \]
    6. associate-/l*98.9%

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

      \[\leadsto \frac{\frac{1}{s}}{\frac{\left(1 + e^{\frac{-\left|x\right|}{s}}\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}{e^{\color{blue}{-\frac{\left|x\right|}{s}}}}} \]
    8. exp-neg99.0%

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

    \[\leadsto \color{blue}{\frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{-s}} + 2\right)}} \]
  4. Step-by-step derivation
    1. expm1-log1p-u99.1%

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(e^{\frac{\left|x\right|}{-s}}\right)\right)} + 2\right)} \]
    2. expm1-udef99.1%

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\color{blue}{\left(e^{\mathsf{log1p}\left(e^{\frac{\left|x\right|}{-s}}\right)} - 1\right)} + 2\right)} \]
    3. log1p-udef99.1%

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

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\color{blue}{\left(e^{\frac{\left|x\right|}{-s}} + 1\right)} - 1\right) + 2\right)} \]
    6. add-sqr-sqrt53.1%

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\left(e^{\frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{-s}} + 1\right) - 1\right) + 2\right)} \]
    8. add-sqr-sqrt97.2%

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\left(e^{\frac{\color{blue}{x}}{-s}} + 1\right) - 1\right) + 2\right)} \]
    9. add-sqr-sqrt-0.0%

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\left(e^{\frac{x}{\color{blue}{\sqrt{\left(-s\right) \cdot \left(-s\right)}}}} + 1\right) - 1\right) + 2\right)} \]
    11. sqr-neg94.5%

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\left(e^{\frac{x}{\color{blue}{\sqrt{s} \cdot \sqrt{s}}}} + 1\right) - 1\right) + 2\right)} \]
    13. add-sqr-sqrt97.2%

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

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

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

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

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

    \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\color{blue}{e^{\frac{x}{s}}} + 2\right)} \]
  8. Taylor expanded in x around 0 97.2%

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

      \[\leadsto \frac{1}{s \cdot \color{blue}{\left(e^{\frac{\left|x\right|}{s}} + 3\right)}} \]
  10. Simplified97.2%

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

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

Alternative 7: 89.2% accurate, 5.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5.000000156871975 \cdot 10^{-23}:\\ \;\;\;\;\frac{\frac{1}{s}}{4 + \frac{x \cdot x}{s \cdot s}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{s \cdot \left(e^{\frac{x}{s}} + 3\right)}\\ \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (if (<= x -5.000000156871975e-23)
   (/ (/ 1.0 s) (+ 4.0 (/ (* x x) (* s s))))
   (/ 1.0 (* s (+ (exp (/ x s)) 3.0)))))
float code(float x, float s) {
	float tmp;
	if (x <= -5.000000156871975e-23f) {
		tmp = (1.0f / s) / (4.0f + ((x * x) / (s * s)));
	} else {
		tmp = 1.0f / (s * (expf((x / s)) + 3.0f));
	}
	return tmp;
}
real(4) function code(x, s)
    real(4), intent (in) :: x
    real(4), intent (in) :: s
    real(4) :: tmp
    if (x <= (-5.000000156871975e-23)) then
        tmp = (1.0e0 / s) / (4.0e0 + ((x * x) / (s * s)))
    else
        tmp = 1.0e0 / (s * (exp((x / s)) + 3.0e0))
    end if
    code = tmp
end function
function code(x, s)
	tmp = Float32(0.0)
	if (x <= Float32(-5.000000156871975e-23))
		tmp = Float32(Float32(Float32(1.0) / s) / Float32(Float32(4.0) + Float32(Float32(x * x) / Float32(s * s))));
	else
		tmp = Float32(Float32(1.0) / Float32(s * Float32(exp(Float32(x / s)) + Float32(3.0))));
	end
	return tmp
end
function tmp_2 = code(x, s)
	tmp = single(0.0);
	if (x <= single(-5.000000156871975e-23))
		tmp = (single(1.0) / s) / (single(4.0) + ((x * x) / (s * s)));
	else
		tmp = single(1.0) / (s * (exp((x / s)) + single(3.0)));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.000000156871975 \cdot 10^{-23}:\\
\;\;\;\;\frac{\frac{1}{s}}{4 + \frac{x \cdot x}{s \cdot s}}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{s \cdot \left(e^{\frac{x}{s}} + 3\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -5.00000016e-23

    1. Initial program 99.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. Step-by-step derivation
      1. *-lft-identity99.7%

        \[\leadsto \color{blue}{1 \cdot \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. associate-*r/99.7%

        \[\leadsto \color{blue}{\frac{1 \cdot 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)}} \]
      3. associate-*l*99.8%

        \[\leadsto \frac{1 \cdot e^{\frac{-\left|x\right|}{s}}}{\color{blue}{s \cdot \left(\left(1 + e^{\frac{-\left|x\right|}{s}}\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right)}} \]
      4. times-frac98.6%

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

        \[\leadsto \color{blue}{\frac{\frac{1}{s} \cdot e^{\frac{-\left|x\right|}{s}}}{\left(1 + e^{\frac{-\left|x\right|}{s}}\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}} \]
      6. associate-/l*98.6%

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

        \[\leadsto \frac{\frac{1}{s}}{\frac{\left(1 + e^{\frac{-\left|x\right|}{s}}\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}{e^{\color{blue}{-\frac{\left|x\right|}{s}}}}} \]
      8. exp-neg98.8%

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

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

      \[\leadsto \frac{\frac{1}{s}}{\color{blue}{\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}} + \left(4 + \left(-1 \cdot \frac{\left|x\right|}{s} + \frac{\left|x\right|}{s}\right)\right)}} \]
    5. Step-by-step derivation
      1. associate-+r+51.4%

        \[\leadsto \frac{\frac{1}{s}}{\color{blue}{\left(\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}} + 4\right) + \left(-1 \cdot \frac{\left|x\right|}{s} + \frac{\left|x\right|}{s}\right)}} \]
      2. distribute-lft1-in51.4%

        \[\leadsto \frac{\frac{1}{s}}{\left(\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}} + 4\right) + \color{blue}{\left(-1 + 1\right) \cdot \frac{\left|x\right|}{s}}} \]
      3. metadata-eval51.4%

        \[\leadsto \frac{\frac{1}{s}}{\left(\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}} + 4\right) + \color{blue}{0} \cdot \frac{\left|x\right|}{s}} \]
      4. mul0-lft80.2%

        \[\leadsto \frac{\frac{1}{s}}{\left(\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}} + 4\right) + \color{blue}{0}} \]
      5. associate-+r+80.2%

        \[\leadsto \frac{\frac{1}{s}}{\color{blue}{\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}} + \left(4 + 0\right)}} \]
      6. metadata-eval80.2%

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

        \[\leadsto \frac{\frac{1}{s}}{\frac{\color{blue}{\left|x\right| \cdot \left|x\right|}}{{s}^{2}} + 4} \]
      8. sqr-abs80.2%

        \[\leadsto \frac{\frac{1}{s}}{\frac{\color{blue}{x \cdot x}}{{s}^{2}} + 4} \]
      9. unpow280.2%

        \[\leadsto \frac{\frac{1}{s}}{\frac{x \cdot x}{\color{blue}{s \cdot s}} + 4} \]
    6. Simplified80.2%

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

    if -5.00000016e-23 < x

    1. Initial program 99.8%

      \[\frac{e^{\frac{-\left|x\right|}{s}}}{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)} \]
    2. Step-by-step derivation
      1. *-lft-identity99.8%

        \[\leadsto \color{blue}{1 \cdot \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. associate-*r/99.8%

        \[\leadsto \color{blue}{\frac{1 \cdot 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)}} \]
      3. associate-*l*99.8%

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{s} \cdot e^{\frac{-\left|x\right|}{s}}}{\left(1 + e^{\frac{-\left|x\right|}{s}}\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}} \]
      6. associate-/l*99.1%

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{-s}} + 2\right)}} \]
    4. Step-by-step derivation
      1. expm1-log1p-u99.2%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(e^{\frac{\left|x\right|}{-s}}\right)\right)} + 2\right)} \]
      2. expm1-udef99.2%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\color{blue}{\left(e^{\mathsf{log1p}\left(e^{\frac{\left|x\right|}{-s}}\right)} - 1\right)} + 2\right)} \]
      3. log1p-udef99.2%

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

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

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

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

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\left(e^{\frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{-s}} + 1\right) - 1\right) + 2\right)} \]
      8. add-sqr-sqrt98.1%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\left(e^{\frac{\color{blue}{x}}{-s}} + 1\right) - 1\right) + 2\right)} \]
      9. add-sqr-sqrt-0.0%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\left(e^{\frac{x}{\color{blue}{\sqrt{-s} \cdot \sqrt{-s}}}} + 1\right) - 1\right) + 2\right)} \]
      10. sqrt-unprod91.8%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\left(e^{\frac{x}{\color{blue}{\sqrt{\left(-s\right) \cdot \left(-s\right)}}}} + 1\right) - 1\right) + 2\right)} \]
      11. sqr-neg91.8%

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

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\left(e^{\frac{x}{\color{blue}{\sqrt{s} \cdot \sqrt{s}}}} + 1\right) - 1\right) + 2\right)} \]
      13. add-sqr-sqrt96.2%

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\color{blue}{e^{\frac{x}{s}}} + 2\right)} \]
    8. Taylor expanded in x around 0 96.9%

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

        \[\leadsto \frac{1}{s \cdot \color{blue}{\left(e^{\frac{\left|x\right|}{s}} + 3\right)}} \]
    10. Simplified96.9%

      \[\leadsto \color{blue}{\frac{1}{s \cdot \left(e^{\frac{\left|x\right|}{s}} + 3\right)}} \]
    11. Step-by-step derivation
      1. distribute-lft-in96.9%

        \[\leadsto \frac{1}{\color{blue}{s \cdot e^{\frac{\left|x\right|}{s}} + s \cdot 3}} \]
      2. div-inv96.9%

        \[\leadsto \frac{1}{s \cdot e^{\color{blue}{\left|x\right| \cdot \frac{1}{s}}} + s \cdot 3} \]
      3. exp-prod79.3%

        \[\leadsto \frac{1}{s \cdot \color{blue}{{\left(e^{\left|x\right|}\right)}^{\left(\frac{1}{s}\right)}} + s \cdot 3} \]
      4. add-sqr-sqrt69.1%

        \[\leadsto \frac{1}{s \cdot {\left(e^{\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right|}\right)}^{\left(\frac{1}{s}\right)} + s \cdot 3} \]
      5. fabs-sqr69.1%

        \[\leadsto \frac{1}{s \cdot {\left(e^{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}\right)}^{\left(\frac{1}{s}\right)} + s \cdot 3} \]
      6. add-sqr-sqrt79.3%

        \[\leadsto \frac{1}{s \cdot {\left(e^{\color{blue}{x}}\right)}^{\left(\frac{1}{s}\right)} + s \cdot 3} \]
      7. exp-prod93.3%

        \[\leadsto \frac{1}{s \cdot \color{blue}{e^{x \cdot \frac{1}{s}}} + s \cdot 3} \]
      8. div-inv93.3%

        \[\leadsto \frac{1}{s \cdot e^{\color{blue}{\frac{x}{s}}} + s \cdot 3} \]
    12. Applied egg-rr93.3%

      \[\leadsto \frac{1}{\color{blue}{s \cdot e^{\frac{x}{s}} + s \cdot 3}} \]
    13. Step-by-step derivation
      1. distribute-lft-in93.3%

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

        \[\leadsto \frac{1}{s \cdot \color{blue}{\left(3 + e^{\frac{x}{s}}\right)}} \]
    14. Simplified93.3%

      \[\leadsto \frac{1}{\color{blue}{s \cdot \left(3 + e^{\frac{x}{s}}\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification88.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.000000156871975 \cdot 10^{-23}:\\ \;\;\;\;\frac{\frac{1}{s}}{4 + \frac{x \cdot x}{s \cdot s}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{s \cdot \left(e^{\frac{x}{s}} + 3\right)}\\ \end{array} \]

Alternative 8: 95.6% accurate, 5.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\frac{x}{s}}\\ \mathbf{if}\;x \leq -1.000000023742228 \cdot 10^{-33}:\\ \;\;\;\;\frac{\frac{t_0}{s}}{4}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{s \cdot \left(t_0 + 3\right)}\\ \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (let* ((t_0 (exp (/ x s))))
   (if (<= x -1.000000023742228e-33)
     (/ (/ t_0 s) 4.0)
     (/ 1.0 (* s (+ t_0 3.0))))))
float code(float x, float s) {
	float t_0 = expf((x / s));
	float tmp;
	if (x <= -1.000000023742228e-33f) {
		tmp = (t_0 / s) / 4.0f;
	} else {
		tmp = 1.0f / (s * (t_0 + 3.0f));
	}
	return tmp;
}
real(4) function code(x, s)
    real(4), intent (in) :: x
    real(4), intent (in) :: s
    real(4) :: t_0
    real(4) :: tmp
    t_0 = exp((x / s))
    if (x <= (-1.000000023742228e-33)) then
        tmp = (t_0 / s) / 4.0e0
    else
        tmp = 1.0e0 / (s * (t_0 + 3.0e0))
    end if
    code = tmp
end function
function code(x, s)
	t_0 = exp(Float32(x / s))
	tmp = Float32(0.0)
	if (x <= Float32(-1.000000023742228e-33))
		tmp = Float32(Float32(t_0 / s) / Float32(4.0));
	else
		tmp = Float32(Float32(1.0) / Float32(s * Float32(t_0 + Float32(3.0))));
	end
	return tmp
end
function tmp_2 = code(x, s)
	t_0 = exp((x / s));
	tmp = single(0.0);
	if (x <= single(-1.000000023742228e-33))
		tmp = (t_0 / s) / single(4.0);
	else
		tmp = single(1.0) / (s * (t_0 + single(3.0)));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{\frac{x}{s}}\\
\mathbf{if}\;x \leq -1.000000023742228 \cdot 10^{-33}:\\
\;\;\;\;\frac{\frac{t_0}{s}}{4}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{s \cdot \left(t_0 + 3\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.00000002e-33

    1. Initial program 99.6%

      \[\frac{e^{\frac{-\left|x\right|}{s}}}{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)} \]
    2. Step-by-step derivation
      1. expm1-log1p-u98.7%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\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)}\right)\right)} \]
      2. expm1-udef98.4%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\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)}\right)} - 1} \]
    3. Applied egg-rr98.4%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{e^{\frac{x}{s}}}{s \cdot {\left(e^{\frac{x}{s}} + 1\right)}^{2}}\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def98.7%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{e^{\frac{x}{s}}}{s \cdot {\left(e^{\frac{x}{s}} + 1\right)}^{2}}\right)\right)} \]
      2. expm1-log1p99.7%

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

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

        \[\leadsto \frac{\frac{e^{\frac{x}{s}}}{s}}{{\color{blue}{\left(1 + e^{\frac{x}{s}}\right)}}^{2}} \]
    5. Simplified99.7%

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

      \[\leadsto \frac{\frac{e^{\frac{x}{s}}}{s}}{{\color{blue}{2}}^{2}} \]

    if -1.00000002e-33 < x

    1. Initial program 99.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. Step-by-step derivation
      1. *-lft-identity99.9%

        \[\leadsto \color{blue}{1 \cdot \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. associate-*r/99.9%

        \[\leadsto \color{blue}{\frac{1 \cdot 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)}} \]
      3. associate-*l*99.8%

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{s} \cdot e^{\frac{-\left|x\right|}{s}}}{\left(1 + e^{\frac{-\left|x\right|}{s}}\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}} \]
      6. associate-/l*99.1%

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{-s}} + 2\right)}} \]
    4. Step-by-step derivation
      1. expm1-log1p-u99.3%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(e^{\frac{\left|x\right|}{-s}}\right)\right)} + 2\right)} \]
      2. expm1-udef99.2%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\color{blue}{\left(e^{\mathsf{log1p}\left(e^{\frac{\left|x\right|}{-s}}\right)} - 1\right)} + 2\right)} \]
      3. log1p-udef99.3%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(e^{\color{blue}{\log \left(1 + e^{\frac{\left|x\right|}{-s}}\right)}} - 1\right) + 2\right)} \]
      4. +-commutative99.3%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(e^{\log \color{blue}{\left(e^{\frac{\left|x\right|}{-s}} + 1\right)}} - 1\right) + 2\right)} \]
      5. add-exp-log99.3%

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

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

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\left(e^{\frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{-s}} + 1\right) - 1\right) + 2\right)} \]
      8. add-sqr-sqrt99.0%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\left(e^{\frac{\color{blue}{x}}{-s}} + 1\right) - 1\right) + 2\right)} \]
      9. add-sqr-sqrt-0.0%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\left(e^{\frac{x}{\color{blue}{\sqrt{-s} \cdot \sqrt{-s}}}} + 1\right) - 1\right) + 2\right)} \]
      10. sqrt-unprod91.3%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\left(e^{\frac{x}{\color{blue}{\sqrt{\left(-s\right) \cdot \left(-s\right)}}}} + 1\right) - 1\right) + 2\right)} \]
      11. sqr-neg91.3%

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

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\left(\left(e^{\frac{x}{\color{blue}{\sqrt{s} \cdot \sqrt{s}}}} + 1\right) - 1\right) + 2\right)} \]
      13. add-sqr-sqrt96.0%

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\color{blue}{e^{\frac{x}{s}}} + 2\right)} \]
    8. Taylor expanded in x around 0 96.7%

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

        \[\leadsto \frac{1}{s \cdot \color{blue}{\left(e^{\frac{\left|x\right|}{s}} + 3\right)}} \]
    10. Simplified96.7%

      \[\leadsto \color{blue}{\frac{1}{s \cdot \left(e^{\frac{\left|x\right|}{s}} + 3\right)}} \]
    11. Step-by-step derivation
      1. distribute-lft-in96.7%

        \[\leadsto \frac{1}{\color{blue}{s \cdot e^{\frac{\left|x\right|}{s}} + s \cdot 3}} \]
      2. div-inv96.7%

        \[\leadsto \frac{1}{s \cdot e^{\color{blue}{\left|x\right| \cdot \frac{1}{s}}} + s \cdot 3} \]
      3. exp-prod81.5%

        \[\leadsto \frac{1}{s \cdot \color{blue}{{\left(e^{\left|x\right|}\right)}^{\left(\frac{1}{s}\right)}} + s \cdot 3} \]
      4. add-sqr-sqrt74.8%

        \[\leadsto \frac{1}{s \cdot {\left(e^{\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right|}\right)}^{\left(\frac{1}{s}\right)} + s \cdot 3} \]
      5. fabs-sqr74.8%

        \[\leadsto \frac{1}{s \cdot {\left(e^{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}\right)}^{\left(\frac{1}{s}\right)} + s \cdot 3} \]
      6. add-sqr-sqrt81.5%

        \[\leadsto \frac{1}{s \cdot {\left(e^{\color{blue}{x}}\right)}^{\left(\frac{1}{s}\right)} + s \cdot 3} \]
      7. exp-prod96.7%

        \[\leadsto \frac{1}{s \cdot \color{blue}{e^{x \cdot \frac{1}{s}}} + s \cdot 3} \]
      8. div-inv96.7%

        \[\leadsto \frac{1}{s \cdot e^{\color{blue}{\frac{x}{s}}} + s \cdot 3} \]
    12. Applied egg-rr96.7%

      \[\leadsto \frac{1}{\color{blue}{s \cdot e^{\frac{x}{s}} + s \cdot 3}} \]
    13. Step-by-step derivation
      1. distribute-lft-in96.7%

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

        \[\leadsto \frac{1}{s \cdot \color{blue}{\left(3 + e^{\frac{x}{s}}\right)}} \]
    14. Simplified96.7%

      \[\leadsto \frac{1}{\color{blue}{s \cdot \left(3 + e^{\frac{x}{s}}\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification96.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.000000023742228 \cdot 10^{-33}:\\ \;\;\;\;\frac{\frac{e^{\frac{x}{s}}}{s}}{4}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{s \cdot \left(e^{\frac{x}{s}} + 3\right)}\\ \end{array} \]

Alternative 9: 64.7% accurate, 46.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -0.0005000000237487257 \lor \neg \left(x \leq 9.999999974752427 \cdot 10^{-7}\right):\\ \;\;\;\;\frac{1}{\frac{x}{s} \cdot \left(x \cdot 2\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25}{s}\\ \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (if (or (<= x -0.0005000000237487257) (not (<= x 9.999999974752427e-7)))
   (/ 1.0 (* (/ x s) (* x 2.0)))
   (/ 0.25 s)))
float code(float x, float s) {
	float tmp;
	if ((x <= -0.0005000000237487257f) || !(x <= 9.999999974752427e-7f)) {
		tmp = 1.0f / ((x / s) * (x * 2.0f));
	} else {
		tmp = 0.25f / s;
	}
	return tmp;
}
real(4) function code(x, s)
    real(4), intent (in) :: x
    real(4), intent (in) :: s
    real(4) :: tmp
    if ((x <= (-0.0005000000237487257e0)) .or. (.not. (x <= 9.999999974752427e-7))) then
        tmp = 1.0e0 / ((x / s) * (x * 2.0e0))
    else
        tmp = 0.25e0 / s
    end if
    code = tmp
end function
function code(x, s)
	tmp = Float32(0.0)
	if ((x <= Float32(-0.0005000000237487257)) || !(x <= Float32(9.999999974752427e-7)))
		tmp = Float32(Float32(1.0) / Float32(Float32(x / s) * Float32(x * Float32(2.0))));
	else
		tmp = Float32(Float32(0.25) / s);
	end
	return tmp
end
function tmp_2 = code(x, s)
	tmp = single(0.0);
	if ((x <= single(-0.0005000000237487257)) || ~((x <= single(9.999999974752427e-7))))
		tmp = single(1.0) / ((x / s) * (x * single(2.0)));
	else
		tmp = single(0.25) / s;
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.0005000000237487257 \lor \neg \left(x \leq 9.999999974752427 \cdot 10^{-7}\right):\\
\;\;\;\;\frac{1}{\frac{x}{s} \cdot \left(x \cdot 2\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -5.00000024e-4 or 9.99999997e-7 < x

    1. Initial program 100.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. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \color{blue}{1 \cdot \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. associate-*r/100.0%

        \[\leadsto \color{blue}{\frac{1 \cdot 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)}} \]
      3. associate-/l*100.0%

        \[\leadsto \color{blue}{\frac{1}{\frac{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}{e^{\frac{-\left|x\right|}{s}}}}} \]
      4. distribute-frac-neg100.0%

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

        \[\leadsto \frac{1}{\frac{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}{\color{blue}{\frac{1}{e^{\frac{\left|x\right|}{s}}}}}} \]
      6. associate-/r/100.0%

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

        \[\leadsto \frac{1}{\color{blue}{\left(\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right)} \cdot e^{\frac{\left|x\right|}{s}}} \]
      8. associate-*l*100.0%

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

      \[\leadsto \color{blue}{\frac{1}{\left(e^{\frac{\left|x\right|}{-s}} + 1\right) \cdot \mathsf{fma}\left(s, e^{\frac{\left|x\right|}{s}}, s\right)}} \]
    4. Taylor expanded in s around inf 4.8%

      \[\leadsto \frac{1}{\color{blue}{2 \cdot \left|x\right| + \left(-2 \cdot \left|x\right| + \left(2 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s} + \left(4 \cdot s + -1 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s}\right)\right)\right)}} \]
    5. Step-by-step derivation
      1. associate-+r+4.8%

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

        \[\leadsto \frac{1}{\left(2 \cdot \left|x\right| + -2 \cdot \left|x\right|\right) + \color{blue}{\left(\left(4 \cdot s + -1 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s}\right) + 2 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s}\right)}} \]
      3. associate-+r+4.8%

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

      \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(2, \frac{x \cdot x}{s}, s \cdot 4\right) - \frac{x \cdot x}{s}}} \]
    7. Step-by-step derivation
      1. fma-udef4.8%

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

      \[\leadsto \frac{1}{\color{blue}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right)} - \frac{x \cdot x}{s}} \]
    9. Step-by-step derivation
      1. add-sqr-sqrt4.8%

        \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \color{blue}{\sqrt{\frac{x \cdot x}{s}} \cdot \sqrt{\frac{x \cdot x}{s}}}} \]
      2. sqrt-unprod27.0%

        \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \color{blue}{\sqrt{\frac{x \cdot x}{s} \cdot \frac{x \cdot x}{s}}}} \]
      3. pow227.0%

        \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \sqrt{\color{blue}{{\left(\frac{x \cdot x}{s}\right)}^{2}}}} \]
    10. Applied egg-rr27.0%

      \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \color{blue}{\sqrt{{\left(\frac{x \cdot x}{s}\right)}^{2}}}} \]
    11. Step-by-step derivation
      1. unpow227.0%

        \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \sqrt{\color{blue}{\frac{x \cdot x}{s} \cdot \frac{x \cdot x}{s}}}} \]
      2. rem-sqrt-square4.8%

        \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \color{blue}{\left|\frac{x \cdot x}{s}\right|}} \]
      3. associate-/l*4.8%

        \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \left|\color{blue}{\frac{x}{\frac{s}{x}}}\right|} \]
    12. Simplified4.8%

      \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \color{blue}{\left|\frac{x}{\frac{s}{x}}\right|}} \]
    13. Taylor expanded in x around inf 69.4%

      \[\leadsto \frac{1}{\color{blue}{2 \cdot \frac{{x}^{2}}{s}}} \]
    14. Step-by-step derivation
      1. *-commutative69.4%

        \[\leadsto \frac{1}{\color{blue}{\frac{{x}^{2}}{s} \cdot 2}} \]
      2. unpow269.4%

        \[\leadsto \frac{1}{\frac{\color{blue}{x \cdot x}}{s} \cdot 2} \]
      3. associate-*l/69.4%

        \[\leadsto \frac{1}{\color{blue}{\left(\frac{x}{s} \cdot x\right)} \cdot 2} \]
      4. associate-*r*69.4%

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

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

    if -5.00000024e-4 < x < 9.99999997e-7

    1. Initial program 99.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -0.0005000000237487257 \lor \neg \left(x \leq 9.999999974752427 \cdot 10^{-7}\right):\\ \;\;\;\;\frac{1}{\frac{x}{s} \cdot \left(x \cdot 2\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25}{s}\\ \end{array} \]

Alternative 10: 78.6% accurate, 47.7× speedup?

\[\begin{array}{l} \\ \frac{\frac{1}{s}}{4 + \frac{x \cdot x}{s \cdot s}} \end{array} \]
(FPCore (x s) :precision binary32 (/ (/ 1.0 s) (+ 4.0 (/ (* x x) (* s s)))))
float code(float x, float s) {
	return (1.0f / s) / (4.0f + ((x * x) / (s * s)));
}
real(4) function code(x, s)
    real(4), intent (in) :: x
    real(4), intent (in) :: s
    code = (1.0e0 / s) / (4.0e0 + ((x * x) / (s * s)))
end function
function code(x, s)
	return Float32(Float32(Float32(1.0) / s) / Float32(Float32(4.0) + Float32(Float32(x * x) / Float32(s * s))))
end
function tmp = code(x, s)
	tmp = (single(1.0) / s) / (single(4.0) + ((x * x) / (s * s)));
end
\begin{array}{l}

\\
\frac{\frac{1}{s}}{4 + \frac{x \cdot x}{s \cdot s}}
\end{array}
Derivation
  1. Initial program 99.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. Step-by-step derivation
    1. *-lft-identity99.7%

      \[\leadsto \color{blue}{1 \cdot \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. associate-*r/99.7%

      \[\leadsto \color{blue}{\frac{1 \cdot 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)}} \]
    3. associate-*l*99.8%

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{s} \cdot e^{\frac{-\left|x\right|}{s}}}{\left(1 + e^{\frac{-\left|x\right|}{s}}\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}} \]
    6. associate-/l*98.9%

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

      \[\leadsto \frac{\frac{1}{s}}{\frac{\left(1 + e^{\frac{-\left|x\right|}{s}}\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}{e^{\color{blue}{-\frac{\left|x\right|}{s}}}}} \]
    8. exp-neg99.0%

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

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

    \[\leadsto \frac{\frac{1}{s}}{\color{blue}{\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}} + \left(4 + \left(-1 \cdot \frac{\left|x\right|}{s} + \frac{\left|x\right|}{s}\right)\right)}} \]
  5. Step-by-step derivation
    1. associate-+r+52.6%

      \[\leadsto \frac{\frac{1}{s}}{\color{blue}{\left(\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}} + 4\right) + \left(-1 \cdot \frac{\left|x\right|}{s} + \frac{\left|x\right|}{s}\right)}} \]
    2. distribute-lft1-in52.6%

      \[\leadsto \frac{\frac{1}{s}}{\left(\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}} + 4\right) + \color{blue}{\left(-1 + 1\right) \cdot \frac{\left|x\right|}{s}}} \]
    3. metadata-eval52.6%

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

      \[\leadsto \frac{\frac{1}{s}}{\left(\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}} + 4\right) + \color{blue}{0}} \]
    5. associate-+r+76.9%

      \[\leadsto \frac{\frac{1}{s}}{\color{blue}{\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}} + \left(4 + 0\right)}} \]
    6. metadata-eval76.9%

      \[\leadsto \frac{\frac{1}{s}}{\frac{{\left(\left|x\right|\right)}^{2}}{{s}^{2}} + \color{blue}{4}} \]
    7. unpow276.9%

      \[\leadsto \frac{\frac{1}{s}}{\frac{\color{blue}{\left|x\right| \cdot \left|x\right|}}{{s}^{2}} + 4} \]
    8. sqr-abs76.9%

      \[\leadsto \frac{\frac{1}{s}}{\frac{\color{blue}{x \cdot x}}{{s}^{2}} + 4} \]
    9. unpow276.9%

      \[\leadsto \frac{\frac{1}{s}}{\frac{x \cdot x}{\color{blue}{s \cdot s}} + 4} \]
  6. Simplified76.9%

    \[\leadsto \frac{\frac{1}{s}}{\color{blue}{\frac{x \cdot x}{s \cdot s} + 4}} \]
  7. Final simplification76.9%

    \[\leadsto \frac{\frac{1}{s}}{4 + \frac{x \cdot x}{s \cdot s}} \]

Alternative 11: 63.5% accurate, 55.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -0.0005000000237487257 \lor \neg \left(x \leq 9.999999974752427 \cdot 10^{-7}\right):\\ \;\;\;\;0.5 \cdot \frac{s}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25}{s}\\ \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (if (or (<= x -0.0005000000237487257) (not (<= x 9.999999974752427e-7)))
   (* 0.5 (/ s (* x x)))
   (/ 0.25 s)))
float code(float x, float s) {
	float tmp;
	if ((x <= -0.0005000000237487257f) || !(x <= 9.999999974752427e-7f)) {
		tmp = 0.5f * (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) :: tmp
    if ((x <= (-0.0005000000237487257e0)) .or. (.not. (x <= 9.999999974752427e-7))) then
        tmp = 0.5e0 * (s / (x * x))
    else
        tmp = 0.25e0 / s
    end if
    code = tmp
end function
function code(x, s)
	tmp = Float32(0.0)
	if ((x <= Float32(-0.0005000000237487257)) || !(x <= Float32(9.999999974752427e-7)))
		tmp = Float32(Float32(0.5) * Float32(s / Float32(x * x)));
	else
		tmp = Float32(Float32(0.25) / s);
	end
	return tmp
end
function tmp_2 = code(x, s)
	tmp = single(0.0);
	if ((x <= single(-0.0005000000237487257)) || ~((x <= single(9.999999974752427e-7))))
		tmp = single(0.5) * (s / (x * x));
	else
		tmp = single(0.25) / s;
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.0005000000237487257 \lor \neg \left(x \leq 9.999999974752427 \cdot 10^{-7}\right):\\
\;\;\;\;0.5 \cdot \frac{s}{x \cdot x}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -5.00000024e-4 or 9.99999997e-7 < x

    1. Initial program 100.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. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \color{blue}{1 \cdot \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. associate-*r/100.0%

        \[\leadsto \color{blue}{\frac{1 \cdot 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)}} \]
      3. associate-/l*100.0%

        \[\leadsto \color{blue}{\frac{1}{\frac{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}{e^{\frac{-\left|x\right|}{s}}}}} \]
      4. distribute-frac-neg100.0%

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

        \[\leadsto \frac{1}{\frac{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}{\color{blue}{\frac{1}{e^{\frac{\left|x\right|}{s}}}}}} \]
      6. associate-/r/100.0%

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

        \[\leadsto \frac{1}{\color{blue}{\left(\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right)} \cdot e^{\frac{\left|x\right|}{s}}} \]
      8. associate-*l*100.0%

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

      \[\leadsto \color{blue}{\frac{1}{\left(e^{\frac{\left|x\right|}{-s}} + 1\right) \cdot \mathsf{fma}\left(s, e^{\frac{\left|x\right|}{s}}, s\right)}} \]
    4. Taylor expanded in s around inf 4.8%

      \[\leadsto \frac{1}{\color{blue}{2 \cdot \left|x\right| + \left(-2 \cdot \left|x\right| + \left(2 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s} + \left(4 \cdot s + -1 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s}\right)\right)\right)}} \]
    5. Step-by-step derivation
      1. associate-+r+4.8%

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

        \[\leadsto \frac{1}{\left(2 \cdot \left|x\right| + -2 \cdot \left|x\right|\right) + \color{blue}{\left(\left(4 \cdot s + -1 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s}\right) + 2 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s}\right)}} \]
      3. associate-+r+4.8%

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

      \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(2, \frac{x \cdot x}{s}, s \cdot 4\right) - \frac{x \cdot x}{s}}} \]
    7. Step-by-step derivation
      1. fma-udef4.8%

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

      \[\leadsto \frac{1}{\color{blue}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right)} - \frac{x \cdot x}{s}} \]
    9. Step-by-step derivation
      1. add-sqr-sqrt4.8%

        \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \color{blue}{\sqrt{\frac{x \cdot x}{s}} \cdot \sqrt{\frac{x \cdot x}{s}}}} \]
      2. sqrt-unprod27.0%

        \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \color{blue}{\sqrt{\frac{x \cdot x}{s} \cdot \frac{x \cdot x}{s}}}} \]
      3. pow227.0%

        \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \sqrt{\color{blue}{{\left(\frac{x \cdot x}{s}\right)}^{2}}}} \]
    10. Applied egg-rr27.0%

      \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \color{blue}{\sqrt{{\left(\frac{x \cdot x}{s}\right)}^{2}}}} \]
    11. Step-by-step derivation
      1. unpow227.0%

        \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \sqrt{\color{blue}{\frac{x \cdot x}{s} \cdot \frac{x \cdot x}{s}}}} \]
      2. rem-sqrt-square4.8%

        \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \color{blue}{\left|\frac{x \cdot x}{s}\right|}} \]
      3. associate-/l*4.8%

        \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \left|\color{blue}{\frac{x}{\frac{s}{x}}}\right|} \]
    12. Simplified4.8%

      \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \color{blue}{\left|\frac{x}{\frac{s}{x}}\right|}} \]
    13. Taylor expanded in x around inf 67.5%

      \[\leadsto \color{blue}{0.5 \cdot \frac{s}{{x}^{2}}} \]
    14. Step-by-step derivation
      1. unpow267.5%

        \[\leadsto 0.5 \cdot \frac{s}{\color{blue}{x \cdot x}} \]
    15. Simplified67.5%

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

    if -5.00000024e-4 < x < 9.99999997e-7

    1. Initial program 99.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -0.0005000000237487257 \lor \neg \left(x \leq 9.999999974752427 \cdot 10^{-7}\right):\\ \;\;\;\;0.5 \cdot \frac{s}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25}{s}\\ \end{array} \]

Alternative 12: 64.5% accurate, 55.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -0.0005000000237487257 \lor \neg \left(x \leq 9.999999974752427 \cdot 10^{-7}\right):\\ \;\;\;\;\frac{1}{\frac{x}{\frac{s}{x}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25}{s}\\ \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (if (or (<= x -0.0005000000237487257) (not (<= x 9.999999974752427e-7)))
   (/ 1.0 (/ x (/ s x)))
   (/ 0.25 s)))
float code(float x, float s) {
	float tmp;
	if ((x <= -0.0005000000237487257f) || !(x <= 9.999999974752427e-7f)) {
		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) :: tmp
    if ((x <= (-0.0005000000237487257e0)) .or. (.not. (x <= 9.999999974752427e-7))) then
        tmp = 1.0e0 / (x / (s / x))
    else
        tmp = 0.25e0 / s
    end if
    code = tmp
end function
function code(x, s)
	tmp = Float32(0.0)
	if ((x <= Float32(-0.0005000000237487257)) || !(x <= Float32(9.999999974752427e-7)))
		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)
	tmp = single(0.0);
	if ((x <= single(-0.0005000000237487257)) || ~((x <= single(9.999999974752427e-7))))
		tmp = single(1.0) / (x / (s / x));
	else
		tmp = single(0.25) / s;
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.0005000000237487257 \lor \neg \left(x \leq 9.999999974752427 \cdot 10^{-7}\right):\\
\;\;\;\;\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 x < -5.00000024e-4 or 9.99999997e-7 < x

    1. Initial program 100.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. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \color{blue}{1 \cdot \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. associate-*r/100.0%

        \[\leadsto \color{blue}{\frac{1 \cdot 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)}} \]
      3. associate-/l*100.0%

        \[\leadsto \color{blue}{\frac{1}{\frac{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}{e^{\frac{-\left|x\right|}{s}}}}} \]
      4. distribute-frac-neg100.0%

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

        \[\leadsto \frac{1}{\frac{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}{\color{blue}{\frac{1}{e^{\frac{\left|x\right|}{s}}}}}} \]
      6. associate-/r/100.0%

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

        \[\leadsto \frac{1}{\color{blue}{\left(\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right)} \cdot e^{\frac{\left|x\right|}{s}}} \]
      8. associate-*l*100.0%

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

      \[\leadsto \color{blue}{\frac{1}{\left(e^{\frac{\left|x\right|}{-s}} + 1\right) \cdot \mathsf{fma}\left(s, e^{\frac{\left|x\right|}{s}}, s\right)}} \]
    4. Taylor expanded in s around inf 4.8%

      \[\leadsto \frac{1}{\color{blue}{2 \cdot \left|x\right| + \left(-2 \cdot \left|x\right| + \left(2 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s} + \left(4 \cdot s + -1 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s}\right)\right)\right)}} \]
    5. Step-by-step derivation
      1. associate-+r+4.8%

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

        \[\leadsto \frac{1}{\left(2 \cdot \left|x\right| + -2 \cdot \left|x\right|\right) + \color{blue}{\left(\left(4 \cdot s + -1 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s}\right) + 2 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s}\right)}} \]
      3. associate-+r+4.8%

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

      \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(2, \frac{x \cdot x}{s}, s \cdot 4\right) - \frac{x \cdot x}{s}}} \]
    7. Taylor expanded in x around inf 69.3%

      \[\leadsto \frac{1}{\color{blue}{\frac{{x}^{2}}{s}}} \]
    8. Step-by-step derivation
      1. unpow269.3%

        \[\leadsto \frac{1}{\frac{\color{blue}{x \cdot x}}{s}} \]
      2. associate-/l*69.3%

        \[\leadsto \frac{1}{\color{blue}{\frac{x}{\frac{s}{x}}}} \]
    9. Simplified69.3%

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

    if -5.00000024e-4 < x < 9.99999997e-7

    1. Initial program 99.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -0.0005000000237487257 \lor \neg \left(x \leq 9.999999974752427 \cdot 10^{-7}\right):\\ \;\;\;\;\frac{1}{\frac{x}{\frac{s}{x}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25}{s}\\ \end{array} \]

Alternative 13: 63.4% accurate, 55.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -0.0005000000237487257:\\ \;\;\;\;0.5 \cdot \frac{s}{x \cdot x}\\ \mathbf{elif}\;x \leq 9.999999974752427 \cdot 10^{-7}:\\ \;\;\;\;\frac{0.25}{s}\\ \mathbf{else}:\\ \;\;\;\;\frac{s}{x} \cdot \frac{0.5}{x}\\ \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (if (<= x -0.0005000000237487257)
   (* 0.5 (/ s (* x x)))
   (if (<= x 9.999999974752427e-7) (/ 0.25 s) (* (/ s x) (/ 0.5 x)))))
float code(float x, float s) {
	float tmp;
	if (x <= -0.0005000000237487257f) {
		tmp = 0.5f * (s / (x * x));
	} else if (x <= 9.999999974752427e-7f) {
		tmp = 0.25f / s;
	} else {
		tmp = (s / x) * (0.5f / x);
	}
	return tmp;
}
real(4) function code(x, s)
    real(4), intent (in) :: x
    real(4), intent (in) :: s
    real(4) :: tmp
    if (x <= (-0.0005000000237487257e0)) then
        tmp = 0.5e0 * (s / (x * x))
    else if (x <= 9.999999974752427e-7) then
        tmp = 0.25e0 / s
    else
        tmp = (s / x) * (0.5e0 / x)
    end if
    code = tmp
end function
function code(x, s)
	tmp = Float32(0.0)
	if (x <= Float32(-0.0005000000237487257))
		tmp = Float32(Float32(0.5) * Float32(s / Float32(x * x)));
	elseif (x <= Float32(9.999999974752427e-7))
		tmp = Float32(Float32(0.25) / s);
	else
		tmp = Float32(Float32(s / x) * Float32(Float32(0.5) / x));
	end
	return tmp
end
function tmp_2 = code(x, s)
	tmp = single(0.0);
	if (x <= single(-0.0005000000237487257))
		tmp = single(0.5) * (s / (x * x));
	elseif (x <= single(9.999999974752427e-7))
		tmp = single(0.25) / s;
	else
		tmp = (s / x) * (single(0.5) / x);
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.0005000000237487257:\\
\;\;\;\;0.5 \cdot \frac{s}{x \cdot x}\\

\mathbf{elif}\;x \leq 9.999999974752427 \cdot 10^{-7}:\\
\;\;\;\;\frac{0.25}{s}\\

\mathbf{else}:\\
\;\;\;\;\frac{s}{x} \cdot \frac{0.5}{x}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -5.00000024e-4

    1. Initial program 100.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. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \color{blue}{1 \cdot \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. associate-*r/100.0%

        \[\leadsto \color{blue}{\frac{1 \cdot 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)}} \]
      3. associate-/l*100.0%

        \[\leadsto \color{blue}{\frac{1}{\frac{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}{e^{\frac{-\left|x\right|}{s}}}}} \]
      4. distribute-frac-neg100.0%

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

        \[\leadsto \frac{1}{\frac{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}{\color{blue}{\frac{1}{e^{\frac{\left|x\right|}{s}}}}}} \]
      6. associate-/r/100.0%

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

        \[\leadsto \frac{1}{\color{blue}{\left(\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right)} \cdot e^{\frac{\left|x\right|}{s}}} \]
      8. associate-*l*100.0%

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

      \[\leadsto \color{blue}{\frac{1}{\left(e^{\frac{\left|x\right|}{-s}} + 1\right) \cdot \mathsf{fma}\left(s, e^{\frac{\left|x\right|}{s}}, s\right)}} \]
    4. Taylor expanded in s around inf 5.1%

      \[\leadsto \frac{1}{\color{blue}{2 \cdot \left|x\right| + \left(-2 \cdot \left|x\right| + \left(2 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s} + \left(4 \cdot s + -1 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s}\right)\right)\right)}} \]
    5. Step-by-step derivation
      1. associate-+r+5.1%

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

        \[\leadsto \frac{1}{\left(2 \cdot \left|x\right| + -2 \cdot \left|x\right|\right) + \color{blue}{\left(\left(4 \cdot s + -1 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s}\right) + 2 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s}\right)}} \]
      3. associate-+r+5.1%

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

      \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(2, \frac{x \cdot x}{s}, s \cdot 4\right) - \frac{x \cdot x}{s}}} \]
    7. Step-by-step derivation
      1. fma-udef5.1%

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

      \[\leadsto \frac{1}{\color{blue}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right)} - \frac{x \cdot x}{s}} \]
    9. Step-by-step derivation
      1. add-sqr-sqrt5.1%

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

        \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \color{blue}{\sqrt{\frac{x \cdot x}{s} \cdot \frac{x \cdot x}{s}}}} \]
      3. pow231.1%

        \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \sqrt{\color{blue}{{\left(\frac{x \cdot x}{s}\right)}^{2}}}} \]
    10. Applied egg-rr31.1%

      \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \color{blue}{\sqrt{{\left(\frac{x \cdot x}{s}\right)}^{2}}}} \]
    11. Step-by-step derivation
      1. unpow231.1%

        \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \sqrt{\color{blue}{\frac{x \cdot x}{s} \cdot \frac{x \cdot x}{s}}}} \]
      2. rem-sqrt-square5.1%

        \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \color{blue}{\left|\frac{x \cdot x}{s}\right|}} \]
      3. associate-/l*5.1%

        \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \left|\color{blue}{\frac{x}{\frac{s}{x}}}\right|} \]
    12. Simplified5.1%

      \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \color{blue}{\left|\frac{x}{\frac{s}{x}}\right|}} \]
    13. Taylor expanded in x around inf 63.3%

      \[\leadsto \color{blue}{0.5 \cdot \frac{s}{{x}^{2}}} \]
    14. Step-by-step derivation
      1. unpow263.3%

        \[\leadsto 0.5 \cdot \frac{s}{\color{blue}{x \cdot x}} \]
    15. Simplified63.3%

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

    if -5.00000024e-4 < x < 9.99999997e-7

    1. Initial program 99.4%

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

      \[\leadsto \color{blue}{\frac{0.25}{s}} \]

    if 9.99999997e-7 < x

    1. Initial program 100.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. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \color{blue}{1 \cdot \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. associate-*r/100.0%

        \[\leadsto \color{blue}{\frac{1 \cdot 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)}} \]
      3. associate-/l*100.0%

        \[\leadsto \color{blue}{\frac{1}{\frac{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}{e^{\frac{-\left|x\right|}{s}}}}} \]
      4. distribute-frac-neg100.0%

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

        \[\leadsto \frac{1}{\frac{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}{\color{blue}{\frac{1}{e^{\frac{\left|x\right|}{s}}}}}} \]
      6. associate-/r/100.0%

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

        \[\leadsto \frac{1}{\color{blue}{\left(\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right)} \cdot e^{\frac{\left|x\right|}{s}}} \]
      8. associate-*l*100.0%

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

      \[\leadsto \color{blue}{\frac{1}{\left(e^{\frac{\left|x\right|}{-s}} + 1\right) \cdot \mathsf{fma}\left(s, e^{\frac{\left|x\right|}{s}}, s\right)}} \]
    4. Taylor expanded in s around inf 4.5%

      \[\leadsto \frac{1}{\color{blue}{2 \cdot \left|x\right| + \left(-2 \cdot \left|x\right| + \left(2 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s} + \left(4 \cdot s + -1 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s}\right)\right)\right)}} \]
    5. Step-by-step derivation
      1. associate-+r+4.5%

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

        \[\leadsto \frac{1}{\left(2 \cdot \left|x\right| + -2 \cdot \left|x\right|\right) + \color{blue}{\left(\left(4 \cdot s + -1 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s}\right) + 2 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s}\right)}} \]
      3. associate-+r+4.5%

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

      \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(2, \frac{x \cdot x}{s}, s \cdot 4\right) - \frac{x \cdot x}{s}}} \]
    7. Step-by-step derivation
      1. fma-udef4.5%

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

      \[\leadsto \frac{1}{\color{blue}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right)} - \frac{x \cdot x}{s}} \]
    9. Step-by-step derivation
      1. add-sqr-sqrt4.5%

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

        \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \color{blue}{\sqrt{\frac{x \cdot x}{s} \cdot \frac{x \cdot x}{s}}}} \]
      3. pow223.4%

        \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \sqrt{\color{blue}{{\left(\frac{x \cdot x}{s}\right)}^{2}}}} \]
    10. Applied egg-rr23.4%

      \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \color{blue}{\sqrt{{\left(\frac{x \cdot x}{s}\right)}^{2}}}} \]
    11. Step-by-step derivation
      1. unpow223.4%

        \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \sqrt{\color{blue}{\frac{x \cdot x}{s} \cdot \frac{x \cdot x}{s}}}} \]
      2. rem-sqrt-square4.5%

        \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \color{blue}{\left|\frac{x \cdot x}{s}\right|}} \]
      3. associate-/l*4.5%

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

      \[\leadsto \frac{1}{\left(2 \cdot \frac{x \cdot x}{s} + s \cdot 4\right) - \color{blue}{\left|\frac{x}{\frac{s}{x}}\right|}} \]
    13. Taylor expanded in x around inf 71.4%

      \[\leadsto \color{blue}{0.5 \cdot \frac{s}{{x}^{2}}} \]
    14. Step-by-step derivation
      1. associate-*r/71.4%

        \[\leadsto \color{blue}{\frac{0.5 \cdot s}{{x}^{2}}} \]
      2. unpow271.4%

        \[\leadsto \frac{0.5 \cdot s}{\color{blue}{x \cdot x}} \]
      3. times-frac71.4%

        \[\leadsto \color{blue}{\frac{0.5}{x} \cdot \frac{s}{x}} \]
    15. Simplified71.4%

      \[\leadsto \color{blue}{\frac{0.5}{x} \cdot \frac{s}{x}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification63.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -0.0005000000237487257:\\ \;\;\;\;0.5 \cdot \frac{s}{x \cdot x}\\ \mathbf{elif}\;x \leq 9.999999974752427 \cdot 10^{-7}:\\ \;\;\;\;\frac{0.25}{s}\\ \mathbf{else}:\\ \;\;\;\;\frac{s}{x} \cdot \frac{0.5}{x}\\ \end{array} \]

Alternative 14: 64.5% accurate, 55.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -0.0005000000237487257:\\ \;\;\;\;\frac{1}{\frac{x}{\frac{s}{x}}}\\ \mathbf{elif}\;x \leq 9.999999974752427 \cdot 10^{-7}:\\ \;\;\;\;\frac{0.25}{s}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{x \cdot x}{s}}\\ \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (if (<= x -0.0005000000237487257)
   (/ 1.0 (/ x (/ s x)))
   (if (<= x 9.999999974752427e-7) (/ 0.25 s) (/ 1.0 (/ (* x x) s)))))
float code(float x, float s) {
	float tmp;
	if (x <= -0.0005000000237487257f) {
		tmp = 1.0f / (x / (s / x));
	} else if (x <= 9.999999974752427e-7f) {
		tmp = 0.25f / s;
	} else {
		tmp = 1.0f / ((x * x) / s);
	}
	return tmp;
}
real(4) function code(x, s)
    real(4), intent (in) :: x
    real(4), intent (in) :: s
    real(4) :: tmp
    if (x <= (-0.0005000000237487257e0)) then
        tmp = 1.0e0 / (x / (s / x))
    else if (x <= 9.999999974752427e-7) then
        tmp = 0.25e0 / s
    else
        tmp = 1.0e0 / ((x * x) / s)
    end if
    code = tmp
end function
function code(x, s)
	tmp = Float32(0.0)
	if (x <= Float32(-0.0005000000237487257))
		tmp = Float32(Float32(1.0) / Float32(x / Float32(s / x)));
	elseif (x <= Float32(9.999999974752427e-7))
		tmp = Float32(Float32(0.25) / s);
	else
		tmp = Float32(Float32(1.0) / Float32(Float32(x * x) / s));
	end
	return tmp
end
function tmp_2 = code(x, s)
	tmp = single(0.0);
	if (x <= single(-0.0005000000237487257))
		tmp = single(1.0) / (x / (s / x));
	elseif (x <= single(9.999999974752427e-7))
		tmp = single(0.25) / s;
	else
		tmp = single(1.0) / ((x * x) / s);
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.0005000000237487257:\\
\;\;\;\;\frac{1}{\frac{x}{\frac{s}{x}}}\\

\mathbf{elif}\;x \leq 9.999999974752427 \cdot 10^{-7}:\\
\;\;\;\;\frac{0.25}{s}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{x \cdot x}{s}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -5.00000024e-4

    1. Initial program 100.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. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \color{blue}{1 \cdot \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. associate-*r/100.0%

        \[\leadsto \color{blue}{\frac{1 \cdot 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)}} \]
      3. associate-/l*100.0%

        \[\leadsto \color{blue}{\frac{1}{\frac{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}{e^{\frac{-\left|x\right|}{s}}}}} \]
      4. distribute-frac-neg100.0%

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

        \[\leadsto \frac{1}{\frac{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}{\color{blue}{\frac{1}{e^{\frac{\left|x\right|}{s}}}}}} \]
      6. associate-/r/100.0%

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

        \[\leadsto \frac{1}{\color{blue}{\left(\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right)} \cdot e^{\frac{\left|x\right|}{s}}} \]
      8. associate-*l*100.0%

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

      \[\leadsto \color{blue}{\frac{1}{\left(e^{\frac{\left|x\right|}{-s}} + 1\right) \cdot \mathsf{fma}\left(s, e^{\frac{\left|x\right|}{s}}, s\right)}} \]
    4. Taylor expanded in s around inf 5.1%

      \[\leadsto \frac{1}{\color{blue}{2 \cdot \left|x\right| + \left(-2 \cdot \left|x\right| + \left(2 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s} + \left(4 \cdot s + -1 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s}\right)\right)\right)}} \]
    5. Step-by-step derivation
      1. associate-+r+5.1%

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

        \[\leadsto \frac{1}{\left(2 \cdot \left|x\right| + -2 \cdot \left|x\right|\right) + \color{blue}{\left(\left(4 \cdot s + -1 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s}\right) + 2 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s}\right)}} \]
      3. associate-+r+5.1%

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

      \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(2, \frac{x \cdot x}{s}, s \cdot 4\right) - \frac{x \cdot x}{s}}} \]
    7. Taylor expanded in x around inf 65.7%

      \[\leadsto \frac{1}{\color{blue}{\frac{{x}^{2}}{s}}} \]
    8. Step-by-step derivation
      1. unpow265.7%

        \[\leadsto \frac{1}{\frac{\color{blue}{x \cdot x}}{s}} \]
      2. associate-/l*65.7%

        \[\leadsto \frac{1}{\color{blue}{\frac{x}{\frac{s}{x}}}} \]
    9. Simplified65.7%

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

    if -5.00000024e-4 < x < 9.99999997e-7

    1. Initial program 99.4%

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

      \[\leadsto \color{blue}{\frac{0.25}{s}} \]

    if 9.99999997e-7 < x

    1. Initial program 100.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. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \color{blue}{1 \cdot \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. associate-*r/100.0%

        \[\leadsto \color{blue}{\frac{1 \cdot 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)}} \]
      3. associate-/l*100.0%

        \[\leadsto \color{blue}{\frac{1}{\frac{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}{e^{\frac{-\left|x\right|}{s}}}}} \]
      4. distribute-frac-neg100.0%

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

        \[\leadsto \frac{1}{\frac{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}{\color{blue}{\frac{1}{e^{\frac{\left|x\right|}{s}}}}}} \]
      6. associate-/r/100.0%

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

        \[\leadsto \frac{1}{\color{blue}{\left(\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right)} \cdot e^{\frac{\left|x\right|}{s}}} \]
      8. associate-*l*100.0%

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

      \[\leadsto \color{blue}{\frac{1}{\left(e^{\frac{\left|x\right|}{-s}} + 1\right) \cdot \mathsf{fma}\left(s, e^{\frac{\left|x\right|}{s}}, s\right)}} \]
    4. Taylor expanded in s around inf 4.5%

      \[\leadsto \frac{1}{\color{blue}{2 \cdot \left|x\right| + \left(-2 \cdot \left|x\right| + \left(2 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s} + \left(4 \cdot s + -1 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s}\right)\right)\right)}} \]
    5. Step-by-step derivation
      1. associate-+r+4.5%

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

        \[\leadsto \frac{1}{\left(2 \cdot \left|x\right| + -2 \cdot \left|x\right|\right) + \color{blue}{\left(\left(4 \cdot s + -1 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s}\right) + 2 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s}\right)}} \]
      3. associate-+r+4.5%

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

      \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(2, \frac{x \cdot x}{s}, s \cdot 4\right) - \frac{x \cdot x}{s}}} \]
    7. Step-by-step derivation
      1. fma-udef4.5%

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{{x}^{2}}{s}}} \]
    10. Step-by-step derivation
      1. unpow272.5%

        \[\leadsto \frac{1}{\frac{\color{blue}{x \cdot x}}{s}} \]
    11. Simplified72.5%

      \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x}{s}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification64.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -0.0005000000237487257:\\ \;\;\;\;\frac{1}{\frac{x}{\frac{s}{x}}}\\ \mathbf{elif}\;x \leq 9.999999974752427 \cdot 10^{-7}:\\ \;\;\;\;\frac{0.25}{s}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{x \cdot x}{s}}\\ \end{array} \]

Alternative 15: 63.3% accurate, 66.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -0.0005000000237487257 \lor \neg \left(x \leq 9.999999974752427 \cdot 10^{-7}\right):\\ \;\;\;\;\frac{s}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25}{s}\\ \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (if (or (<= x -0.0005000000237487257) (not (<= x 9.999999974752427e-7)))
   (/ s (* x x))
   (/ 0.25 s)))
float code(float x, float s) {
	float tmp;
	if ((x <= -0.0005000000237487257f) || !(x <= 9.999999974752427e-7f)) {
		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) :: tmp
    if ((x <= (-0.0005000000237487257e0)) .or. (.not. (x <= 9.999999974752427e-7))) then
        tmp = s / (x * x)
    else
        tmp = 0.25e0 / s
    end if
    code = tmp
end function
function code(x, s)
	tmp = Float32(0.0)
	if ((x <= Float32(-0.0005000000237487257)) || !(x <= Float32(9.999999974752427e-7)))
		tmp = Float32(s / Float32(x * x));
	else
		tmp = Float32(Float32(0.25) / s);
	end
	return tmp
end
function tmp_2 = code(x, s)
	tmp = single(0.0);
	if ((x <= single(-0.0005000000237487257)) || ~((x <= single(9.999999974752427e-7))))
		tmp = s / (x * x);
	else
		tmp = single(0.25) / s;
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.0005000000237487257 \lor \neg \left(x \leq 9.999999974752427 \cdot 10^{-7}\right):\\
\;\;\;\;\frac{s}{x \cdot x}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -5.00000024e-4 or 9.99999997e-7 < x

    1. Initial program 100.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. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \color{blue}{1 \cdot \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. associate-*r/100.0%

        \[\leadsto \color{blue}{\frac{1 \cdot 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)}} \]
      3. associate-/l*100.0%

        \[\leadsto \color{blue}{\frac{1}{\frac{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}{e^{\frac{-\left|x\right|}{s}}}}} \]
      4. distribute-frac-neg100.0%

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

        \[\leadsto \frac{1}{\frac{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}{\color{blue}{\frac{1}{e^{\frac{\left|x\right|}{s}}}}}} \]
      6. associate-/r/100.0%

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

        \[\leadsto \frac{1}{\color{blue}{\left(\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right)} \cdot e^{\frac{\left|x\right|}{s}}} \]
      8. associate-*l*100.0%

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

      \[\leadsto \color{blue}{\frac{1}{\left(e^{\frac{\left|x\right|}{-s}} + 1\right) \cdot \mathsf{fma}\left(s, e^{\frac{\left|x\right|}{s}}, s\right)}} \]
    4. Taylor expanded in s around inf 4.8%

      \[\leadsto \frac{1}{\color{blue}{2 \cdot \left|x\right| + \left(-2 \cdot \left|x\right| + \left(2 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s} + \left(4 \cdot s + -1 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s}\right)\right)\right)}} \]
    5. Step-by-step derivation
      1. associate-+r+4.8%

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

        \[\leadsto \frac{1}{\left(2 \cdot \left|x\right| + -2 \cdot \left|x\right|\right) + \color{blue}{\left(\left(4 \cdot s + -1 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s}\right) + 2 \cdot \frac{{\left(\left|x\right|\right)}^{2}}{s}\right)}} \]
      3. associate-+r+4.8%

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

      \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(2, \frac{x \cdot x}{s}, s \cdot 4\right) - \frac{x \cdot x}{s}}} \]
    7. Taylor expanded in x around inf 67.2%

      \[\leadsto \color{blue}{\frac{s}{{x}^{2}}} \]
    8. Step-by-step derivation
      1. unpow267.2%

        \[\leadsto \frac{s}{\color{blue}{x \cdot x}} \]
    9. Simplified67.2%

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

    if -5.00000024e-4 < x < 9.99999997e-7

    1. Initial program 99.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -0.0005000000237487257 \lor \neg \left(x \leq 9.999999974752427 \cdot 10^{-7}\right):\\ \;\;\;\;\frac{s}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25}{s}\\ \end{array} \]

Alternative 16: 26.7% accurate, 206.7× speedup?

\[\begin{array}{l} \\ \frac{0.25}{s} \end{array} \]
(FPCore (x s) :precision binary32 (/ 0.25 s))
float code(float x, float s) {
	return 0.25f / s;
}
real(4) function code(x, s)
    real(4), intent (in) :: x
    real(4), intent (in) :: s
    code = 0.25e0 / s
end function
function code(x, s)
	return Float32(Float32(0.25) / s)
end
function tmp = code(x, s)
	tmp = single(0.25) / s;
end
\begin{array}{l}

\\
\frac{0.25}{s}
\end{array}
Derivation
  1. Initial program 99.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. Taylor expanded in s around inf 29.7%

    \[\leadsto \color{blue}{\frac{0.25}{s}} \]
  3. Final simplification29.7%

    \[\leadsto \frac{0.25}{s} \]

Reproduce

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