Sample trimmed logistic on [-pi, pi]

Percentage Accurate: 99.0% → 99.0%
Time: 17.5s
Alternatives: 11
Speedup: 1.3×

Specification

?
\[\left(2.328306437 \cdot 10^{-10} \leq u \land u \leq 1\right) \land \left(0 \leq s \land s \leq 1.0651631\right)\]
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{1 + e^{\frac{\pi}{s}}}\\ \left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\pi}{s}}} - t\_0\right) + t\_0} - 1\right) \end{array} \end{array} \]
(FPCore (u s)
 :precision binary32
 (let* ((t_0 (/ 1.0 (+ 1.0 (exp (/ PI s))))))
   (*
    (- s)
    (log
     (-
      (/ 1.0 (+ (* u (- (/ 1.0 (+ 1.0 (exp (/ (- PI) s)))) t_0)) t_0))
      1.0)))))
float code(float u, float s) {
	float t_0 = 1.0f / (1.0f + expf((((float) M_PI) / s)));
	return -s * logf(((1.0f / ((u * ((1.0f / (1.0f + expf((-((float) M_PI) / s)))) - t_0)) + t_0)) - 1.0f));
}
function code(u, s)
	t_0 = Float32(Float32(1.0) / Float32(Float32(1.0) + exp(Float32(Float32(pi) / s))))
	return Float32(Float32(-s) * log(Float32(Float32(Float32(1.0) / Float32(Float32(u * Float32(Float32(Float32(1.0) / Float32(Float32(1.0) + exp(Float32(Float32(-Float32(pi)) / s)))) - t_0)) + t_0)) - Float32(1.0))))
end
function tmp = code(u, s)
	t_0 = single(1.0) / (single(1.0) + exp((single(pi) / s)));
	tmp = -s * log(((single(1.0) / ((u * ((single(1.0) / (single(1.0) + exp((-single(pi) / s)))) - t_0)) + t_0)) - single(1.0)));
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{1}{1 + e^{\frac{\pi}{s}}}\\
\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\pi}{s}}} - t\_0\right) + t\_0} - 1\right)
\end{array}
\end{array}

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 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.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{1 + e^{\frac{\pi}{s}}}\\ \left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\pi}{s}}} - t\_0\right) + t\_0} - 1\right) \end{array} \end{array} \]
(FPCore (u s)
 :precision binary32
 (let* ((t_0 (/ 1.0 (+ 1.0 (exp (/ PI s))))))
   (*
    (- s)
    (log
     (-
      (/ 1.0 (+ (* u (- (/ 1.0 (+ 1.0 (exp (/ (- PI) s)))) t_0)) t_0))
      1.0)))))
float code(float u, float s) {
	float t_0 = 1.0f / (1.0f + expf((((float) M_PI) / s)));
	return -s * logf(((1.0f / ((u * ((1.0f / (1.0f + expf((-((float) M_PI) / s)))) - t_0)) + t_0)) - 1.0f));
}
function code(u, s)
	t_0 = Float32(Float32(1.0) / Float32(Float32(1.0) + exp(Float32(Float32(pi) / s))))
	return Float32(Float32(-s) * log(Float32(Float32(Float32(1.0) / Float32(Float32(u * Float32(Float32(Float32(1.0) / Float32(Float32(1.0) + exp(Float32(Float32(-Float32(pi)) / s)))) - t_0)) + t_0)) - Float32(1.0))))
end
function tmp = code(u, s)
	t_0 = single(1.0) / (single(1.0) + exp((single(pi) / s)));
	tmp = -s * log(((single(1.0) / ((u * ((single(1.0) / (single(1.0) + exp((-single(pi) / s)))) - t_0)) + t_0)) - single(1.0)));
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{1}{1 + e^{\frac{\pi}{s}}}\\
\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\pi}{s}}} - t\_0\right) + t\_0} - 1\right)
\end{array}
\end{array}

Alternative 1: 99.0% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{-\frac{\pi}{s}}} + \frac{1 - u}{1 + {e}^{\left(\frac{\pi}{s}\right)}}} + -1\right) \end{array} \]
(FPCore (u s)
 :precision binary32
 (*
  (- s)
  (log
   (+
    (/
     1.0
     (+
      (/ u (+ 1.0 (exp (- (/ PI s)))))
      (/ (- 1.0 u) (+ 1.0 (pow E (/ PI s))))))
    -1.0))))
float code(float u, float s) {
	return -s * logf(((1.0f / ((u / (1.0f + expf(-(((float) M_PI) / s)))) + ((1.0f - u) / (1.0f + powf(((float) M_E), (((float) M_PI) / s)))))) + -1.0f));
}
function code(u, s)
	return Float32(Float32(-s) * log(Float32(Float32(Float32(1.0) / Float32(Float32(u / Float32(Float32(1.0) + exp(Float32(-Float32(Float32(pi) / s))))) + Float32(Float32(Float32(1.0) - u) / Float32(Float32(1.0) + (Float32(exp(1)) ^ Float32(Float32(pi) / s)))))) + Float32(-1.0))))
end
function tmp = code(u, s)
	tmp = -s * log(((single(1.0) / ((u / (single(1.0) + exp(-(single(pi) / s)))) + ((single(1.0) - u) / (single(1.0) + (single(2.71828182845904523536) ^ (single(pi) / s)))))) + single(-1.0)));
end
\begin{array}{l}

