Logistic distribution

Percentage Accurate: 99.6% → 99.6%
Time: 12.6s
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.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 \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.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)}{e^{\color{blue}{-\frac{\left|x\right|}{s}}}}} \]
    5. exp-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)}{\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.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. Final simplification99.9%

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

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

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

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

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

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

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

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

Alternative 3: 97.1% 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.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.4%

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

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

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

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

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

    \[\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. add-sqr-sqrt-0.0%

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

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

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

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{\color{blue}{s}}} + 2\right)} \]
    6. *-un-lft-identity96.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 77.6% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(\frac{x}{s} \cdot \frac{x}{s}\right) \cdot -0.0625\\ \mathbf{if}\;\left|x\right| \leq 4.999999943633011 \cdot 10^{-27}:\\ \;\;\;\;\frac{\frac{0.0625 - t_0 \cdot t_0}{0.25 - t_0}}{s}\\ \mathbf{elif}\;\left|x\right| \leq 18000000319488:\\ \;\;\;\;\frac{1}{s \cdot \left(2 + 2 \cdot \left(1 + \left(\frac{x}{s} + \frac{0.5 \cdot \left(x \cdot x\right)}{s \cdot s}\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \frac{1}{x \cdot \frac{x}{s}}\\ \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (let* ((t_0 (* (* (/ x s) (/ x s)) -0.0625)))
   (if (<= (fabs x) 4.999999943633011e-27)
     (/ (/ (- 0.0625 (* t_0 t_0)) (- 0.25 t_0)) s)
     (if (<= (fabs x) 18000000319488.0)
       (/
        1.0
        (* s (+ 2.0 (* 2.0 (+ 1.0 (+ (/ x s) (/ (* 0.5 (* x x)) (* s s))))))))
       (* 2.0 (/ 1.0 (* x (/ x s))))))))
float code(float x, float s) {
	float t_0 = ((x / s) * (x / s)) * -0.0625f;
	float tmp;
	if (fabsf(x) <= 4.999999943633011e-27f) {
		tmp = ((0.0625f - (t_0 * t_0)) / (0.25f - t_0)) / s;
	} else if (fabsf(x) <= 18000000319488.0f) {
		tmp = 1.0f / (s * (2.0f + (2.0f * (1.0f + ((x / s) + ((0.5f * (x * x)) / (s * s)))))));
	} else {
		tmp = 2.0f * (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) :: t_0
    real(4) :: tmp
    t_0 = ((x / s) * (x / s)) * (-0.0625e0)
    if (abs(x) <= 4.999999943633011e-27) then
        tmp = ((0.0625e0 - (t_0 * t_0)) / (0.25e0 - t_0)) / s
    else if (abs(x) <= 18000000319488.0e0) then
        tmp = 1.0e0 / (s * (2.0e0 + (2.0e0 * (1.0e0 + ((x / s) + ((0.5e0 * (x * x)) / (s * s)))))))
    else
        tmp = 2.0e0 * (1.0e0 / (x * (x / s)))
    end if
    code = tmp
end function
function code(x, s)
	t_0 = Float32(Float32(Float32(x / s) * Float32(x / s)) * Float32(-0.0625))
	tmp = Float32(0.0)
	if (abs(x) <= Float32(4.999999943633011e-27))
		tmp = Float32(Float32(Float32(Float32(0.0625) - Float32(t_0 * t_0)) / Float32(Float32(0.25) - t_0)) / s);
	elseif (abs(x) <= Float32(18000000319488.0))
		tmp = Float32(Float32(1.0) / Float32(s * Float32(Float32(2.0) + Float32(Float32(2.0) * Float32(Float32(1.0) + Float32(Float32(x / s) + Float32(Float32(Float32(0.5) * Float32(x * x)) / Float32(s * s))))))));
	else
		tmp = Float32(Float32(2.0) * Float32(Float32(1.0) / Float32(x * Float32(x / s))));
	end
	return tmp
end
function tmp_2 = code(x, s)
	t_0 = ((x / s) * (x / s)) * single(-0.0625);
	tmp = single(0.0);
	if (abs(x) <= single(4.999999943633011e-27))
		tmp = ((single(0.0625) - (t_0 * t_0)) / (single(0.25) - t_0)) / s;
	elseif (abs(x) <= single(18000000319488.0))
		tmp = single(1.0) / (s * (single(2.0) + (single(2.0) * (single(1.0) + ((x / s) + ((single(0.5) * (x * x)) / (s * s)))))));
	else
		tmp = single(2.0) * (single(1.0) / (x * (x / s)));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(\frac{x}{s} \cdot \frac{x}{s}\right) \cdot -0.0625\\
\mathbf{if}\;\left|x\right| \leq 4.999999943633011 \cdot 10^{-27}:\\
\;\;\;\;\frac{\frac{0.0625 - t_0 \cdot t_0}{0.25 - t_0}}{s}\\

\mathbf{elif}\;\left|x\right| \leq 18000000319488:\\
\;\;\;\;\frac{1}{s \cdot \left(2 + 2 \cdot \left(1 + \left(\frac{x}{s} + \frac{0.5 \cdot \left(x \cdot x\right)}{s \cdot s}\right)\right)\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (fabs.f32 x) < 4.99999994e-27

    1. Initial program 99.2%

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

        \[\leadsto \frac{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)}} \]
      2. +-commutative99.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{e^{\frac{x}{s} - \left(2 \cdot \mathsf{log1p}\left(e^{\frac{x}{s}}\right) + \log s\right)}} \]
    6. Step-by-step derivation
      1. associate--r+91.1%

        \[\leadsto e^{\color{blue}{\left(\frac{x}{s} - 2 \cdot \mathsf{log1p}\left(e^{\frac{x}{s}}\right)\right) - \log s}} \]
      2. exp-diff91.9%

        \[\leadsto \color{blue}{\frac{e^{\frac{x}{s} - 2 \cdot \mathsf{log1p}\left(e^{\frac{x}{s}}\right)}}{e^{\log s}}} \]
      3. cancel-sign-sub-inv91.9%

        \[\leadsto \frac{e^{\color{blue}{\frac{x}{s} + \left(-2\right) \cdot \mathsf{log1p}\left(e^{\frac{x}{s}}\right)}}}{e^{\log s}} \]
      4. metadata-eval91.9%

        \[\leadsto \frac{e^{\frac{x}{s} + \color{blue}{-2} \cdot \mathsf{log1p}\left(e^{\frac{x}{s}}\right)}}{e^{\log s}} \]
      5. rem-exp-log99.9%

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

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

      \[\leadsto \frac{\color{blue}{0.25 + -0.0625 \cdot \frac{{x}^{2}}{{s}^{2}}}}{s} \]
    9. Step-by-step derivation
      1. unpow262.8%

        \[\leadsto \frac{0.25 + -0.0625 \cdot \frac{\color{blue}{x \cdot x}}{{s}^{2}}}{s} \]
      2. unpow262.8%

        \[\leadsto \frac{0.25 + -0.0625 \cdot \frac{x \cdot x}{\color{blue}{s \cdot s}}}{s} \]
    10. Simplified62.8%

      \[\leadsto \frac{\color{blue}{0.25 + -0.0625 \cdot \frac{x \cdot x}{s \cdot s}}}{s} \]
    11. Step-by-step derivation
      1. flip-+62.8%

        \[\leadsto \frac{\color{blue}{\frac{0.25 \cdot 0.25 - \left(-0.0625 \cdot \frac{x \cdot x}{s \cdot s}\right) \cdot \left(-0.0625 \cdot \frac{x \cdot x}{s \cdot s}\right)}{0.25 - -0.0625 \cdot \frac{x \cdot x}{s \cdot s}}}}{s} \]
      2. metadata-eval62.8%

        \[\leadsto \frac{\frac{\color{blue}{0.0625} - \left(-0.0625 \cdot \frac{x \cdot x}{s \cdot s}\right) \cdot \left(-0.0625 \cdot \frac{x \cdot x}{s \cdot s}\right)}{0.25 - -0.0625 \cdot \frac{x \cdot x}{s \cdot s}}}{s} \]
      3. *-commutative62.8%

        \[\leadsto \frac{\frac{0.0625 - \color{blue}{\left(\frac{x \cdot x}{s \cdot s} \cdot -0.0625\right)} \cdot \left(-0.0625 \cdot \frac{x \cdot x}{s \cdot s}\right)}{0.25 - -0.0625 \cdot \frac{x \cdot x}{s \cdot s}}}{s} \]
      4. times-frac62.8%

        \[\leadsto \frac{\frac{0.0625 - \left(\color{blue}{\left(\frac{x}{s} \cdot \frac{x}{s}\right)} \cdot -0.0625\right) \cdot \left(-0.0625 \cdot \frac{x \cdot x}{s \cdot s}\right)}{0.25 - -0.0625 \cdot \frac{x \cdot x}{s \cdot s}}}{s} \]
      5. *-commutative62.8%

        \[\leadsto \frac{\frac{0.0625 - \left(\left(\frac{x}{s} \cdot \frac{x}{s}\right) \cdot -0.0625\right) \cdot \color{blue}{\left(\frac{x \cdot x}{s \cdot s} \cdot -0.0625\right)}}{0.25 - -0.0625 \cdot \frac{x \cdot x}{s \cdot s}}}{s} \]
      6. times-frac62.8%

        \[\leadsto \frac{\frac{0.0625 - \left(\left(\frac{x}{s} \cdot \frac{x}{s}\right) \cdot -0.0625\right) \cdot \left(\color{blue}{\left(\frac{x}{s} \cdot \frac{x}{s}\right)} \cdot -0.0625\right)}{0.25 - -0.0625 \cdot \frac{x \cdot x}{s \cdot s}}}{s} \]
      7. *-commutative62.8%

        \[\leadsto \frac{\frac{0.0625 - \left(\left(\frac{x}{s} \cdot \frac{x}{s}\right) \cdot -0.0625\right) \cdot \left(\left(\frac{x}{s} \cdot \frac{x}{s}\right) \cdot -0.0625\right)}{0.25 - \color{blue}{\frac{x \cdot x}{s \cdot s} \cdot -0.0625}}}{s} \]
      8. times-frac84.4%

        \[\leadsto \frac{\frac{0.0625 - \left(\left(\frac{x}{s} \cdot \frac{x}{s}\right) \cdot -0.0625\right) \cdot \left(\left(\frac{x}{s} \cdot \frac{x}{s}\right) \cdot -0.0625\right)}{0.25 - \color{blue}{\left(\frac{x}{s} \cdot \frac{x}{s}\right)} \cdot -0.0625}}{s} \]
    12. Applied egg-rr84.4%

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

    if 4.99999994e-27 < (fabs.f32 x) < 1.80000003e13

    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.9%

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

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

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

        \[\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.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)}{e^{\color{blue}{-\frac{\left|x\right|}{s}}}}} \]
      8. exp-neg99.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)}{\color{blue}{\frac{1}{e^{\frac{\left|x\right|}{s}}}}}} \]
    3. Simplified99.9%

      \[\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. add-sqr-sqrt-0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\color{blue}{1 \cdot e^{\frac{x}{s}}} + 2\right)} \]
    6. Step-by-step derivation
      1. *-lft-identity98.0%

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{1}{s}}{e^{\frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{s}} + \left(e^{\frac{x}{s}} + 2\right)}\right)} - 1 \]
      5. add-sqr-sqrt62.4%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{1}{s}}{e^{\frac{\color{blue}{x}}{s}} + \left(e^{\frac{x}{s}} + 2\right)}\right)} - 1 \]
    9. Applied egg-rr62.4%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{s \cdot \left(2 + \color{blue}{\left(1 + \left(\frac{x}{s} + 0.5 \cdot \frac{{x}^{2}}{{s}^{2}}\right)\right)} \cdot 2\right)} \]
    13. Step-by-step derivation
      1. associate-*r/67.9%

        \[\leadsto \frac{1}{s \cdot \left(2 + \left(1 + \left(\frac{x}{s} + \color{blue}{\frac{0.5 \cdot {x}^{2}}{{s}^{2}}}\right)\right) \cdot 2\right)} \]
      2. unpow267.9%

        \[\leadsto \frac{1}{s \cdot \left(2 + \left(1 + \left(\frac{x}{s} + \frac{0.5 \cdot {x}^{2}}{\color{blue}{s \cdot s}}\right)\right) \cdot 2\right)} \]
      3. unpow267.9%

        \[\leadsto \frac{1}{s \cdot \left(2 + \left(1 + \left(\frac{x}{s} + \frac{0.5 \cdot \color{blue}{\left(x \cdot x\right)}}{s \cdot s}\right)\right) \cdot 2\right)} \]
    14. Simplified67.9%

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

    if 1.80000003e13 < (fabs.f32 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 \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.8%

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

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

        \[\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.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)}{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.8%

      \[\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. add-sqr-sqrt-0.0%

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

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

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

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

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{\color{blue}{s}}} + 2\right)} \]
      6. *-un-lft-identity98.8%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 63.5%

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

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

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

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \color{blue}{\left(3 + \left(\frac{x}{s} + \frac{0.5 \cdot \left(x \cdot x\right)}{s \cdot s}\right)\right)}} \]
    11. Taylor expanded in s around 0 92.4%

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

        \[\leadsto 2 \cdot \frac{s}{\color{blue}{x \cdot x}} \]
    13. Simplified92.4%

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

        \[\leadsto 2 \cdot \color{blue}{\frac{1}{\frac{x \cdot x}{s}}} \]
      2. inv-pow94.3%

        \[\leadsto 2 \cdot \color{blue}{{\left(\frac{x \cdot x}{s}\right)}^{-1}} \]
    15. Applied egg-rr94.3%

      \[\leadsto 2 \cdot \color{blue}{{\left(\frac{x \cdot x}{s}\right)}^{-1}} \]
    16. Step-by-step derivation
      1. unpow-194.3%

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

        \[\leadsto 2 \cdot \frac{1}{\color{blue}{x \cdot \frac{x}{s}}} \]
    17. Simplified94.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left|x\right| \leq 4.999999943633011 \cdot 10^{-27}:\\ \;\;\;\;\frac{\frac{0.0625 - \left(\left(\frac{x}{s} \cdot \frac{x}{s}\right) \cdot -0.0625\right) \cdot \left(\left(\frac{x}{s} \cdot \frac{x}{s}\right) \cdot -0.0625\right)}{0.25 - \left(\frac{x}{s} \cdot \frac{x}{s}\right) \cdot -0.0625}}{s}\\ \mathbf{elif}\;\left|x\right| \leq 18000000319488:\\ \;\;\;\;\frac{1}{s \cdot \left(2 + 2 \cdot \left(1 + \left(\frac{x}{s} + \frac{0.5 \cdot \left(x \cdot x\right)}{s \cdot s}\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \frac{1}{x \cdot \frac{x}{s}}\\ \end{array} \]

Alternative 5: 96.4% 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.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.4%

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

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

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

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

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

    \[\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. add-sqr-sqrt-0.0%

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

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

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

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{\color{blue}{s}}} + 2\right)} \]
    6. *-un-lft-identity96.6%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\color{blue}{e^{\frac{x}{s}}} + 2\right)} \]
  7. Simplified98.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.6%

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

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

