Logistic distribution

Percentage Accurate: 99.5% → 99.4%
Time: 21.9s
Alternatives: 18
Speedup: 2.9×

Specification

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

\\
\begin{array}{l}
t_0 := e^{\frac{-\left|x\right|}{s}}\\
t_1 := 1 + t_0\\
\frac{t_0}{\left(s \cdot t_1\right) \cdot t_1}
\end{array}
\end{array}

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 18 alternatives:

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

Initial Program: 99.5% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := e^{\frac{-\left|x\right|}{s}}\\
t_1 := 1 + t_0\\
\frac{t_0}{\left(s \cdot t_1\right) \cdot t_1}
\end{array}
\end{array}

Alternative 1: 99.4% accurate, 0.6× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{1}{1 + e^{\frac{\left|x\right|}{-s}}}}{\mathsf{fma}\left(s, e^{\frac{\left|x\right|}{s}}, s\right)}} \]
  3. Step-by-step derivation
    1. add-sqr-sqrt99.7%

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

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

    \[\leadsto \frac{\frac{1}{1 + e^{\frac{\left|x\right|}{-s}}}}{\mathsf{fma}\left(s, \color{blue}{{\left(e^{\sqrt{\frac{\left|x\right|}{s}}}\right)}^{\left(\sqrt{\frac{\left|x\right|}{s}}\right)}}, s\right)} \]
  5. Step-by-step derivation
    1. add-exp-log99.8%

      \[\leadsto \frac{\color{blue}{e^{\log \left(\frac{1}{1 + e^{\frac{\left|x\right|}{-s}}}\right)}}}{\mathsf{fma}\left(s, {\left(e^{\sqrt{\frac{\left|x\right|}{s}}}\right)}^{\left(\sqrt{\frac{\left|x\right|}{s}}\right)}, s\right)} \]
    2. log-rec99.8%

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

      \[\leadsto \frac{e^{-\color{blue}{\mathsf{log1p}\left(e^{\frac{\left|x\right|}{-s}}\right)}}}{\mathsf{fma}\left(s, {\left(e^{\sqrt{\frac{\left|x\right|}{s}}}\right)}^{\left(\sqrt{\frac{\left|x\right|}{s}}\right)}, s\right)} \]
  6. Applied egg-rr99.8%

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

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

Alternative 2: 53.7% accurate, 0.8× speedup?

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

\\
\frac{\frac{1}{e^{\frac{\left|x\right|}{-s}} + 1}}{\mathsf{fma}\left(s, {\left(e^{\sqrt{\frac{\left|x\right|}{s}}}\right)}^{\left(\sqrt{\frac{x}{s}}\right)}, s\right)}
\end{array}
Derivation
  1. Initial program 99.6%

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

    \[\leadsto \color{blue}{\frac{\frac{1}{1 + e^{\frac{\left|x\right|}{-s}}}}{\mathsf{fma}\left(s, e^{\frac{\left|x\right|}{s}}, s\right)}} \]
  3. Step-by-step derivation
    1. add-sqr-sqrt99.7%

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

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

    \[\leadsto \frac{\frac{1}{1 + e^{\frac{\left|x\right|}{-s}}}}{\mathsf{fma}\left(s, \color{blue}{{\left(e^{\sqrt{\frac{\left|x\right|}{s}}}\right)}^{\left(\sqrt{\frac{\left|x\right|}{s}}\right)}}, s\right)} \]
  5. Step-by-step derivation
    1. expm1-log1p-u99.7%

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

      \[\leadsto \frac{\frac{1}{1 + e^{\frac{\left|x\right|}{-s}}}}{\mathsf{fma}\left(s, {\left(e^{\sqrt{\frac{\left|x\right|}{s}}}\right)}^{\color{blue}{\left(e^{\mathsf{log1p}\left(\sqrt{\frac{\left|x\right|}{s}}\right)} - 1\right)}}, s\right)} \]
  6. Applied egg-rr99.6%

    \[\leadsto \frac{\frac{1}{1 + e^{\frac{\left|x\right|}{-s}}}}{\mathsf{fma}\left(s, {\left(e^{\sqrt{\frac{\left|x\right|}{s}}}\right)}^{\color{blue}{\left(e^{\mathsf{log1p}\left(\sqrt{\frac{\left|x\right|}{s}}\right)} - 1\right)}}, s\right)} \]
  7. Step-by-step derivation
    1. expm1-def99.7%

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

      \[\leadsto \frac{\frac{1}{1 + e^{\frac{\left|x\right|}{-s}}}}{\mathsf{fma}\left(s, {\left(e^{\sqrt{\frac{\left|x\right|}{s}}}\right)}^{\color{blue}{\left(\sqrt{\frac{\left|x\right|}{s}}\right)}}, s\right)} \]
    3. unpow199.8%

      \[\leadsto \frac{\frac{1}{1 + e^{\frac{\left|x\right|}{-s}}}}{\mathsf{fma}\left(s, {\left(e^{\sqrt{\frac{\left|x\right|}{s}}}\right)}^{\left(\sqrt{\frac{\left|\color{blue}{{x}^{1}}\right|}{s}}\right)}, s\right)} \]
    4. sqr-pow56.9%

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

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

      \[\leadsto \frac{\frac{1}{1 + e^{\frac{\left|x\right|}{-s}}}}{\mathsf{fma}\left(s, {\left(e^{\sqrt{\frac{\left|x\right|}{s}}}\right)}^{\left(\sqrt{\frac{\color{blue}{{x}^{1}}}{s}}\right)}, s\right)} \]
    7. unpow156.9%

      \[\leadsto \frac{\frac{1}{1 + e^{\frac{\left|x\right|}{-s}}}}{\mathsf{fma}\left(s, {\left(e^{\sqrt{\frac{\left|x\right|}{s}}}\right)}^{\left(\sqrt{\frac{\color{blue}{x}}{s}}\right)}, s\right)} \]
  8. Simplified56.9%

    \[\leadsto \frac{\frac{1}{1 + e^{\frac{\left|x\right|}{-s}}}}{\mathsf{fma}\left(s, {\left(e^{\sqrt{\frac{\left|x\right|}{s}}}\right)}^{\color{blue}{\left(\sqrt{\frac{x}{s}}\right)}}, s\right)} \]
  9. Final simplification56.9%

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