\\
\left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{-\frac{\pi}{s}}} + \frac{1 - u}{1 + {e}^{\left(\frac{\pi}{s}\right)}}} + -1\right)
\end{array}
Derivation
  1. Initial program 98.8%

    \[\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\pi}{s}}} - \frac{1}{1 + e^{\frac{\pi}{s}}}\right) + \frac{1}{1 + e^{\frac{\pi}{s}}}} - 1\right) \]
  2. Simplified98.8%

    \[\leadsto \color{blue}{\left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{0 - \frac{\pi}{s}}} + \frac{1 - u}{1 + e^{\frac{\pi}{s}}}} + -1\right)} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. *-lft-identityN/A

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(u, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(1, \left({\left(e^{1}\right)}^{\left(\frac{\mathsf{PI}\left(\right)}{s}\right)}\right)\right)\right)\right)\right), -1\right)\right)\right) \]
    3. pow-lowering-pow.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(u, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(1, \mathsf{pow.f32}\left(\left(e^{1}\right), \left(\frac{\mathsf{PI}\left(\right)}{s}\right)\right)\right)\right)\right)\right), -1\right)\right)\right) \]
    4. exp-1-eN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(u, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(1, \mathsf{pow.f32}\left(\mathsf{E}\left(\right), \left(\frac{\mathsf{PI}\left(\right)}{s}\right)\right)\right)\right)\right)\right), -1\right)\right)\right) \]
    5. E-lowering-E.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(u, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(1, \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \left(\frac{\mathsf{PI}\left(\right)}{s}\right)\right)\right)\right)\right)\right), -1\right)\right)\right) \]
    6. /-lowering-/.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(u, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(1, \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{PI}\left(\right), s\right)\right)\right)\right)\right)\right), -1\right)\right)\right) \]
    7. PI-lowering-PI.f3298.8%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(u, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(1, \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right)\right), -1\right)\right)\right) \]
  5. Applied egg-rr98.8%

    \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{0 - \frac{\pi}{s}}} + \frac{1 - u}{1 + \color{blue}{{e}^{\left(\frac{\pi}{s}\right)}}}} + -1\right) \]
  6. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \log \left(\frac{1}{\frac{u}{1 + e^{0 - \frac{\mathsf{PI}\left(\right)}{s}}} + \frac{1 - u}{1 + {\mathsf{E}\left(\right)}^{\left(\frac{\mathsf{PI}\left(\right)}{s}\right)}}} + -1\right) \cdot \color{blue}{\left(\mathsf{neg}\left(s\right)\right)} \]
    2. distribute-rgt-neg-outN/A

      \[\leadsto \mathsf{neg}\left(\log \left(\frac{1}{\frac{u}{1 + e^{0 - \frac{\mathsf{PI}\left(\right)}{s}}} + \frac{1 - u}{1 + {\mathsf{E}\left(\right)}^{\left(\frac{\mathsf{PI}\left(\right)}{s}\right)}}} + -1\right) \cdot s\right) \]
    3. distribute-lft-neg-inN/A

      \[\leadsto \left(\mathsf{neg}\left(\log \left(\frac{1}{\frac{u}{1 + e^{0 - \frac{\mathsf{PI}\left(\right)}{s}}} + \frac{1 - u}{1 + {\mathsf{E}\left(\right)}^{\left(\frac{\mathsf{PI}\left(\right)}{s}\right)}}} + -1\right)\right)\right) \cdot \color{blue}{s} \]
    4. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\left(\mathsf{neg}\left(\log \left(\frac{1}{\frac{u}{1 + e^{0 - \frac{\mathsf{PI}\left(\right)}{s}}} + \frac{1 - u}{1 + {\mathsf{E}\left(\right)}^{\left(\frac{\mathsf{PI}\left(\right)}{s}\right)}}} + -1\right)\right)\right), \color{blue}{s}\right) \]
  7. Applied egg-rr98.8%

    \[\leadsto \color{blue}{\left(-\log \left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{e^{\frac{\pi}{s}} + 1}} + -1\right)\right) \cdot s} \]
  8. Step-by-step derivation
    1. *-lft-identityN/A

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(\mathsf{log.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(u, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{neg.f32}\left(s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(\left({\left(e^{1}\right)}^{\left(\frac{\mathsf{PI}\left(\right)}{s}\right)}\right), 1\right)\right)\right)\right), -1\right)\right)\right), s\right) \]
    3. pow-lowering-pow.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(\mathsf{log.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(u, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{neg.f32}\left(s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(\mathsf{pow.f32}\left(\left(e^{1}\right), \left(\frac{\mathsf{PI}\left(\right)}{s}\right)\right), 1\right)\right)\right)\right), -1\right)\right)\right), s\right) \]
    4. exp-1-eN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(\mathsf{log.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(u, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{neg.f32}\left(s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(\mathsf{pow.f32}\left(\mathsf{E}\left(\right), \left(\frac{\mathsf{PI}\left(\right)}{s}\right)\right), 1\right)\right)\right)\right), -1\right)\right)\right), s\right) \]
    5. E-lowering-E.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(\mathsf{log.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(u, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{neg.f32}\left(s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(\mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \left(\frac{\mathsf{PI}\left(\right)}{s}\right)\right), 1\right)\right)\right)\right), -1\right)\right)\right), s\right) \]
    6. /-lowering-/.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(\mathsf{log.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(u, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{neg.f32}\left(s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(\mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{PI}\left(\right), s\right)\right), 1\right)\right)\right)\right), -1\right)\right)\right), s\right) \]
    7. PI-lowering-PI.f3298.8%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(\mathsf{log.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(u, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{neg.f32}\left(s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(\mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right), 1\right)\right)\right)\right), -1\right)\right)\right), s\right) \]
  9. Applied egg-rr98.8%

    \[\leadsto \left(-\log \left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{\color{blue}{{e}^{\left(\frac{\pi}{s}\right)}} + 1}} + -1\right)\right) \cdot s \]
  10. Final simplification98.8%

    \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{-\frac{\pi}{s}}} + \frac{1 - u}{1 + {e}^{\left(\frac{\pi}{s}\right)}}} + -1\right) \]
  11. Add Preprocessing

Alternative 2: 99.0% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \left(-s\right) \cdot \log \left(-1 + \frac{1}{\frac{u}{1 + e^{-\frac{\pi}{s}}} + \frac{1 - u}{1 + e^{\frac{\pi}{s}}}}\right) \end{array} \]
(FPCore (u s)
 :precision binary32
 (*
  (- s)
  (log
   (+
    -1.0
    (/
     1.0
     (+
      (/ u (+ 1.0 (exp (- (/ PI s)))))
      (/ (- 1.0 u) (+ 1.0 (exp (/ PI s))))))))))
float code(float u, float s) {
	return -s * logf((-1.0f + (1.0f / ((u / (1.0f + expf(-(((float) M_PI) / s)))) + ((1.0f - u) / (1.0f + expf((((float) M_PI) / s))))))));
}
function code(u, s)
	return Float32(Float32(-s) * log(Float32(Float32(-1.0) + Float32(Float32(1.0) / Float32(Float32(u / Float32(Float32(1.0) + exp(Float32(-Float32(Float32(pi) / s))))) + Float32(Float32(Float32(1.0) - u) / Float32(Float32(1.0) + exp(Float32(Float32(pi) / s)))))))))
end
function tmp = code(u, s)
	tmp = -s * log((single(-1.0) + (single(1.0) / ((u / (single(1.0) + exp(-(single(pi) / s)))) + ((single(1.0) - u) / (single(1.0) + exp((single(pi) / s))))))));
end
\begin{array}{l}

\\
\left(-s\right) \cdot \log \left(-1 + \frac{1}{\frac{u}{1 + e^{-\frac{\pi}{s}}} + \frac{1 - u}{1 + e^{\frac{\pi}{s}}}}\right)
\end{array}
Derivation
  1. Initial program 98.8%

    \[\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\pi}{s}}} - \frac{1}{1 + e^{\frac{\pi}{s}}}\right) + \frac{1}{1 + e^{\frac{\pi}{s}}}} - 1\right) \]
  2. Simplified98.8%

    \[\leadsto \color{blue}{\left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{0 - \frac{\pi}{s}}} + \frac{1 - u}{1 + e^{\frac{\pi}{s}}}} + -1\right)} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \log \left(\frac{1}{\frac{u}{1 + e^{0 - \frac{\mathsf{PI}\left(\right)}{s}}} + \frac{1 - u}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}} + -1\right) \cdot \color{blue}{\left(\mathsf{neg}\left(s\right)\right)} \]
    2. neg-mul-1N/A

      \[\leadsto \log \left(\frac{1}{\frac{u}{1 + e^{0 - \frac{\mathsf{PI}\left(\right)}{s}}} + \frac{1 - u}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}} + -1\right) \cdot \left(-1 \cdot \color{blue}{s}\right) \]
    3. associate-*r*N/A

      \[\leadsto \left(\log \left(\frac{1}{\frac{u}{1 + e^{0 - \frac{\mathsf{PI}\left(\right)}{s}}} + \frac{1 - u}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}} + -1\right) \cdot -1\right) \cdot \color{blue}{s} \]
    4. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\left(\log \left(\frac{1}{\frac{u}{1 + e^{0 - \frac{\mathsf{PI}\left(\right)}{s}}} + \frac{1 - u}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}} + -1\right) \cdot -1\right), \color{blue}{s}\right) \]
  5. Applied egg-rr98.8%

    \[\leadsto \color{blue}{\left(-\log \left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{\frac{\pi}{s}}}} + -1\right)\right) \cdot s} \]
  6. Final simplification98.8%

    \[\leadsto \left(-s\right) \cdot \log \left(-1 + \frac{1}{\frac{u}{1 + e^{-\frac{\pi}{s}}} + \frac{1 - u}{1 + e^{\frac{\pi}{s}}}}\right) \]
  7. Add Preprocessing