Alternative 6: 94.8% accurate, 3.0× speedup?

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

\\
\frac{e^{\frac{-\left|x\right|}{s}}}{s \cdot 4}
\end{array}
Derivation
  1. Initial program 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. associate-*l*99.8%

      \[\leadsto \frac{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)}} \]
    2. +-commutative99.8%

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

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

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

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

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

Alternative 7: 94.4% accurate, 5.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 2.600000032318924 \cdot 10^{-27}:\\ \;\;\;\;\frac{1}{s \cdot \left(2 + 2 \cdot e^{-\frac{x}{s}}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{s \cdot 2 + s \cdot \left(2 \cdot e^{\frac{x}{s}}\right)}\\ \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (if (<= x 2.600000032318924e-27)
   (/ 1.0 (* s (+ 2.0 (* 2.0 (exp (- (/ x s)))))))
   (/ 1.0 (+ (* s 2.0) (* s (* 2.0 (exp (/ x s))))))))
float code(float x, float s) {
	float tmp;
	if (x <= 2.600000032318924e-27f) {
		tmp = 1.0f / (s * (2.0f + (2.0f * expf(-(x / s)))));
	} else {
		tmp = 1.0f / ((s * 2.0f) + (s * (2.0f * expf((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 <= 2.600000032318924e-27) then
        tmp = 1.0e0 / (s * (2.0e0 + (2.0e0 * exp(-(x / s)))))
    else
        tmp = 1.0e0 / ((s * 2.0e0) + (s * (2.0e0 * exp((x / s)))))
    end if
    code = tmp
end function
function code(x, s)
	tmp = Float32(0.0)
	if (x <= Float32(2.600000032318924e-27))
		tmp = Float32(Float32(1.0) / Float32(s * Float32(Float32(2.0) + Float32(Float32(2.0) * exp(Float32(-Float32(x / s)))))));
	else
		tmp = Float32(Float32(1.0) / Float32(Float32(s * Float32(2.0)) + Float32(s * Float32(Float32(2.0) * exp(Float32(x / s))))));
	end
	return tmp
end
function tmp_2 = code(x, s)
	tmp = single(0.0);
	if (x <= single(2.600000032318924e-27))
		tmp = single(1.0) / (s * (single(2.0) + (single(2.0) * exp(-(x / s)))));
	else
		tmp = single(1.0) / ((s * single(2.0)) + (s * (single(2.0) * exp((x / s)))));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.600000032318924 \cdot 10^{-27}:\\
\;\;\;\;\frac{1}{s \cdot \left(2 + 2 \cdot e^{-\frac{x}{s}}\right)}\\

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


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

    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-frac99.8%

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

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

        \[\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.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)}{e^{\color{blue}{-\frac{\left|x\right|}{s}}}}} \]
      8. exp-neg99.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)}{\color{blue}{\frac{1}{e^{\frac{\left|x\right|}{s}}}}}} \]
    3. Simplified99.9%

      \[\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. add-sqr-sqrt-0.0%

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

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

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

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

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{\color{blue}{s}}} + 2\right)} \]
      6. *-un-lft-identity96.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{1}{s}}{e^{\frac{\color{blue}{x}}{s}} + \left(e^{\frac{x}{s}} + 2\right)}\right)} - 1 \]
    9. Applied egg-rr31.0%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{s \cdot \left(2 + e^{\frac{x}{s}} \cdot 2\right)}} \]
    12. Step-by-step derivation
      1. div-inv32.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.60000003e-27 < 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.9%

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

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

      \[\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. add-sqr-sqrt-0.0%

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

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

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

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

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{\color{blue}{s}}} + 2\right)} \]
      6. *-un-lft-identity96.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{1}{s}}{e^{\frac{\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right|}{s}} + \left(e^{\frac{x}{s}} + 2\right)}\right)} - 1 \]
      4. fabs-sqr96.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 94.4% accurate, 5.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 2.600000032318924 \cdot 10^{-27}:\\ \;\;\;\;\frac{1}{s \cdot \left(2 + 2 \cdot e^{-\frac{x}{s}}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{s \cdot \left(2 + 2 \cdot e^{\frac{x}{s}}\right)}\\ \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (if (<= x 2.600000032318924e-27)
   (/ 1.0 (* s (+ 2.0 (* 2.0 (exp (- (/ x s)))))))
   (/ 1.0 (* s (+ 2.0 (* 2.0 (exp (/ x s))))))))
float code(float x, float s) {
	float tmp;
	if (x <= 2.600000032318924e-27f) {
		tmp = 1.0f / (s * (2.0f + (2.0f * expf(-(x / s)))));
	} else {
		tmp = 1.0f / (s * (2.0f + (2.0f * expf((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 <= 2.600000032318924e-27) then
        tmp = 1.0e0 / (s * (2.0e0 + (2.0e0 * exp(-(x / s)))))
    else
        tmp = 1.0e0 / (s * (2.0e0 + (2.0e0 * exp((x / s)))))
    end if
    code = tmp
end function
function code(x, s)
	tmp = Float32(0.0)
	if (x <= Float32(2.600000032318924e-27))
		tmp = Float32(Float32(1.0) / Float32(s * Float32(Float32(2.0) + Float32(Float32(2.0) * exp(Float32(-Float32(x / s)))))));
	else
		tmp = Float32(Float32(1.0) / Float32(s * Float32(Float32(2.0) + Float32(Float32(2.0) * exp(Float32(x / s))))));
	end
	return tmp
end
function tmp_2 = code(x, s)
	tmp = single(0.0);
	if (x <= single(2.600000032318924e-27))
		tmp = single(1.0) / (s * (single(2.0) + (single(2.0) * exp(-(x / s)))));
	else
		tmp = single(1.0) / (s * (single(2.0) + (single(2.0) * exp((x / s)))));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.600000032318924 \cdot 10^{-27}:\\
\;\;\;\;\frac{1}{s \cdot \left(2 + 2 \cdot e^{-\frac{x}{s}}\right)}\\

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


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

    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-frac99.8%

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

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

        \[\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.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)}{e^{\color{blue}{-\frac{\left|x\right|}{s}}}}} \]
      8. exp-neg99.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)}{\color{blue}{\frac{1}{e^{\frac{\left|x\right|}{s}}}}}} \]
    3. Simplified99.9%

      \[\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. add-sqr-sqrt-0.0%

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

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

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

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

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{\color{blue}{s}}} + 2\right)} \]
      6. *-un-lft-identity96.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{1}{s}}{e^{\frac{\color{blue}{x}}{s}} + \left(e^{\frac{x}{s}} + 2\right)}\right)} - 1 \]
    9. Applied egg-rr31.0%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{s \cdot \left(2 + e^{\frac{x}{s}} \cdot 2\right)}} \]
    12. Step-by-step derivation
      1. div-inv32.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.60000003e-27 < 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.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 95.0% accurate, 5.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\frac{x}{s}}\\ \mathbf{if}\;x \leq -1.000000046701102 \cdot 10^{-34}:\\ \;\;\;\;\frac{t_0}{s \cdot 4}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{s \cdot \left(2 + 2 \cdot t_0\right)}\\ \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (let* ((t_0 (exp (/ x s))))
   (if (<= x -1.000000046701102e-34)
     (/ t_0 (* s 4.0))
     (/ 1.0 (* s (+ 2.0 (* 2.0 t_0)))))))
