Sample trimmed logistic on [-pi, pi]

Percentage Accurate: 99.0% → 99.0%
Time: 10.0s
Alternatives: 8
Speedup: 1.4×

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 8 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.4× speedup?

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

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

    \[\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. Step-by-step derivation
    1. distribute-lft-neg-out98.9%

      \[\leadsto \color{blue}{-s \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. distribute-rgt-neg-in98.9%

      \[\leadsto \color{blue}{s \cdot \left(-\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)\right)} \]
    3. sub-neg98.9%

      \[\leadsto s \cdot \left(-\log \color{blue}{\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}}}} + \left(-1\right)\right)}\right) \]
  3. Simplified98.9%

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

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

Alternative 2: 11.6% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \mathsf{log1p}\left(\mathsf{expm1}\left(s \cdot \left(-4 \cdot \frac{\pi \cdot \mathsf{fma}\left(-0.5, u, 0.25\right)}{s}\right)\right)\right) \end{array} \]
(FPCore (u s)
 :precision binary32
 (log1p (expm1 (* s (* -4.0 (/ (* PI (fma -0.5 u 0.25)) s))))))
float code(float u, float s) {
	return log1pf(expm1f((s * (-4.0f * ((((float) M_PI) * fmaf(-0.5f, u, 0.25f)) / s)))));
}
function code(u, s)
	return log1p(expm1(Float32(s * Float32(Float32(-4.0) * Float32(Float32(Float32(pi) * fma(Float32(-0.5), u, Float32(0.25))) / s)))))
end
\begin{array}{l}

\\
\mathsf{log1p}\left(\mathsf{expm1}\left(s \cdot \left(-4 \cdot \frac{\pi \cdot \mathsf{fma}\left(-0.5, u, 0.25\right)}{s}\right)\right)\right)
\end{array}
Derivation
  1. Initial program 98.9%

    \[\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. Step-by-step derivation
    1. distribute-lft-neg-out98.9%

      \[\leadsto \color{blue}{-s \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. distribute-rgt-neg-in98.9%

      \[\leadsto \color{blue}{s \cdot \left(-\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)\right)} \]
    3. sub-neg98.9%

      \[\leadsto s \cdot \left(-\log \color{blue}{\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}}}} + \left(-1\right)\right)}\right) \]
  3. Simplified98.9%

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

    \[\leadsto s \cdot \left(-\color{blue}{4 \cdot \frac{-0.25 \cdot \left(u \cdot \pi\right) - \left(0.25 \cdot \left(u \cdot \pi\right) + -0.25 \cdot \pi\right)}{s}}\right) \]
  5. Step-by-step derivation
    1. associate--r+11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\color{blue}{\left(-0.25 \cdot \left(u \cdot \pi\right) - 0.25 \cdot \left(u \cdot \pi\right)\right) - -0.25 \cdot \pi}}{s}\right) \]
    2. cancel-sign-sub-inv11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\color{blue}{\left(-0.25 \cdot \left(u \cdot \pi\right) - 0.25 \cdot \left(u \cdot \pi\right)\right) + \left(--0.25\right) \cdot \pi}}{s}\right) \]
    3. distribute-rgt-out--11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\color{blue}{\left(u \cdot \pi\right) \cdot \left(-0.25 - 0.25\right)} + \left(--0.25\right) \cdot \pi}{s}\right) \]
    4. *-commutative11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\color{blue}{\left(\pi \cdot u\right)} \cdot \left(-0.25 - 0.25\right) + \left(--0.25\right) \cdot \pi}{s}\right) \]
    5. metadata-eval11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\left(\pi \cdot u\right) \cdot \color{blue}{-0.5} + \left(--0.25\right) \cdot \pi}{s}\right) \]
    6. metadata-eval11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\left(\pi \cdot u\right) \cdot -0.5 + \color{blue}{0.25} \cdot \pi}{s}\right) \]
    7. *-commutative11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\left(\pi \cdot u\right) \cdot -0.5 + \color{blue}{\pi \cdot 0.25}}{s}\right) \]
  6. Simplified11.0%

    \[\leadsto s \cdot \left(-\color{blue}{4 \cdot \frac{\left(\pi \cdot u\right) \cdot -0.5 + \pi \cdot 0.25}{s}}\right) \]
  7. Step-by-step derivation
    1. *-un-lft-identity11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\color{blue}{1 \cdot \left(\left(\pi \cdot u\right) \cdot -0.5 + \pi \cdot 0.25\right)}}{s}\right) \]
    2. add-sqr-sqrt11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{1 \cdot \left(\left(\pi \cdot u\right) \cdot -0.5 + \pi \cdot 0.25\right)}{\color{blue}{\sqrt{s} \cdot \sqrt{s}}}\right) \]
    3. times-frac11.0%

      \[\leadsto s \cdot \left(-4 \cdot \color{blue}{\left(\frac{1}{\sqrt{s}} \cdot \frac{\left(\pi \cdot u\right) \cdot -0.5 + \pi \cdot 0.25}{\sqrt{s}}\right)}\right) \]
    4. +-commutative11.0%

      \[\leadsto s \cdot \left(-4 \cdot \left(\frac{1}{\sqrt{s}} \cdot \frac{\color{blue}{\pi \cdot 0.25 + \left(\pi \cdot u\right) \cdot -0.5}}{\sqrt{s}}\right)\right) \]
    5. fma-def11.0%

      \[\leadsto s \cdot \left(-4 \cdot \left(\frac{1}{\sqrt{s}} \cdot \frac{\color{blue}{\mathsf{fma}\left(\pi, 0.25, \left(\pi \cdot u\right) \cdot -0.5\right)}}{\sqrt{s}}\right)\right) \]
    6. associate-*l*11.0%

      \[\leadsto s \cdot \left(-4 \cdot \left(\frac{1}{\sqrt{s}} \cdot \frac{\mathsf{fma}\left(\pi, 0.25, \color{blue}{\pi \cdot \left(u \cdot -0.5\right)}\right)}{\sqrt{s}}\right)\right) \]
  8. Applied egg-rr11.0%

    \[\leadsto s \cdot \left(-4 \cdot \color{blue}{\left(\frac{1}{\sqrt{s}} \cdot \frac{\mathsf{fma}\left(\pi, 0.25, \pi \cdot \left(u \cdot -0.5\right)\right)}{\sqrt{s}}\right)}\right) \]
  9. Step-by-step derivation
    1. associate-*l/11.0%

      \[\leadsto s \cdot \left(-4 \cdot \color{blue}{\frac{1 \cdot \frac{\mathsf{fma}\left(\pi, 0.25, \pi \cdot \left(u \cdot -0.5\right)\right)}{\sqrt{s}}}{\sqrt{s}}}\right) \]
    2. *-lft-identity11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\color{blue}{\frac{\mathsf{fma}\left(\pi, 0.25, \pi \cdot \left(u \cdot -0.5\right)\right)}{\sqrt{s}}}}{\sqrt{s}}\right) \]
    3. fma-udef11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\frac{\color{blue}{\pi \cdot 0.25 + \pi \cdot \left(u \cdot -0.5\right)}}{\sqrt{s}}}{\sqrt{s}}\right) \]
    4. +-commutative11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\frac{\color{blue}{\pi \cdot \left(u \cdot -0.5\right) + \pi \cdot 0.25}}{\sqrt{s}}}{\sqrt{s}}\right) \]
    5. distribute-lft-out11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\frac{\color{blue}{\pi \cdot \left(u \cdot -0.5 + 0.25\right)}}{\sqrt{s}}}{\sqrt{s}}\right) \]
  10. Simplified11.0%

    \[\leadsto s \cdot \left(-4 \cdot \color{blue}{\frac{\frac{\pi \cdot \left(u \cdot -0.5 + 0.25\right)}{\sqrt{s}}}{\sqrt{s}}}\right) \]
  11. Step-by-step derivation
    1. log1p-expm1-u11.0%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(s \cdot \left(-4 \cdot \frac{\frac{\pi \cdot \left(u \cdot -0.5 + 0.25\right)}{\sqrt{s}}}{\sqrt{s}}\right)\right)\right)} \]
    2. distribute-lft-neg-in11.0%

      \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(s \cdot \color{blue}{\left(\left(-4\right) \cdot \frac{\frac{\pi \cdot \left(u \cdot -0.5 + 0.25\right)}{\sqrt{s}}}{\sqrt{s}}\right)}\right)\right) \]
    3. metadata-eval11.0%

      \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(s \cdot \left(\color{blue}{-4} \cdot \frac{\frac{\pi \cdot \left(u \cdot -0.5 + 0.25\right)}{\sqrt{s}}}{\sqrt{s}}\right)\right)\right) \]
    4. associate-/l/11.0%

      \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(s \cdot \left(-4 \cdot \color{blue}{\frac{\pi \cdot \left(u \cdot -0.5 + 0.25\right)}{\sqrt{s} \cdot \sqrt{s}}}\right)\right)\right) \]
    5. *-commutative11.0%

      \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(s \cdot \left(-4 \cdot \frac{\pi \cdot \left(\color{blue}{-0.5 \cdot u} + 0.25\right)}{\sqrt{s} \cdot \sqrt{s}}\right)\right)\right) \]
    6. fma-udef11.0%

      \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(s \cdot \left(-4 \cdot \frac{\pi \cdot \color{blue}{\mathsf{fma}\left(-0.5, u, 0.25\right)}}{\sqrt{s} \cdot \sqrt{s}}\right)\right)\right) \]
    7. add-sqr-sqrt11.0%

      \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(s \cdot \left(-4 \cdot \frac{\pi \cdot \mathsf{fma}\left(-0.5, u, 0.25\right)}{\color{blue}{s}}\right)\right)\right) \]
  12. Applied egg-rr11.0%

    \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(s \cdot \left(-4 \cdot \frac{\pi \cdot \mathsf{fma}\left(-0.5, u, 0.25\right)}{s}\right)\right)\right)} \]
  13. Final simplification11.0%

    \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(s \cdot \left(-4 \cdot \frac{\pi \cdot \mathsf{fma}\left(-0.5, u, 0.25\right)}{s}\right)\right)\right) \]

