Logistic distribution

Percentage Accurate: 99.5% → 99.6%
Time: 11.6s
Alternatives: 14
Speedup: 1.0×

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

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

\\
\begin{array}{l}
t_0 := e^{\frac{\left|x\right|}{-s}}\\
\frac{t_0}{\left(t_0 + 1\right) \cdot \left(s + \frac{s}{e^{\frac{\left|x\right|}{s}}}\right)}
\end{array}
\end{array}
Derivation
  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}}}{\left(1 + e^{\frac{\left|x\right|}{-s}}\right) \cdot \left(s + \frac{s}{e^{\frac{\left|x\right|}{s}}}\right)}} \]
  3. Final simplification99.5%

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

Alternative 2: 62.3% accurate, 1.5× speedup?

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

\\
\frac{1}{e^{\frac{\left|x\right|}{-s}} + 1} \cdot \frac{1}{\mathsf{fma}\left(s, e^{\frac{x}{s}}, s\right)}
\end{array}
Derivation
  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{\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. div-inv99.5%

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

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

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

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

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

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

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

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

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

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

Alternative 3: 62.3% accurate, 1.5× speedup?

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

\\
\frac{\frac{1}{\mathsf{fma}\left(s, e^{\frac{x}{s}}, s\right)}}{1 + e^{\frac{-\left|x\right|}{s}}}
\end{array}
Derivation
  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{\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. div-inv99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 62.3% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \frac{1}{s \cdot \left(\left(1 + e^{\frac{-\left|x\right|}{s}}\right) \cdot \left(1 + e^{\frac{x}{s}}\right)\right)} \end{array} \]
(FPCore (x s)
 :precision binary32
 (/ 1.0 (* s (* (+ 1.0 (exp (/ (- (fabs x)) s))) (+ 1.0 (exp (/ x s)))))))
float code(float x, float s) {
	return 1.0f / (s * ((1.0f + expf((-fabsf(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((-abs(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(-abs(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((-abs(x) / s))) * (single(1.0) + exp((x / s)))));
end
\begin{array}{l}

\\
\frac{1}{s \cdot \left(\left(1 + e^{\frac{-\left|x\right|}{s}}\right) \cdot \left(1 + e^{\frac{x}{s}}\right)\right)}
\end{array}
Derivation
  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{\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 s around 0 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 62.3% accurate, 2.0× speedup?

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

\\
\frac{\frac{1}{s \cdot \left(1 + e^{\frac{x}{s}}\right)}}{1 + e^{\frac{-\left|x\right|}{s}}}
\end{array}
Derivation
  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{\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. div-inv99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 81.6% accurate, 5.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 9.999999998199587 \cdot 10^{-24}:\\
\;\;\;\;\frac{1}{\frac{x}{\frac{s}{x}} + s \cdot 4}\\

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


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

    1. Initial program 97.7%

      \[\frac{e^{\frac{-\left|x\right|}{s}}}{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)} \]
    2. Simplified97.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 s around 0 97.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x}{s} \cdot 1 + s \cdot 4}} \]
    9. Step-by-step derivation
      1. *-un-lft-identity76.9%

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

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

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

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

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

    1. Initial program 99.9%

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

      \[\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 s around 0 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left|x\right| \leq 9.999999998199587 \cdot 10^{-24}:\\ \;\;\;\;\frac{1}{\frac{x}{\frac{s}{x}} + s \cdot 4}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{s \cdot \left(\frac{x \cdot x}{s \cdot s} + \left(4 + \frac{0}{s}\right)\right)}\\ \end{array} \]

Alternative 7: 60.3% accurate, 5.7× speedup?

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

\\
\frac{0.5}{s + s \cdot e^{\frac{x}{s}}}
\end{array}
Derivation
  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{\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 s around inf 95.3%

    \[\leadsto \frac{\color{blue}{0.5}}{\mathsf{fma}\left(s, e^{\frac{\left|x\right|}{s}}, s\right)} \]
  4. Step-by-step derivation
    1. expm1-log1p-u94.3%

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

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

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{0.5}{\mathsf{fma}\left(s, e^{\frac{x}{s}}, s\right)}\right)} - 1} \]
  6. Step-by-step derivation
    1. expm1-def57.5%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{0.5}{\mathsf{fma}\left(s, e^{\frac{x}{s}}, s\right)}\right)\right)} \]
    2. expm1-log1p58.6%

      \[\leadsto \color{blue}{\frac{0.5}{\mathsf{fma}\left(s, e^{\frac{x}{s}}, s\right)}} \]
  7. Simplified58.6%

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

      \[\leadsto \frac{0.5}{\color{blue}{s \cdot e^{\frac{x}{s}} + s}} \]
  9. Applied egg-rr58.6%

    \[\leadsto \frac{0.5}{\color{blue}{s \cdot e^{\frac{x}{s}} + s}} \]
  10. Final simplification58.6%

    \[\leadsto \frac{0.5}{s + s \cdot e^{\frac{x}{s}}} \]

Alternative 8: 65.8% accurate, 56.4× speedup?

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