Alternative 3: 97.7% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \left(-s\right) \cdot \log \left(\frac{1}{u} + \left(-1 + \frac{e^{-\frac{\pi}{s}}}{u}\right)\right) \end{array} \]
(FPCore (u s)
 :precision binary32
 (* (- s) (log (+ (/ 1.0 u) (+ -1.0 (/ (exp (- (/ PI s))) u))))))
float code(float u, float s) {
	return -s * logf(((1.0f / u) + (-1.0f + (expf(-(((float) M_PI) / s)) / u))));
}
function code(u, s)
	return Float32(Float32(-s) * log(Float32(Float32(Float32(1.0) / u) + Float32(Float32(-1.0) + Float32(exp(Float32(-Float32(Float32(pi) / s))) / u)))))
end
function tmp = code(u, s)
	tmp = -s * log(((single(1.0) / u) + (single(-1.0) + (exp(-(single(pi) / s)) / u))));
end
\begin{array}{l}

\\
\left(-s\right) \cdot \log \left(\frac{1}{u} + \left(-1 + \frac{e^{-\frac{\pi}{s}}}{u}\right)\right)
\end{array}
Derivation
  1. Initial program 98.8%

    \[\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\pi}{s}}} - \frac{1}{1 + e^{\frac{\pi}{s}}}\right) + \frac{1}{1 + e^{\frac{\pi}{s}}}} - 1\right) \]
  2. Simplified98.8%

    \[\leadsto \color{blue}{\left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{0 - \frac{\pi}{s}}} + \frac{1 - u}{1 + e^{\frac{\pi}{s}}}} + -1\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in s around -inf

    \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(u, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(1, \color{blue}{\left(1 + -1 \cdot \frac{-1 \cdot \mathsf{PI}\left(\right) + -1 \cdot \frac{\frac{1}{6} \cdot \frac{{\mathsf{PI}\left(\right)}^{3}}{s} + \frac{1}{2} \cdot {\mathsf{PI}\left(\right)}^{2}}{s}}{s}\right)}\right)\right)\right)\right), -1\right)\right)\right) \]
  5. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(u, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(1, \left(1 + \left(\mathsf{neg}\left(\frac{-1 \cdot \mathsf{PI}\left(\right) + -1 \cdot \frac{\frac{1}{6} \cdot \frac{{\mathsf{PI}\left(\right)}^{3}}{s} + \frac{1}{2} \cdot {\mathsf{PI}\left(\right)}^{2}}{s}}{s}\right)\right)\right)\right)\right)\right)\right), -1\right)\right)\right) \]
    2. unsub-negN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(u, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(1, \left(1 - \frac{-1 \cdot \mathsf{PI}\left(\right) + -1 \cdot \frac{\frac{1}{6} \cdot \frac{{\mathsf{PI}\left(\right)}^{3}}{s} + \frac{1}{2} \cdot {\mathsf{PI}\left(\right)}^{2}}{s}}{s}\right)\right)\right)\right)\right), -1\right)\right)\right) \]
    3. --lowering--.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(u, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(1, \left(\frac{-1 \cdot \mathsf{PI}\left(\right) + -1 \cdot \frac{\frac{1}{6} \cdot \frac{{\mathsf{PI}\left(\right)}^{3}}{s} + \frac{1}{2} \cdot {\mathsf{PI}\left(\right)}^{2}}{s}}{s}\right)\right)\right)\right)\right)\right), -1\right)\right)\right) \]
    4. /-lowering-/.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(u, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\left(-1 \cdot \mathsf{PI}\left(\right) + -1 \cdot \frac{\frac{1}{6} \cdot \frac{{\mathsf{PI}\left(\right)}^{3}}{s} + \frac{1}{2} \cdot {\mathsf{PI}\left(\right)}^{2}}{s}\right), s\right)\right)\right)\right)\right)\right), -1\right)\right)\right) \]
  6. Simplified94.2%

    \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{0 - \frac{\pi}{s}}} + \frac{1 - u}{1 + \color{blue}{\left(1 - \frac{\left(-\pi\right) - \frac{\frac{\left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot 0.16666666666666666}{s} + \pi \cdot \left(\pi \cdot 0.5\right)}{s}}{s}\right)}}} + -1\right) \]
  7. Taylor expanded in s around 0

    \[\leadsto \color{blue}{-1 \cdot \left(s \cdot \log \left(\left(\frac{1}{u} + \frac{e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{s}\right)}}{u}\right) - 1\right)\right)} \]
  8. Step-by-step derivation
    1. associate-*r*N/A

      \[\leadsto \left(-1 \cdot s\right) \cdot \color{blue}{\log \left(\left(\frac{1}{u} + \frac{e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{s}\right)}}{u}\right) - 1\right)} \]
    2. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\left(-1 \cdot s\right), \color{blue}{\log \left(\left(\frac{1}{u} + \frac{e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{s}\right)}}{u}\right) - 1\right)}\right) \]
    3. mul-1-negN/A

      \[\leadsto \mathsf{*.f32}\left(\left(\mathsf{neg}\left(s\right)\right), \log \color{blue}{\left(\left(\frac{1}{u} + \frac{e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{s}\right)}}{u}\right) - 1\right)}\right) \]
    4. neg-lowering-neg.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \log \color{blue}{\left(\left(\frac{1}{u} + \frac{e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{s}\right)}}{u}\right) - 1\right)}\right) \]
    5. log-lowering-log.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\left(\left(\frac{1}{u} + \frac{e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{s}\right)}}{u}\right) - 1\right)\right)\right) \]
    6. associate--l+N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\left(\frac{1}{u} + \left(\frac{e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{s}\right)}}{u} - 1\right)\right)\right)\right) \]
    7. +-lowering-+.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\mathsf{+.f32}\left(\left(\frac{1}{u}\right), \left(\frac{e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{s}\right)}}{u} - 1\right)\right)\right)\right) \]
    8. /-lowering-/.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, u\right), \left(\frac{e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{s}\right)}}{u} - 1\right)\right)\right)\right) \]
    9. sub-negN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, u\right), \left(\frac{e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{s}\right)}}{u} + \left(\mathsf{neg}\left(1\right)\right)\right)\right)\right)\right) \]
    10. metadata-evalN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, u\right), \left(\frac{e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{s}\right)}}{u} + -1\right)\right)\right)\right) \]
    11. +-lowering-+.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, u\right), \mathsf{+.f32}\left(\left(\frac{e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{s}\right)}}{u}\right), -1\right)\right)\right)\right) \]
  9. Simplified96.9%

    \[\leadsto \color{blue}{\left(-s\right) \cdot \log \left(\frac{1}{u} + \left(\frac{e^{0 - \frac{\pi}{s}}}{u} + -1\right)\right)} \]
  10. Final simplification96.9%

    \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{u} + \left(-1 + \frac{e^{-\frac{\pi}{s}}}{u}\right)\right) \]
  11. Add Preprocessing

Alternative 4: 24.9% accurate, 3.7× speedup?

\[\begin{array}{l} \\ \left(-s\right) \cdot \log \left(1 + \frac{\left(\pi \cdot \left(u \cdot 0.5\right) + \pi \cdot -0.25\right) \cdot -4}{s}\right) \end{array} \]
(FPCore (u s)
 :precision binary32
 (* (- s) (log (+ 1.0 (/ (* (+ (* PI (* u 0.5)) (* PI -0.25)) -4.0) s)))))
float code(float u, float s) {
	return -s * logf((1.0f + ((((((float) M_PI) * (u * 0.5f)) + (((float) M_PI) * -0.25f)) * -4.0f) / s)));
}
function code(u, s)
	return Float32(Float32(-s) * log(Float32(Float32(1.0) + Float32(Float32(Float32(Float32(Float32(pi) * Float32(u * Float32(0.5))) + Float32(Float32(pi) * Float32(-0.25))) * Float32(-4.0)) / s))))