Alternative 3: 99.5% accurate, 2.0× speedup?

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

\\
\frac{1}{\mathsf{fma}\left(s, e^{\frac{x}{s}}, s\right) \cdot \left(1 + e^{\frac{-x}{s}}\right)}
\end{array}
Derivation
  1. Initial program 99.6%

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

    \[\leadsto \color{blue}{\frac{\frac{1}{1 + e^{\frac{\left|x\right|}{-s}}}}{\mathsf{fma}\left(s, e^{\frac{\left|x\right|}{s}}, s\right)}} \]
  3. Step-by-step derivation
    1. add-sqr-sqrt99.7%

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

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

    \[\leadsto \frac{\frac{1}{1 + e^{\frac{\left|x\right|}{-s}}}}{\mathsf{fma}\left(s, \color{blue}{{\left(e^{\sqrt{\frac{\left|x\right|}{s}}}\right)}^{\left(\sqrt{\frac{\left|x\right|}{s}}\right)}}, s\right)} \]
  5. Taylor expanded in x around 0 99.7%

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{\left|\color{blue}{{x}^{1}}\right|}{s}}, s\right) \cdot \left(1 + e^{-1 \cdot \frac{\left|x\right|}{s}}\right)} \]
    5. sqr-pow52.6%

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

      \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{\color{blue}{{x}^{\left(\frac{1}{2}\right)} \cdot {x}^{\left(\frac{1}{2}\right)}}}{s}}, s\right) \cdot \left(1 + e^{-1 \cdot \frac{\left|x\right|}{s}}\right)} \]
    7. sqr-pow63.1%

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

      \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{\color{blue}{x}}{s}}, s\right) \cdot \left(1 + e^{-1 \cdot \frac{\left|x\right|}{s}}\right)} \]
    9. neg-mul-163.1%

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

      \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{x}{s}}, s\right) \cdot \left(1 + e^{-\frac{\left|\color{blue}{{x}^{1}}\right|}{s}}\right)} \]
    11. sqr-pow52.6%

      \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{x}{s}}, s\right) \cdot \left(1 + e^{-\frac{\left|\color{blue}{{x}^{\left(\frac{1}{2}\right)} \cdot {x}^{\left(\frac{1}{2}\right)}}\right|}{s}}\right)} \]
    12. fabs-sqr52.6%

      \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{x}{s}}, s\right) \cdot \left(1 + e^{-\frac{\color{blue}{{x}^{\left(\frac{1}{2}\right)} \cdot {x}^{\left(\frac{1}{2}\right)}}}{s}}\right)} \]
    13. sqr-pow99.7%

      \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{x}{s}}, s\right) \cdot \left(1 + e^{-\frac{\color{blue}{{x}^{1}}}{s}}\right)} \]
    14. unpow199.7%

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

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

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