float code(float x, float s) {
	float t_0 = expf((x / s));
	float tmp;
	if (x <= -1.000000046701102e-34f) {
		tmp = t_0 / (s * 4.0f);
	} else {
		tmp = 1.0f / (s * (2.0f + (2.0f * t_0)));
	}
	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.000000046701102e-34)) then
        tmp = t_0 / (s * 4.0e0)
    else
        tmp = 1.0e0 / (s * (2.0e0 + (2.0e0 * t_0)))
    end if
    code = tmp
end function
function code(x, s)
	t_0 = exp(Float32(x / s))
	tmp = Float32(0.0)
	if (x <= Float32(-1.000000046701102e-34))
		tmp = Float32(t_0 / Float32(s * Float32(4.0)));
	else
		tmp = Float32(Float32(1.0) / Float32(s * Float32(Float32(2.0) + Float32(Float32(2.0) * t_0))));
	end
	return tmp
end
function tmp_2 = code(x, s)
	t_0 = exp((x / s));
	tmp = single(0.0);
	if (x <= single(-1.000000046701102e-34))
		tmp = t_0 / (s * single(4.0));
	else
		tmp = single(1.0) / (s * (single(2.0) + (single(2.0) * t_0)));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

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

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


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

    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. associate-*l*99.9%

        \[\leadsto \frac{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)}} \]
      2. +-commutative99.9%

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

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

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

      \[\leadsto \frac{e^{\frac{-\left|x\right|}{s}}}{s \cdot \color{blue}{4}} \]
    5. Step-by-step derivation
      1. expm1-log1p-u96.1%

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

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

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{e^{\frac{x}{s}}}{s \cdot 4}\right)\right)} \]
      2. expm1-log1p96.6%

        \[\leadsto \color{blue}{\frac{e^{\frac{x}{s}}}{s \cdot 4}} \]
    8. Simplified96.6%

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

    if -1.00000005e-34 < 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.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.1%

        \[\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.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)}{\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-u96.5%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 86.9% accurate, 5.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.999999943633011 \cdot 10^{-27}:\\
\;\;\;\;\frac{e^{\frac{x}{s}}}{s \cdot 4}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{s \cdot \left(2 + 2 \cdot \left(1 + \left(\frac{x}{s} + \frac{0.5 \cdot \left(x \cdot x\right)}{s \cdot s}\right)\right)\right)}\\


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

    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. associate-*l*99.8%

        \[\leadsto \frac{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)}} \]
      2. +-commutative99.8%

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

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

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

      \[\leadsto \frac{e^{\frac{-\left|x\right|}{s}}}{s \cdot \color{blue}{4}} \]
    5. Step-by-step derivation
      1. expm1-log1p-u94.5%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{e^{\frac{-\left|x\right|}{s}}}{s \cdot 4}\right)\right)} \]
      2. expm1-udef94.5%

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

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

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

        \[\leadsto \color{blue}{\frac{e^{\frac{x}{s}}}{s \cdot 4}} \]
    8. Simplified95.4%

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

    if 4.99999994e-27 < 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.9%

        \[\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/98.9%

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

      \[\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. add-sqr-sqrt-0.0%

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

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

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

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

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{\color{blue}{s}}} + 2\right)} \]
      6. *-un-lft-identity96.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{1}{s}}{e^{\frac{\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right|}{s}} + \left(e^{\frac{x}{s}} + 2\right)}\right)} - 1 \]
      4. fabs-sqr96.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{s \cdot \left(2 + \color{blue}{\left(1 + \left(\frac{x}{s} + 0.5 \cdot \frac{{x}^{2}}{{s}^{2}}\right)\right)} \cdot 2\right)} \]
    13. Step-by-step derivation
      1. associate-*r/79.1%

        \[\leadsto \frac{1}{s \cdot \left(2 + \left(1 + \left(\frac{x}{s} + \color{blue}{\frac{0.5 \cdot {x}^{2}}{{s}^{2}}}\right)\right) \cdot 2\right)} \]
      2. unpow279.1%

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

        \[\leadsto \frac{1}{s \cdot \left(2 + \left(1 + \left(\frac{x}{s} + \frac{0.5 \cdot \color{blue}{\left(x \cdot x\right)}}{s \cdot s}\right)\right) \cdot 2\right)} \]
    14. Simplified79.1%

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

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