Alternative 3: 11.6% accurate, 2.3× speedup?

\[\begin{array}{l} \\ s \cdot \left(\mathsf{fma}\left(0.25, \frac{\pi}{s}, -0.5 \cdot \frac{u}{\frac{s}{\pi}}\right) \cdot \left(-4\right)\right) \end{array} \]
(FPCore (u s)
 :precision binary32
 (* s (* (fma 0.25 (/ PI s) (* -0.5 (/ u (/ s PI)))) (- 4.0))))
float code(float u, float s) {
	return s * (fmaf(0.25f, (((float) M_PI) / s), (-0.5f * (u / (s / ((float) M_PI))))) * -4.0f);
}
function code(u, s)
	return Float32(s * Float32(fma(Float32(0.25), Float32(Float32(pi) / s), Float32(Float32(-0.5) * Float32(u / Float32(s / Float32(pi))))) * Float32(-Float32(4.0))))
end
\begin{array}{l}

\\
s \cdot \left(\mathsf{fma}\left(0.25, \frac{\pi}{s}, -0.5 \cdot \frac{u}{\frac{s}{\pi}}\right) \cdot \left(-4\right)\right)
\end{array}
Derivation
  1. Initial program 98.9%

    \[\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. Step-by-step derivation
    1. distribute-lft-neg-out98.9%

      \[\leadsto \color{blue}{-s \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. distribute-rgt-neg-in98.9%

      \[\leadsto \color{blue}{s \cdot \left(-\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)\right)} \]
    3. sub-neg98.9%

      \[\leadsto s \cdot \left(-\log \color{blue}{\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}}}} + \left(-1\right)\right)}\right) \]
  3. Simplified98.9%

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

    \[\leadsto s \cdot \left(-\color{blue}{4 \cdot \frac{-0.25 \cdot \left(u \cdot \pi\right) - \left(0.25 \cdot \left(u \cdot \pi\right) + -0.25 \cdot \pi\right)}{s}}\right) \]
  5. Step-by-step derivation
    1. associate--r+11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\color{blue}{\left(-0.25 \cdot \left(u \cdot \pi\right) - 0.25 \cdot \left(u \cdot \pi\right)\right) - -0.25 \cdot \pi}}{s}\right) \]
    2. cancel-sign-sub-inv11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\color{blue}{\left(-0.25 \cdot \left(u \cdot \pi\right) - 0.25 \cdot \left(u \cdot \pi\right)\right) + \left(--0.25\right) \cdot \pi}}{s}\right) \]
    3. distribute-rgt-out--11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\color{blue}{\left(u \cdot \pi\right) \cdot \left(-0.25 - 0.25\right)} + \left(--0.25\right) \cdot \pi}{s}\right) \]
    4. *-commutative11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\color{blue}{\left(\pi \cdot u\right)} \cdot \left(-0.25 - 0.25\right) + \left(--0.25\right) \cdot \pi}{s}\right) \]
    5. metadata-eval11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\left(\pi \cdot u\right) \cdot \color{blue}{-0.5} + \left(--0.25\right) \cdot \pi}{s}\right) \]
    6. metadata-eval11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\left(\pi \cdot u\right) \cdot -0.5 + \color{blue}{0.25} \cdot \pi}{s}\right) \]
    7. *-commutative11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\left(\pi \cdot u\right) \cdot -0.5 + \color{blue}{\pi \cdot 0.25}}{s}\right) \]
  6. Simplified11.0%

    \[\leadsto s \cdot \left(-\color{blue}{4 \cdot \frac{\left(\pi \cdot u\right) \cdot -0.5 + \pi \cdot 0.25}{s}}\right) \]
  7. Step-by-step derivation
    1. *-un-lft-identity11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\color{blue}{1 \cdot \left(\left(\pi \cdot u\right) \cdot -0.5 + \pi \cdot 0.25\right)}}{s}\right) \]
    2. add-cube-cbrt11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{1 \cdot \left(\left(\pi \cdot u\right) \cdot -0.5 + \pi \cdot 0.25\right)}{\color{blue}{\left(\sqrt[3]{s} \cdot \sqrt[3]{s}\right) \cdot \sqrt[3]{s}}}\right) \]
    3. times-frac11.0%

      \[\leadsto s \cdot \left(-4 \cdot \color{blue}{\left(\frac{1}{\sqrt[3]{s} \cdot \sqrt[3]{s}} \cdot \frac{\left(\pi \cdot u\right) \cdot -0.5 + \pi \cdot 0.25}{\sqrt[3]{s}}\right)}\right) \]
    4. pow211.0%

      \[\leadsto s \cdot \left(-4 \cdot \left(\frac{1}{\color{blue}{{\left(\sqrt[3]{s}\right)}^{2}}} \cdot \frac{\left(\pi \cdot u\right) \cdot -0.5 + \pi \cdot 0.25}{\sqrt[3]{s}}\right)\right) \]
    5. +-commutative11.0%

      \[\leadsto s \cdot \left(-4 \cdot \left(\frac{1}{{\left(\sqrt[3]{s}\right)}^{2}} \cdot \frac{\color{blue}{\pi \cdot 0.25 + \left(\pi \cdot u\right) \cdot -0.5}}{\sqrt[3]{s}}\right)\right) \]
    6. fma-def11.0%

      \[\leadsto s \cdot \left(-4 \cdot \left(\frac{1}{{\left(\sqrt[3]{s}\right)}^{2}} \cdot \frac{\color{blue}{\mathsf{fma}\left(\pi, 0.25, \left(\pi \cdot u\right) \cdot -0.5\right)}}{\sqrt[3]{s}}\right)\right) \]
    7. associate-*l*11.0%

      \[\leadsto s \cdot \left(-4 \cdot \left(\frac{1}{{\left(\sqrt[3]{s}\right)}^{2}} \cdot \frac{\mathsf{fma}\left(\pi, 0.25, \color{blue}{\pi \cdot \left(u \cdot -0.5\right)}\right)}{\sqrt[3]{s}}\right)\right) \]
  8. Applied egg-rr11.0%

    \[\leadsto s \cdot \left(-4 \cdot \color{blue}{\left(\frac{1}{{\left(\sqrt[3]{s}\right)}^{2}} \cdot \frac{\mathsf{fma}\left(\pi, 0.25, \pi \cdot \left(u \cdot -0.5\right)\right)}{\sqrt[3]{s}}\right)}\right) \]
  9. Step-by-step derivation
    1. associate-*l/11.0%

      \[\leadsto s \cdot \left(-4 \cdot \color{blue}{\frac{1 \cdot \frac{\mathsf{fma}\left(\pi, 0.25, \pi \cdot \left(u \cdot -0.5\right)\right)}{\sqrt[3]{s}}}{{\left(\sqrt[3]{s}\right)}^{2}}}\right) \]
    2. *-lft-identity11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\color{blue}{\frac{\mathsf{fma}\left(\pi, 0.25, \pi \cdot \left(u \cdot -0.5\right)\right)}{\sqrt[3]{s}}}}{{\left(\sqrt[3]{s}\right)}^{2}}\right) \]
    3. fma-udef11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\frac{\color{blue}{\pi \cdot 0.25 + \pi \cdot \left(u \cdot -0.5\right)}}{\sqrt[3]{s}}}{{\left(\sqrt[3]{s}\right)}^{2}}\right) \]
    4. +-commutative11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\frac{\color{blue}{\pi \cdot \left(u \cdot -0.5\right) + \pi \cdot 0.25}}{\sqrt[3]{s}}}{{\left(\sqrt[3]{s}\right)}^{2}}\right) \]
    5. distribute-lft-out11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\frac{\color{blue}{\pi \cdot \left(u \cdot -0.5 + 0.25\right)}}{\sqrt[3]{s}}}{{\left(\sqrt[3]{s}\right)}^{2}}\right) \]
  10. Simplified11.0%

    \[\leadsto s \cdot \left(-4 \cdot \color{blue}{\frac{\frac{\pi \cdot \left(u \cdot -0.5 + 0.25\right)}{\sqrt[3]{s}}}{{\left(\sqrt[3]{s}\right)}^{2}}}\right) \]
  11. Taylor expanded in u around 0 11.0%

    \[\leadsto s \cdot \left(-4 \cdot \color{blue}{\left(0.25 \cdot \frac{\pi}{s} + -0.5 \cdot \frac{u \cdot \pi}{s}\right)}\right) \]
  12. Step-by-step derivation
    1. fma-def11.0%

      \[\leadsto s \cdot \left(-4 \cdot \color{blue}{\mathsf{fma}\left(0.25, \frac{\pi}{s}, -0.5 \cdot \frac{u \cdot \pi}{s}\right)}\right) \]
    2. associate-/l*11.0%

      \[\leadsto s \cdot \left(-4 \cdot \mathsf{fma}\left(0.25, \frac{\pi}{s}, -0.5 \cdot \color{blue}{\frac{u}{\frac{s}{\pi}}}\right)\right) \]
  13. Simplified11.0%

    \[\leadsto s \cdot \left(-4 \cdot \color{blue}{\mathsf{fma}\left(0.25, \frac{\pi}{s}, -0.5 \cdot \frac{u}{\frac{s}{\pi}}\right)}\right) \]
  14. Final simplification11.0%

    \[\leadsto s \cdot \left(\mathsf{fma}\left(0.25, \frac{\pi}{s}, -0.5 \cdot \frac{u}{\frac{s}{\pi}}\right) \cdot \left(-4\right)\right) \]