end
function tmp = code(u, s)
	tmp = -s * log((single(1.0) + ((((single(pi) * (u * single(0.5))) + (single(pi) * single(-0.25))) * single(-4.0)) / s)));
end
\begin{array}{l}

\\
\left(-s\right) \cdot \log \left(1 + \frac{\left(\pi \cdot \left(u \cdot 0.5\right) + \pi \cdot -0.25\right) \cdot -4}{s}\right)
\end{array}
Derivation
  1. Initial program 98.8%

    \[\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\pi}{s}}} - \frac{1}{1 + e^{\frac{\pi}{s}}}\right) + \frac{1}{1 + e^{\frac{\pi}{s}}}} - 1\right) \]
  2. Simplified98.8%

    \[\leadsto \color{blue}{\left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{0 - \frac{\pi}{s}}} + \frac{1 - u}{1 + e^{\frac{\pi}{s}}}} + -1\right)} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. *-lft-identityN/A

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(u, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(1, \left({\left(e^{1}\right)}^{\left(\frac{\mathsf{PI}\left(\right)}{s}\right)}\right)\right)\right)\right)\right), -1\right)\right)\right) \]
    3. pow-lowering-pow.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(u, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(1, \mathsf{pow.f32}\left(\left(e^{1}\right), \left(\frac{\mathsf{PI}\left(\right)}{s}\right)\right)\right)\right)\right)\right), -1\right)\right)\right) \]
    4. exp-1-eN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(u, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(1, \mathsf{pow.f32}\left(\mathsf{E}\left(\right), \left(\frac{\mathsf{PI}\left(\right)}{s}\right)\right)\right)\right)\right)\right), -1\right)\right)\right) \]
    5. E-lowering-E.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(u, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(1, \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \left(\frac{\mathsf{PI}\left(\right)}{s}\right)\right)\right)\right)\right)\right), -1\right)\right)\right) \]
    6. /-lowering-/.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(u, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(1, \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{PI}\left(\right), s\right)\right)\right)\right)\right)\right), -1\right)\right)\right) \]
    7. PI-lowering-PI.f3298.8%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(u, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(1, \mathsf{pow.f32}\left(\mathsf{E.f32}\left(\right), \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right)\right), -1\right)\right)\right) \]
  5. Applied egg-rr98.8%

    \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{0 - \frac{\pi}{s}}} + \frac{1 - u}{1 + \color{blue}{{e}^{\left(\frac{\pi}{s}\right)}}}} + -1\right) \]
  6. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \log \left(\frac{1}{\frac{u}{1 + e^{0 - \frac{\mathsf{PI}\left(\right)}{s}}} + \frac{1 - u}{1 + {\mathsf{E}\left(\right)}^{\left(\frac{\mathsf{PI}\left(\right)}{s}\right)}}} + -1\right) \cdot \color{blue}{\left(\mathsf{neg}\left(s\right)\right)} \]
    2. distribute-rgt-neg-outN/A

      \[\leadsto \mathsf{neg}\left(\log \left(\frac{1}{\frac{u}{1 + e^{0 - \frac{\mathsf{PI}\left(\right)}{s}}} + \frac{1 - u}{1 + {\mathsf{E}\left(\right)}^{\left(\frac{\mathsf{PI}\left(\right)}{s}\right)}}} + -1\right) \cdot s\right) \]
    3. distribute-lft-neg-inN/A

      \[\leadsto \left(\mathsf{neg}\left(\log \left(\frac{1}{\frac{u}{1 + e^{0 - \frac{\mathsf{PI}\left(\right)}{s}}} + \frac{1 - u}{1 + {\mathsf{E}\left(\right)}^{\left(\frac{\mathsf{PI}\left(\right)}{s}\right)}}} + -1\right)\right)\right) \cdot \color{blue}{s} \]
    4. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\left(\mathsf{neg}\left(\log \left(\frac{1}{\frac{u}{1 + e^{0 - \frac{\mathsf{PI}\left(\right)}{s}}} + \frac{1 - u}{1 + {\mathsf{E}\left(\right)}^{\left(\frac{\mathsf{PI}\left(\right)}{s}\right)}}} + -1\right)\right)\right), \color{blue}{s}\right) \]
  7. Applied egg-rr98.8%

    \[\leadsto \color{blue}{\left(-\log \left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{e^{\frac{\pi}{s}} + 1}} + -1\right)\right) \cdot s} \]
  8. Taylor expanded in s around inf

    \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(\mathsf{log.f32}\left(\color{blue}{\left(1 + -4 \cdot \frac{\frac{1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) - \left(\frac{-1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)}{s}\right)}\right)\right), s\right) \]
  9. Step-by-step derivation
    1. +-lowering-+.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(\mathsf{log.f32}\left(\mathsf{+.f32}\left(1, \left(-4 \cdot \frac{\frac{1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) - \left(\frac{-1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)}{s}\right)\right)\right)\right), s\right) \]
    2. associate-*r/N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(\mathsf{log.f32}\left(\mathsf{+.f32}\left(1, \left(\frac{-4 \cdot \left(\frac{1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) - \left(\frac{-1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)\right)}{s}\right)\right)\right)\right), s\right) \]
    3. /-lowering-/.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(\mathsf{log.f32}\left(\mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\left(-4 \cdot \left(\frac{1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) - \left(\frac{-1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)\right)\right), s\right)\right)\right)\right), s\right) \]
  10. Simplified25.5%

    \[\leadsto \left(-\log \color{blue}{\left(1 + \frac{\left(\pi \cdot \left(0.5 \cdot u\right) + \pi \cdot -0.25\right) \cdot -4}{s}\right)}\right) \cdot s \]
  11. Final simplification25.5%

    \[\leadsto \left(-s\right) \cdot \log \left(1 + \frac{\left(\pi \cdot \left(u \cdot 0.5\right) + \pi \cdot -0.25\right) \cdot -4}{s}\right) \]
  12. Add Preprocessing

Alternative 5: 14.0% accurate, 27.1× speedup?

\[\begin{array}{l} \\ \frac{\pi}{s} \cdot \frac{\left(-s\right) \cdot \left(s + u \cdot \left(s \cdot -2\right)\right)}{s} \end{array} \]
(FPCore (u s)
 :precision binary32
 (* (/ PI s) (/ (* (- s) (+ s (* u (* s -2.0)))) s)))
float code(float u, float s) {
	return (((float) M_PI) / s) * ((-s * (s + (u * (s * -2.0f)))) / s);
}
function code(u, s)
	return Float32(Float32(Float32(pi) / s) * Float32(Float32(Float32(-s) * Float32(s + Float32(u * Float32(s * Float32(-2.0))))) / s))
end
function tmp = code(u, s)
	tmp = (single(pi) / s) * ((-s * (s + (u * (s * single(-2.0))))) / s);
end
\begin{array}{l}

