Logistic function

Percentage Accurate: 99.8% → 99.8%
Time: 10.2s
Alternatives: 17
Speedup: 1.0×

Specification

?
\[0 \leq s \land s \leq 1.0651631\]
\[\begin{array}{l} \\ \frac{1}{1 + e^{\frac{-x}{s}}} \end{array} \]
(FPCore (x s) :precision binary32 (/ 1.0 (+ 1.0 (exp (/ (- x) s)))))
float code(float x, float s) {
	return 1.0f / (1.0f + 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)))
end function
function code(x, s)
	return Float32(Float32(1.0) / Float32(Float32(1.0) + exp(Float32(Float32(-x) / s))))
end
function tmp = code(x, s)
	tmp = single(1.0) / (single(1.0) + exp((-x / s)));
end
\begin{array}{l}

\\
\frac{1}{1 + e^{\frac{-x}{s}}}
\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 17 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.8% accurate, 1.0× speedup?

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

\\
\frac{1}{1 + e^{\frac{-x}{s}}}
\end{array}

Alternative 1: 99.8% accurate, 0.5× speedup?

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

\\
\frac{1}{1 + \frac{e^{\frac{x}{s} \cdot -0.3333333333333333}}{e^{\frac{0.6666666666666666}{\frac{s}{x}}}}}
\end{array}
Derivation
  1. Initial program 99.8%

    \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. *-lft-identityN/A

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

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \left({\left(e^{1}\right)}^{\color{blue}{\left(\frac{\mathsf{neg}\left(x\right)}{s}\right)}}\right)\right)\right) \]
    3. pow-lowering-pow.f32N/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{pow.f32}\left(\left(e^{1}\right), \color{blue}{\left(\frac{\mathsf{neg}\left(x\right)}{s}\right)}\right)\right)\right) \]
    4. exp-1-eN/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{pow.f32}\left(\mathsf{E}\left(\right), \left(\frac{\color{blue}{\mathsf{neg}\left(x\right)}}{s}\right)\right)\right)\right) \]
    5. E-lowering-E.f32N/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \left(\frac{\color{blue}{\mathsf{neg}\left(x\right)}}{s}\right)\right)\right)\right) \]
    6. distribute-frac-negN/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \left(\mathsf{neg}\left(\frac{x}{s}\right)\right)\right)\right)\right) \]
    7. neg-sub0N/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \left(0 - \color{blue}{\frac{x}{s}}\right)\right)\right)\right) \]
    8. --lowering--.f32N/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{\_.f32}\left(0, \color{blue}{\left(\frac{x}{s}\right)}\right)\right)\right)\right) \]
    9. /-lowering-/.f3299.7%

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(x, \color{blue}{s}\right)\right)\right)\right)\right) \]
  4. Applied egg-rr99.7%

    \[\leadsto \frac{1}{1 + \color{blue}{{e}^{\left(0 - \frac{x}{s}\right)}}} \]
  5. Step-by-step derivation
    1. add-cube-cbrtN/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \left({\left(\left(\sqrt[3]{\mathsf{E}\left(\right)} \cdot \sqrt[3]{\mathsf{E}\left(\right)}\right) \cdot \sqrt[3]{\mathsf{E}\left(\right)}\right)}^{\left(\color{blue}{0} - \frac{x}{s}\right)}\right)\right)\right) \]
    2. unpow-prod-downN/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \left({\left(\sqrt[3]{\mathsf{E}\left(\right)} \cdot \sqrt[3]{\mathsf{E}\left(\right)}\right)}^{\left(0 - \frac{x}{s}\right)} \cdot \color{blue}{{\left(\sqrt[3]{\mathsf{E}\left(\right)}\right)}^{\left(0 - \frac{x}{s}\right)}}\right)\right)\right) \]
    3. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\left({\left(\sqrt[3]{\mathsf{E}\left(\right)} \cdot \sqrt[3]{\mathsf{E}\left(\right)}\right)}^{\left(0 - \frac{x}{s}\right)}\right), \color{blue}{\left({\left(\sqrt[3]{\mathsf{E}\left(\right)}\right)}^{\left(0 - \frac{x}{s}\right)}\right)}\right)\right)\right) \]
  6. Applied egg-rr99.8%

    \[\leadsto \frac{1}{1 + \color{blue}{\frac{1}{e^{0.6666666666666666 \cdot \frac{x}{s}}} \cdot \frac{1}{e^{0.3333333333333333 \cdot \frac{x}{s}}}}} \]
  7. Step-by-step derivation
    1. associate-*l/N/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \left(\frac{1 \cdot \frac{1}{e^{\frac{1}{3} \cdot \frac{x}{s}}}}{\color{blue}{e^{\frac{2}{3} \cdot \frac{x}{s}}}}\right)\right)\right) \]
    2. div-invN/A

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

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\left(\frac{1}{e^{\frac{1}{3} \cdot \frac{x}{s}}}\right), \color{blue}{\left(e^{\frac{2}{3} \cdot \frac{x}{s}}\right)}\right)\right)\right) \]
    4. rec-expN/A

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

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{exp.f32}\left(\left(\mathsf{neg}\left(\frac{1}{3} \cdot \frac{x}{s}\right)\right)\right), \left(e^{\color{blue}{\frac{2}{3} \cdot \frac{x}{s}}}\right)\right)\right)\right) \]
    6. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{exp.f32}\left(\left(\mathsf{neg}\left(\frac{x}{s} \cdot \frac{1}{3}\right)\right)\right), \left(e^{\frac{2}{3} \cdot \frac{x}{s}}\right)\right)\right)\right) \]
    7. distribute-rgt-neg-inN/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{exp.f32}\left(\left(\frac{x}{s} \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)\right), \left(e^{\color{blue}{\frac{2}{3}} \cdot \frac{x}{s}}\right)\right)\right)\right) \]
    8. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{*.f32}\left(\left(\frac{x}{s}\right), \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)\right), \left(e^{\color{blue}{\frac{2}{3}} \cdot \frac{x}{s}}\right)\right)\right)\right) \]
    9. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(x, s\right), \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)\right), \left(e^{\frac{2}{3} \cdot \frac{x}{s}}\right)\right)\right)\right) \]
    10. metadata-evalN/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(x, s\right), \frac{-1}{3}\right)\right), \left(e^{\frac{2}{3} \cdot \frac{x}{s}}\right)\right)\right)\right) \]
    11. exp-lowering-exp.f32N/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(x, s\right), \frac{-1}{3}\right)\right), \mathsf{exp.f32}\left(\left(\frac{2}{3} \cdot \frac{x}{s}\right)\right)\right)\right)\right) \]
    12. clear-numN/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(x, s\right), \frac{-1}{3}\right)\right), \mathsf{exp.f32}\left(\left(\frac{2}{3} \cdot \frac{1}{\frac{s}{x}}\right)\right)\right)\right)\right) \]
    13. un-div-invN/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(x, s\right), \frac{-1}{3}\right)\right), \mathsf{exp.f32}\left(\left(\frac{\frac{2}{3}}{\frac{s}{x}}\right)\right)\right)\right)\right) \]
    14. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(x, s\right), \frac{-1}{3}\right)\right), \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\frac{2}{3}, \left(\frac{s}{x}\right)\right)\right)\right)\right)\right) \]
    15. /-lowering-/.f3299.8%

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{*.f32}\left(\mathsf{/.f32}\left(x, s\right), \frac{-1}{3}\right)\right), \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\frac{2}{3}, \mathsf{/.f32}\left(s, x\right)\right)\right)\right)\right)\right) \]
  8. Applied egg-rr99.8%

    \[\leadsto \frac{1}{1 + \color{blue}{\frac{e^{\frac{x}{s} \cdot -0.3333333333333333}}{e^{\frac{0.6666666666666666}{\frac{s}{x}}}}}} \]
  9. Add Preprocessing

Alternative 2: 99.8% accurate, 1.0× speedup?

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

\\
\frac{1}{1 + e^{0 - \frac{x}{s}}}
\end{array}
Derivation
  1. Initial program 99.8%

    \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
  2. Add Preprocessing
  3. Final simplification99.8%

    \[\leadsto \frac{1}{1 + e^{0 - \frac{x}{s}}} \]
  4. Add Preprocessing

Alternative 3: 65.6% accurate, 3.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.9999999593223797 \cdot 10^{-31}:\\
\;\;\;\;\frac{1}{2 + x \cdot \left(x \cdot \left(\frac{x \cdot \frac{-0.16666666666666666}{s \cdot s}}{s} + \frac{0.5}{s \cdot s}\right) + \frac{-1}{s}\right)}\\