Alternative 4: 11.6% accurate, 3.5× speedup?

\[\begin{array}{l} \\ s \cdot \left(\frac{\pi}{s} \cdot \left(-4 \cdot \mathsf{fma}\left(-0.5, u, 0.25\right)\right)\right) \end{array} \]
(FPCore (u s)
 :precision binary32
 (* s (* (/ PI s) (* -4.0 (fma -0.5 u 0.25)))))
float code(float u, float s) {
	return s * ((((float) M_PI) / s) * (-4.0f * fmaf(-0.5f, u, 0.25f)));
}
function code(u, s)
	return Float32(s * Float32(Float32(Float32(pi) / s) * Float32(Float32(-4.0) * fma(Float32(-0.5), u, Float32(0.25)))))
end
\begin{array}{l}

\\
s \cdot \left(\frac{\pi}{s} \cdot \left(-4 \cdot \mathsf{fma}\left(-0.5, u, 0.25\right)\right)\right)
\end{array}
Derivation
  1. Initial program 98.9%

    \[\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. Step-by-step derivation
    1. distribute-lft-neg-out98.9%

      \[\leadsto \color{blue}{-s \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. distribute-rgt-neg-in98.9%

      \[\leadsto \color{blue}{s \cdot \left(-\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)\right)} \]
    3. sub-neg98.9%

      \[\leadsto s \cdot \left(-\log \color{blue}{\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}}}} + \left(-1\right)\right)}\right) \]
  3. Simplified98.9%

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

    \[\leadsto s \cdot \left(-\color{blue}{4 \cdot \frac{-0.25 \cdot \left(u \cdot \pi\right) - \left(0.25 \cdot \left(u \cdot \pi\right) + -0.25 \cdot \pi\right)}{s}}\right) \]
  5. Step-by-step derivation
    1. associate--r+11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\color{blue}{\left(-0.25 \cdot \left(u \cdot \pi\right) - 0.25 \cdot \left(u \cdot \pi\right)\right) - -0.25 \cdot \pi}}{s}\right) \]
    2. cancel-sign-sub-inv11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\color{blue}{\left(-0.25 \cdot \left(u \cdot \pi\right) - 0.25 \cdot \left(u \cdot \pi\right)\right) + \left(--0.25\right) \cdot \pi}}{s}\right) \]
    3. distribute-rgt-out--11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\color{blue}{\left(u \cdot \pi\right) \cdot \left(-0.25 - 0.25\right)} + \left(--0.25\right) \cdot \pi}{s}\right) \]
    4. *-commutative11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\color{blue}{\left(\pi \cdot u\right)} \cdot \left(-0.25 - 0.25\right) + \left(--0.25\right) \cdot \pi}{s}\right) \]
    5. metadata-eval11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\left(\pi \cdot u\right) \cdot \color{blue}{-0.5} + \left(--0.25\right) \cdot \pi}{s}\right) \]
    6. metadata-eval11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\left(\pi \cdot u\right) \cdot -0.5 + \color{blue}{0.25} \cdot \pi}{s}\right) \]
    7. *-commutative11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\left(\pi \cdot u\right) \cdot -0.5 + \color{blue}{\pi \cdot 0.25}}{s}\right) \]
  6. Simplified11.0%

    \[\leadsto s \cdot \left(-\color{blue}{4 \cdot \frac{\left(\pi \cdot u\right) \cdot -0.5 + \pi \cdot 0.25}{s}}\right) \]
  7. Step-by-step derivation
    1. *-un-lft-identity11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\color{blue}{1 \cdot \left(\left(\pi \cdot u\right) \cdot -0.5 + \pi \cdot 0.25\right)}}{s}\right) \]
    2. add-cube-cbrt11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{1 \cdot \left(\left(\pi \cdot u\right) \cdot -0.5 + \pi \cdot 0.25\right)}{\color{blue}{\left(\sqrt[3]{s} \cdot \sqrt[3]{s}\right) \cdot \sqrt[3]{s}}}\right) \]
    3. times-frac11.0%

      \[\leadsto s \cdot \left(-4 \cdot \color{blue}{\left(\frac{1}{\sqrt[3]{s} \cdot \sqrt[3]{s}} \cdot \frac{\left(\pi \cdot u\right) \cdot -0.5 + \pi \cdot 0.25}{\sqrt[3]{s}}\right)}\right) \]
    4. pow211.0%

      \[\leadsto s \cdot \left(-4 \cdot \left(\frac{1}{\color{blue}{{\left(\sqrt[3]{s}\right)}^{2}}} \cdot \frac{\left(\pi \cdot u\right) \cdot -0.5 + \pi \cdot 0.25}{\sqrt[3]{s}}\right)\right) \]
    5. +-commutative11.0%

      \[\leadsto s \cdot \left(-4 \cdot \left(\frac{1}{{\left(\sqrt[3]{s}\right)}^{2}} \cdot \frac{\color{blue}{\pi \cdot 0.25 + \left(\pi \cdot u\right) \cdot -0.5}}{\sqrt[3]{s}}\right)\right) \]
    6. fma-def11.0%

      \[\leadsto s \cdot \left(-4 \cdot \left(\frac{1}{{\left(\sqrt[3]{s}\right)}^{2}} \cdot \frac{\color{blue}{\mathsf{fma}\left(\pi, 0.25, \left(\pi \cdot u\right) \cdot -0.5\right)}}{\sqrt[3]{s}}\right)\right) \]
    7. associate-*l*11.0%

      \[\leadsto s \cdot \left(-4 \cdot \left(\frac{1}{{\left(\sqrt[3]{s}\right)}^{2}} \cdot \frac{\mathsf{fma}\left(\pi, 0.25, \color{blue}{\pi \cdot \left(u \cdot -0.5\right)}\right)}{\sqrt[3]{s}}\right)\right) \]
  8. Applied egg-rr11.0%

    \[\leadsto s \cdot \left(-4 \cdot \color{blue}{\left(\frac{1}{{\left(\sqrt[3]{s}\right)}^{2}} \cdot \frac{\mathsf{fma}\left(\pi, 0.25, \pi \cdot \left(u \cdot -0.5\right)\right)}{\sqrt[3]{s}}\right)}\right) \]
  9. Step-by-step derivation
    1. associate-*l/11.0%

      \[\leadsto s \cdot \left(-4 \cdot \color{blue}{\frac{1 \cdot \frac{\mathsf{fma}\left(\pi, 0.25, \pi \cdot \left(u \cdot -0.5\right)\right)}{\sqrt[3]{s}}}{{\left(\sqrt[3]{s}\right)}^{2}}}\right) \]
    2. *-lft-identity11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\color{blue}{\frac{\mathsf{fma}\left(\pi, 0.25, \pi \cdot \left(u \cdot -0.5\right)\right)}{\sqrt[3]{s}}}}{{\left(\sqrt[3]{s}\right)}^{2}}\right) \]
    3. fma-udef11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\frac{\color{blue}{\pi \cdot 0.25 + \pi \cdot \left(u \cdot -0.5\right)}}{\sqrt[3]{s}}}{{\left(\sqrt[3]{s}\right)}^{2}}\right) \]
    4. +-commutative11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\frac{\color{blue}{\pi \cdot \left(u \cdot -0.5\right) + \pi \cdot 0.25}}{\sqrt[3]{s}}}{{\left(\sqrt[3]{s}\right)}^{2}}\right) \]
    5. distribute-lft-out11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\frac{\color{blue}{\pi \cdot \left(u \cdot -0.5 + 0.25\right)}}{\sqrt[3]{s}}}{{\left(\sqrt[3]{s}\right)}^{2}}\right) \]
  10. Simplified11.0%

    \[\leadsto s \cdot \left(-4 \cdot \color{blue}{\frac{\frac{\pi \cdot \left(u \cdot -0.5 + 0.25\right)}{\sqrt[3]{s}}}{{\left(\sqrt[3]{s}\right)}^{2}}}\right) \]
  11. Step-by-step derivation
    1. div-inv11.0%

      \[\leadsto s \cdot \left(-4 \cdot \color{blue}{\left(\frac{\pi \cdot \left(u \cdot -0.5 + 0.25\right)}{\sqrt[3]{s}} \cdot \frac{1}{{\left(\sqrt[3]{s}\right)}^{2}}\right)}\right) \]
    2. associate-/l*11.0%

      \[\leadsto s \cdot \left(-4 \cdot \left(\color{blue}{\frac{\pi}{\frac{\sqrt[3]{s}}{u \cdot -0.5 + 0.25}}} \cdot \frac{1}{{\left(\sqrt[3]{s}\right)}^{2}}\right)\right) \]
    3. fma-def11.0%

      \[\leadsto s \cdot \left(-4 \cdot \left(\frac{\pi}{\frac{\sqrt[3]{s}}{\color{blue}{\mathsf{fma}\left(u, -0.5, 0.25\right)}}} \cdot \frac{1}{{\left(\sqrt[3]{s}\right)}^{2}}\right)\right) \]
  12. Applied egg-rr11.0%

    \[\leadsto s \cdot \left(-4 \cdot \color{blue}{\left(\frac{\pi}{\frac{\sqrt[3]{s}}{\mathsf{fma}\left(u, -0.5, 0.25\right)}} \cdot \frac{1}{{\left(\sqrt[3]{s}\right)}^{2}}\right)}\right) \]
  13. Step-by-step derivation
    1. associate-*l/11.0%

      \[\leadsto s \cdot \left(-4 \cdot \color{blue}{\frac{\pi \cdot \frac{1}{{\left(\sqrt[3]{s}\right)}^{2}}}{\frac{\sqrt[3]{s}}{\mathsf{fma}\left(u, -0.5, 0.25\right)}}}\right) \]
    2. fma-udef11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\pi \cdot \frac{1}{{\left(\sqrt[3]{s}\right)}^{2}}}{\frac{\sqrt[3]{s}}{\color{blue}{u \cdot -0.5 + 0.25}}}\right) \]
    3. *-commutative11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\pi \cdot \frac{1}{{\left(\sqrt[3]{s}\right)}^{2}}}{\frac{\sqrt[3]{s}}{\color{blue}{-0.5 \cdot u} + 0.25}}\right) \]
    4. +-commutative11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\pi \cdot \frac{1}{{\left(\sqrt[3]{s}\right)}^{2}}}{\frac{\sqrt[3]{s}}{\color{blue}{0.25 + -0.5 \cdot u}}}\right) \]
    5. associate-/r/11.0%

      \[\leadsto s \cdot \left(-4 \cdot \color{blue}{\left(\frac{\pi \cdot \frac{1}{{\left(\sqrt[3]{s}\right)}^{2}}}{\sqrt[3]{s}} \cdot \left(0.25 + -0.5 \cdot u\right)\right)}\right) \]
    6. associate-*r/11.0%

      \[\leadsto s \cdot \left(-4 \cdot \left(\frac{\color{blue}{\frac{\pi \cdot 1}{{\left(\sqrt[3]{s}\right)}^{2}}}}{\sqrt[3]{s}} \cdot \left(0.25 + -0.5 \cdot u\right)\right)\right) \]
    7. *-rgt-identity11.0%

      \[\leadsto s \cdot \left(-4 \cdot \left(\frac{\frac{\color{blue}{\pi}}{{\left(\sqrt[3]{s}\right)}^{2}}}{\sqrt[3]{s}} \cdot \left(0.25 + -0.5 \cdot u\right)\right)\right) \]
    8. +-commutative11.0%

      \[\leadsto s \cdot \left(-4 \cdot \left(\frac{\frac{\pi}{{\left(\sqrt[3]{s}\right)}^{2}}}{\sqrt[3]{s}} \cdot \color{blue}{\left(-0.5 \cdot u + 0.25\right)}\right)\right) \]
    9. fma-def11.0%

      \[\leadsto s \cdot \left(-4 \cdot \left(\frac{\frac{\pi}{{\left(\sqrt[3]{s}\right)}^{2}}}{\sqrt[3]{s}} \cdot \color{blue}{\mathsf{fma}\left(-0.5, u, 0.25\right)}\right)\right) \]
  14. Simplified11.0%

    \[\leadsto s \cdot \left(-4 \cdot \color{blue}{\left(\frac{\frac{\pi}{{\left(\sqrt[3]{s}\right)}^{2}}}{\sqrt[3]{s}} \cdot \mathsf{fma}\left(-0.5, u, 0.25\right)\right)}\right) \]
  15. Step-by-step derivation
    1. pow111.0%

      \[\leadsto \color{blue}{{\left(s \cdot \left(-4 \cdot \left(\frac{\frac{\pi}{{\left(\sqrt[3]{s}\right)}^{2}}}{\sqrt[3]{s}} \cdot \mathsf{fma}\left(-0.5, u, 0.25\right)\right)\right)\right)}^{1}} \]
    2. distribute-lft-neg-in11.0%

      \[\leadsto {\left(s \cdot \color{blue}{\left(\left(-4\right) \cdot \left(\frac{\frac{\pi}{{\left(\sqrt[3]{s}\right)}^{2}}}{\sqrt[3]{s}} \cdot \mathsf{fma}\left(-0.5, u, 0.25\right)\right)\right)}\right)}^{1} \]
    3. metadata-eval11.0%

      \[\leadsto {\left(s \cdot \left(\color{blue}{-4} \cdot \left(\frac{\frac{\pi}{{\left(\sqrt[3]{s}\right)}^{2}}}{\sqrt[3]{s}} \cdot \mathsf{fma}\left(-0.5, u, 0.25\right)\right)\right)\right)}^{1} \]
  16. Applied egg-rr11.0%

    \[\leadsto \color{blue}{{\left(s \cdot \left(-4 \cdot \left(\frac{\frac{\pi}{{\left(\sqrt[3]{s}\right)}^{2}}}{\sqrt[3]{s}} \cdot \mathsf{fma}\left(-0.5, u, 0.25\right)\right)\right)\right)}^{1}} \]
  17. Step-by-step derivation
    1. unpow111.0%

      \[\leadsto \color{blue}{s \cdot \left(-4 \cdot \left(\frac{\frac{\pi}{{\left(\sqrt[3]{s}\right)}^{2}}}{\sqrt[3]{s}} \cdot \mathsf{fma}\left(-0.5, u, 0.25\right)\right)\right)} \]
    2. associate-*r*11.0%

      \[\leadsto \color{blue}{\left(s \cdot -4\right) \cdot \left(\frac{\frac{\pi}{{\left(\sqrt[3]{s}\right)}^{2}}}{\sqrt[3]{s}} \cdot \mathsf{fma}\left(-0.5, u, 0.25\right)\right)} \]
    3. associate-/l/11.0%

      \[\leadsto \left(s \cdot -4\right) \cdot \left(\color{blue}{\frac{\pi}{\sqrt[3]{s} \cdot {\left(\sqrt[3]{s}\right)}^{2}}} \cdot \mathsf{fma}\left(-0.5, u, 0.25\right)\right) \]
    4. unpow211.0%

      \[\leadsto \left(s \cdot -4\right) \cdot \left(\frac{\pi}{\sqrt[3]{s} \cdot \color{blue}{\left(\sqrt[3]{s} \cdot \sqrt[3]{s}\right)}} \cdot \mathsf{fma}\left(-0.5, u, 0.25\right)\right) \]
    5. rem-3cbrt-rft11.0%

      \[\leadsto \left(s \cdot -4\right) \cdot \left(\frac{\pi}{\color{blue}{s}} \cdot \mathsf{fma}\left(-0.5, u, 0.25\right)\right) \]
    6. *-commutative11.0%

      \[\leadsto \left(s \cdot -4\right) \cdot \color{blue}{\left(\mathsf{fma}\left(-0.5, u, 0.25\right) \cdot \frac{\pi}{s}\right)} \]
    7. associate-*r/11.0%

      \[\leadsto \left(s \cdot -4\right) \cdot \color{blue}{\frac{\mathsf{fma}\left(-0.5, u, 0.25\right) \cdot \pi}{s}} \]
    8. *-commutative11.0%

      \[\leadsto \left(s \cdot -4\right) \cdot \frac{\color{blue}{\pi \cdot \mathsf{fma}\left(-0.5, u, 0.25\right)}}{s} \]
    9. associate-*r*11.0%

      \[\leadsto \color{blue}{s \cdot \left(-4 \cdot \frac{\pi \cdot \mathsf{fma}\left(-0.5, u, 0.25\right)}{s}\right)} \]
    10. *-commutative11.0%

      \[\leadsto s \cdot \color{blue}{\left(\frac{\pi \cdot \mathsf{fma}\left(-0.5, u, 0.25\right)}{s} \cdot -4\right)} \]
    11. associate-*l/11.0%

      \[\leadsto s \cdot \left(\color{blue}{\left(\frac{\pi}{s} \cdot \mathsf{fma}\left(-0.5, u, 0.25\right)\right)} \cdot -4\right) \]
    12. associate-*l*11.0%

      \[\leadsto s \cdot \color{blue}{\left(\frac{\pi}{s} \cdot \left(\mathsf{fma}\left(-0.5, u, 0.25\right) \cdot -4\right)\right)} \]
    13. *-commutative11.0%

      \[\leadsto s \cdot \left(\frac{\pi}{s} \cdot \color{blue}{\left(-4 \cdot \mathsf{fma}\left(-0.5, u, 0.25\right)\right)}\right) \]
  18. Simplified11.0%

    \[\leadsto \color{blue}{s \cdot \left(\frac{\pi}{s} \cdot \left(-4 \cdot \mathsf{fma}\left(-0.5, u, 0.25\right)\right)\right)} \]
  19. Final simplification11.0%

    \[\leadsto s \cdot \left(\frac{\pi}{s} \cdot \left(-4 \cdot \mathsf{fma}\left(-0.5, u, 0.25\right)\right)\right) \]