\\
\frac{\pi}{s} \cdot \frac{\left(-s\right) \cdot \left(s + u \cdot \left(s \cdot -2\right)\right)}{s}
\end{array}
Derivation
  1. Initial program 98.8%

    \[\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\pi}{s}}} - \frac{1}{1 + e^{\frac{\pi}{s}}}\right) + \frac{1}{1 + e^{\frac{\pi}{s}}}} - 1\right) \]
  2. Simplified98.8%

    \[\leadsto \color{blue}{\left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{0 - \frac{\pi}{s}}} + \frac{1 - u}{1 + e^{\frac{\pi}{s}}}} + -1\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in s around inf

    \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \color{blue}{\left(-4 \cdot \frac{\frac{1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) - \left(\frac{-1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)}{s}\right)}\right) \]
  5. Step-by-step derivation
    1. associate-*r/N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \left(\frac{-4 \cdot \left(\frac{1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) - \left(\frac{-1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)\right)}{\color{blue}{s}}\right)\right) \]
    2. *-commutativeN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \left(\frac{\left(\frac{1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) - \left(\frac{-1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)\right) \cdot -4}{s}\right)\right) \]
    3. associate-/l*N/A

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{*.f32}\left(\left(\frac{1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) - \left(\frac{-1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)\right), \color{blue}{\left(\frac{-4}{s}\right)}\right)\right) \]
  6. Simplified12.2%

    \[\leadsto \left(-s\right) \cdot \color{blue}{\left(\left(\left(\pi \cdot u\right) \cdot 0.5 + \pi \cdot -0.25\right) \cdot \frac{-4}{s}\right)} \]
  7. Taylor expanded in u around 0

    \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \color{blue}{\left(-2 \cdot \frac{u \cdot \mathsf{PI}\left(\right)}{s} + \frac{\mathsf{PI}\left(\right)}{s}\right)}\right) \]
  8. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \left(\frac{\mathsf{PI}\left(\right)}{s} + \color{blue}{-2 \cdot \frac{u \cdot \mathsf{PI}\left(\right)}{s}}\right)\right) \]
    2. +-lowering-+.f32N/A

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{PI}\left(\right), s\right), \left(\color{blue}{-2} \cdot \frac{u \cdot \mathsf{PI}\left(\right)}{s}\right)\right)\right) \]
    4. PI-lowering-PI.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \left(-2 \cdot \frac{u \cdot \mathsf{PI}\left(\right)}{s}\right)\right)\right) \]
    5. associate-*r/N/A

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \mathsf{/.f32}\left(\left(-2 \cdot \left(u \cdot \mathsf{PI}\left(\right)\right)\right), \color{blue}{s}\right)\right)\right) \]
    7. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(-2, \left(u \cdot \mathsf{PI}\left(\right)\right)\right), s\right)\right)\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(-2, \left(\mathsf{PI}\left(\right) \cdot u\right)\right), s\right)\right)\right) \]
    9. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(\mathsf{PI}\left(\right), u\right)\right), s\right)\right)\right) \]
    10. PI-lowering-PI.f3212.2%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), u\right)\right), s\right)\right)\right) \]
  9. Simplified12.2%

    \[\leadsto \left(-s\right) \cdot \color{blue}{\left(\frac{\pi}{s} + \frac{-2 \cdot \left(\pi \cdot u\right)}{s}\right)} \]
  10. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \left(\frac{-2 \cdot \left(\mathsf{PI}\left(\right) \cdot u\right)}{s} + \color{blue}{\frac{\mathsf{PI}\left(\right)}{s}}\right)\right) \]
    2. clear-numN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \left(\frac{-2 \cdot \left(\mathsf{PI}\left(\right) \cdot u\right)}{s} + \frac{1}{\color{blue}{\frac{s}{\mathsf{PI}\left(\right)}}}\right)\right) \]
    3. frac-addN/A

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{/.f32}\left(\left(\left(-2 \cdot \left(\mathsf{PI}\left(\right) \cdot u\right)\right) \cdot \frac{s}{\mathsf{PI}\left(\right)} + s \cdot 1\right), \color{blue}{\left(s \cdot \frac{s}{\mathsf{PI}\left(\right)}\right)}\right)\right) \]
  11. Applied egg-rr10.7%

    \[\leadsto \left(-s\right) \cdot \color{blue}{\frac{\frac{u \cdot \left(\pi \cdot -2\right)}{\frac{\pi}{s}} + s}{\frac{s}{\frac{\pi}{s}}}} \]
  12. Step-by-step derivation
    1. associate-*r/N/A

      \[\leadsto \frac{\left(\mathsf{neg}\left(s\right)\right) \cdot \left(\frac{u \cdot \left(\mathsf{PI}\left(\right) \cdot -2\right)}{\frac{\mathsf{PI}\left(\right)}{s}} + s\right)}{\color{blue}{\frac{s}{\frac{\mathsf{PI}\left(\right)}{s}}}} \]
    2. associate-/r/N/A

      \[\leadsto \frac{\left(\mathsf{neg}\left(s\right)\right) \cdot \left(\frac{u \cdot \left(\mathsf{PI}\left(\right) \cdot -2\right)}{\frac{\mathsf{PI}\left(\right)}{s}} + s\right)}{s} \cdot \color{blue}{\frac{\mathsf{PI}\left(\right)}{s}} \]
    3. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\left(\frac{\left(\mathsf{neg}\left(s\right)\right) \cdot \left(\frac{u \cdot \left(\mathsf{PI}\left(\right) \cdot -2\right)}{\frac{\mathsf{PI}\left(\right)}{s}} + s\right)}{s}\right), \color{blue}{\left(\frac{\mathsf{PI}\left(\right)}{s}\right)}\right) \]
  13. Applied egg-rr14.7%

    \[\leadsto \color{blue}{\frac{\left(-s\right) \cdot \left(s + u \cdot \left(1 \cdot \left(-2 \cdot s\right)\right)\right)}{s} \cdot \frac{\pi}{s}} \]
  14. Final simplification14.7%

    \[\leadsto \frac{\pi}{s} \cdot \frac{\left(-s\right) \cdot \left(s + u \cdot \left(s \cdot -2\right)\right)}{s} \]
  15. Add Preprocessing

Alternative 6: 11.5% accurate, 30.9× speedup?

\[\begin{array}{l} \\ s \cdot \left(\frac{\pi}{s} \cdot \frac{-0.25 + \frac{u}{2}}{--0.25}\right) \end{array} \]
(FPCore (u s)
 :precision binary32
 (* s (* (/ PI s) (/ (+ -0.25 (/ u 2.0)) (- -0.25)))))
float code(float u, float s) {
	return s * ((((float) M_PI) / s) * ((-0.25f + (u / 2.0f)) / -(-0.25f)));
}
function code(u, s)
	return Float32(s * Float32(Float32(Float32(pi) / s) * Float32(Float32(Float32(-0.25) + Float32(u / Float32(2.0))) / Float32(-Float32(-0.25)))))
end
function tmp = code(u, s)
	tmp = s * ((single(pi) / s) * ((single(-0.25) + (u / single(2.0))) / -single(-0.25)));
end
\begin{array}{l}