Alternative 4: 99.5% accurate, 2.9× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{1}{1 + e^{\frac{\left|x\right|}{-s}}}}{\mathsf{fma}\left(s, e^{\frac{\left|x\right|}{s}}, s\right)}} \]
  3. Step-by-step derivation
    1. add-sqr-sqrt99.7%

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

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

    \[\leadsto \frac{\frac{1}{1 + e^{\frac{\left|x\right|}{-s}}}}{\mathsf{fma}\left(s, \color{blue}{{\left(e^{\sqrt{\frac{\left|x\right|}{s}}}\right)}^{\left(\sqrt{\frac{\left|x\right|}{s}}\right)}}, s\right)} \]
  5. Taylor expanded in x around 0 99.7%

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{\left|\color{blue}{{x}^{1}}\right|}{s}}, s\right) \cdot \left(1 + e^{-1 \cdot \frac{\left|x\right|}{s}}\right)} \]
    5. sqr-pow52.6%

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

      \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{\color{blue}{{x}^{\left(\frac{1}{2}\right)} \cdot {x}^{\left(\frac{1}{2}\right)}}}{s}}, s\right) \cdot \left(1 + e^{-1 \cdot \frac{\left|x\right|}{s}}\right)} \]
    7. sqr-pow63.1%

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

      \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{\color{blue}{x}}{s}}, s\right) \cdot \left(1 + e^{-1 \cdot \frac{\left|x\right|}{s}}\right)} \]
    9. neg-mul-163.1%

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

      \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{x}{s}}, s\right) \cdot \left(1 + e^{-\frac{\left|\color{blue}{{x}^{1}}\right|}{s}}\right)} \]
    11. sqr-pow52.6%

      \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{x}{s}}, s\right) \cdot \left(1 + e^{-\frac{\left|\color{blue}{{x}^{\left(\frac{1}{2}\right)} \cdot {x}^{\left(\frac{1}{2}\right)}}\right|}{s}}\right)} \]
    12. fabs-sqr52.6%

      \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{x}{s}}, s\right) \cdot \left(1 + e^{-\frac{\color{blue}{{x}^{\left(\frac{1}{2}\right)} \cdot {x}^{\left(\frac{1}{2}\right)}}}{s}}\right)} \]
    13. sqr-pow99.7%

      \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{x}{s}}, s\right) \cdot \left(1 + e^{-\frac{\color{blue}{{x}^{1}}}{s}}\right)} \]
    14. unpow199.7%

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

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

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

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

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

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

Alternative 5: 99.5% accurate, 2.9× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{1}{1 + e^{\frac{\left|x\right|}{-s}}}}{\mathsf{fma}\left(s, e^{\frac{\left|x\right|}{s}}, s\right)}} \]
  3. Step-by-step derivation
    1. add-sqr-sqrt99.7%

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

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

    \[\leadsto \frac{\frac{1}{1 + e^{\frac{\left|x\right|}{-s}}}}{\mathsf{fma}\left(s, \color{blue}{{\left(e^{\sqrt{\frac{\left|x\right|}{s}}}\right)}^{\left(\sqrt{\frac{\left|x\right|}{s}}\right)}}, s\right)} \]
  5. Taylor expanded in x around 0 99.7%

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{\left|\color{blue}{{x}^{1}}\right|}{s}}, s\right) \cdot \left(1 + e^{-1 \cdot \frac{\left|x\right|}{s}}\right)} \]
    5. sqr-pow52.6%

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

      \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{\color{blue}{{x}^{\left(\frac{1}{2}\right)} \cdot {x}^{\left(\frac{1}{2}\right)}}}{s}}, s\right) \cdot \left(1 + e^{-1 \cdot \frac{\left|x\right|}{s}}\right)} \]
    7. sqr-pow63.1%

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

      \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{\color{blue}{x}}{s}}, s\right) \cdot \left(1 + e^{-1 \cdot \frac{\left|x\right|}{s}}\right)} \]
    9. neg-mul-163.1%

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

      \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{x}{s}}, s\right) \cdot \left(1 + e^{-\frac{\left|\color{blue}{{x}^{1}}\right|}{s}}\right)} \]
    11. sqr-pow52.6%

      \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{x}{s}}, s\right) \cdot \left(1 + e^{-\frac{\left|\color{blue}{{x}^{\left(\frac{1}{2}\right)} \cdot {x}^{\left(\frac{1}{2}\right)}}\right|}{s}}\right)} \]
    12. fabs-sqr52.6%

      \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{x}{s}}, s\right) \cdot \left(1 + e^{-\frac{\color{blue}{{x}^{\left(\frac{1}{2}\right)} \cdot {x}^{\left(\frac{1}{2}\right)}}}{s}}\right)} \]
    13. sqr-pow99.7%

      \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{x}{s}}, s\right) \cdot \left(1 + e^{-\frac{\color{blue}{{x}^{1}}}{s}}\right)} \]
    14. unpow199.7%

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

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

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

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

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