Alternative 5: 11.6% accurate, 6.6× 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.9%

    \[\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. Step-by-step derivation
    1. distribute-lft-neg-out98.9%

      \[\leadsto \color{blue}{-s \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. distribute-rgt-neg-in98.9%

      \[\leadsto \color{blue}{s \cdot \left(-\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)\right)} \]
    3. sub-neg98.9%

      \[\leadsto s \cdot \left(-\log \color{blue}{\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}}}} + \left(-1\right)\right)}\right) \]
  3. Simplified98.9%

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

    \[\leadsto s \cdot \left(-\color{blue}{4 \cdot \frac{-0.25 \cdot \left(u \cdot \pi\right) - \left(0.25 \cdot \left(u \cdot \pi\right) + -0.25 \cdot \pi\right)}{s}}\right) \]
  5. Step-by-step derivation
    1. pow111.0%

      \[\leadsto \color{blue}{{\left(s \cdot \left(-4 \cdot \frac{-0.25 \cdot \left(u \cdot \pi\right) - \left(0.25 \cdot \left(u \cdot \pi\right) + -0.25 \cdot \pi\right)}{s}\right)\right)}^{1}} \]
    2. distribute-lft-neg-in11.0%

      \[\leadsto {\left(s \cdot \color{blue}{\left(\left(-4\right) \cdot \frac{-0.25 \cdot \left(u \cdot \pi\right) - \left(0.25 \cdot \left(u \cdot \pi\right) + -0.25 \cdot \pi\right)}{s}\right)}\right)}^{1} \]
    3. metadata-eval11.0%

      \[\leadsto {\left(s \cdot \left(\color{blue}{-4} \cdot \frac{-0.25 \cdot \left(u \cdot \pi\right) - \left(0.25 \cdot \left(u \cdot \pi\right) + -0.25 \cdot \pi\right)}{s}\right)\right)}^{1} \]
    4. *-commutative11.0%

      \[\leadsto {\left(s \cdot \left(-4 \cdot \frac{-0.25 \cdot \color{blue}{\left(\pi \cdot u\right)} - \left(0.25 \cdot \left(u \cdot \pi\right) + -0.25 \cdot \pi\right)}{s}\right)\right)}^{1} \]
    5. fma-def11.0%

      \[\leadsto {\left(s \cdot \left(-4 \cdot \frac{-0.25 \cdot \left(\pi \cdot u\right) - \color{blue}{\mathsf{fma}\left(0.25, u \cdot \pi, -0.25 \cdot \pi\right)}}{s}\right)\right)}^{1} \]
    6. *-commutative11.0%

      \[\leadsto {\left(s \cdot \left(-4 \cdot \frac{-0.25 \cdot \left(\pi \cdot u\right) - \mathsf{fma}\left(0.25, \color{blue}{\pi \cdot u}, -0.25 \cdot \pi\right)}{s}\right)\right)}^{1} \]
    7. *-commutative11.0%

      \[\leadsto {\left(s \cdot \left(-4 \cdot \frac{-0.25 \cdot \left(\pi \cdot u\right) - \mathsf{fma}\left(0.25, \pi \cdot u, \color{blue}{\pi \cdot -0.25}\right)}{s}\right)\right)}^{1} \]
  6. Applied egg-rr11.0%

    \[\leadsto \color{blue}{{\left(s \cdot \left(-4 \cdot \frac{-0.25 \cdot \left(\pi \cdot u\right) - \mathsf{fma}\left(0.25, \pi \cdot u, \pi \cdot -0.25\right)}{s}\right)\right)}^{1}} \]
  7. Step-by-step derivation
    1. unpow111.0%

      \[\leadsto \color{blue}{s \cdot \left(-4 \cdot \frac{-0.25 \cdot \left(\pi \cdot u\right) - \mathsf{fma}\left(0.25, \pi \cdot u, \pi \cdot -0.25\right)}{s}\right)} \]
    2. associate-*r*11.0%

      \[\leadsto \color{blue}{\left(s \cdot -4\right) \cdot \frac{-0.25 \cdot \left(\pi \cdot u\right) - \mathsf{fma}\left(0.25, \pi \cdot u, \pi \cdot -0.25\right)}{s}} \]
    3. associate-*r/11.0%

      \[\leadsto \color{blue}{\frac{\left(s \cdot -4\right) \cdot \left(-0.25 \cdot \left(\pi \cdot u\right) - \mathsf{fma}\left(0.25, \pi \cdot u, \pi \cdot -0.25\right)\right)}{s}} \]
  8. Simplified11.0%

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

    \[\leadsto s \cdot \frac{\pi \cdot \left(-1 + u \cdot 2\right)}{s} \]