\\
s \cdot \left(\frac{\pi}{s} \cdot \frac{-0.25 + \frac{u}{2}}{--0.25}\right)
\end{array}
Derivation
  1. Initial program 98.8%

    \[\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\pi}{s}}} - \frac{1}{1 + e^{\frac{\pi}{s}}}\right) + \frac{1}{1 + e^{\frac{\pi}{s}}}} - 1\right) \]
  2. Simplified98.8%

    \[\leadsto \color{blue}{\left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{0 - \frac{\pi}{s}}} + \frac{1 - u}{1 + e^{\frac{\pi}{s}}}} + -1\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in s around inf

    \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \color{blue}{\left(-4 \cdot \frac{\frac{1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) - \left(\frac{-1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)}{s}\right)}\right) \]
  5. Step-by-step derivation
    1. associate-*r/N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \left(\frac{-4 \cdot \left(\frac{1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) - \left(\frac{-1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)\right)}{\color{blue}{s}}\right)\right) \]
    2. *-commutativeN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \left(\frac{\left(\frac{1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) - \left(\frac{-1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)\right) \cdot -4}{s}\right)\right) \]
    3. associate-/l*N/A

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{*.f32}\left(\left(\frac{1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) - \left(\frac{-1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)\right), \color{blue}{\left(\frac{-4}{s}\right)}\right)\right) \]
  6. Simplified12.2%

    \[\leadsto \left(-s\right) \cdot \color{blue}{\left(\left(\left(\pi \cdot u\right) \cdot 0.5 + \pi \cdot -0.25\right) \cdot \frac{-4}{s}\right)} \]
  7. Step-by-step derivation
    1. clear-numN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \left(\left(\left(\mathsf{PI}\left(\right) \cdot u\right) \cdot \frac{1}{2} + \mathsf{PI}\left(\right) \cdot \frac{-1}{4}\right) \cdot \frac{1}{\color{blue}{\frac{s}{-4}}}\right)\right) \]
    2. un-div-invN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \left(\frac{\left(\mathsf{PI}\left(\right) \cdot u\right) \cdot \frac{1}{2} + \mathsf{PI}\left(\right) \cdot \frac{-1}{4}}{\color{blue}{\frac{s}{-4}}}\right)\right) \]
    3. associate-*l*N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \left(\frac{\mathsf{PI}\left(\right) \cdot \left(u \cdot \frac{1}{2}\right) + \mathsf{PI}\left(\right) \cdot \frac{-1}{4}}{\frac{s}{-4}}\right)\right) \]
    4. distribute-lft-outN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \left(\frac{\mathsf{PI}\left(\right) \cdot \left(u \cdot \frac{1}{2} + \frac{-1}{4}\right)}{\frac{\color{blue}{s}}{-4}}\right)\right) \]
    5. div-invN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \left(\frac{\mathsf{PI}\left(\right) \cdot \left(u \cdot \frac{1}{2} + \frac{-1}{4}\right)}{s \cdot \color{blue}{\frac{1}{-4}}}\right)\right) \]
    6. metadata-evalN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \left(\frac{\mathsf{PI}\left(\right) \cdot \left(u \cdot \frac{1}{2} + \frac{-1}{4}\right)}{s \cdot \frac{-1}{4}}\right)\right) \]
    7. times-fracN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \left(\frac{\mathsf{PI}\left(\right)}{s} \cdot \color{blue}{\frac{u \cdot \frac{1}{2} + \frac{-1}{4}}{\frac{-1}{4}}}\right)\right) \]
    8. *-lowering-*.f32N/A

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{*.f32}\left(\mathsf{/.f32}\left(\mathsf{PI}\left(\right), s\right), \left(\frac{\color{blue}{u \cdot \frac{1}{2} + \frac{-1}{4}}}{\frac{-1}{4}}\right)\right)\right) \]
    10. PI-lowering-PI.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{*.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \left(\frac{\color{blue}{u \cdot \frac{1}{2}} + \frac{-1}{4}}{\frac{-1}{4}}\right)\right)\right) \]
    11. /-lowering-/.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{*.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \mathsf{/.f32}\left(\left(u \cdot \frac{1}{2} + \frac{-1}{4}\right), \color{blue}{\frac{-1}{4}}\right)\right)\right) \]
    12. +-lowering-+.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{*.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\left(u \cdot \frac{1}{2}\right), \frac{-1}{4}\right), \frac{-1}{4}\right)\right)\right) \]
    13. metadata-evalN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{*.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\left(u \cdot \frac{1}{2}\right), \frac{-1}{4}\right), \frac{-1}{4}\right)\right)\right) \]
    14. metadata-evalN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{*.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\left(u \cdot \frac{1}{1 + 1}\right), \frac{-1}{4}\right), \frac{-1}{4}\right)\right)\right) \]
    15. div-invN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{*.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\left(\frac{u}{1 + 1}\right), \frac{-1}{4}\right), \frac{-1}{4}\right)\right)\right) \]
    16. /-lowering-/.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{*.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(u, \left(1 + 1\right)\right), \frac{-1}{4}\right), \frac{-1}{4}\right)\right)\right) \]
    17. metadata-eval12.2%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{*.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(u, 2\right), \frac{-1}{4}\right), \frac{-1}{4}\right)\right)\right) \]
  8. Applied egg-rr12.2%

    \[\leadsto \left(-s\right) \cdot \color{blue}{\left(\frac{\pi}{s} \cdot \frac{\frac{u}{2} + -0.25}{-0.25}\right)} \]
  9. Final simplification12.2%

    \[\leadsto s \cdot \left(\frac{\pi}{s} \cdot \frac{-0.25 + \frac{u}{2}}{--0.25}\right) \]
  10. Add Preprocessing

Alternative 7: 11.5% accurate, 33.3× speedup?

\[\begin{array}{l} \\ \frac{s}{\frac{1}{\frac{\pi \cdot \left(-1 - u \cdot -2\right)}{s}}} \end{array} \]
(FPCore (u s)
 :precision binary32
 (/ s (/ 1.0 (/ (* PI (- -1.0 (* u -2.0))) s))))
float code(float u, float s) {
	return s / (1.0f / ((((float) M_PI) * (-1.0f - (u * -2.0f))) / s));
}
function code(u, s)
	return Float32(s / Float32(Float32(1.0) / Float32(Float32(Float32(pi) * Float32(Float32(-1.0) - Float32(u * Float32(-2.0)))) / s)))
end
function tmp = code(u, s)
	tmp = s / (single(1.0) / ((single(pi) * (single(-1.0) - (u * single(-2.0)))) / s));
end
\begin{array}{l}

\\
\frac{s}{\frac{1}{\frac{\pi \cdot \left(-1 - u \cdot -2\right)}{s}}}
\end{array}
Derivation
  1. Initial program 98.8%

    \[\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\pi}{s}}} - \frac{1}{1 + e^{\frac{\pi}{s}}}\right) + \frac{1}{1 + e^{\frac{\pi}{s}}}} - 1\right) \]
  2. Simplified98.8%

    \[\leadsto \color{blue}{\left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{0 - \frac{\pi}{s}}} + \frac{1 - u}{1 + e^{\frac{\pi}{s}}}} + -1\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in s around inf

    \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \color{blue}{\left(-4 \cdot \frac{\frac{1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) - \left(\frac{-1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)}{s}\right)}\right) \]
  5. Step-by-step derivation
    1. associate-*r/N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \left(\frac{-4 \cdot \left(\frac{1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) - \left(\frac{-1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)\right)}{\color{blue}{s}}\right)\right) \]
    2. *-commutativeN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \left(\frac{\left(\frac{1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) - \left(\frac{-1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)\right) \cdot -4}{s}\right)\right) \]
    3. associate-/l*N/A

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{*.f32}\left(\left(\frac{1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) - \left(\frac{-1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)\right), \color{blue}{\left(\frac{-4}{s}\right)}\right)\right) \]
  6. Simplified12.2%

    \[\leadsto \left(-s\right) \cdot \color{blue}{\left(\left(\left(\pi \cdot u\right) \cdot 0.5 + \pi \cdot -0.25\right) \cdot \frac{-4}{s}\right)} \]
  7. Taylor expanded in u around 0

    \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \color{blue}{\left(-2 \cdot \frac{u \cdot \mathsf{PI}\left(\right)}{s} + \frac{\mathsf{PI}\left(\right)}{s}\right)}\right) \]
  8. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \left(\frac{\mathsf{PI}\left(\right)}{s} + \color{blue}{-2 \cdot \frac{u \cdot \mathsf{PI}\left(\right)}{s}}\right)\right) \]
    2. +-lowering-+.f32N/A

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{PI}\left(\right), s\right), \left(\color{blue}{-2} \cdot \frac{u \cdot \mathsf{PI}\left(\right)}{s}\right)\right)\right) \]
    4. PI-lowering-PI.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \left(-2 \cdot \frac{u \cdot \mathsf{PI}\left(\right)}{s}\right)\right)\right) \]
    5. associate-*r/N/A

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \mathsf{/.f32}\left(\left(-2 \cdot \left(u \cdot \mathsf{PI}\left(\right)\right)\right), \color{blue}{s}\right)\right)\right) \]
    7. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(-2, \left(u \cdot \mathsf{PI}\left(\right)\right)\right), s\right)\right)\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(-2, \left(\mathsf{PI}\left(\right) \cdot u\right)\right), s\right)\right)\right) \]
    9. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(\mathsf{PI}\left(\right), u\right)\right), s\right)\right)\right) \]
    10. PI-lowering-PI.f3212.2%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), u\right)\right), s\right)\right)\right) \]
  9. Simplified12.2%

    \[\leadsto \left(-s\right) \cdot \color{blue}{\left(\frac{\pi}{s} + \frac{-2 \cdot \left(\pi \cdot u\right)}{s}\right)} \]
  10. Applied egg-rr12.2%

    \[\leadsto \color{blue}{\frac{-s}{\frac{1}{\frac{\pi \cdot \left(u \cdot -2 + 1\right)}{s}}}} \]
  11. Final simplification12.2%

    \[\leadsto \frac{s}{\frac{1}{\frac{\pi \cdot \left(-1 - u \cdot -2\right)}{s}}} \]
  12. Add Preprocessing