Alternative 6: 95.0% accurate, 2.9× speedup?

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

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

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

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

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

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

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

Alternative 7: 59.1% accurate, 3.0× speedup?

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

\\
\frac{1}{\mathsf{fma}\left(s, e^{\frac{x}{s}}, s\right) \cdot 2}
\end{array}
Derivation
  1. Initial program 99.6%

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

    \[\leadsto \color{blue}{\frac{\frac{1}{1 + e^{\frac{\left|x\right|}{-s}}}}{\mathsf{fma}\left(s, e^{\frac{\left|x\right|}{s}}, s\right)}} \]
  3. Step-by-step derivation
    1. add-sqr-sqrt99.7%

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

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

    \[\leadsto \frac{\frac{1}{1 + e^{\frac{\left|x\right|}{-s}}}}{\mathsf{fma}\left(s, \color{blue}{{\left(e^{\sqrt{\frac{\left|x\right|}{s}}}\right)}^{\left(\sqrt{\frac{\left|x\right|}{s}}\right)}}, s\right)} \]
  5. Taylor expanded in x around 0 99.7%

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{\left|\color{blue}{{x}^{1}}\right|}{s}}, s\right) \cdot \left(1 + e^{-1 \cdot \frac{\left|x\right|}{s}}\right)} \]
    5. sqr-pow52.6%

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

      \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{\color{blue}{{x}^{\left(\frac{1}{2}\right)} \cdot {x}^{\left(\frac{1}{2}\right)}}}{s}}, s\right) \cdot \left(1 + e^{-1 \cdot \frac{\left|x\right|}{s}}\right)} \]
    7. sqr-pow63.1%

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

      \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{\color{blue}{x}}{s}}, s\right) \cdot \left(1 + e^{-1 \cdot \frac{\left|x\right|}{s}}\right)} \]
    9. neg-mul-163.1%

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

      \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{x}{s}}, s\right) \cdot \left(1 + e^{-\frac{\left|\color{blue}{{x}^{1}}\right|}{s}}\right)} \]
    11. sqr-pow52.6%

      \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{x}{s}}, s\right) \cdot \left(1 + e^{-\frac{\left|\color{blue}{{x}^{\left(\frac{1}{2}\right)} \cdot {x}^{\left(\frac{1}{2}\right)}}\right|}{s}}\right)} \]
    12. fabs-sqr52.6%

      \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{x}{s}}, s\right) \cdot \left(1 + e^{-\frac{\color{blue}{{x}^{\left(\frac{1}{2}\right)} \cdot {x}^{\left(\frac{1}{2}\right)}}}{s}}\right)} \]
    13. sqr-pow99.7%

      \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{x}{s}}, s\right) \cdot \left(1 + e^{-\frac{\color{blue}{{x}^{1}}}{s}}\right)} \]
    14. unpow199.7%

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

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

    \[\leadsto \frac{1}{\mathsf{fma}\left(s, e^{\frac{x}{s}}, s\right) \cdot \left(1 + \color{blue}{1}\right)} \]
  9. Final simplification60.1%

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

Alternative 8: 94.6% 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.6%

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

    \[\leadsto \frac{e^{\frac{-\left|x\right|}{s}}}{\color{blue}{4 \cdot s}} \]
  3. Step-by-step derivation
    1. *-commutative94.3%

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

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

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