\\
\frac{1}{s \cdot 4 + x \cdot \frac{x}{s}}
\end{array}
Derivation
  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{\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 s around 0 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x}{s} \cdot 1 + s \cdot 4}} \]
  9. Step-by-step derivation
    1. *-un-lft-identity63.4%

      \[\leadsto \color{blue}{1 \cdot \frac{1}{\frac{x \cdot x}{s} \cdot 1 + s \cdot 4}} \]
    2. *-rgt-identity63.4%

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

      \[\leadsto 1 \cdot \frac{1}{\color{blue}{\frac{x}{\frac{s}{x}}} + s \cdot 4} \]
  10. Applied egg-rr64.2%

    \[\leadsto \color{blue}{1 \cdot \frac{1}{\frac{x}{\frac{s}{x}} + s \cdot 4}} \]
  11. Step-by-step derivation
    1. *-lft-identity64.2%

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

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

    \[\leadsto \color{blue}{\frac{1}{\frac{x}{s} \cdot x + s \cdot 4}} \]
  13. Final simplification64.2%

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

Alternative 9: 65.8% accurate, 56.4× speedup?

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

\\
\frac{1}{\frac{x}{\frac{s}{x}} + s \cdot 4}
\end{array}
Derivation
  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{\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 s around 0 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x}{s} \cdot 1 + s \cdot 4}} \]
  9. Step-by-step derivation
    1. *-un-lft-identity63.4%

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

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

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

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

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

Alternative 10: 45.1% accurate, 67.9× speedup?

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

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


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

    1. Initial program 99.3%

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

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

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

    if 3.50000009e-5 < 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 s around 0 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x}{s} \cdot 1 + s \cdot 4}} \]
    9. Taylor expanded in x around inf 72.4%

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

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

      \[\leadsto \color{blue}{\frac{s}{x \cdot x}} \]
    12. Step-by-step derivation
      1. associate-/r*72.4%

        \[\leadsto \color{blue}{\frac{\frac{s}{x}}{x}} \]
      2. div-inv72.4%

        \[\leadsto \frac{\color{blue}{s \cdot \frac{1}{x}}}{x} \]
      3. *-un-lft-identity72.4%

        \[\leadsto \frac{s \cdot \frac{1}{x}}{\color{blue}{1 \cdot x}} \]
      4. times-frac72.4%

        \[\leadsto \color{blue}{\frac{s}{1} \cdot \frac{\frac{1}{x}}{x}} \]
      5. /-rgt-identity72.4%

        \[\leadsto \color{blue}{s} \cdot \frac{\frac{1}{x}}{x} \]
    13. Applied egg-rr72.4%

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

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

Alternative 11: 45.8% accurate, 67.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.5000000934815034 \cdot 10^{-5}:\\
\;\;\;\;\frac{0.25}{s}\\

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


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

    1. Initial program 99.3%

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

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

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

    if 3.50000009e-5 < 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 s around 0 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x}{s} \cdot 1 + s \cdot 4}} \]
    9. Taylor expanded in x around inf 72.4%

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x}{s}}} \]
      2. un-div-inv73.3%

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot x\right) \cdot \frac{1}{s}}} \]
      3. *-rgt-identity73.3%

        \[\leadsto \frac{1}{\color{blue}{\left(\left(x \cdot x\right) \cdot \frac{1}{s}\right) \cdot 1}} \]
      4. inv-pow73.3%

        \[\leadsto \color{blue}{{\left(\left(\left(x \cdot x\right) \cdot \frac{1}{s}\right) \cdot 1\right)}^{-1}} \]
      5. *-rgt-identity73.3%

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

        \[\leadsto {\color{blue}{\left(x \cdot \left(x \cdot \frac{1}{s}\right)\right)}}^{-1} \]
      7. div-inv73.3%

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

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

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

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

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

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

Alternative 12: 45.2% accurate, 87.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 3.5000000934815034 \cdot 10^{-5}:\\ \;\;\;\;\frac{0.25}{s}\\ \mathbf{else}:\\ \;\;\;\;\frac{s}{x \cdot x}\\ \end{array} \end{array} \]
(FPCore (x s)
 :precision binary32
 (if (<= x 3.5000000934815034e-5) (/ 0.25 s) (/ s (* x x))))
float code(float x, float s) {
	float tmp;
	if (x <= 3.5000000934815034e-5f) {
		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 <= 3.5000000934815034e-5) 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(3.5000000934815034e-5))
		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(3.5000000934815034e-5))
		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 3.5000000934815034 \cdot 10^{-5}:\\
\;\;\;\;\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 < 3.50000009e-5

    1. Initial program 99.3%

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

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

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

    if 3.50000009e-5 < 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 s around 0 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x}{s} \cdot 1 + s \cdot 4}} \]
    9. Taylor expanded in x around inf 72.4%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 3.5000000934815034 \cdot 10^{-5}:\\ \;\;\;\;\frac{0.25}{s}\\ \mathbf{else}:\\ \;\;\;\;\frac{s}{x \cdot x}\\ \end{array} \]

Alternative 13: 45.1% accurate, 87.0× speedup?

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

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


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

    1. Initial program 99.3%

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

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

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

    if 3.50000009e-5 < 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 s around 0 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x}{s} \cdot 1 + s \cdot 4}} \]
    9. Taylor expanded in x around inf 72.4%

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

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

        \[\leadsto \color{blue}{\frac{\frac{s}{x}}{x}} \]
    11. Simplified72.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 3.5000000934815034 \cdot 10^{-5}:\\ \;\;\;\;\frac{0.25}{s}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{s}{x}}{x}\\ \end{array} \]

Alternative 14: 26.9% 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.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}}}{\left(1 + e^{\frac{\left|x\right|}{-s}}\right) \cdot \left(s + \frac{s}{e^{\frac{\left|x\right|}{s}}}\right)}} \]
  3. Taylor expanded in s around inf 23.9%

    \[\leadsto \color{blue}{\frac{0.25}{s}} \]
  4. Final simplification23.9%

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

Reproduce

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