Alternative 8: 11.5% accurate, 39.4× speedup?

\[\begin{array}{l} \\ s \cdot \frac{\pi \cdot \left(-1 - u \cdot -2\right)}{s} \end{array} \]
(FPCore (u s) :precision binary32 (* s (/ (* PI (- -1.0 (* u -2.0))) s)))
float code(float u, float s) {
	return s * ((((float) M_PI) * (-1.0f - (u * -2.0f))) / s);
}
function code(u, s)
	return Float32(s * Float32(Float32(Float32(pi) * Float32(Float32(-1.0) - Float32(u * Float32(-2.0)))) / s))
end
function tmp = code(u, s)
	tmp = s * ((single(pi) * (single(-1.0) - (u * single(-2.0)))) / s);
end
\begin{array}{l}

\\
s \cdot \frac{\pi \cdot \left(-1 - u \cdot -2\right)}{s}
\end{array}
Derivation
  1. Initial program 98.8%

    \[\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\pi}{s}}} - \frac{1}{1 + e^{\frac{\pi}{s}}}\right) + \frac{1}{1 + e^{\frac{\pi}{s}}}} - 1\right) \]
  2. Simplified98.8%

    \[\leadsto \color{blue}{\left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{0 - \frac{\pi}{s}}} + \frac{1 - u}{1 + e^{\frac{\pi}{s}}}} + -1\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in s around inf

    \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \color{blue}{\left(-4 \cdot \frac{\frac{1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) - \left(\frac{-1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)}{s}\right)}\right) \]
  5. Step-by-step derivation
    1. associate-*r/N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \left(\frac{-4 \cdot \left(\frac{1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) - \left(\frac{-1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)\right)}{\color{blue}{s}}\right)\right) \]
    2. *-commutativeN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \left(\frac{\left(\frac{1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) - \left(\frac{-1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)\right) \cdot -4}{s}\right)\right) \]
    3. associate-/l*N/A

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{*.f32}\left(\left(\frac{1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) - \left(\frac{-1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)\right), \color{blue}{\left(\frac{-4}{s}\right)}\right)\right) \]
  6. Simplified12.2%

    \[\leadsto \left(-s\right) \cdot \color{blue}{\left(\left(\left(\pi \cdot u\right) \cdot 0.5 + \pi \cdot -0.25\right) \cdot \frac{-4}{s}\right)} \]
  7. Taylor expanded in u around 0

    \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \color{blue}{\left(-2 \cdot \frac{u \cdot \mathsf{PI}\left(\right)}{s} + \frac{\mathsf{PI}\left(\right)}{s}\right)}\right) \]
  8. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \left(\frac{\mathsf{PI}\left(\right)}{s} + \color{blue}{-2 \cdot \frac{u \cdot \mathsf{PI}\left(\right)}{s}}\right)\right) \]
    2. +-lowering-+.f32N/A

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{PI}\left(\right), s\right), \left(\color{blue}{-2} \cdot \frac{u \cdot \mathsf{PI}\left(\right)}{s}\right)\right)\right) \]
    4. PI-lowering-PI.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \left(-2 \cdot \frac{u \cdot \mathsf{PI}\left(\right)}{s}\right)\right)\right) \]
    5. associate-*r/N/A

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \mathsf{/.f32}\left(\left(-2 \cdot \left(u \cdot \mathsf{PI}\left(\right)\right)\right), \color{blue}{s}\right)\right)\right) \]
    7. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(-2, \left(u \cdot \mathsf{PI}\left(\right)\right)\right), s\right)\right)\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(-2, \left(\mathsf{PI}\left(\right) \cdot u\right)\right), s\right)\right)\right) \]
    9. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(\mathsf{PI}\left(\right), u\right)\right), s\right)\right)\right) \]
    10. PI-lowering-PI.f3212.2%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), u\right)\right), s\right)\right)\right) \]
  9. Simplified12.2%

    \[\leadsto \left(-s\right) \cdot \color{blue}{\left(\frac{\pi}{s} + \frac{-2 \cdot \left(\pi \cdot u\right)}{s}\right)} \]
  10. Applied egg-rr12.2%

    \[\leadsto \color{blue}{\frac{\pi \cdot \left(u \cdot -2 + 1\right)}{s} \cdot \left(-s\right)} \]
  11. Final simplification12.2%

    \[\leadsto s \cdot \frac{\pi \cdot \left(-1 - u \cdot -2\right)}{s} \]
  12. Add Preprocessing

Alternative 9: 11.5% accurate, 61.9× speedup?

\[\begin{array}{l} \\ \pi \cdot \left(-1 + u \cdot 2\right) \end{array} \]
(FPCore (u s) :precision binary32 (* PI (+ -1.0 (* u 2.0))))
float code(float u, float s) {
	return ((float) M_PI) * (-1.0f + (u * 2.0f));
}
function code(u, s)
	return Float32(Float32(pi) * Float32(Float32(-1.0) + Float32(u * Float32(2.0))))
end
function tmp = code(u, s)
	tmp = single(pi) * (single(-1.0) + (u * single(2.0)));
end
\begin{array}{l}