Alternative 11: 77.3% accurate, 21.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -9999999827968:\\ \;\;\;\;2 \cdot \frac{1}{x \cdot \frac{x}{s}}\\ \mathbf{elif}\;x \leq -1.000000045813705 \cdot 10^{-18} \lor \neg \left(x \leq 4.999999943633011 \cdot 10^{-27}\right):\\ \;\;\;\;\frac{1}{s \cdot \left(2 + 2 \cdot \left(1 + \left(\frac{x}{s} + \frac{0.5 \cdot \left(x \cdot x\right)}{s \cdot s}\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\frac{x}{s} \cdot \frac{x}{s}\right) \cdot -0.0625 + 0.25}{s}\\ \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (if (<= x -9999999827968.0)
   (* 2.0 (/ 1.0 (* x (/ x s))))
   (if (or (<= x -1.000000045813705e-18) (not (<= x 4.999999943633011e-27)))
     (/
      1.0
      (* s (+ 2.0 (* 2.0 (+ 1.0 (+ (/ x s) (/ (* 0.5 (* x x)) (* s s))))))))
     (/ (+ (* (* (/ x s) (/ x s)) -0.0625) 0.25) s))))
float code(float x, float s) {
	float tmp;
	if (x <= -9999999827968.0f) {
		tmp = 2.0f * (1.0f / (x * (x / s)));
	} else if ((x <= -1.000000045813705e-18f) || !(x <= 4.999999943633011e-27f)) {
		tmp = 1.0f / (s * (2.0f + (2.0f * (1.0f + ((x / s) + ((0.5f * (x * x)) / (s * s)))))));
	} else {
		tmp = ((((x / s) * (x / s)) * -0.0625f) + 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 <= (-9999999827968.0e0)) then
        tmp = 2.0e0 * (1.0e0 / (x * (x / s)))
    else if ((x <= (-1.000000045813705e-18)) .or. (.not. (x <= 4.999999943633011e-27))) then
        tmp = 1.0e0 / (s * (2.0e0 + (2.0e0 * (1.0e0 + ((x / s) + ((0.5e0 * (x * x)) / (s * s)))))))
    else
        tmp = ((((x / s) * (x / s)) * (-0.0625e0)) + 0.25e0) / s
    end if
    code = tmp
end function
function code(x, s)
	tmp = Float32(0.0)
	if (x <= Float32(-9999999827968.0))
		tmp = Float32(Float32(2.0) * Float32(Float32(1.0) / Float32(x * Float32(x / s))));
	elseif ((x <= Float32(-1.000000045813705e-18)) || !(x <= Float32(4.999999943633011e-27)))
		tmp = Float32(Float32(1.0) / Float32(s * Float32(Float32(2.0) + Float32(Float32(2.0) * Float32(Float32(1.0) + Float32(Float32(x / s) + Float32(Float32(Float32(0.5) * Float32(x * x)) / Float32(s * s))))))));
	else
		tmp = Float32(Float32(Float32(Float32(Float32(x / s) * Float32(x / s)) * Float32(-0.0625)) + Float32(0.25)) / s);
	end
	return tmp
end
function tmp_2 = code(x, s)
	tmp = single(0.0);
	if (x <= single(-9999999827968.0))
		tmp = single(2.0) * (single(1.0) / (x * (x / s)));
	elseif ((x <= single(-1.000000045813705e-18)) || ~((x <= single(4.999999943633011e-27))))
		tmp = single(1.0) / (s * (single(2.0) + (single(2.0) * (single(1.0) + ((x / s) + ((single(0.5) * (x * x)) / (s * s)))))));
	else
		tmp = ((((x / s) * (x / s)) * single(-0.0625)) + single(0.25)) / s;
	end
	tmp_2 = tmp;
end
\begin{array}{l}

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

\mathbf{elif}\;x \leq -1.000000045813705 \cdot 10^{-18} \lor \neg \left(x \leq 4.999999943633011 \cdot 10^{-27}\right):\\
\;\;\;\;\frac{1}{s \cdot \left(2 + 2 \cdot \left(1 + \left(\frac{x}{s} + \frac{0.5 \cdot \left(x \cdot x\right)}{s \cdot s}\right)\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{x}{s} \cdot \frac{x}{s}\right) \cdot -0.0625 + 0.25}{s}\\


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

    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 \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-frac100.0%

        \[\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/100.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*100.0%

        \[\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-neg100.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)}{e^{\color{blue}{-\frac{\left|x\right|}{s}}}}} \]
      8. exp-neg100.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. Simplified100.0%

      \[\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. add-sqr-sqrt-0.0%

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

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

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

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

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{\color{blue}{s}}} + 2\right)} \]
      6. *-un-lft-identity100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\color{blue}{1 \cdot e^{\frac{x}{s}}} + 2\right)} \]
    6. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\color{blue}{e^{\frac{x}{s}}} + 2\right)} \]
    7. Simplified100.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 36.2%

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

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

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

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \color{blue}{\left(3 + \left(\frac{x}{s} + \frac{0.5 \cdot \left(x \cdot x\right)}{s \cdot s}\right)\right)}} \]
    11. Taylor expanded in s around 0 90.9%

      \[\leadsto \color{blue}{2 \cdot \frac{s}{{x}^{2}}} \]
    12. Step-by-step derivation
      1. unpow290.9%

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

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

        \[\leadsto 2 \cdot \color{blue}{\frac{1}{\frac{x \cdot x}{s}}} \]
      2. inv-pow91.4%

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

      \[\leadsto 2 \cdot \color{blue}{{\left(\frac{x \cdot x}{s}\right)}^{-1}} \]
    16. Step-by-step derivation
      1. unpow-191.4%

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

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

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

    if -9999999830000 < x < -1.00000005e-18 or 4.99999994e-27 < 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.9%

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

        \[\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.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)}{e^{\color{blue}{-\frac{\left|x\right|}{s}}}}} \]
      8. exp-neg99.3%

        \[\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. add-sqr-sqrt-0.0%

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

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

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

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

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{\color{blue}{s}}} + 2\right)} \]
      6. *-un-lft-identity97.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{1}{s}}{e^{\frac{\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right|}{s}} + \left(e^{\frac{x}{s}} + 2\right)}\right)} - 1 \]
      4. fabs-sqr66.8%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{1}{s}}{e^{\frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{s}} + \left(e^{\frac{x}{s}} + 2\right)}\right)} - 1 \]
      5. add-sqr-sqrt69.9%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{1}{s}}{e^{\frac{\color{blue}{x}}{s}} + \left(e^{\frac{x}{s}} + 2\right)}\right)} - 1 \]
    9. Applied egg-rr69.9%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{s \cdot \left(2 + \color{blue}{\left(1 + \left(\frac{x}{s} + 0.5 \cdot \frac{{x}^{2}}{{s}^{2}}\right)\right)} \cdot 2\right)} \]
    13. Step-by-step derivation
      1. associate-*r/74.3%

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

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

        \[\leadsto \frac{1}{s \cdot \left(2 + \left(1 + \left(\frac{x}{s} + \frac{0.5 \cdot \color{blue}{\left(x \cdot x\right)}}{s \cdot s}\right)\right) \cdot 2\right)} \]
    14. Simplified74.3%

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

    if -1.00000005e-18 < x < 4.99999994e-27

    1. Initial program 99.3%

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

        \[\leadsto \frac{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)}} \]
      2. +-commutative99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{e^{\frac{x}{s} - \left(2 \cdot \mathsf{log1p}\left(e^{\frac{x}{s}}\right) + \log s\right)}} \]
    6. Step-by-step derivation
      1. associate--r+91.3%

        \[\leadsto e^{\color{blue}{\left(\frac{x}{s} - 2 \cdot \mathsf{log1p}\left(e^{\frac{x}{s}}\right)\right) - \log s}} \]
      2. exp-diff92.1%

        \[\leadsto \color{blue}{\frac{e^{\frac{x}{s} - 2 \cdot \mathsf{log1p}\left(e^{\frac{x}{s}}\right)}}{e^{\log s}}} \]
      3. cancel-sign-sub-inv92.1%

        \[\leadsto \frac{e^{\color{blue}{\frac{x}{s} + \left(-2\right) \cdot \mathsf{log1p}\left(e^{\frac{x}{s}}\right)}}}{e^{\log s}} \]
      4. metadata-eval92.1%

        \[\leadsto \frac{e^{\frac{x}{s} + \color{blue}{-2} \cdot \mathsf{log1p}\left(e^{\frac{x}{s}}\right)}}{e^{\log s}} \]
      5. rem-exp-log99.9%

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

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

      \[\leadsto \frac{\color{blue}{0.25 + -0.0625 \cdot \frac{{x}^{2}}{{s}^{2}}}}{s} \]
    9. Step-by-step derivation
      1. unpow266.7%

        \[\leadsto \frac{0.25 + -0.0625 \cdot \frac{\color{blue}{x \cdot x}}{{s}^{2}}}{s} \]
      2. unpow266.7%

        \[\leadsto \frac{0.25 + -0.0625 \cdot \frac{x \cdot x}{\color{blue}{s \cdot s}}}{s} \]
    10. Simplified66.7%

      \[\leadsto \frac{\color{blue}{0.25 + -0.0625 \cdot \frac{x \cdot x}{s \cdot s}}}{s} \]
    11. Step-by-step derivation
      1. times-frac85.0%

        \[\leadsto \frac{0.25 + -0.0625 \cdot \color{blue}{\left(\frac{x}{s} \cdot \frac{x}{s}\right)}}{s} \]
    12. Applied egg-rr85.0%

      \[\leadsto \frac{0.25 + -0.0625 \cdot \color{blue}{\left(\frac{x}{s} \cdot \frac{x}{s}\right)}}{s} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification79.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -9999999827968:\\ \;\;\;\;2 \cdot \frac{1}{x \cdot \frac{x}{s}}\\ \mathbf{elif}\;x \leq -1.000000045813705 \cdot 10^{-18} \lor \neg \left(x \leq 4.999999943633011 \cdot 10^{-27}\right):\\ \;\;\;\;\frac{1}{s \cdot \left(2 + 2 \cdot \left(1 + \left(\frac{x}{s} + \frac{0.5 \cdot \left(x \cdot x\right)}{s \cdot s}\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\frac{x}{s} \cdot \frac{x}{s}\right) \cdot -0.0625 + 0.25}{s}\\ \end{array} \]

Alternative 12: 63.2% accurate, 35.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{x}{s} \cdot \frac{x}{s}\right) \cdot -0.0625 + 0.25}{s}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -9.99999997e-7 or 1.99999999e-11 < 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 \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.3%

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

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

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

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

        \[\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. add-sqr-sqrt-0.0%

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

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

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

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

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{\color{blue}{s}}} + 2\right)} \]
      6. *-un-lft-identity98.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\color{blue}{1 \cdot e^{\frac{x}{s}}} + 2\right)} \]
    6. Step-by-step derivation
      1. *-lft-identity98.5%

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

      \[\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 78.0%

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

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

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

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \color{blue}{\left(3 + \left(\frac{x}{s} + \frac{0.5 \cdot \left(x \cdot x\right)}{s \cdot s}\right)\right)}} \]
    11. Taylor expanded in s around 0 63.2%

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

        \[\leadsto 2 \cdot \frac{s}{\color{blue}{x \cdot x}} \]
    13. Simplified63.2%

      \[\leadsto \color{blue}{2 \cdot \frac{s}{x \cdot x}} \]
    14. Step-by-step derivation
      1. clear-num66.8%

        \[\leadsto 2 \cdot \color{blue}{\frac{1}{\frac{x \cdot x}{s}}} \]
      2. inv-pow66.8%

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

      \[\leadsto 2 \cdot \color{blue}{{\left(\frac{x \cdot x}{s}\right)}^{-1}} \]
    16. Step-by-step derivation
      1. unpow-166.8%

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

        \[\leadsto 2 \cdot \frac{1}{\color{blue}{x \cdot \frac{x}{s}}} \]
    17. Simplified66.8%

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

    if -9.99999997e-7 < x < 1.99999999e-11

    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. Step-by-step derivation
      1. associate-*l*99.6%

        \[\leadsto \frac{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)}} \]
      2. +-commutative99.6%

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

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

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

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

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

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

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

        \[\leadsto e^{\frac{\color{blue}{\sqrt{\left(-\left|x\right|\right) \cdot \left(-\left|x\right|\right)}}}{s} - \log \left(s \cdot \left(\left(e^{\frac{-\left|x\right|}{s}} + 1\right) \cdot \left(e^{\frac{-\left|x\right|}{s}} + 1\right)\right)\right)} \]
      6. sqr-neg58.0%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{e^{\frac{x}{s} - \left(2 \cdot \mathsf{log1p}\left(e^{\frac{x}{s}}\right) + \log s\right)}} \]
    6. Step-by-step derivation
      1. associate--r+94.1%

        \[\leadsto e^{\color{blue}{\left(\frac{x}{s} - 2 \cdot \mathsf{log1p}\left(e^{\frac{x}{s}}\right)\right) - \log s}} \]
      2. exp-diff94.4%

        \[\leadsto \color{blue}{\frac{e^{\frac{x}{s} - 2 \cdot \mathsf{log1p}\left(e^{\frac{x}{s}}\right)}}{e^{\log s}}} \]
      3. cancel-sign-sub-inv94.4%

        \[\leadsto \frac{e^{\color{blue}{\frac{x}{s} + \left(-2\right) \cdot \mathsf{log1p}\left(e^{\frac{x}{s}}\right)}}}{e^{\log s}} \]
      4. metadata-eval94.4%

        \[\leadsto \frac{e^{\frac{x}{s} + \color{blue}{-2} \cdot \mathsf{log1p}\left(e^{\frac{x}{s}}\right)}}{e^{\log s}} \]
      5. rem-exp-log99.9%

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

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

      \[\leadsto \frac{\color{blue}{0.25 + -0.0625 \cdot \frac{{x}^{2}}{{s}^{2}}}}{s} \]
    9. Step-by-step derivation
      1. unpow255.9%

        \[\leadsto \frac{0.25 + -0.0625 \cdot \frac{\color{blue}{x \cdot x}}{{s}^{2}}}{s} \]
      2. unpow255.9%

        \[\leadsto \frac{0.25 + -0.0625 \cdot \frac{x \cdot x}{\color{blue}{s \cdot s}}}{s} \]
    10. Simplified55.9%

      \[\leadsto \frac{\color{blue}{0.25 + -0.0625 \cdot \frac{x \cdot x}{s \cdot s}}}{s} \]
    11. Step-by-step derivation
      1. times-frac65.0%

        \[\leadsto \frac{0.25 + -0.0625 \cdot \color{blue}{\left(\frac{x}{s} \cdot \frac{x}{s}\right)}}{s} \]
    12. Applied egg-rr65.0%

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

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