Alternative 6: 11.6% accurate, 6.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.9%

    \[\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. Step-by-step derivation
    1. distribute-lft-neg-out98.9%

      \[\leadsto \color{blue}{-s \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. distribute-rgt-neg-in98.9%

      \[\leadsto \color{blue}{s \cdot \left(-\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)\right)} \]
    3. sub-neg98.9%

      \[\leadsto s \cdot \left(-\log \color{blue}{\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}}}} + \left(-1\right)\right)}\right) \]
  3. Simplified98.9%

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

    \[\leadsto s \cdot \left(-\color{blue}{4 \cdot \frac{-0.25 \cdot \left(u \cdot \pi\right) - \left(0.25 \cdot \left(u \cdot \pi\right) + -0.25 \cdot \pi\right)}{s}}\right) \]
  5. Step-by-step derivation
    1. associate--r+11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\color{blue}{\left(-0.25 \cdot \left(u \cdot \pi\right) - 0.25 \cdot \left(u \cdot \pi\right)\right) - -0.25 \cdot \pi}}{s}\right) \]
    2. cancel-sign-sub-inv11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\color{blue}{\left(-0.25 \cdot \left(u \cdot \pi\right) - 0.25 \cdot \left(u \cdot \pi\right)\right) + \left(--0.25\right) \cdot \pi}}{s}\right) \]
    3. distribute-rgt-out--11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\color{blue}{\left(u \cdot \pi\right) \cdot \left(-0.25 - 0.25\right)} + \left(--0.25\right) \cdot \pi}{s}\right) \]
    4. *-commutative11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\color{blue}{\left(\pi \cdot u\right)} \cdot \left(-0.25 - 0.25\right) + \left(--0.25\right) \cdot \pi}{s}\right) \]
    5. metadata-eval11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\left(\pi \cdot u\right) \cdot \color{blue}{-0.5} + \left(--0.25\right) \cdot \pi}{s}\right) \]
    6. metadata-eval11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\left(\pi \cdot u\right) \cdot -0.5 + \color{blue}{0.25} \cdot \pi}{s}\right) \]
    7. *-commutative11.0%

      \[\leadsto s \cdot \left(-4 \cdot \frac{\left(\pi \cdot u\right) \cdot -0.5 + \color{blue}{\pi \cdot 0.25}}{s}\right) \]
  6. Simplified11.0%

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

    \[\leadsto \color{blue}{-4 \cdot \left(-0.5 \cdot \left(u \cdot \pi\right) + 0.25 \cdot \pi\right)} \]
  8. Step-by-step derivation
    1. distribute-lft-in11.0%

      \[\leadsto \color{blue}{-4 \cdot \left(-0.5 \cdot \left(u \cdot \pi\right)\right) + -4 \cdot \left(0.25 \cdot \pi\right)} \]
    2. associate-*r*11.0%

      \[\leadsto \color{blue}{\left(-4 \cdot -0.5\right) \cdot \left(u \cdot \pi\right)} + -4 \cdot \left(0.25 \cdot \pi\right) \]
    3. metadata-eval11.0%

      \[\leadsto \color{blue}{2} \cdot \left(u \cdot \pi\right) + -4 \cdot \left(0.25 \cdot \pi\right) \]
    4. associate-*r*11.0%

      \[\leadsto 2 \cdot \left(u \cdot \pi\right) + \color{blue}{\left(-4 \cdot 0.25\right) \cdot \pi} \]
    5. metadata-eval11.0%

      \[\leadsto 2 \cdot \left(u \cdot \pi\right) + \color{blue}{-1} \cdot \pi \]
    6. associate-*r*11.0%

      \[\leadsto \color{blue}{\left(2 \cdot u\right) \cdot \pi} + -1 \cdot \pi \]
    7. distribute-rgt-out11.0%

      \[\leadsto \color{blue}{\pi \cdot \left(2 \cdot u + -1\right)} \]
    8. *-commutative11.0%

      \[\leadsto \pi \cdot \left(\color{blue}{u \cdot 2} + -1\right) \]
  9. Simplified11.0%

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

    \[\leadsto \pi \cdot \left(-1 + u \cdot 2\right) \]