\mathbf{else}:\\
\;\;\;\;0.5\\


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

    1. Initial program 99.6%

      \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \mathsf{/.f32}\left(1, \color{blue}{\left(2 + x \cdot \left(x \cdot \left(\frac{-1}{6} \cdot \frac{x}{{s}^{3}} + \frac{1}{2} \cdot \frac{1}{{s}^{2}}\right) - \frac{1}{s}\right)\right)}\right) \]
    4. Simplified86.8%

      \[\leadsto \frac{1}{\color{blue}{2 + x \cdot \left(x \cdot \left(\frac{x \cdot -0.16666666666666666}{s \cdot \left(s \cdot s\right)} + \frac{0.5}{s \cdot s}\right) + \frac{-1}{s}\right)}} \]
    5. Step-by-step derivation
      1. times-fracN/A

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\left(\frac{x}{s} \cdot \frac{\frac{-1}{6}}{s \cdot s}\right), \mathsf{/.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(s, s\right)\right)\right)\right), \mathsf{/.f32}\left(-1, s\right)\right)\right)\right)\right) \]
      2. associate-*l/N/A

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\left(\frac{x \cdot \frac{\frac{-1}{6}}{s \cdot s}}{s}\right), \mathsf{/.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(s, s\right)\right)\right)\right), \mathsf{/.f32}\left(-1, s\right)\right)\right)\right)\right) \]
      3. /-lowering-/.f32N/A

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{/.f32}\left(\left(x \cdot \frac{\frac{-1}{6}}{s \cdot s}\right), s\right), \mathsf{/.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(s, s\right)\right)\right)\right), \mathsf{/.f32}\left(-1, s\right)\right)\right)\right)\right) \]
      4. *-lowering-*.f32N/A

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(x, \left(\frac{\frac{-1}{6}}{s \cdot s}\right)\right), s\right), \mathsf{/.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(s, s\right)\right)\right)\right), \mathsf{/.f32}\left(-1, s\right)\right)\right)\right)\right) \]
      5. /-lowering-/.f32N/A

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\frac{-1}{6}, \left(s \cdot s\right)\right)\right), s\right), \mathsf{/.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(s, s\right)\right)\right)\right), \mathsf{/.f32}\left(-1, s\right)\right)\right)\right)\right) \]
      6. *-lowering-*.f3288.6%

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\frac{-1}{6}, \mathsf{*.f32}\left(s, s\right)\right)\right), s\right), \mathsf{/.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(s, s\right)\right)\right)\right), \mathsf{/.f32}\left(-1, s\right)\right)\right)\right)\right) \]
    6. Applied egg-rr88.6%

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

    if -1.99999996e-31 < x

    1. Initial program 99.9%

      \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{1}{2}} \]
    4. Step-by-step derivation
      1. Simplified48.1%

        \[\leadsto \color{blue}{0.5} \]
    5. Recombined 2 regimes into one program.
    6. Add Preprocessing

    Alternative 4: 65.6% accurate, 3.9× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.9999999593223797 \cdot 10^{-31}:\\ \;\;\;\;\frac{1}{2 + x \cdot \left(\frac{-1}{s} + x \cdot \frac{0.5 + \frac{x \cdot -0.16666666666666666}{s}}{s \cdot s}\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \end{array} \]
    (FPCore (x s)
     :precision binary32
     (if (<= x -1.9999999593223797e-31)
       (/
        1.0
        (+
         2.0
         (*
          x
          (+
           (/ -1.0 s)
           (* x (/ (+ 0.5 (/ (* x -0.16666666666666666) s)) (* s s)))))))
       0.5))
    float code(float x, float s) {
    	float tmp;
    	if (x <= -1.9999999593223797e-31f) {
    		tmp = 1.0f / (2.0f + (x * ((-1.0f / s) + (x * ((0.5f + ((x * -0.16666666666666666f) / s)) / (s * s))))));
    	} else {
    		tmp = 0.5f;
    	}
    	return tmp;
    }
    
    real(4) function code(x, s)
        real(4), intent (in) :: x
        real(4), intent (in) :: s
        real(4) :: tmp
        if (x <= (-1.9999999593223797e-31)) then
            tmp = 1.0e0 / (2.0e0 + (x * (((-1.0e0) / s) + (x * ((0.5e0 + ((x * (-0.16666666666666666e0)) / s)) / (s * s))))))
        else
            tmp = 0.5e0
        end if
        code = tmp
    end function
    
    function code(x, s)
    	tmp = Float32(0.0)
    	if (x <= Float32(-1.9999999593223797e-31))
    		tmp = Float32(Float32(1.0) / Float32(Float32(2.0) + Float32(x * Float32(Float32(Float32(-1.0) / s) + Float32(x * Float32(Float32(Float32(0.5) + Float32(Float32(x * Float32(-0.16666666666666666)) / s)) / Float32(s * s)))))));
    	else
    		tmp = Float32(0.5);
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, s)
    	tmp = single(0.0);
    	if (x <= single(-1.9999999593223797e-31))
    		tmp = single(1.0) / (single(2.0) + (x * ((single(-1.0) / s) + (x * ((single(0.5) + ((x * single(-0.16666666666666666)) / s)) / (s * s))))));
    	else
    		tmp = single(0.5);
    	end
    	tmp_2 = tmp;
    end
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;x \leq -1.9999999593223797 \cdot 10^{-31}:\\
    \;\;\;\;\frac{1}{2 + x \cdot \left(\frac{-1}{s} + x \cdot \frac{0.5 + \frac{x \cdot -0.16666666666666666}{s}}{s \cdot s}\right)}\\
    
    \mathbf{else}:\\
    \;\;\;\;0.5\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x < -1.99999996e-31

      1. Initial program 99.6%

        \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
      2. Add Preprocessing
      3. Taylor expanded in x around 0

        \[\leadsto \mathsf{/.f32}\left(1, \color{blue}{\left(2 + x \cdot \left(x \cdot \left(\frac{-1}{6} \cdot \frac{x}{{s}^{3}} + \frac{1}{2} \cdot \frac{1}{{s}^{2}}\right) - \frac{1}{s}\right)\right)}\right) \]
      4. Simplified86.8%

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

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

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\left(\frac{1}{2} + \frac{-1}{6} \cdot \frac{x}{s}\right), \left({s}^{2}\right)\right)\right), \mathsf{/.f32}\left(-1, s\right)\right)\right)\right)\right) \]
        2. +-lowering-+.f32N/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\frac{1}{2}, \left(\frac{-1}{6} \cdot \frac{x}{s}\right)\right), \left({s}^{2}\right)\right)\right), \mathsf{/.f32}\left(-1, s\right)\right)\right)\right)\right) \]
        3. associate-*r/N/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\frac{1}{2}, \left(\frac{\frac{-1}{6} \cdot x}{s}\right)\right), \left({s}^{2}\right)\right)\right), \mathsf{/.f32}\left(-1, s\right)\right)\right)\right)\right) \]
        4. /-lowering-/.f32N/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\frac{1}{2}, \mathsf{/.f32}\left(\left(\frac{-1}{6} \cdot x\right), s\right)\right), \left({s}^{2}\right)\right)\right), \mathsf{/.f32}\left(-1, s\right)\right)\right)\right)\right) \]
        5. *-commutativeN/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\frac{1}{2}, \mathsf{/.f32}\left(\left(x \cdot \frac{-1}{6}\right), s\right)\right), \left({s}^{2}\right)\right)\right), \mathsf{/.f32}\left(-1, s\right)\right)\right)\right)\right) \]
        6. *-lowering-*.f32N/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\frac{1}{2}, \mathsf{/.f32}\left(\mathsf{*.f32}\left(x, \frac{-1}{6}\right), s\right)\right), \left({s}^{2}\right)\right)\right), \mathsf{/.f32}\left(-1, s\right)\right)\right)\right)\right) \]
        7. unpow2N/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\frac{1}{2}, \mathsf{/.f32}\left(\mathsf{*.f32}\left(x, \frac{-1}{6}\right), s\right)\right), \left(s \cdot s\right)\right)\right), \mathsf{/.f32}\left(-1, s\right)\right)\right)\right)\right) \]
        8. *-lowering-*.f3288.6%

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\frac{1}{2}, \mathsf{/.f32}\left(\mathsf{*.f32}\left(x, \frac{-1}{6}\right), s\right)\right), \mathsf{*.f32}\left(s, s\right)\right)\right), \mathsf{/.f32}\left(-1, s\right)\right)\right)\right)\right) \]
      7. Simplified88.6%

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

      if -1.99999996e-31 < x

      1. Initial program 99.9%

        \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
      2. Add Preprocessing
      3. Taylor expanded in x around 0

        \[\leadsto \color{blue}{\frac{1}{2}} \]
      4. Step-by-step derivation
        1. Simplified48.1%

          \[\leadsto \color{blue}{0.5} \]
      5. Recombined 2 regimes into one program.
      6. Final simplification66.0%

        \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.9999999593223797 \cdot 10^{-31}:\\ \;\;\;\;\frac{1}{2 + x \cdot \left(\frac{-1}{s} + x \cdot \frac{0.5 + \frac{x \cdot -0.16666666666666666}{s}}{s \cdot s}\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
      7. Add Preprocessing

      Alternative 5: 64.9% accurate, 4.1× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.9999999593223797 \cdot 10^{-31}:\\ \;\;\;\;\frac{1}{2 + x \cdot \left(\frac{-1}{s} + x \cdot \frac{x \cdot -0.16666666666666666}{s \cdot \left(s \cdot s\right)}\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \end{array} \]
      (FPCore (x s)
       :precision binary32
       (if (<= x -1.9999999593223797e-31)
         (/
          1.0
          (+
           2.0
           (* x (+ (/ -1.0 s) (* x (/ (* x -0.16666666666666666) (* s (* s s))))))))
         0.5))
      float code(float x, float s) {
      	float tmp;
      	if (x <= -1.9999999593223797e-31f) {
      		tmp = 1.0f / (2.0f + (x * ((-1.0f / s) + (x * ((x * -0.16666666666666666f) / (s * (s * s)))))));
      	} else {
      		tmp = 0.5f;
      	}
      	return tmp;
      }
      
      real(4) function code(x, s)
          real(4), intent (in) :: x
          real(4), intent (in) :: s
          real(4) :: tmp
          if (x <= (-1.9999999593223797e-31)) then
              tmp = 1.0e0 / (2.0e0 + (x * (((-1.0e0) / s) + (x * ((x * (-0.16666666666666666e0)) / (s * (s * s)))))))
          else
              tmp = 0.5e0
          end if
          code = tmp
      end function
      
      function code(x, s)
      	tmp = Float32(0.0)
      	if (x <= Float32(-1.9999999593223797e-31))
      		tmp = Float32(Float32(1.0) / Float32(Float32(2.0) + Float32(x * Float32(Float32(Float32(-1.0) / s) + Float32(x * Float32(Float32(x * Float32(-0.16666666666666666)) / Float32(s * Float32(s * s))))))));
      	else
      		tmp = Float32(0.5);
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, s)
      	tmp = single(0.0);
      	if (x <= single(-1.9999999593223797e-31))
      		tmp = single(1.0) / (single(2.0) + (x * ((single(-1.0) / s) + (x * ((x * single(-0.16666666666666666)) / (s * (s * s)))))));
      	else
      		tmp = single(0.5);
      	end
      	tmp_2 = tmp;
      end
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;x \leq -1.9999999593223797 \cdot 10^{-31}:\\
      \;\;\;\;\frac{1}{2 + x \cdot \left(\frac{-1}{s} + x \cdot \frac{x \cdot -0.16666666666666666}{s \cdot \left(s \cdot s\right)}\right)}\\
      
      \mathbf{else}:\\
      \;\;\;\;0.5\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if x < -1.99999996e-31

        1. Initial program 99.6%

          \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
        2. Add Preprocessing
        3. Taylor expanded in x around 0

          \[\leadsto \mathsf{/.f32}\left(1, \color{blue}{\left(2 + x \cdot \left(x \cdot \left(\frac{-1}{6} \cdot \frac{x}{{s}^{3}} + \frac{1}{2} \cdot \frac{1}{{s}^{2}}\right) - \frac{1}{s}\right)\right)}\right) \]
        4. Simplified86.8%

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

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{*.f32}\left(x, \color{blue}{\left(\frac{-1}{6} \cdot \frac{x}{{s}^{3}}\right)}\right), \mathsf{/.f32}\left(-1, s\right)\right)\right)\right)\right) \]
        6. Step-by-step derivation
          1. associate-*r/N/A

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{*.f32}\left(x, \left(\frac{\frac{-1}{6} \cdot x}{{s}^{3}}\right)\right), \mathsf{/.f32}\left(-1, s\right)\right)\right)\right)\right) \]
          2. /-lowering-/.f32N/A

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\left(\frac{-1}{6} \cdot x\right), \left({s}^{3}\right)\right)\right), \mathsf{/.f32}\left(-1, s\right)\right)\right)\right)\right) \]
          3. *-commutativeN/A

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\left(x \cdot \frac{-1}{6}\right), \left({s}^{3}\right)\right)\right), \mathsf{/.f32}\left(-1, s\right)\right)\right)\right)\right) \]
          4. *-lowering-*.f32N/A

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\mathsf{*.f32}\left(x, \frac{-1}{6}\right), \left({s}^{3}\right)\right)\right), \mathsf{/.f32}\left(-1, s\right)\right)\right)\right)\right) \]
          5. cube-multN/A

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\mathsf{*.f32}\left(x, \frac{-1}{6}\right), \left(s \cdot \left(s \cdot s\right)\right)\right)\right), \mathsf{/.f32}\left(-1, s\right)\right)\right)\right)\right) \]
          6. unpow2N/A

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\mathsf{*.f32}\left(x, \frac{-1}{6}\right), \left(s \cdot {s}^{2}\right)\right)\right), \mathsf{/.f32}\left(-1, s\right)\right)\right)\right)\right) \]
          7. *-lowering-*.f32N/A

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\mathsf{*.f32}\left(x, \frac{-1}{6}\right), \mathsf{*.f32}\left(s, \left({s}^{2}\right)\right)\right)\right), \mathsf{/.f32}\left(-1, s\right)\right)\right)\right)\right) \]
          8. unpow2N/A

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\mathsf{*.f32}\left(x, \frac{-1}{6}\right), \mathsf{*.f32}\left(s, \left(s \cdot s\right)\right)\right)\right), \mathsf{/.f32}\left(-1, s\right)\right)\right)\right)\right) \]
          9. *-lowering-*.f3286.2%

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\mathsf{*.f32}\left(x, \frac{-1}{6}\right), \mathsf{*.f32}\left(s, \mathsf{*.f32}\left(s, s\right)\right)\right)\right), \mathsf{/.f32}\left(-1, s\right)\right)\right)\right)\right) \]
        7. Simplified86.2%

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

        if -1.99999996e-31 < x

        1. Initial program 99.9%

          \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
        2. Add Preprocessing
        3. Taylor expanded in x around 0

          \[\leadsto \color{blue}{\frac{1}{2}} \]
        4. Step-by-step derivation
          1. Simplified48.1%

            \[\leadsto \color{blue}{0.5} \]
        5. Recombined 2 regimes into one program.
        6. Final simplification64.9%

          \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.9999999593223797 \cdot 10^{-31}:\\ \;\;\;\;\frac{1}{2 + x \cdot \left(\frac{-1}{s} + x \cdot \frac{x \cdot -0.16666666666666666}{s \cdot \left(s \cdot s\right)}\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
        7. Add Preprocessing

        Alternative 6: 62.0% accurate, 4.9× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -4.99999991225835 \cdot 10^{-15}:\\ \;\;\;\;\frac{1}{2 + x \cdot \frac{-0.16666666666666666 \cdot \left(x \cdot x\right)}{s \cdot \left(s \cdot s\right)}}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \end{array} \]
        (FPCore (x s)
         :precision binary32
         (if (<= x -4.99999991225835e-15)
           (/ 1.0 (+ 2.0 (* x (/ (* -0.16666666666666666 (* x x)) (* s (* s s))))))
           0.5))
        float code(float x, float s) {
        	float tmp;
        	if (x <= -4.99999991225835e-15f) {
        		tmp = 1.0f / (2.0f + (x * ((-0.16666666666666666f * (x * x)) / (s * (s * s)))));
        	} else {
        		tmp = 0.5f;
        	}
        	return tmp;
        }
        
        real(4) function code(x, s)
            real(4), intent (in) :: x
            real(4), intent (in) :: s
            real(4) :: tmp
            if (x <= (-4.99999991225835e-15)) then
                tmp = 1.0e0 / (2.0e0 + (x * (((-0.16666666666666666e0) * (x * x)) / (s * (s * s)))))
            else
                tmp = 0.5e0
            end if
            code = tmp
        end function
        
        function code(x, s)
        	tmp = Float32(0.0)
        	if (x <= Float32(-4.99999991225835e-15))
        		tmp = Float32(Float32(1.0) / Float32(Float32(2.0) + Float32(x * Float32(Float32(Float32(-0.16666666666666666) * Float32(x * x)) / Float32(s * Float32(s * s))))));
        	else
        		tmp = Float32(0.5);
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, s)
        	tmp = single(0.0);
        	if (x <= single(-4.99999991225835e-15))
        		tmp = single(1.0) / (single(2.0) + (x * ((single(-0.16666666666666666) * (x * x)) / (s * (s * s)))));
        	else
        		tmp = single(0.5);
        	end
        	tmp_2 = tmp;
        end
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;x \leq -4.99999991225835 \cdot 10^{-15}:\\
        \;\;\;\;\frac{1}{2 + x \cdot \frac{-0.16666666666666666 \cdot \left(x \cdot x\right)}{s \cdot \left(s \cdot s\right)}}\\
        
        \mathbf{else}:\\
        \;\;\;\;0.5\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if x < -4.99999991e-15

          1. Initial program 99.7%

            \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
          2. Add Preprocessing
          3. Taylor expanded in x around 0

            \[\leadsto \mathsf{/.f32}\left(1, \color{blue}{\left(2 + x \cdot \left(x \cdot \left(\frac{-1}{6} \cdot \frac{x}{{s}^{3}} + \frac{1}{2} \cdot \frac{1}{{s}^{2}}\right) - \frac{1}{s}\right)\right)}\right) \]
          4. Simplified88.6%

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

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \color{blue}{\left(\frac{-1}{6} \cdot \frac{{x}^{2}}{{s}^{3}}\right)}\right)\right)\right) \]
          6. Step-by-step derivation
            1. associate-*r/N/A

              \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \left(\frac{\frac{-1}{6} \cdot {x}^{2}}{\color{blue}{{s}^{3}}}\right)\right)\right)\right) \]
            2. /-lowering-/.f32N/A

              \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\left(\frac{-1}{6} \cdot {x}^{2}\right), \color{blue}{\left({s}^{3}\right)}\right)\right)\right)\right) \]
            3. *-commutativeN/A

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

              \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\left({x}^{2}\right), \frac{-1}{6}\right), \left({\color{blue}{s}}^{3}\right)\right)\right)\right)\right) \]
            5. unpow2N/A

              \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\left(x \cdot x\right), \frac{-1}{6}\right), \left({s}^{3}\right)\right)\right)\right)\right) \]
            6. *-lowering-*.f32N/A

              \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(x, x\right), \frac{-1}{6}\right), \left({s}^{3}\right)\right)\right)\right)\right) \]
            7. cube-multN/A

              \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(x, x\right), \frac{-1}{6}\right), \left(s \cdot \color{blue}{\left(s \cdot s\right)}\right)\right)\right)\right)\right) \]
            8. unpow2N/A

              \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(x, x\right), \frac{-1}{6}\right), \left(s \cdot {s}^{\color{blue}{2}}\right)\right)\right)\right)\right) \]
            9. *-lowering-*.f32N/A

              \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(x, x\right), \frac{-1}{6}\right), \mathsf{*.f32}\left(s, \color{blue}{\left({s}^{2}\right)}\right)\right)\right)\right)\right) \]
            10. unpow2N/A

              \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(x, x\right), \frac{-1}{6}\right), \mathsf{*.f32}\left(s, \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right)\right) \]
            11. *-lowering-*.f3286.3%

              \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(x, x\right), \frac{-1}{6}\right), \mathsf{*.f32}\left(s, \mathsf{*.f32}\left(s, \color{blue}{s}\right)\right)\right)\right)\right)\right) \]
          7. Simplified86.3%

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

          if -4.99999991e-15 < x

          1. Initial program 99.8%

            \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
          2. Add Preprocessing
          3. Taylor expanded in x around 0

            \[\leadsto \color{blue}{\frac{1}{2}} \]
          4. Step-by-step derivation
            1. Simplified49.9%

              \[\leadsto \color{blue}{0.5} \]
          5. Recombined 2 regimes into one program.
          6. Final simplification63.5%

            \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.99999991225835 \cdot 10^{-15}:\\ \;\;\;\;\frac{1}{2 + x \cdot \frac{-0.16666666666666666 \cdot \left(x \cdot x\right)}{s \cdot \left(s \cdot s\right)}}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
          7. Add Preprocessing

          Alternative 7: 63.3% accurate, 4.9× speedup?

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

            1. Initial program 99.6%

              \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
            2. Add Preprocessing
            3. Taylor expanded in x around 0

              \[\leadsto \mathsf{/.f32}\left(1, \color{blue}{\left(2 + x \cdot \left(x \cdot \left(\frac{-1}{6} \cdot \frac{x}{{s}^{3}} + \frac{1}{2} \cdot \frac{1}{{s}^{2}}\right) - \frac{1}{s}\right)\right)}\right) \]
            4. Simplified86.8%

              \[\leadsto \frac{1}{\color{blue}{2 + x \cdot \left(x \cdot \left(\frac{x \cdot -0.16666666666666666}{s \cdot \left(s \cdot s\right)} + \frac{0.5}{s \cdot s}\right) + \frac{-1}{s}\right)}} \]
            5. Taylor expanded in x around 0

              \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{*.f32}\left(x, \color{blue}{\left(\frac{\frac{1}{2}}{{s}^{2}}\right)}\right), \mathsf{/.f32}\left(-1, s\right)\right)\right)\right)\right) \]
            6. Step-by-step derivation
              1. /-lowering-/.f32N/A

                \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\frac{1}{2}, \left({s}^{2}\right)\right)\right), \mathsf{/.f32}\left(-1, s\right)\right)\right)\right)\right) \]
              2. unpow2N/A

                \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\frac{1}{2}, \left(s \cdot s\right)\right)\right), \mathsf{/.f32}\left(-1, s\right)\right)\right)\right)\right) \]
              3. *-lowering-*.f3280.0%

                \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(x, \mathsf{+.f32}\left(\mathsf{*.f32}\left(x, \mathsf{/.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(s, s\right)\right)\right), \mathsf{/.f32}\left(-1, s\right)\right)\right)\right)\right) \]
            7. Simplified80.0%

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

            if -1.99999996e-31 < x

            1. Initial program 99.9%

              \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
            2. Add Preprocessing
            3. Taylor expanded in x around 0

              \[\leadsto \color{blue}{\frac{1}{2}} \]
            4. Step-by-step derivation
              1. Simplified48.1%

                \[\leadsto \color{blue}{0.5} \]
            5. Recombined 2 regimes into one program.
            6. Final simplification62.2%

              \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.9999999593223797 \cdot 10^{-31}:\\ \;\;\;\;\frac{1}{2 + x \cdot \left(\frac{-1}{s} + x \cdot \frac{0.5}{s \cdot s}\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
            7. Add Preprocessing

            Alternative 8: 60.8% accurate, 5.4× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.99999996490334 \cdot 10^{-13}:\\ \;\;\;\;\frac{1}{\frac{-0.16666666666666666 \cdot \left(x \cdot \left(x \cdot x\right)\right)}{s \cdot \left(s \cdot s\right)}}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \end{array} \]
            (FPCore (x s)
             :precision binary32
             (if (<= x -1.99999996490334e-13)
               (/ 1.0 (/ (* -0.16666666666666666 (* x (* x x))) (* s (* s s))))
               0.5))
            float code(float x, float s) {
            	float tmp;
            	if (x <= -1.99999996490334e-13f) {
            		tmp = 1.0f / ((-0.16666666666666666f * (x * (x * x))) / (s * (s * s)));
            	} else {
            		tmp = 0.5f;
            	}
            	return tmp;
            }
            
            real(4) function code(x, s)
                real(4), intent (in) :: x
                real(4), intent (in) :: s
                real(4) :: tmp
                if (x <= (-1.99999996490334e-13)) then
                    tmp = 1.0e0 / (((-0.16666666666666666e0) * (x * (x * x))) / (s * (s * s)))
                else
                    tmp = 0.5e0
                end if
                code = tmp
            end function
            
            function code(x, s)
            	tmp = Float32(0.0)
            	if (x <= Float32(-1.99999996490334e-13))
            		tmp = Float32(Float32(1.0) / Float32(Float32(Float32(-0.16666666666666666) * Float32(x * Float32(x * x))) / Float32(s * Float32(s * s))));
            	else
            		tmp = Float32(0.5);
            	end
            	return tmp
            end
            
            function tmp_2 = code(x, s)
            	tmp = single(0.0);
            	if (x <= single(-1.99999996490334e-13))
            		tmp = single(1.0) / ((single(-0.16666666666666666) * (x * (x * x))) / (s * (s * s)));
            	else
            		tmp = single(0.5);
            	end
            	tmp_2 = tmp;
            end
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;x \leq -1.99999996490334 \cdot 10^{-13}:\\
            \;\;\;\;\frac{1}{\frac{-0.16666666666666666 \cdot \left(x \cdot \left(x \cdot x\right)\right)}{s \cdot \left(s \cdot s\right)}}\\
            
            \mathbf{else}:\\
            \;\;\;\;0.5\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if x < -1.99999996e-13

              1. Initial program 99.8%

                \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
              2. Add Preprocessing
              3. Taylor expanded in x around 0

                \[\leadsto \mathsf{/.f32}\left(1, \color{blue}{\left(2 + x \cdot \left(x \cdot \left(\frac{-1}{6} \cdot \frac{x}{{s}^{3}} + \frac{1}{2} \cdot \frac{1}{{s}^{2}}\right) - \frac{1}{s}\right)\right)}\right) \]
              4. Simplified88.1%

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

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

                  \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot {x}^{3}}{\color{blue}{{s}^{3}}}\right)\right) \]
                2. *-rgt-identityN/A

                  \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot 1\right)}{{s}^{3}}\right)\right) \]
                3. metadata-evalN/A

                  \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot {1}^{3}\right)}{{s}^{3}}\right)\right) \]
                4. log-EN/A

                  \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}\right)}{{s}^{3}}\right)\right) \]
                5. cube-multN/A

                  \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}\right)}{s \cdot \color{blue}{\left(s \cdot s\right)}}\right)\right) \]
                6. unpow2N/A

                  \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}\right)}{s \cdot {s}^{\color{blue}{2}}}\right)\right) \]
                7. associate-/r*N/A

                  \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}\right)}{s}}{\color{blue}{{s}^{2}}}\right)\right) \]
                8. associate-*r/N/A

                  \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \frac{{x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}}{s}}{{\color{blue}{s}}^{2}}\right)\right) \]
                9. /-lowering-/.f32N/A

                  \[\leadsto \mathsf{/.f32}\left(1, \mathsf{/.f32}\left(\left(\frac{-1}{6} \cdot \frac{{x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}}{s}\right), \color{blue}{\left({s}^{2}\right)}\right)\right) \]
              7. Simplified82.3%

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

                  \[\leadsto \mathsf{/.f32}\left(1, \color{blue}{\left(\frac{\frac{-1}{6} \cdot \frac{x \cdot \left(x \cdot x\right)}{s}}{s \cdot s}\right)}\right) \]
                2. associate-*r/N/A

                  \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{\frac{-1}{6} \cdot \left(x \cdot \left(x \cdot x\right)\right)}{s}}{\color{blue}{s} \cdot s}\right)\right) \]
                3. associate-/l/N/A

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

                  \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \left(x \cdot \left(x \cdot x\right)\right)}{{s}^{\color{blue}{3}}}\right)\right) \]
                5. /-lowering-/.f32N/A

                  \[\leadsto \mathsf{/.f32}\left(1, \mathsf{/.f32}\left(\left(\frac{-1}{6} \cdot \left(x \cdot \left(x \cdot x\right)\right)\right), \color{blue}{\left({s}^{3}\right)}\right)\right) \]
                6. *-lowering-*.f32N/A

                  \[\leadsto \mathsf{/.f32}\left(1, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{-1}{6}, \left(x \cdot \left(x \cdot x\right)\right)\right), \left({\color{blue}{s}}^{3}\right)\right)\right) \]
                7. *-lowering-*.f32N/A

                  \[\leadsto \mathsf{/.f32}\left(1, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{-1}{6}, \mathsf{*.f32}\left(x, \left(x \cdot x\right)\right)\right), \left({s}^{3}\right)\right)\right) \]
                8. *-lowering-*.f32N/A

                  \[\leadsto \mathsf{/.f32}\left(1, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{-1}{6}, \mathsf{*.f32}\left(x, \mathsf{*.f32}\left(x, x\right)\right)\right), \left({s}^{3}\right)\right)\right) \]
                9. pow3N/A

                  \[\leadsto \mathsf{/.f32}\left(1, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{-1}{6}, \mathsf{*.f32}\left(x, \mathsf{*.f32}\left(x, x\right)\right)\right), \left(\left(s \cdot s\right) \cdot \color{blue}{s}\right)\right)\right) \]
                10. *-lowering-*.f32N/A

                  \[\leadsto \mathsf{/.f32}\left(1, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{-1}{6}, \mathsf{*.f32}\left(x, \mathsf{*.f32}\left(x, x\right)\right)\right), \mathsf{*.f32}\left(\left(s \cdot s\right), \color{blue}{s}\right)\right)\right) \]
                11. *-lowering-*.f3284.2%

                  \[\leadsto \mathsf{/.f32}\left(1, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{-1}{6}, \mathsf{*.f32}\left(x, \mathsf{*.f32}\left(x, x\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(s, s\right), s\right)\right)\right) \]
              9. Applied egg-rr84.2%

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

              if -1.99999996e-13 < x

              1. Initial program 99.8%

                \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
              2. Add Preprocessing
              3. Taylor expanded in x around 0

                \[\leadsto \color{blue}{\frac{1}{2}} \]
              4. Step-by-step derivation
                1. Simplified50.1%

                  \[\leadsto \color{blue}{0.5} \]
              5. Recombined 2 regimes into one program.
              6. Final simplification62.1%

                \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.99999996490334 \cdot 10^{-13}:\\ \;\;\;\;\frac{1}{\frac{-0.16666666666666666 \cdot \left(x \cdot \left(x \cdot x\right)\right)}{s \cdot \left(s \cdot s\right)}}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
              7. Add Preprocessing

              Alternative 9: 60.8% accurate, 6.0× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.99999996490334 \cdot 10^{-13}:\\ \;\;\;\;\frac{-6}{\frac{x \cdot \left(x \cdot x\right)}{s \cdot \left(s \cdot s\right)}}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \end{array} \]
              (FPCore (x s)
               :precision binary32
               (if (<= x -1.99999996490334e-13)
                 (/ -6.0 (/ (* x (* x x)) (* s (* s s))))
                 0.5))
              float code(float x, float s) {
              	float tmp;
              	if (x <= -1.99999996490334e-13f) {
              		tmp = -6.0f / ((x * (x * x)) / (s * (s * s)));
              	} else {
              		tmp = 0.5f;
              	}
              	return tmp;
              }
              
              real(4) function code(x, s)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: s
                  real(4) :: tmp
                  if (x <= (-1.99999996490334e-13)) then
                      tmp = (-6.0e0) / ((x * (x * x)) / (s * (s * s)))
                  else
                      tmp = 0.5e0
                  end if
                  code = tmp
              end function
              
              function code(x, s)
              	tmp = Float32(0.0)
              	if (x <= Float32(-1.99999996490334e-13))
              		tmp = Float32(Float32(-6.0) / Float32(Float32(x * Float32(x * x)) / Float32(s * Float32(s * s))));
              	else
              		tmp = Float32(0.5);
              	end
              	return tmp
              end
              
              function tmp_2 = code(x, s)
              	tmp = single(0.0);
              	if (x <= single(-1.99999996490334e-13))
              		tmp = single(-6.0) / ((x * (x * x)) / (s * (s * s)));
              	else
              		tmp = single(0.5);
              	end
              	tmp_2 = tmp;
              end
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;x \leq -1.99999996490334 \cdot 10^{-13}:\\
              \;\;\;\;\frac{-6}{\frac{x \cdot \left(x \cdot x\right)}{s \cdot \left(s \cdot s\right)}}\\
              
              \mathbf{else}:\\
              \;\;\;\;0.5\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if x < -1.99999996e-13

                1. Initial program 99.8%

                  \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
                2. Add Preprocessing
                3. Taylor expanded in x around 0

                  \[\leadsto \mathsf{/.f32}\left(1, \color{blue}{\left(2 + x \cdot \left(x \cdot \left(\frac{-1}{6} \cdot \frac{x}{{s}^{3}} + \frac{1}{2} \cdot \frac{1}{{s}^{2}}\right) - \frac{1}{s}\right)\right)}\right) \]
                4. Simplified88.1%

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

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

                    \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot {x}^{3}}{\color{blue}{{s}^{3}}}\right)\right) \]
                  2. *-rgt-identityN/A

                    \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot 1\right)}{{s}^{3}}\right)\right) \]
                  3. metadata-evalN/A

                    \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot {1}^{3}\right)}{{s}^{3}}\right)\right) \]
                  4. log-EN/A

                    \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}\right)}{{s}^{3}}\right)\right) \]
                  5. cube-multN/A

                    \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}\right)}{s \cdot \color{blue}{\left(s \cdot s\right)}}\right)\right) \]
                  6. unpow2N/A

                    \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}\right)}{s \cdot {s}^{\color{blue}{2}}}\right)\right) \]
                  7. associate-/r*N/A

                    \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}\right)}{s}}{\color{blue}{{s}^{2}}}\right)\right) \]
                  8. associate-*r/N/A

                    \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \frac{{x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}}{s}}{{\color{blue}{s}}^{2}}\right)\right) \]
                  9. /-lowering-/.f32N/A

                    \[\leadsto \mathsf{/.f32}\left(1, \mathsf{/.f32}\left(\left(\frac{-1}{6} \cdot \frac{{x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}}{s}\right), \color{blue}{\left({s}^{2}\right)}\right)\right) \]
                7. Simplified82.3%

                  \[\leadsto \frac{1}{\color{blue}{\frac{-0.16666666666666666 \cdot \frac{x \cdot \left(x \cdot x\right)}{s}}{s \cdot s}}} \]
                8. Step-by-step derivation
                  1. associate-/l*N/A

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

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

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

                    \[\leadsto \frac{{\frac{-1}{6}}^{-1}}{\frac{\color{blue}{\frac{x \cdot \left(x \cdot x\right)}{s}}}{s \cdot s}} \]
                  5. /-lowering-/.f32N/A

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

                    \[\leadsto \mathsf{/.f32}\left(-6, \left(\frac{\color{blue}{\frac{x \cdot \left(x \cdot x\right)}{s}}}{s \cdot s}\right)\right) \]
                  7. associate-/l/N/A

                    \[\leadsto \mathsf{/.f32}\left(-6, \left(\frac{x \cdot \left(x \cdot x\right)}{\color{blue}{\left(s \cdot s\right) \cdot s}}\right)\right) \]
                  8. pow3N/A

                    \[\leadsto \mathsf{/.f32}\left(-6, \left(\frac{x \cdot \left(x \cdot x\right)}{{s}^{\color{blue}{3}}}\right)\right) \]
                  9. /-lowering-/.f32N/A

                    \[\leadsto \mathsf{/.f32}\left(-6, \mathsf{/.f32}\left(\left(x \cdot \left(x \cdot x\right)\right), \color{blue}{\left({s}^{3}\right)}\right)\right) \]
                  10. *-lowering-*.f32N/A

                    \[\leadsto \mathsf{/.f32}\left(-6, \mathsf{/.f32}\left(\mathsf{*.f32}\left(x, \left(x \cdot x\right)\right), \left({\color{blue}{s}}^{3}\right)\right)\right) \]
                  11. *-lowering-*.f32N/A

                    \[\leadsto \mathsf{/.f32}\left(-6, \mathsf{/.f32}\left(\mathsf{*.f32}\left(x, \mathsf{*.f32}\left(x, x\right)\right), \left({s}^{3}\right)\right)\right) \]
                  12. pow3N/A

                    \[\leadsto \mathsf{/.f32}\left(-6, \mathsf{/.f32}\left(\mathsf{*.f32}\left(x, \mathsf{*.f32}\left(x, x\right)\right), \left(\left(s \cdot s\right) \cdot \color{blue}{s}\right)\right)\right) \]
                  13. *-lowering-*.f32N/A

                    \[\leadsto \mathsf{/.f32}\left(-6, \mathsf{/.f32}\left(\mathsf{*.f32}\left(x, \mathsf{*.f32}\left(x, x\right)\right), \mathsf{*.f32}\left(\left(s \cdot s\right), \color{blue}{s}\right)\right)\right) \]
                  14. *-lowering-*.f3284.2%

                    \[\leadsto \mathsf{/.f32}\left(-6, \mathsf{/.f32}\left(\mathsf{*.f32}\left(x, \mathsf{*.f32}\left(x, x\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(s, s\right), s\right)\right)\right) \]
                9. Applied egg-rr84.2%

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

                if -1.99999996e-13 < x

                1. Initial program 99.8%

                  \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
                2. Add Preprocessing
                3. Taylor expanded in x around 0

                  \[\leadsto \color{blue}{\frac{1}{2}} \]
                4. Step-by-step derivation
                  1. Simplified50.1%

                    \[\leadsto \color{blue}{0.5} \]
                5. Recombined 2 regimes into one program.
                6. Final simplification62.1%

                  \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.99999996490334 \cdot 10^{-13}:\\ \;\;\;\;\frac{-6}{\frac{x \cdot \left(x \cdot x\right)}{s \cdot \left(s \cdot s\right)}}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
                7. Add Preprocessing

                Alternative 10: 59.6% accurate, 6.0× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.99999996490334 \cdot 10^{-13}:\\ \;\;\;\;\frac{s}{\frac{x \cdot \left(x \cdot x\right)}{s}} \cdot \frac{s}{-0.16666666666666666}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \end{array} \]
                (FPCore (x s)
                 :precision binary32
                 (if (<= x -1.99999996490334e-13)
                   (* (/ s (/ (* x (* x x)) s)) (/ s -0.16666666666666666))
                   0.5))
                float code(float x, float s) {
                	float tmp;
                	if (x <= -1.99999996490334e-13f) {
                		tmp = (s / ((x * (x * x)) / s)) * (s / -0.16666666666666666f);
                	} else {
                		tmp = 0.5f;
                	}
                	return tmp;
                }
                
                real(4) function code(x, s)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: s
                    real(4) :: tmp
                    if (x <= (-1.99999996490334e-13)) then
                        tmp = (s / ((x * (x * x)) / s)) * (s / (-0.16666666666666666e0))
                    else
                        tmp = 0.5e0
                    end if
                    code = tmp
                end function
                
                function code(x, s)
                	tmp = Float32(0.0)
                	if (x <= Float32(-1.99999996490334e-13))
                		tmp = Float32(Float32(s / Float32(Float32(x * Float32(x * x)) / s)) * Float32(s / Float32(-0.16666666666666666)));
                	else
                		tmp = Float32(0.5);
                	end
                	return tmp
                end
                
                function tmp_2 = code(x, s)
                	tmp = single(0.0);
                	if (x <= single(-1.99999996490334e-13))
                		tmp = (s / ((x * (x * x)) / s)) * (s / single(-0.16666666666666666));
                	else
                		tmp = single(0.5);
                	end
                	tmp_2 = tmp;
                end
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;x \leq -1.99999996490334 \cdot 10^{-13}:\\
                \;\;\;\;\frac{s}{\frac{x \cdot \left(x \cdot x\right)}{s}} \cdot \frac{s}{-0.16666666666666666}\\
                
                \mathbf{else}:\\
                \;\;\;\;0.5\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if x < -1.99999996e-13

                  1. Initial program 99.8%

                    \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
                  2. Add Preprocessing
                  3. Taylor expanded in x around 0

                    \[\leadsto \mathsf{/.f32}\left(1, \color{blue}{\left(2 + x \cdot \left(x \cdot \left(\frac{-1}{6} \cdot \frac{x}{{s}^{3}} + \frac{1}{2} \cdot \frac{1}{{s}^{2}}\right) - \frac{1}{s}\right)\right)}\right) \]
                  4. Simplified88.1%

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

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

                      \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot {x}^{3}}{\color{blue}{{s}^{3}}}\right)\right) \]
                    2. *-rgt-identityN/A

                      \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot 1\right)}{{s}^{3}}\right)\right) \]
                    3. metadata-evalN/A

                      \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot {1}^{3}\right)}{{s}^{3}}\right)\right) \]
                    4. log-EN/A

                      \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}\right)}{{s}^{3}}\right)\right) \]
                    5. cube-multN/A

                      \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}\right)}{s \cdot \color{blue}{\left(s \cdot s\right)}}\right)\right) \]
                    6. unpow2N/A

                      \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}\right)}{s \cdot {s}^{\color{blue}{2}}}\right)\right) \]
                    7. associate-/r*N/A

                      \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}\right)}{s}}{\color{blue}{{s}^{2}}}\right)\right) \]
                    8. associate-*r/N/A

                      \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \frac{{x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}}{s}}{{\color{blue}{s}}^{2}}\right)\right) \]
                    9. /-lowering-/.f32N/A

                      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{/.f32}\left(\left(\frac{-1}{6} \cdot \frac{{x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}}{s}\right), \color{blue}{\left({s}^{2}\right)}\right)\right) \]
                  7. Simplified82.3%

                    \[\leadsto \frac{1}{\color{blue}{\frac{-0.16666666666666666 \cdot \frac{x \cdot \left(x \cdot x\right)}{s}}{s \cdot s}}} \]
                  8. Step-by-step derivation
                    1. clear-numN/A

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

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

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

                      \[\leadsto \mathsf{*.f32}\left(\left(\frac{s}{\frac{x \cdot \left(x \cdot x\right)}{s}}\right), \color{blue}{\left(\frac{s}{\frac{-1}{6}}\right)}\right) \]
                    5. /-lowering-/.f32N/A

                      \[\leadsto \mathsf{*.f32}\left(\mathsf{/.f32}\left(s, \left(\frac{x \cdot \left(x \cdot x\right)}{s}\right)\right), \left(\frac{\color{blue}{s}}{\frac{-1}{6}}\right)\right) \]
                    6. /-lowering-/.f32N/A

                      \[\leadsto \mathsf{*.f32}\left(\mathsf{/.f32}\left(s, \mathsf{/.f32}\left(\left(x \cdot \left(x \cdot x\right)\right), s\right)\right), \left(\frac{s}{\frac{-1}{6}}\right)\right) \]
                    7. *-lowering-*.f32N/A

                      \[\leadsto \mathsf{*.f32}\left(\mathsf{/.f32}\left(s, \mathsf{/.f32}\left(\mathsf{*.f32}\left(x, \left(x \cdot x\right)\right), s\right)\right), \left(\frac{s}{\frac{-1}{6}}\right)\right) \]
                    8. *-lowering-*.f32N/A

                      \[\leadsto \mathsf{*.f32}\left(\mathsf{/.f32}\left(s, \mathsf{/.f32}\left(\mathsf{*.f32}\left(x, \mathsf{*.f32}\left(x, x\right)\right), s\right)\right), \left(\frac{s}{\frac{-1}{6}}\right)\right) \]
                    9. /-lowering-/.f3279.8%

                      \[\leadsto \mathsf{*.f32}\left(\mathsf{/.f32}\left(s, \mathsf{/.f32}\left(\mathsf{*.f32}\left(x, \mathsf{*.f32}\left(x, x\right)\right), s\right)\right), \mathsf{/.f32}\left(s, \color{blue}{\frac{-1}{6}}\right)\right) \]
                  9. Applied egg-rr79.8%

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

                  if -1.99999996e-13 < x

                  1. Initial program 99.8%

                    \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
                  2. Add Preprocessing
                  3. Taylor expanded in x around 0

                    \[\leadsto \color{blue}{\frac{1}{2}} \]
                  4. Step-by-step derivation
                    1. Simplified50.1%

                      \[\leadsto \color{blue}{0.5} \]
                  5. Recombined 2 regimes into one program.
                  6. Add Preprocessing

                  Alternative 11: 59.6% accurate, 6.0× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.99999996490334 \cdot 10^{-13}:\\ \;\;\;\;\frac{s}{-0.16666666666666666} \cdot \frac{s}{\frac{x}{s} \cdot \left(x \cdot x\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \end{array} \]
                  (FPCore (x s)
                   :precision binary32
                   (if (<= x -1.99999996490334e-13)
                     (* (/ s -0.16666666666666666) (/ s (* (/ x s) (* x x))))
                     0.5))
                  float code(float x, float s) {
                  	float tmp;
                  	if (x <= -1.99999996490334e-13f) {
                  		tmp = (s / -0.16666666666666666f) * (s / ((x / s) * (x * x)));
                  	} else {
                  		tmp = 0.5f;
                  	}
                  	return tmp;
                  }
                  
                  real(4) function code(x, s)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: s
                      real(4) :: tmp
                      if (x <= (-1.99999996490334e-13)) then
                          tmp = (s / (-0.16666666666666666e0)) * (s / ((x / s) * (x * x)))
                      else
                          tmp = 0.5e0
                      end if
                      code = tmp
                  end function
                  
                  function code(x, s)
                  	tmp = Float32(0.0)
                  	if (x <= Float32(-1.99999996490334e-13))
                  		tmp = Float32(Float32(s / Float32(-0.16666666666666666)) * Float32(s / Float32(Float32(x / s) * Float32(x * x))));
                  	else
                  		tmp = Float32(0.5);
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(x, s)
                  	tmp = single(0.0);
                  	if (x <= single(-1.99999996490334e-13))
                  		tmp = (s / single(-0.16666666666666666)) * (s / ((x / s) * (x * x)));
                  	else
                  		tmp = single(0.5);
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;x \leq -1.99999996490334 \cdot 10^{-13}:\\
                  \;\;\;\;\frac{s}{-0.16666666666666666} \cdot \frac{s}{\frac{x}{s} \cdot \left(x \cdot x\right)}\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;0.5\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if x < -1.99999996e-13

                    1. Initial program 99.8%

                      \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
                    2. Add Preprocessing
                    3. Taylor expanded in x around 0

                      \[\leadsto \mathsf{/.f32}\left(1, \color{blue}{\left(2 + x \cdot \left(x \cdot \left(\frac{-1}{6} \cdot \frac{x}{{s}^{3}} + \frac{1}{2} \cdot \frac{1}{{s}^{2}}\right) - \frac{1}{s}\right)\right)}\right) \]
                    4. Simplified88.1%

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

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

                        \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot {x}^{3}}{\color{blue}{{s}^{3}}}\right)\right) \]
                      2. *-rgt-identityN/A

                        \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot 1\right)}{{s}^{3}}\right)\right) \]
                      3. metadata-evalN/A

                        \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot {1}^{3}\right)}{{s}^{3}}\right)\right) \]
                      4. log-EN/A

                        \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}\right)}{{s}^{3}}\right)\right) \]
                      5. cube-multN/A

                        \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}\right)}{s \cdot \color{blue}{\left(s \cdot s\right)}}\right)\right) \]
                      6. unpow2N/A

                        \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}\right)}{s \cdot {s}^{\color{blue}{2}}}\right)\right) \]
                      7. associate-/r*N/A

                        \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}\right)}{s}}{\color{blue}{{s}^{2}}}\right)\right) \]
                      8. associate-*r/N/A

                        \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \frac{{x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}}{s}}{{\color{blue}{s}}^{2}}\right)\right) \]
                      9. /-lowering-/.f32N/A

                        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{/.f32}\left(\left(\frac{-1}{6} \cdot \frac{{x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}}{s}\right), \color{blue}{\left({s}^{2}\right)}\right)\right) \]
                    7. Simplified82.3%

                      \[\leadsto \frac{1}{\color{blue}{\frac{-0.16666666666666666 \cdot \frac{x \cdot \left(x \cdot x\right)}{s}}{s \cdot s}}} \]
                    8. Step-by-step derivation
                      1. clear-numN/A

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

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

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

                        \[\leadsto \mathsf{*.f32}\left(\left(\frac{s}{\frac{x \cdot \left(x \cdot x\right)}{s}}\right), \color{blue}{\left(\frac{s}{\frac{-1}{6}}\right)}\right) \]
                      5. /-lowering-/.f32N/A

                        \[\leadsto \mathsf{*.f32}\left(\mathsf{/.f32}\left(s, \left(\frac{x \cdot \left(x \cdot x\right)}{s}\right)\right), \left(\frac{\color{blue}{s}}{\frac{-1}{6}}\right)\right) \]
                      6. /-lowering-/.f32N/A

                        \[\leadsto \mathsf{*.f32}\left(\mathsf{/.f32}\left(s, \mathsf{/.f32}\left(\left(x \cdot \left(x \cdot x\right)\right), s\right)\right), \left(\frac{s}{\frac{-1}{6}}\right)\right) \]
                      7. *-lowering-*.f32N/A

                        \[\leadsto \mathsf{*.f32}\left(\mathsf{/.f32}\left(s, \mathsf{/.f32}\left(\mathsf{*.f32}\left(x, \left(x \cdot x\right)\right), s\right)\right), \left(\frac{s}{\frac{-1}{6}}\right)\right) \]
                      8. *-lowering-*.f32N/A

                        \[\leadsto \mathsf{*.f32}\left(\mathsf{/.f32}\left(s, \mathsf{/.f32}\left(\mathsf{*.f32}\left(x, \mathsf{*.f32}\left(x, x\right)\right), s\right)\right), \left(\frac{s}{\frac{-1}{6}}\right)\right) \]
                      9. /-lowering-/.f3279.8%

                        \[\leadsto \mathsf{*.f32}\left(\mathsf{/.f32}\left(s, \mathsf{/.f32}\left(\mathsf{*.f32}\left(x, \mathsf{*.f32}\left(x, x\right)\right), s\right)\right), \mathsf{/.f32}\left(s, \color{blue}{\frac{-1}{6}}\right)\right) \]
                    9. Applied egg-rr79.8%

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

                        \[\leadsto \mathsf{*.f32}\left(\mathsf{/.f32}\left(s, \left(\frac{\left(x \cdot x\right) \cdot x}{s}\right)\right), \mathsf{/.f32}\left(s, \frac{-1}{6}\right)\right) \]
                      2. associate-/l*N/A

                        \[\leadsto \mathsf{*.f32}\left(\mathsf{/.f32}\left(s, \left(\left(x \cdot x\right) \cdot \frac{x}{s}\right)\right), \mathsf{/.f32}\left(s, \frac{-1}{6}\right)\right) \]
                      3. *-lowering-*.f32N/A

                        \[\leadsto \mathsf{*.f32}\left(\mathsf{/.f32}\left(s, \mathsf{*.f32}\left(\left(x \cdot x\right), \left(\frac{x}{s}\right)\right)\right), \mathsf{/.f32}\left(s, \frac{-1}{6}\right)\right) \]
                      4. *-lowering-*.f32N/A

                        \[\leadsto \mathsf{*.f32}\left(\mathsf{/.f32}\left(s, \mathsf{*.f32}\left(\mathsf{*.f32}\left(x, x\right), \left(\frac{x}{s}\right)\right)\right), \mathsf{/.f32}\left(s, \frac{-1}{6}\right)\right) \]
                      5. /-lowering-/.f3279.8%

                        \[\leadsto \mathsf{*.f32}\left(\mathsf{/.f32}\left(s, \mathsf{*.f32}\left(\mathsf{*.f32}\left(x, x\right), \mathsf{/.f32}\left(x, s\right)\right)\right), \mathsf{/.f32}\left(s, \frac{-1}{6}\right)\right) \]
                    11. Applied egg-rr79.8%

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

                    if -1.99999996e-13 < x

                    1. Initial program 99.8%

                      \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
                    2. Add Preprocessing
                    3. Taylor expanded in x around 0

                      \[\leadsto \color{blue}{\frac{1}{2}} \]
                    4. Step-by-step derivation
                      1. Simplified50.1%

                        \[\leadsto \color{blue}{0.5} \]
                    5. Recombined 2 regimes into one program.
                    6. Final simplification60.6%

                      \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.99999996490334 \cdot 10^{-13}:\\ \;\;\;\;\frac{s}{-0.16666666666666666} \cdot \frac{s}{\frac{x}{s} \cdot \left(x \cdot x\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
                    7. Add Preprocessing

                    Alternative 12: 59.6% accurate, 6.0× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.99999996490334 \cdot 10^{-13}:\\ \;\;\;\;s \cdot \frac{s}{\frac{-0.16666666666666666}{\frac{s}{x \cdot \left(x \cdot x\right)}}}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \end{array} \]
                    (FPCore (x s)
                     :precision binary32
                     (if (<= x -1.99999996490334e-13)
                       (* s (/ s (/ -0.16666666666666666 (/ s (* x (* x x))))))
                       0.5))
                    float code(float x, float s) {
                    	float tmp;
                    	if (x <= -1.99999996490334e-13f) {
                    		tmp = s * (s / (-0.16666666666666666f / (s / (x * (x * x)))));
                    	} else {
                    		tmp = 0.5f;
                    	}
                    	return tmp;
                    }
                    
                    real(4) function code(x, s)
                        real(4), intent (in) :: x
                        real(4), intent (in) :: s
                        real(4) :: tmp
                        if (x <= (-1.99999996490334e-13)) then
                            tmp = s * (s / ((-0.16666666666666666e0) / (s / (x * (x * x)))))
                        else
                            tmp = 0.5e0
                        end if
                        code = tmp
                    end function
                    
                    function code(x, s)
                    	tmp = Float32(0.0)
                    	if (x <= Float32(-1.99999996490334e-13))
                    		tmp = Float32(s * Float32(s / Float32(Float32(-0.16666666666666666) / Float32(s / Float32(x * Float32(x * x))))));
                    	else
                    		tmp = Float32(0.5);
                    	end
                    	return tmp
                    end
                    
                    function tmp_2 = code(x, s)
                    	tmp = single(0.0);
                    	if (x <= single(-1.99999996490334e-13))
                    		tmp = s * (s / (single(-0.16666666666666666) / (s / (x * (x * x)))));
                    	else
                    		tmp = single(0.5);
                    	end
                    	tmp_2 = tmp;
                    end
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    \mathbf{if}\;x \leq -1.99999996490334 \cdot 10^{-13}:\\
                    \;\;\;\;s \cdot \frac{s}{\frac{-0.16666666666666666}{\frac{s}{x \cdot \left(x \cdot x\right)}}}\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;0.5\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if x < -1.99999996e-13

                      1. Initial program 99.8%

                        \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
                      2. Add Preprocessing
                      3. Taylor expanded in x around 0

                        \[\leadsto \mathsf{/.f32}\left(1, \color{blue}{\left(2 + x \cdot \left(x \cdot \left(\frac{-1}{6} \cdot \frac{x}{{s}^{3}} + \frac{1}{2} \cdot \frac{1}{{s}^{2}}\right) - \frac{1}{s}\right)\right)}\right) \]
                      4. Simplified88.1%

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

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

                          \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot {x}^{3}}{\color{blue}{{s}^{3}}}\right)\right) \]
                        2. *-rgt-identityN/A

                          \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot 1\right)}{{s}^{3}}\right)\right) \]
                        3. metadata-evalN/A

                          \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot {1}^{3}\right)}{{s}^{3}}\right)\right) \]
                        4. log-EN/A

                          \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}\right)}{{s}^{3}}\right)\right) \]
                        5. cube-multN/A

                          \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}\right)}{s \cdot \color{blue}{\left(s \cdot s\right)}}\right)\right) \]
                        6. unpow2N/A

                          \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}\right)}{s \cdot {s}^{\color{blue}{2}}}\right)\right) \]
                        7. associate-/r*N/A

                          \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{\frac{-1}{6} \cdot \left({x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}\right)}{s}}{\color{blue}{{s}^{2}}}\right)\right) \]
                        8. associate-*r/N/A

                          \[\leadsto \mathsf{/.f32}\left(1, \left(\frac{\frac{-1}{6} \cdot \frac{{x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}}{s}}{{\color{blue}{s}}^{2}}\right)\right) \]
                        9. /-lowering-/.f32N/A

                          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{/.f32}\left(\left(\frac{-1}{6} \cdot \frac{{x}^{3} \cdot {\log \mathsf{E}\left(\right)}^{3}}{s}\right), \color{blue}{\left({s}^{2}\right)}\right)\right) \]
                      7. Simplified82.3%

                        \[\leadsto \frac{1}{\color{blue}{\frac{-0.16666666666666666 \cdot \frac{x \cdot \left(x \cdot x\right)}{s}}{s \cdot s}}} \]
                      8. Step-by-step derivation
                        1. clear-numN/A

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

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

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

                          \[\leadsto \mathsf{*.f32}\left(s, \mathsf{/.f32}\left(s, \color{blue}{\left(\frac{-1}{6} \cdot \frac{x \cdot \left(x \cdot x\right)}{s}\right)}\right)\right) \]
                        5. clear-numN/A

                          \[\leadsto \mathsf{*.f32}\left(s, \mathsf{/.f32}\left(s, \left(\frac{-1}{6} \cdot \frac{1}{\color{blue}{\frac{s}{x \cdot \left(x \cdot x\right)}}}\right)\right)\right) \]
                        6. un-div-invN/A

                          \[\leadsto \mathsf{*.f32}\left(s, \mathsf{/.f32}\left(s, \left(\frac{\frac{-1}{6}}{\color{blue}{\frac{s}{x \cdot \left(x \cdot x\right)}}}\right)\right)\right) \]
                        7. /-lowering-/.f32N/A

                          \[\leadsto \mathsf{*.f32}\left(s, \mathsf{/.f32}\left(s, \mathsf{/.f32}\left(\frac{-1}{6}, \color{blue}{\left(\frac{s}{x \cdot \left(x \cdot x\right)}\right)}\right)\right)\right) \]
                        8. /-lowering-/.f32N/A

                          \[\leadsto \mathsf{*.f32}\left(s, \mathsf{/.f32}\left(s, \mathsf{/.f32}\left(\frac{-1}{6}, \mathsf{/.f32}\left(s, \color{blue}{\left(x \cdot \left(x \cdot x\right)\right)}\right)\right)\right)\right) \]
                        9. *-lowering-*.f32N/A

                          \[\leadsto \mathsf{*.f32}\left(s, \mathsf{/.f32}\left(s, \mathsf{/.f32}\left(\frac{-1}{6}, \mathsf{/.f32}\left(s, \mathsf{*.f32}\left(x, \color{blue}{\left(x \cdot x\right)}\right)\right)\right)\right)\right) \]
                        10. *-lowering-*.f3279.8%

                          \[\leadsto \mathsf{*.f32}\left(s, \mathsf{/.f32}\left(s, \mathsf{/.f32}\left(\frac{-1}{6}, \mathsf{/.f32}\left(s, \mathsf{*.f32}\left(x, \mathsf{*.f32}\left(x, \color{blue}{x}\right)\right)\right)\right)\right)\right) \]
                      9. Applied egg-rr79.8%

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

                      if -1.99999996e-13 < x

                      1. Initial program 99.8%

                        \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
                      2. Add Preprocessing
                      3. Taylor expanded in x around 0

                        \[\leadsto \color{blue}{\frac{1}{2}} \]
                      4. Step-by-step derivation
                        1. Simplified50.1%

                          \[\leadsto \color{blue}{0.5} \]
                      5. Recombined 2 regimes into one program.
                      6. Add Preprocessing

                      Alternative 13: 51.0% accurate, 8.3× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.99999996490334 \cdot 10^{-13}:\\ \;\;\;\;\frac{\frac{s \cdot \left(-s\right)}{s}}{x}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \end{array} \]
                      (FPCore (x s)
                       :precision binary32
                       (if (<= x -1.99999996490334e-13) (/ (/ (* s (- s)) s) x) 0.5))
                      float code(float x, float s) {
                      	float tmp;
                      	if (x <= -1.99999996490334e-13f) {
                      		tmp = ((s * -s) / s) / x;
                      	} else {
                      		tmp = 0.5f;
                      	}
                      	return tmp;
                      }
                      
                      real(4) function code(x, s)
                          real(4), intent (in) :: x
                          real(4), intent (in) :: s
                          real(4) :: tmp
                          if (x <= (-1.99999996490334e-13)) then
                              tmp = ((s * -s) / s) / x
                          else
                              tmp = 0.5e0
                          end if
                          code = tmp
                      end function
                      
                      function code(x, s)
                      	tmp = Float32(0.0)
                      	if (x <= Float32(-1.99999996490334e-13))
                      		tmp = Float32(Float32(Float32(s * Float32(-s)) / s) / x);
                      	else
                      		tmp = Float32(0.5);
                      	end
                      	return tmp
                      end
                      
                      function tmp_2 = code(x, s)
                      	tmp = single(0.0);
                      	if (x <= single(-1.99999996490334e-13))
                      		tmp = ((s * -s) / s) / x;
                      	else
                      		tmp = single(0.5);
                      	end
                      	tmp_2 = tmp;
                      end
                      
                      \begin{array}{l}
                      
                      \\
                      \begin{array}{l}
                      \mathbf{if}\;x \leq -1.99999996490334 \cdot 10^{-13}:\\
                      \;\;\;\;\frac{\frac{s \cdot \left(-s\right)}{s}}{x}\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;0.5\\
                      
                      
                      \end{array}
                      \end{array}
                      
                      Derivation
                      1. Split input into 2 regimes
                      2. if x < -1.99999996e-13

                        1. Initial program 99.8%

                          \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
                        2. Add Preprocessing
                        3. Taylor expanded in x around 0

                          \[\leadsto \mathsf{/.f32}\left(1, \color{blue}{\left(2 + -1 \cdot \frac{x}{s}\right)}\right) \]
                        4. Step-by-step derivation
                          1. mul-1-negN/A

                            \[\leadsto \mathsf{/.f32}\left(1, \left(2 + \left(\mathsf{neg}\left(\frac{x}{s}\right)\right)\right)\right) \]
                          2. unsub-negN/A

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

                            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{\_.f32}\left(2, \color{blue}{\left(\frac{x}{s}\right)}\right)\right) \]
                          4. /-lowering-/.f3248.9%

                            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{\_.f32}\left(2, \mathsf{/.f32}\left(x, \color{blue}{s}\right)\right)\right) \]
                        5. Simplified48.9%

                          \[\leadsto \frac{1}{\color{blue}{2 - \frac{x}{s}}} \]
                        6. Taylor expanded in x around inf

                          \[\leadsto \color{blue}{-1 \cdot \frac{s}{x}} \]
                        7. Step-by-step derivation
                          1. mul-1-negN/A

                            \[\leadsto \mathsf{neg}\left(\frac{s}{x}\right) \]
                          2. neg-sub0N/A

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

                            \[\leadsto \mathsf{\_.f32}\left(0, \color{blue}{\left(\frac{s}{x}\right)}\right) \]
                          4. /-lowering-/.f3243.1%

                            \[\leadsto \mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(s, \color{blue}{x}\right)\right) \]
                        8. Simplified43.1%

                          \[\leadsto \color{blue}{0 - \frac{s}{x}} \]
                        9. Step-by-step derivation
                          1. sub0-negN/A

                            \[\leadsto \mathsf{neg}\left(\frac{s}{x}\right) \]
                          2. distribute-neg-fracN/A

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

                            \[\leadsto \mathsf{/.f32}\left(\left(\mathsf{neg}\left(s\right)\right), \color{blue}{x}\right) \]
                          4. neg-lowering-neg.f3243.1%

                            \[\leadsto \mathsf{/.f32}\left(\mathsf{neg.f32}\left(s\right), x\right) \]
                        10. Applied egg-rr43.1%

                          \[\leadsto \color{blue}{\frac{-s}{x}} \]
                        11. Step-by-step derivation
                          1. neg-sub0N/A

                            \[\leadsto \mathsf{/.f32}\left(\left(0 - s\right), x\right) \]
                          2. flip--N/A

                            \[\leadsto \mathsf{/.f32}\left(\left(\frac{0 \cdot 0 - s \cdot s}{0 + s}\right), x\right) \]
                          3. metadata-evalN/A

                            \[\leadsto \mathsf{/.f32}\left(\left(\frac{0 - s \cdot s}{0 + s}\right), x\right) \]
                          4. neg-sub0N/A

                            \[\leadsto \mathsf{/.f32}\left(\left(\frac{\mathsf{neg}\left(s \cdot s\right)}{0 + s}\right), x\right) \]
                          5. /-lowering-/.f32N/A

                            \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(\mathsf{neg}\left(s \cdot s\right)\right), \left(0 + s\right)\right), x\right) \]
                          6. neg-sub0N/A

                            \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(0 - s \cdot s\right), \left(0 + s\right)\right), x\right) \]
                          7. --lowering--.f32N/A

                            \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{\_.f32}\left(0, \left(s \cdot s\right)\right), \left(0 + s\right)\right), x\right) \]
                          8. *-lowering-*.f32N/A

                            \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{*.f32}\left(s, s\right)\right), \left(0 + s\right)\right), x\right) \]
                          9. +-lowering-+.f3258.9%

                            \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{*.f32}\left(s, s\right)\right), \mathsf{+.f32}\left(0, s\right)\right), x\right) \]
                        12. Applied egg-rr58.9%

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

                        if -1.99999996e-13 < x

                        1. Initial program 99.8%

                          \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
                        2. Add Preprocessing
                        3. Taylor expanded in x around 0

                          \[\leadsto \color{blue}{\frac{1}{2}} \]
                        4. Step-by-step derivation
                          1. Simplified50.1%

                            \[\leadsto \color{blue}{0.5} \]
                        5. Recombined 2 regimes into one program.
                        6. Final simplification53.2%

                          \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.99999996490334 \cdot 10^{-13}:\\ \;\;\;\;\frac{\frac{s \cdot \left(-s\right)}{s}}{x}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
                        7. Add Preprocessing

                        Alternative 14: 48.4% accurate, 9.0× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.9999999593223797 \cdot 10^{-31}:\\ \;\;\;\;\frac{1}{2 - \frac{x}{s}}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \end{array} \]
                        (FPCore (x s)
                         :precision binary32
                         (if (<= x -1.9999999593223797e-31) (/ 1.0 (- 2.0 (/ x s))) 0.5))
                        float code(float x, float s) {
                        	float tmp;
                        	if (x <= -1.9999999593223797e-31f) {
                        		tmp = 1.0f / (2.0f - (x / s));
                        	} else {
                        		tmp = 0.5f;
                        	}
                        	return tmp;
                        }
                        
                        real(4) function code(x, s)
                            real(4), intent (in) :: x
                            real(4), intent (in) :: s
                            real(4) :: tmp
                            if (x <= (-1.9999999593223797e-31)) then
                                tmp = 1.0e0 / (2.0e0 - (x / s))
                            else
                                tmp = 0.5e0
                            end if
                            code = tmp
                        end function
                        
                        function code(x, s)
                        	tmp = Float32(0.0)
                        	if (x <= Float32(-1.9999999593223797e-31))
                        		tmp = Float32(Float32(1.0) / Float32(Float32(2.0) - Float32(x / s)));
                        	else
                        		tmp = Float32(0.5);
                        	end
                        	return tmp
                        end
                        
                        function tmp_2 = code(x, s)
                        	tmp = single(0.0);
                        	if (x <= single(-1.9999999593223797e-31))
                        		tmp = single(1.0) / (single(2.0) - (x / s));
                        	else
                        		tmp = single(0.5);
                        	end
                        	tmp_2 = tmp;
                        end
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;x \leq -1.9999999593223797 \cdot 10^{-31}:\\
                        \;\;\;\;\frac{1}{2 - \frac{x}{s}}\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;0.5\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if x < -1.99999996e-31

                          1. Initial program 99.6%

                            \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
                          2. Add Preprocessing
                          3. Taylor expanded in x around 0

                            \[\leadsto \mathsf{/.f32}\left(1, \color{blue}{\left(2 + -1 \cdot \frac{x}{s}\right)}\right) \]
                          4. Step-by-step derivation
                            1. mul-1-negN/A

                              \[\leadsto \mathsf{/.f32}\left(1, \left(2 + \left(\mathsf{neg}\left(\frac{x}{s}\right)\right)\right)\right) \]
                            2. unsub-negN/A

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

                              \[\leadsto \mathsf{/.f32}\left(1, \mathsf{\_.f32}\left(2, \color{blue}{\left(\frac{x}{s}\right)}\right)\right) \]
                            4. /-lowering-/.f3252.2%

                              \[\leadsto \mathsf{/.f32}\left(1, \mathsf{\_.f32}\left(2, \mathsf{/.f32}\left(x, \color{blue}{s}\right)\right)\right) \]
                          5. Simplified52.2%

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

                          if -1.99999996e-31 < x

                          1. Initial program 99.9%

                            \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
                          2. Add Preprocessing
                          3. Taylor expanded in x around 0

                            \[\leadsto \color{blue}{\frac{1}{2}} \]
                          4. Step-by-step derivation
                            1. Simplified48.1%

                              \[\leadsto \color{blue}{0.5} \]
                          5. Recombined 2 regimes into one program.
                          6. Add Preprocessing

                          Alternative 15: 47.5% accurate, 10.8× speedup?

                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -4.999999969612645 \cdot 10^{-9}:\\ \;\;\;\;\frac{-1}{\frac{x}{s}}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \end{array} \]
                          (FPCore (x s)
                           :precision binary32
                           (if (<= x -4.999999969612645e-9) (/ -1.0 (/ x s)) 0.5))
                          float code(float x, float s) {
                          	float tmp;
                          	if (x <= -4.999999969612645e-9f) {
                          		tmp = -1.0f / (x / s);
                          	} else {
                          		tmp = 0.5f;
                          	}
                          	return tmp;
                          }
                          
                          real(4) function code(x, s)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: s
                              real(4) :: tmp
                              if (x <= (-4.999999969612645e-9)) then
                                  tmp = (-1.0e0) / (x / s)
                              else
                                  tmp = 0.5e0
                              end if
                              code = tmp
                          end function
                          
                          function code(x, s)
                          	tmp = Float32(0.0)
                          	if (x <= Float32(-4.999999969612645e-9))
                          		tmp = Float32(Float32(-1.0) / Float32(x / s));
                          	else
                          		tmp = Float32(0.5);
                          	end
                          	return tmp
                          end
                          
                          function tmp_2 = code(x, s)
                          	tmp = single(0.0);
                          	if (x <= single(-4.999999969612645e-9))
                          		tmp = single(-1.0) / (x / s);
                          	else
                          		tmp = single(0.5);
                          	end
                          	tmp_2 = tmp;
                          end
                          
                          \begin{array}{l}
                          
                          \\
                          \begin{array}{l}
                          \mathbf{if}\;x \leq -4.999999969612645 \cdot 10^{-9}:\\
                          \;\;\;\;\frac{-1}{\frac{x}{s}}\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;0.5\\
                          
                          
                          \end{array}
                          \end{array}
                          
                          Derivation
                          1. Split input into 2 regimes
                          2. if x < -4.99999997e-9

                            1. Initial program 99.8%

                              \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
                            2. Add Preprocessing
                            3. Taylor expanded in x around 0

                              \[\leadsto \mathsf{/.f32}\left(1, \color{blue}{\left(2 + -1 \cdot \frac{x}{s}\right)}\right) \]
                            4. Step-by-step derivation
                              1. mul-1-negN/A

                                \[\leadsto \mathsf{/.f32}\left(1, \left(2 + \left(\mathsf{neg}\left(\frac{x}{s}\right)\right)\right)\right) \]
                              2. unsub-negN/A

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

                                \[\leadsto \mathsf{/.f32}\left(1, \mathsf{\_.f32}\left(2, \color{blue}{\left(\frac{x}{s}\right)}\right)\right) \]
                              4. /-lowering-/.f3252.3%

                                \[\leadsto \mathsf{/.f32}\left(1, \mathsf{\_.f32}\left(2, \mathsf{/.f32}\left(x, \color{blue}{s}\right)\right)\right) \]
                            5. Simplified52.3%

                              \[\leadsto \frac{1}{\color{blue}{2 - \frac{x}{s}}} \]
                            6. Taylor expanded in x around inf

                              \[\leadsto \color{blue}{-1 \cdot \frac{s}{x}} \]
                            7. Step-by-step derivation
                              1. mul-1-negN/A

                                \[\leadsto \mathsf{neg}\left(\frac{s}{x}\right) \]
                              2. neg-sub0N/A

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

                                \[\leadsto \mathsf{\_.f32}\left(0, \color{blue}{\left(\frac{s}{x}\right)}\right) \]
                              4. /-lowering-/.f3248.2%

                                \[\leadsto \mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(s, \color{blue}{x}\right)\right) \]
                            8. Simplified48.2%

                              \[\leadsto \color{blue}{0 - \frac{s}{x}} \]
                            9. Step-by-step derivation
                              1. sub0-negN/A

                                \[\leadsto \mathsf{neg}\left(\frac{s}{x}\right) \]
                              2. clear-numN/A

                                \[\leadsto \mathsf{neg}\left(\frac{1}{\frac{x}{s}}\right) \]
                              3. distribute-neg-fracN/A

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

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

                                \[\leadsto \mathsf{/.f32}\left(-1, \color{blue}{\left(\frac{x}{s}\right)}\right) \]
                              6. /-lowering-/.f3252.3%

                                \[\leadsto \mathsf{/.f32}\left(-1, \mathsf{/.f32}\left(x, \color{blue}{s}\right)\right) \]
                            10. Applied egg-rr52.3%

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

                            if -4.99999997e-9 < x

                            1. Initial program 99.7%

                              \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
                            2. Add Preprocessing
                            3. Taylor expanded in x around 0

                              \[\leadsto \color{blue}{\frac{1}{2}} \]
                            4. Step-by-step derivation
                              1. Simplified48.2%

                                \[\leadsto \color{blue}{0.5} \]
                            5. Recombined 2 regimes into one program.
                            6. Add Preprocessing

                            Alternative 16: 46.2% accurate, 12.0× speedup?

                            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -4.999999969612645 \cdot 10^{-9}:\\ \;\;\;\;\frac{s}{-x}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \end{array} \]
                            (FPCore (x s)
                             :precision binary32
                             (if (<= x -4.999999969612645e-9) (/ s (- x)) 0.5))
                            float code(float x, float s) {
                            	float tmp;
                            	if (x <= -4.999999969612645e-9f) {
                            		tmp = s / -x;
                            	} else {
                            		tmp = 0.5f;
                            	}
                            	return tmp;
                            }
                            
                            real(4) function code(x, s)
                                real(4), intent (in) :: x
                                real(4), intent (in) :: s
                                real(4) :: tmp
                                if (x <= (-4.999999969612645e-9)) then
                                    tmp = s / -x
                                else
                                    tmp = 0.5e0
                                end if
                                code = tmp
                            end function
                            
                            function code(x, s)
                            	tmp = Float32(0.0)
                            	if (x <= Float32(-4.999999969612645e-9))
                            		tmp = Float32(s / Float32(-x));
                            	else
                            		tmp = Float32(0.5);
                            	end
                            	return tmp
                            end
                            
                            function tmp_2 = code(x, s)
                            	tmp = single(0.0);
                            	if (x <= single(-4.999999969612645e-9))
                            		tmp = s / -x;
                            	else
                            		tmp = single(0.5);
                            	end
                            	tmp_2 = tmp;
                            end
                            
                            \begin{array}{l}
                            
                            \\
                            \begin{array}{l}
                            \mathbf{if}\;x \leq -4.999999969612645 \cdot 10^{-9}:\\
                            \;\;\;\;\frac{s}{-x}\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;0.5\\
                            
                            
                            \end{array}
                            \end{array}
                            
                            Derivation
                            1. Split input into 2 regimes
                            2. if x < -4.99999997e-9

                              1. Initial program 99.8%

                                \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
                              2. Add Preprocessing
                              3. Taylor expanded in x around 0

                                \[\leadsto \mathsf{/.f32}\left(1, \color{blue}{\left(2 + -1 \cdot \frac{x}{s}\right)}\right) \]
                              4. Step-by-step derivation
                                1. mul-1-negN/A

                                  \[\leadsto \mathsf{/.f32}\left(1, \left(2 + \left(\mathsf{neg}\left(\frac{x}{s}\right)\right)\right)\right) \]
                                2. unsub-negN/A

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

                                  \[\leadsto \mathsf{/.f32}\left(1, \mathsf{\_.f32}\left(2, \color{blue}{\left(\frac{x}{s}\right)}\right)\right) \]
                                4. /-lowering-/.f3252.3%

                                  \[\leadsto \mathsf{/.f32}\left(1, \mathsf{\_.f32}\left(2, \mathsf{/.f32}\left(x, \color{blue}{s}\right)\right)\right) \]
                              5. Simplified52.3%

                                \[\leadsto \frac{1}{\color{blue}{2 - \frac{x}{s}}} \]
                              6. Taylor expanded in x around inf

                                \[\leadsto \color{blue}{-1 \cdot \frac{s}{x}} \]
                              7. Step-by-step derivation
                                1. mul-1-negN/A

                                  \[\leadsto \mathsf{neg}\left(\frac{s}{x}\right) \]
                                2. neg-sub0N/A

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

                                  \[\leadsto \mathsf{\_.f32}\left(0, \color{blue}{\left(\frac{s}{x}\right)}\right) \]
                                4. /-lowering-/.f3248.2%

                                  \[\leadsto \mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(s, \color{blue}{x}\right)\right) \]
                              8. Simplified48.2%

                                \[\leadsto \color{blue}{0 - \frac{s}{x}} \]
                              9. Step-by-step derivation
                                1. sub0-negN/A

                                  \[\leadsto \mathsf{neg}\left(\frac{s}{x}\right) \]
                                2. distribute-neg-fracN/A

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

                                  \[\leadsto \mathsf{/.f32}\left(\left(\mathsf{neg}\left(s\right)\right), \color{blue}{x}\right) \]
                                4. neg-lowering-neg.f3248.2%

                                  \[\leadsto \mathsf{/.f32}\left(\mathsf{neg.f32}\left(s\right), x\right) \]
                              10. Applied egg-rr48.2%

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

                              if -4.99999997e-9 < x

                              1. Initial program 99.7%

                                \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
                              2. Add Preprocessing
                              3. Taylor expanded in x around 0

                                \[\leadsto \color{blue}{\frac{1}{2}} \]
                              4. Step-by-step derivation
                                1. Simplified48.2%

                                  \[\leadsto \color{blue}{0.5} \]
                              5. Recombined 2 regimes into one program.
                              6. Final simplification48.2%

                                \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.999999969612645 \cdot 10^{-9}:\\ \;\;\;\;\frac{s}{-x}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
                              7. Add Preprocessing

                              Alternative 17: 34.9% accurate, 108.0× speedup?

                              \[\begin{array}{l} \\ 0.5 \end{array} \]
                              (FPCore (x s) :precision binary32 0.5)
                              float code(float x, float s) {
                              	return 0.5f;
                              }
                              
                              real(4) function code(x, s)
                                  real(4), intent (in) :: x
                                  real(4), intent (in) :: s
                                  code = 0.5e0
                              end function
                              
                              function code(x, s)
                              	return Float32(0.5)
                              end
                              
                              function tmp = code(x, s)
                              	tmp = single(0.5);
                              end
                              
                              \begin{array}{l}
                              
                              \\
                              0.5
                              \end{array}
                              
                              Derivation
                              1. Initial program 99.8%

                                \[\frac{1}{1 + e^{\frac{-x}{s}}} \]
                              2. Add Preprocessing
                              3. Taylor expanded in x around 0

                                \[\leadsto \color{blue}{\frac{1}{2}} \]
                              4. Step-by-step derivation
                                1. Simplified35.7%

                                  \[\leadsto \color{blue}{0.5} \]
                                2. Add Preprocessing

                                Reproduce

                                ?
                                herbie shell --seed 2024138 
                                (FPCore (x s)
                                  :name "Logistic function"
                                  :precision binary32
                                  :pre (and (<= 0.0 s) (<= s 1.0651631))
                                  (/ 1.0 (+ 1.0 (exp (/ (- x) s)))))