Alternative 9: 85.4% accurate, 4.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \frac{x}{s}\\ \mathbf{if}\;x \leq 0.012000000104308128:\\ \;\;\;\;\frac{1}{\left(1 + \left(1 + \left(0.5 \cdot \left(\frac{x}{s} \cdot \frac{x}{s}\right) - \frac{x}{s}\right)\right)\right) \cdot \left(s + s \cdot e^{\frac{x}{s}}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt[3]{t_0 \cdot \left(t_0 \cdot t_0\right)} + s \cdot 4}\\ \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (let* ((t_0 (* x (/ x s))))
   (if (<= x 0.012000000104308128)
     (/
      1.0
      (*
       (+ 1.0 (+ 1.0 (- (* 0.5 (* (/ x s) (/ x s))) (/ x s))))
       (+ s (* s (exp (/ x s))))))
     (/ 1.0 (+ (cbrt (* t_0 (* t_0 t_0))) (* s 4.0))))))
float code(float x, float s) {
	float t_0 = x * (x / s);
	float tmp;
	if (x <= 0.012000000104308128f) {
		tmp = 1.0f / ((1.0f + (1.0f + ((0.5f * ((x / s) * (x / s))) - (x / s)))) * (s + (s * expf((x / s)))));
	} else {
		tmp = 1.0f / (cbrtf((t_0 * (t_0 * t_0))) + (s * 4.0f));
	}
	return tmp;
}
function code(x, s)
	t_0 = Float32(x * Float32(x / s))
	tmp = Float32(0.0)
	if (x <= Float32(0.012000000104308128))
		tmp = Float32(Float32(1.0) / Float32(Float32(Float32(1.0) + Float32(Float32(1.0) + Float32(Float32(Float32(0.5) * Float32(Float32(x / s) * Float32(x / s))) - Float32(x / s)))) * Float32(s + Float32(s * exp(Float32(x / s))))));
	else
		tmp = Float32(Float32(1.0) / Float32(cbrt(Float32(t_0 * Float32(t_0 * t_0))) + Float32(s * Float32(4.0))));
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \frac{x}{s}\\
\mathbf{if}\;x \leq 0.012000000104308128:\\
\;\;\;\;\frac{1}{\left(1 + \left(1 + \left(0.5 \cdot \left(\frac{x}{s} \cdot \frac{x}{s}\right) - \frac{x}{s}\right)\right)\right) \cdot \left(s + s \cdot e^{\frac{x}{s}}\right)}\\

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


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

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0120000001 < 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. Simplified100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{x}{\frac{s}{x}} + \left(s \cdot 4 + 0\right)}} \]
    7. Step-by-step derivation
      1. add-cbrt-cube100.0%

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

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

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

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

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

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

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

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

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

Alternative 10: 79.3% accurate, 5.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \frac{x}{s}\\ \frac{1}{\sqrt[3]{t_0 \cdot \left(t_0 \cdot t_0\right)} + s \cdot 4} \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (let* ((t_0 (* x (/ x s)))) (/ 1.0 (+ (cbrt (* t_0 (* t_0 t_0))) (* s 4.0)))))
float code(float x, float s) {
	float t_0 = x * (x / s);
	return 1.0f / (cbrtf((t_0 * (t_0 * t_0))) + (s * 4.0f));
}
function code(x, s)
	t_0 = Float32(x * Float32(x / s))
	return Float32(Float32(1.0) / Float32(cbrt(Float32(t_0 * Float32(t_0 * t_0))) + Float32(s * Float32(4.0))))
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \frac{x}{s}\\
\frac{1}{\sqrt[3]{t_0 \cdot \left(t_0 \cdot t_0\right)} + s \cdot 4}
\end{array}
\end{array}
Derivation
  1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{1}{\color{blue}{\frac{x}{\frac{s}{x}} + \left(s \cdot 4 + 0\right)}} \]
  7. Step-by-step derivation
    1. add-cbrt-cube80.3%

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

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

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

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

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

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

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

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

    \[\leadsto \frac{1}{\sqrt[3]{\left(x \cdot \frac{x}{s}\right) \cdot \left(\left(x \cdot \frac{x}{s}\right) \cdot \left(x \cdot \frac{x}{s}\right)\right)} + s \cdot 4} \]