Alternative 7: 11.4% accurate, 7.2× 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.9%

    \[\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. Step-by-step derivation
    1. distribute-lft-neg-out98.9%

      \[\leadsto \color{blue}{-s \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. distribute-rgt-neg-in98.9%

      \[\leadsto \color{blue}{s \cdot \left(-\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)\right)} \]
    3. sub-neg98.9%

      \[\leadsto s \cdot \left(-\log \color{blue}{\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}}}} + \left(-1\right)\right)}\right) \]
  3. Simplified98.9%

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

    \[\leadsto \color{blue}{-1 \cdot \pi} \]
  5. Step-by-step derivation
    1. mul-1-neg10.7%

      \[\leadsto \color{blue}{-\pi} \]
  6. Simplified10.7%

    \[\leadsto \color{blue}{-\pi} \]
  7. Final simplification10.7%

    \[\leadsto -\pi \]

Alternative 8: 4.6% accurate, 7.3× 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(pi)
end
function tmp = code(u, s)
	tmp = single(pi);
end
\begin{array}{l}

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

    \[\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. Step-by-step derivation
    1. distribute-lft-neg-out98.9%

      \[\leadsto \color{blue}{-s \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. distribute-rgt-neg-in98.9%

      \[\leadsto \color{blue}{s \cdot \left(-\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)\right)} \]
    3. sub-neg98.9%

      \[\leadsto s \cdot \left(-\log \color{blue}{\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}}}} + \left(-1\right)\right)}\right) \]
  3. Simplified98.9%

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

    \[\leadsto s \cdot \left(-\color{blue}{\frac{\pi}{s}}\right) \]
  5. Step-by-step derivation
    1. expm1-log1p-u-0.0%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(s \cdot \left(-\frac{\pi}{s}\right)\right)\right)} \]
    2. expm1-udef-0.0%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(s \cdot \left(-\frac{\pi}{s}\right)\right)} - 1} \]
    3. add-sqr-sqrt-0.0%

      \[\leadsto e^{\mathsf{log1p}\left(s \cdot \color{blue}{\left(\sqrt{-\frac{\pi}{s}} \cdot \sqrt{-\frac{\pi}{s}}\right)}\right)} - 1 \]
    4. sqrt-unprod3.3%

      \[\leadsto e^{\mathsf{log1p}\left(s \cdot \color{blue}{\sqrt{\left(-\frac{\pi}{s}\right) \cdot \left(-\frac{\pi}{s}\right)}}\right)} - 1 \]
    5. sqr-neg3.3%

      \[\leadsto e^{\mathsf{log1p}\left(s \cdot \sqrt{\color{blue}{\frac{\pi}{s} \cdot \frac{\pi}{s}}}\right)} - 1 \]
    6. sqrt-unprod4.7%

      \[\leadsto e^{\mathsf{log1p}\left(s \cdot \color{blue}{\left(\sqrt{\frac{\pi}{s}} \cdot \sqrt{\frac{\pi}{s}}\right)}\right)} - 1 \]
    7. add-sqr-sqrt4.7%

      \[\leadsto e^{\mathsf{log1p}\left(s \cdot \color{blue}{\frac{\pi}{s}}\right)} - 1 \]
  6. Applied egg-rr4.7%

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

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(s \cdot \frac{\pi}{s}\right)\right)} \]
    2. expm1-log1p4.7%

      \[\leadsto \color{blue}{s \cdot \frac{\pi}{s}} \]
    3. associate-*r/4.7%

      \[\leadsto \color{blue}{\frac{s \cdot \pi}{s}} \]
    4. associate-*l/4.7%

      \[\leadsto \color{blue}{\frac{s}{s} \cdot \pi} \]
    5. *-inverses4.7%

      \[\leadsto \color{blue}{1} \cdot \pi \]
    6. *-lft-identity4.7%

      \[\leadsto \color{blue}{\pi} \]
  8. Simplified4.7%

    \[\leadsto \color{blue}{\pi} \]
  9. Final simplification4.7%

    \[\leadsto \pi \]

Reproduce

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