\\
\pi \cdot \left(-1 + u \cdot 2\right)
\end{array}
Derivation
  1. Initial program 98.8%

    \[\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\pi}{s}}} - \frac{1}{1 + e^{\frac{\pi}{s}}}\right) + \frac{1}{1 + e^{\frac{\pi}{s}}}} - 1\right) \]
  2. Simplified98.8%

    \[\leadsto \color{blue}{\left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{0 - \frac{\pi}{s}}} + \frac{1 - u}{1 + e^{\frac{\pi}{s}}}} + -1\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in s around inf

    \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \color{blue}{\left(-4 \cdot \frac{\frac{1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) - \left(\frac{-1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)}{s}\right)}\right) \]
  5. Step-by-step derivation
    1. associate-*r/N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \left(\frac{-4 \cdot \left(\frac{1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) - \left(\frac{-1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)\right)}{\color{blue}{s}}\right)\right) \]
    2. *-commutativeN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \left(\frac{\left(\frac{1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) - \left(\frac{-1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)\right) \cdot -4}{s}\right)\right) \]
    3. associate-/l*N/A

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{*.f32}\left(\left(\frac{1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) - \left(\frac{-1}{4} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)\right), \color{blue}{\left(\frac{-4}{s}\right)}\right)\right) \]
  6. Simplified12.2%

    \[\leadsto \left(-s\right) \cdot \color{blue}{\left(\left(\left(\pi \cdot u\right) \cdot 0.5 + \pi \cdot -0.25\right) \cdot \frac{-4}{s}\right)} \]
  7. Taylor expanded in u around 0

    \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \color{blue}{\left(-2 \cdot \frac{u \cdot \mathsf{PI}\left(\right)}{s} + \frac{\mathsf{PI}\left(\right)}{s}\right)}\right) \]
  8. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \left(\frac{\mathsf{PI}\left(\right)}{s} + \color{blue}{-2 \cdot \frac{u \cdot \mathsf{PI}\left(\right)}{s}}\right)\right) \]
    2. +-lowering-+.f32N/A

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{PI}\left(\right), s\right), \left(\color{blue}{-2} \cdot \frac{u \cdot \mathsf{PI}\left(\right)}{s}\right)\right)\right) \]
    4. PI-lowering-PI.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \left(-2 \cdot \frac{u \cdot \mathsf{PI}\left(\right)}{s}\right)\right)\right) \]
    5. associate-*r/N/A

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \mathsf{/.f32}\left(\left(-2 \cdot \left(u \cdot \mathsf{PI}\left(\right)\right)\right), \color{blue}{s}\right)\right)\right) \]
    7. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(-2, \left(u \cdot \mathsf{PI}\left(\right)\right)\right), s\right)\right)\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(-2, \left(\mathsf{PI}\left(\right) \cdot u\right)\right), s\right)\right)\right) \]
    9. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(\mathsf{PI}\left(\right), u\right)\right), s\right)\right)\right) \]
    10. PI-lowering-PI.f3212.2%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), u\right)\right), s\right)\right)\right) \]
  9. Simplified12.2%

    \[\leadsto \left(-s\right) \cdot \color{blue}{\left(\frac{\pi}{s} + \frac{-2 \cdot \left(\pi \cdot u\right)}{s}\right)} \]
  10. Taylor expanded in s around 0

    \[\leadsto \color{blue}{-1 \cdot \left(\mathsf{PI}\left(\right) + -2 \cdot \left(u \cdot \mathsf{PI}\left(\right)\right)\right)} \]
  11. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto -1 \cdot \left(-2 \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \color{blue}{\mathsf{PI}\left(\right)}\right) \]
    2. distribute-lft-inN/A

      \[\leadsto -1 \cdot \left(-2 \cdot \left(u \cdot \mathsf{PI}\left(\right)\right)\right) + \color{blue}{-1 \cdot \mathsf{PI}\left(\right)} \]
    3. associate-*r*N/A

      \[\leadsto \left(-1 \cdot -2\right) \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \color{blue}{-1} \cdot \mathsf{PI}\left(\right) \]
    4. metadata-evalN/A

      \[\leadsto 2 \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + -1 \cdot \mathsf{PI}\left(\right) \]
    5. associate-*r*N/A

      \[\leadsto \left(2 \cdot u\right) \cdot \mathsf{PI}\left(\right) + \color{blue}{-1} \cdot \mathsf{PI}\left(\right) \]
    6. distribute-rgt-outN/A

      \[\leadsto \mathsf{PI}\left(\right) \cdot \color{blue}{\left(2 \cdot u + -1\right)} \]
    7. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{PI}\left(\right), \color{blue}{\left(2 \cdot u + -1\right)}\right) \]
    8. PI-lowering-PI.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \left(\color{blue}{2 \cdot u} + -1\right)\right) \]
    9. +-lowering-+.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{+.f32}\left(\left(2 \cdot u\right), \color{blue}{-1}\right)\right) \]
    10. *-lowering-*.f3212.2%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(2, u\right), -1\right)\right) \]
  12. Simplified12.2%

    \[\leadsto \color{blue}{\pi \cdot \left(2 \cdot u + -1\right)} \]
  13. Final simplification12.2%

    \[\leadsto \pi \cdot \left(-1 + u \cdot 2\right) \]
  14. Add Preprocessing

Alternative 10: 11.3% accurate, 61.9× speedup?

\[\begin{array}{l} \\ 0 - s \cdot \frac{\pi}{s} \end{array} \]
(FPCore (u s) :precision binary32 (- 0.0 (* s (/ PI s))))
float code(float u, float s) {
	return 0.0f - (s * (((float) M_PI) / s));
}
function code(u, s)
	return Float32(Float32(0.0) - Float32(s * Float32(Float32(pi) / s)))
end
function tmp = code(u, s)
	tmp = single(0.0) - (s * (single(pi) / s));
end
\begin{array}{l}

\\
0 - s \cdot \frac{\pi}{s}
\end{array}
Derivation
  1. Initial program 98.8%

    \[\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\pi}{s}}} - \frac{1}{1 + e^{\frac{\pi}{s}}}\right) + \frac{1}{1 + e^{\frac{\pi}{s}}}} - 1\right) \]
  2. Simplified98.8%

    \[\leadsto \color{blue}{\left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{0 - \frac{\pi}{s}}} + \frac{1 - u}{1 + e^{\frac{\pi}{s}}}} + -1\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in u around 0

    \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \color{blue}{\left(\frac{\mathsf{PI}\left(\right)}{s}\right)}\right) \]
  5. Step-by-step derivation
    1. /-lowering-/.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{/.f32}\left(\mathsf{PI}\left(\right), \color{blue}{s}\right)\right) \]
    2. PI-lowering-PI.f3212.0%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right) \]
  6. Simplified12.0%

    \[\leadsto \left(-s\right) \cdot \color{blue}{\frac{\pi}{s}} \]
  7. Final simplification12.0%

    \[\leadsto 0 - s \cdot \frac{\pi}{s} \]
  8. Add Preprocessing

Alternative 11: 11.3% accurate, 216.5× speedup?

\[\begin{array}{l} \\ -\pi \end{array} \]
(FPCore (u s) :precision binary32 (- PI))
float code(float u, float s) {
	return -((float) M_PI);
}
function code(u, s)
	return Float32(-Float32(pi))
end
function tmp = code(u, s)
	tmp = -single(pi);
end
\begin{array}{l}

\\
-\pi
\end{array}
Derivation
  1. Initial program 98.8%

    \[\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\pi}{s}}} - \frac{1}{1 + e^{\frac{\pi}{s}}}\right) + \frac{1}{1 + e^{\frac{\pi}{s}}}} - 1\right) \]
  2. Simplified98.8%

    \[\leadsto \color{blue}{\left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{0 - \frac{\pi}{s}}} + \frac{1 - u}{1 + e^{\frac{\pi}{s}}}} + -1\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in u around 0

    \[\leadsto \color{blue}{-1 \cdot \mathsf{PI}\left(\right)} \]
  5. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{neg}\left(\mathsf{PI}\left(\right)\right) \]
    2. neg-lowering-neg.f32N/A

      \[\leadsto \mathsf{neg.f32}\left(\mathsf{PI}\left(\right)\right) \]
    3. PI-lowering-PI.f3212.0%

      \[\leadsto \mathsf{neg.f32}\left(\mathsf{PI.f32}\left(\right)\right) \]
  6. Simplified12.0%

    \[\leadsto \color{blue}{-\pi} \]
  7. Add Preprocessing

Reproduce

?
herbie shell --seed 2024164 
(FPCore (u s)
  :name "Sample trimmed logistic on [-pi, pi]"
  :precision binary32
  :pre (and (and (<= 2.328306437e-10 u) (<= u 1.0)) (and (<= 0.0 s) (<= s 1.0651631)))
  (* (- s) (log (- (/ 1.0 (+ (* u (- (/ 1.0 (+ 1.0 (exp (/ (- PI) s)))) (/ 1.0 (+ 1.0 (exp (/ PI s)))))) (/ 1.0 (+ 1.0 (exp (/ PI s)))))) 1.0))))