Alternative 11: 78.5% accurate, 5.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{s}{x \cdot x}\\ \mathbf{if}\;x \leq 0.003000000026077032:\\ \;\;\;\;\frac{1}{\left(1 + \left(1 + \left(0.5 \cdot \left(\frac{x}{s} \cdot \frac{x}{s}\right) - \frac{x}{s}\right)\right)\right) \cdot \left(s + \left(x + s\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{t_0 \cdot \left(t_0 \cdot t_0\right)}\\ \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (let* ((t_0 (/ s (* x x))))
   (if (<= x 0.003000000026077032)
     (/
      1.0
      (*
       (+ 1.0 (+ 1.0 (- (* 0.5 (* (/ x s) (/ x s))) (/ x s))))
       (+ s (+ x s))))
     (cbrt (* t_0 (* t_0 t_0))))))
float code(float x, float s) {
	float t_0 = s / (x * x);
	float tmp;
	if (x <= 0.003000000026077032f) {
		tmp = 1.0f / ((1.0f + (1.0f + ((0.5f * ((x / s) * (x / s))) - (x / s)))) * (s + (x + s)));
	} else {
		tmp = cbrtf((t_0 * (t_0 * t_0)));
	}
	return tmp;
}
function code(x, s)
	t_0 = Float32(s / Float32(x * x))
	tmp = Float32(0.0)
	if (x <= Float32(0.003000000026077032))
		tmp = Float32(Float32(1.0) / Float32(Float32(Float32(1.0) + Float32(Float32(1.0) + Float32(Float32(Float32(0.5) * Float32(Float32(x / s) * Float32(x / s))) - Float32(x / s)))) * Float32(s + Float32(x + s))));
	else
		tmp = cbrt(Float32(t_0 * Float32(t_0 * t_0)));
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{s}{x \cdot x}\\
\mathbf{if}\;x \leq 0.003000000026077032:\\
\;\;\;\;\frac{1}{\left(1 + \left(1 + \left(0.5 \cdot \left(\frac{x}{s} \cdot \frac{x}{s}\right) - \frac{x}{s}\right)\right)\right) \cdot \left(s + \left(x + s\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{t_0 \cdot \left(t_0 \cdot t_0\right)}\\


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

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\left(1 + \left(1 + \left(0.5 \cdot \left(\frac{x}{s} \cdot \frac{x}{s}\right) - \frac{x}{s}\right)\right)\right) \cdot \left(s + \color{blue}{\left(s + \left|x\right|\right)}\right)} \]
    8. Step-by-step derivation
      1. +-commutative71.7%

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

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

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

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

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

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

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

    if 0.00300000003 < 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. Simplified100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{s}{\color{blue}{x \cdot x}} \]
    9. Simplified70.5%

      \[\leadsto \color{blue}{\frac{s}{x \cdot x}} \]
    10. Step-by-step derivation
      1. add-cbrt-cube96.2%

        \[\leadsto \color{blue}{\sqrt[3]{\left(\frac{s}{x \cdot x} \cdot \frac{s}{x \cdot x}\right) \cdot \frac{s}{x \cdot x}}} \]
    11. Applied egg-rr96.2%

      \[\leadsto \color{blue}{\sqrt[3]{\left(\frac{s}{x \cdot x} \cdot \frac{s}{x \cdot x}\right) \cdot \frac{s}{x \cdot x}}} \]
    12. Step-by-step derivation
      1. associate-*l*96.2%

        \[\leadsto \sqrt[3]{\color{blue}{\frac{s}{x \cdot x} \cdot \left(\frac{s}{x \cdot x} \cdot \frac{s}{x \cdot x}\right)}} \]
    13. Simplified96.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.003000000026077032:\\ \;\;\;\;\frac{1}{\left(1 + \left(1 + \left(0.5 \cdot \left(\frac{x}{s} \cdot \frac{x}{s}\right) - \frac{x}{s}\right)\right)\right) \cdot \left(s + \left(x + s\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{\frac{s}{x \cdot x} \cdot \left(\frac{s}{x \cdot x} \cdot \frac{s}{x \cdot x}\right)}\\ \end{array} \]

Alternative 12: 77.5% accurate, 5.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 2000000:\\ \;\;\;\;\frac{1}{\left(1 + \left(1 + \left(0.5 \cdot \left(\frac{x}{s} \cdot \frac{x}{s}\right) - \frac{x}{s}\right)\right)\right) \cdot \left(s + \left(x + s\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{s}{\sqrt[3]{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}}\\ \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (if (<= x 2000000.0)
   (/
    1.0
    (* (+ 1.0 (+ 1.0 (- (* 0.5 (* (/ x s) (/ x s))) (/ x s)))) (+ s (+ x s))))
   (/ s (cbrt (* (* x x) (* (* x x) (* x x)))))))
float code(float x, float s) {
	float tmp;
	if (x <= 2000000.0f) {
		tmp = 1.0f / ((1.0f + (1.0f + ((0.5f * ((x / s) * (x / s))) - (x / s)))) * (s + (x + s)));
	} else {
		tmp = s / cbrtf(((x * x) * ((x * x) * (x * x))));
	}
	return tmp;
}
function code(x, s)
	tmp = Float32(0.0)
	if (x <= Float32(2000000.0))
		tmp = Float32(Float32(1.0) / Float32(Float32(Float32(1.0) + Float32(Float32(1.0) + Float32(Float32(Float32(0.5) * Float32(Float32(x / s) * Float32(x / s))) - Float32(x / s)))) * Float32(s + Float32(x + s))));
	else
		tmp = Float32(s / cbrt(Float32(Float32(x * x) * Float32(Float32(x * x) * Float32(x * x)))));
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 2000000:\\
\;\;\;\;\frac{1}{\left(1 + \left(1 + \left(0.5 \cdot \left(\frac{x}{s} \cdot \frac{x}{s}\right) - \frac{x}{s}\right)\right)\right) \cdot \left(s + \left(x + s\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{s}{\sqrt[3]{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}}\\


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

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\left(1 + \left(1 + \left(0.5 \cdot \left(\frac{x}{s} \cdot \frac{x}{s}\right) - \frac{x}{s}\right)\right)\right) \cdot \left(s + \color{blue}{\left(s + \left|x\right|\right)}\right)} \]
    8. Step-by-step derivation
      1. +-commutative70.8%

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

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

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

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

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

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

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

    if 2e6 < 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. Simplified100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{s}{\color{blue}{x \cdot x}} \]
    9. Simplified80.4%

      \[\leadsto \color{blue}{\frac{s}{x \cdot x}} \]
    10. Step-by-step derivation
      1. add-cbrt-cube100.0%

        \[\leadsto \frac{s}{\color{blue}{\sqrt[3]{\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right)}}} \]
    11. Applied egg-rr100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2000000:\\ \;\;\;\;\frac{1}{\left(1 + \left(1 + \left(0.5 \cdot \left(\frac{x}{s} \cdot \frac{x}{s}\right) - \frac{x}{s}\right)\right)\right) \cdot \left(s + \left(x + s\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{s}{\sqrt[3]{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}}\\ \end{array} \]

Alternative 13: 75.5% accurate, 22.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 50000000188416:\\
\;\;\;\;\frac{1}{\left(1 + \left(1 + \left(0.5 \cdot \left(\frac{x}{s} \cdot \frac{x}{s}\right) - \frac{x}{s}\right)\right)\right) \cdot \left(s + \left(x + s\right)\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 5.00000002e13

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\left(1 + \left(1 + \left(0.5 \cdot \left(\frac{x}{s} \cdot \frac{x}{s}\right) - \frac{x}{s}\right)\right)\right) \cdot \left(s + \color{blue}{\left(s + \left|x\right|\right)}\right)} \]
    8. Step-by-step derivation
      1. +-commutative71.4%

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

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

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

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

        \[\leadsto \frac{1}{\left(1 + \left(1 + \left(0.5 \cdot \left(\frac{x}{s} \cdot \frac{x}{s}\right) - \frac{x}{s}\right)\right)\right) \cdot \left(s + \left(\color{blue}{{x}^{1}} + s\right)\right)} \]
      6. unpow172.0%

        \[\leadsto \frac{1}{\left(1 + \left(1 + \left(0.5 \cdot \left(\frac{x}{s} \cdot \frac{x}{s}\right) - \frac{x}{s}\right)\right)\right) \cdot \left(s + \left(\color{blue}{x} + s\right)\right)} \]
    9. Simplified72.0%

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

    if 5.00000002e13 < 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. Simplified100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{x}{\frac{s}{x}} + \left(s \cdot 4 + 0\right)}} \]
    7. Step-by-step derivation
      1. associate-/r/100.0%

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

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

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

Alternative 14: 72.5% accurate, 24.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 10000000000:\\
\;\;\;\;\frac{1}{\left(1 + \left(1 + \left(0.5 \cdot \left(\frac{x}{s} \cdot \frac{x}{s}\right) - \frac{x}{s}\right)\right)\right) \cdot \left(s + s\right)}\\

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


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

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1e10 < 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. Simplified100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{x}{\frac{s}{x}} + \left(s \cdot 4 + 0\right)}} \]
    7. Step-by-step derivation
      1. associate-/r/94.3%

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

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

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

Alternative 15: 65.2% accurate, 56.4× speedup?

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

\\
\frac{1}{x \cdot \frac{x}{s} + s \cdot 4}
\end{array}
Derivation
  1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{1}{\color{blue}{\frac{x}{\frac{s}{x}} + \left(s \cdot 4 + 0\right)}} \]
  7. Step-by-step derivation
    1. associate-/r/65.6%

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

    \[\leadsto \frac{1}{\color{blue}{\frac{x}{s} \cdot x} + \left(s \cdot 4 + 0\right)} \]
  9. Final simplification65.6%

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