Alternative 13: 62.8% accurate, 46.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -9.99999997e-7 or 1.99999999e-11 < 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 \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.3%

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

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

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

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

        \[\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. add-sqr-sqrt-0.0%

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

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

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

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

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{\color{blue}{s}}} + 2\right)} \]
      6. *-un-lft-identity98.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\color{blue}{1 \cdot e^{\frac{x}{s}}} + 2\right)} \]
    6. Step-by-step derivation
      1. *-lft-identity98.5%

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

      \[\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 78.0%

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

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

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

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \color{blue}{\left(3 + \left(\frac{x}{s} + \frac{0.5 \cdot \left(x \cdot x\right)}{s \cdot s}\right)\right)}} \]
    11. Taylor expanded in s around 0 63.2%

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

        \[\leadsto 2 \cdot \frac{s}{\color{blue}{x \cdot x}} \]
    13. Simplified63.2%

      \[\leadsto \color{blue}{2 \cdot \frac{s}{x \cdot x}} \]
    14. Step-by-step derivation
      1. clear-num66.8%

        \[\leadsto 2 \cdot \color{blue}{\frac{1}{\frac{x \cdot x}{s}}} \]
      2. inv-pow66.8%

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

      \[\leadsto 2 \cdot \color{blue}{{\left(\frac{x \cdot x}{s}\right)}^{-1}} \]
    16. Step-by-step derivation
      1. unpow-166.8%

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

        \[\leadsto 2 \cdot \frac{1}{\color{blue}{x \cdot \frac{x}{s}}} \]
    17. Simplified66.8%

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

    if -9.99999997e-7 < x < 1.99999999e-11

    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. Step-by-step derivation
      1. associate-*l*99.6%

        \[\leadsto \frac{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)}} \]
      2. +-commutative99.6%

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

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

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

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

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

Alternative 14: 61.5% accurate, 55.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.999999974752427 \cdot 10^{-7} \lor \neg \left(x \leq 1.9999999920083944 \cdot 10^{-11}\right):\\
\;\;\;\;2 \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 < -9.99999997e-7 or 1.99999999e-11 < 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 \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.3%

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

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

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

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

        \[\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. add-sqr-sqrt-0.0%

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

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

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

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

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{\color{blue}{s}}} + 2\right)} \]
      6. *-un-lft-identity98.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\color{blue}{1 \cdot e^{\frac{x}{s}}} + 2\right)} \]
    6. Step-by-step derivation
      1. *-lft-identity98.5%

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

      \[\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 78.0%

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

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

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

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \color{blue}{\left(3 + \left(\frac{x}{s} + \frac{0.5 \cdot \left(x \cdot x\right)}{s \cdot s}\right)\right)}} \]
    11. Taylor expanded in s around 0 63.2%

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

        \[\leadsto 2 \cdot \frac{s}{\color{blue}{x \cdot x}} \]
    13. Simplified63.2%

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

    if -9.99999997e-7 < x < 1.99999999e-11

    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. Step-by-step derivation
      1. associate-*l*99.6%

        \[\leadsto \frac{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)}} \]
      2. +-commutative99.6%

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

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

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

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

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