Alternative 16: 43.6% accurate, 67.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.006000000052154064:\\ \;\;\;\;\frac{0.25}{s}\\ \mathbf{else}:\\ \;\;\;\;s \cdot \frac{1}{x \cdot x}\\ \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (if (<= x 0.006000000052154064) (/ 0.25 s) (* s (/ 1.0 (* x x)))))
float code(float x, float s) {
	float tmp;
	if (x <= 0.006000000052154064f) {
		tmp = 0.25f / s;
	} else {
		tmp = s * (1.0f / (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 <= 0.006000000052154064e0) then
        tmp = 0.25e0 / s
    else
        tmp = s * (1.0e0 / (x * x))
    end if
    code = tmp
end function
function code(x, s)
	tmp = Float32(0.0)
	if (x <= Float32(0.006000000052154064))
		tmp = Float32(Float32(0.25) / s);
	else
		tmp = Float32(s * Float32(Float32(1.0) / Float32(x * x)));
	end
	return tmp
end
function tmp_2 = code(x, s)
	tmp = single(0.0);
	if (x <= single(0.006000000052154064))
		tmp = single(0.25) / s;
	else
		tmp = s * (single(1.0) / (x * x));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.006000000052154064:\\
\;\;\;\;\frac{0.25}{s}\\

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


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

    1. Initial program 99.5%

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

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

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

    if 0.00600000005 < 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. Simplified100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{s}{\color{blue}{x \cdot x}} \]
    9. Simplified71.3%

      \[\leadsto \color{blue}{\frac{s}{x \cdot x}} \]
    10. Step-by-step derivation
      1. div-inv71.3%

        \[\leadsto \color{blue}{s \cdot \frac{1}{x \cdot x}} \]
    11. Applied egg-rr71.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.006000000052154064:\\ \;\;\;\;\frac{0.25}{s}\\ \mathbf{else}:\\ \;\;\;\;s \cdot \frac{1}{x \cdot x}\\ \end{array} \]

Alternative 17: 43.6% accurate, 87.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.006000000052154064:\\ \;\;\;\;\frac{0.25}{s}\\ \mathbf{else}:\\ \;\;\;\;\frac{s}{x \cdot x}\\ \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (if (<= x 0.006000000052154064) (/ 0.25 s) (/ s (* x x))))
float code(float x, float s) {
	float tmp;
	if (x <= 0.006000000052154064f) {
		tmp = 0.25f / s;
	} else {
		tmp = 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 <= 0.006000000052154064e0) then
        tmp = 0.25e0 / s
    else
        tmp = s / (x * x)
    end if
    code = tmp
end function
function code(x, s)
	tmp = Float32(0.0)
	if (x <= Float32(0.006000000052154064))
		tmp = Float32(Float32(0.25) / s);
	else
		tmp = Float32(s / Float32(x * x));
	end
	return tmp
end
function tmp_2 = code(x, s)
	tmp = single(0.0);
	if (x <= single(0.006000000052154064))
		tmp = single(0.25) / s;
	else
		tmp = s / (x * x);
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.006000000052154064:\\
\;\;\;\;\frac{0.25}{s}\\

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


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

    1. Initial program 99.5%

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

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

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

    if 0.00600000005 < 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. Simplified100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{s}{\color{blue}{x \cdot x}} \]
    9. Simplified71.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.006000000052154064:\\ \;\;\;\;\frac{0.25}{s}\\ \mathbf{else}:\\ \;\;\;\;\frac{s}{x \cdot x}\\ \end{array} \]

Alternative 18: 25.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.6%

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

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

    \[\leadsto \color{blue}{\frac{0.25}{s}} \]
  4. Final simplification26.1%

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

Reproduce

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