Alternative 15: 61.4% accurate, 55.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.999999974752427 \cdot 10^{-7}:\\
\;\;\;\;2 \cdot \frac{\frac{s}{x}}{x}\\

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

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


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

    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 \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-frac100.0%

        \[\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/100.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*100.0%

        \[\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-neg100.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)}{e^{\color{blue}{-\frac{\left|x\right|}{s}}}}} \]
      8. exp-neg100.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. Simplified100.0%

      \[\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. add-sqr-sqrt-0.0%

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

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

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

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

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{\color{blue}{s}}} + 2\right)} \]
      6. *-un-lft-identity99.1%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\color{blue}{1 \cdot e^{\frac{x}{s}}} + 2\right)} \]
    6. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\color{blue}{e^{\frac{x}{s}}} + 2\right)} \]
    7. Simplified100.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 59.5%

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

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

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

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \color{blue}{\left(3 + \left(\frac{x}{s} + \frac{0.5 \cdot \left(x \cdot x\right)}{s \cdot s}\right)\right)}} \]
    11. Taylor expanded in s around 0 66.2%

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

        \[\leadsto 2 \cdot \frac{s}{\color{blue}{x \cdot x}} \]
    13. Simplified66.2%

      \[\leadsto \color{blue}{2 \cdot \frac{s}{x \cdot x}} \]
    14. Taylor expanded in s around 0 66.2%

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

        \[\leadsto 2 \cdot \frac{s}{\color{blue}{x \cdot x}} \]
      2. associate-/r*66.2%

        \[\leadsto 2 \cdot \color{blue}{\frac{\frac{s}{x}}{x}} \]
    16. Simplified66.2%

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

    if -9.99999997e-7 < x < 1.99999999e-11

    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. Step-by-step derivation
      1. associate-*l*99.6%

        \[\leadsto \frac{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)}} \]
      2. +-commutative99.6%

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

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

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

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

    if 1.99999999e-11 < 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 \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.6%

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

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

      \[\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. add-sqr-sqrt-0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\color{blue}{1 \cdot e^{\frac{x}{s}}} + 2\right)} \]
    6. Step-by-step derivation
      1. *-lft-identity97.0%

        \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(\color{blue}{e^{\frac{x}{s}}} + 2\right)} \]
    7. Simplified97.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 97.1%

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

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

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

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

      \[\leadsto \frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \color{blue}{\left(3 + \left(\frac{x}{s} + \frac{0.5 \cdot \left(x \cdot x\right)}{s \cdot s}\right)\right)}} \]
    11. Taylor expanded in s around 0 60.1%

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

        \[\leadsto 2 \cdot \frac{s}{\color{blue}{x \cdot x}} \]
    13. Simplified60.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -9.999999974752427 \cdot 10^{-7}:\\ \;\;\;\;2 \cdot \frac{\frac{s}{x}}{x}\\ \mathbf{elif}\;x \leq 1.9999999920083944 \cdot 10^{-11}:\\ \;\;\;\;\frac{0.25}{s}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \frac{s}{x \cdot x}\\ \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.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. associate-*l*99.8%

      \[\leadsto \frac{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)}} \]
    2. +-commutative99.8%

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

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

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

    \[\leadsto \color{blue}{\frac{0.25}{s}} \]
  5. Final simplification29.0%

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

Reproduce

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