Sample trimmed logistic on [-pi, pi]

Percentage Accurate: 98.9% → 98.9%
Time: 18.9s
Alternatives: 12
Speedup: 0.7×

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 12 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: 98.9% 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: 98.9% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{u}{1 + e^{-\frac{\pi}{s}}} + \frac{1 - u}{1 + e^{\frac{\pi}{s}}}\\
s \cdot \left(-\log \left(\frac{{t\_0}^{-2} + -1}{\frac{1}{t\_0} - -1}\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 99.0%

    \[\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. Simplified99.0%

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

      \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{\color{blue}{\frac{1}{\frac{s}{\pi}}}}}} + -1\right) \]
    2. associate-/r/99.0%

      \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{\color{blue}{\frac{1}{s} \cdot \pi}}}} + -1\right) \]
  5. Applied egg-rr99.0%

    \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{\color{blue}{\frac{1}{s} \cdot \pi}}}} + -1\right) \]
  6. Step-by-step derivation
    1. flip-+99.0%

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

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

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

Alternative 2: 98.9% accurate, 0.7× speedup?

\[\begin{array}{l} \\ s \cdot \left(-\log \left(-1 + \frac{1}{\frac{u}{1 + e^{-\frac{\pi}{s}}} + \frac{1 - u}{1 + e^{\sqrt[3]{\frac{{\pi}^{3}}{{s}^{3}}}}}}\right)\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 (cbrt (/ (pow PI 3.0) (pow s 3.0)))))))))))))
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(cbrtf((powf(((float) M_PI), 3.0f) / powf(s, 3.0f))))))))));
}
function code(u, s)
	return Float32(s * Float32(-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(cbrt(Float32((Float32(pi) ^ Float32(3.0)) / (s ^ Float32(3.0)))))))))))))
end
\begin{array}{l}

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

    \[\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. Simplified99.0%

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

      \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{\frac{\pi}{\color{blue}{\sqrt{s} \cdot \sqrt{s}}}}}} + -1\right) \]
    2. add-cbrt-cube99.0%

      \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{\frac{\color{blue}{\sqrt[3]{\left(\pi \cdot \pi\right) \cdot \pi}}}{\sqrt{s} \cdot \sqrt{s}}}}} + -1\right) \]
    3. sqrt-unprod99.0%

      \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{\frac{\sqrt[3]{\left(\pi \cdot \pi\right) \cdot \pi}}{\color{blue}{\sqrt{s \cdot s}}}}}} + -1\right) \]
    4. sqr-neg99.0%

      \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{\frac{\sqrt[3]{\left(\pi \cdot \pi\right) \cdot \pi}}{\sqrt{\color{blue}{\left(-s\right) \cdot \left(-s\right)}}}}}} + -1\right) \]
    5. sqrt-unprod-0.0%

      \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{\frac{\sqrt[3]{\left(\pi \cdot \pi\right) \cdot \pi}}{\color{blue}{\sqrt{-s} \cdot \sqrt{-s}}}}}} + -1\right) \]
    6. add-sqr-sqrt2.3%

      \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{\frac{\sqrt[3]{\left(\pi \cdot \pi\right) \cdot \pi}}{\color{blue}{-s}}}}} + -1\right) \]
    7. add-cbrt-cube2.3%

      \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{\frac{\sqrt[3]{\left(\pi \cdot \pi\right) \cdot \pi}}{\color{blue}{\sqrt[3]{\left(\left(-s\right) \cdot \left(-s\right)\right) \cdot \left(-s\right)}}}}}} + -1\right) \]
    8. cbrt-undiv2.3%

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

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

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

      \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{\sqrt[3]{\frac{{\pi}^{3}}{{\color{blue}{\left(\sqrt{-s} \cdot \sqrt{-s}\right)}}^{3}}}}}} + -1\right) \]
    12. sqrt-unprod99.0%

      \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{\sqrt[3]{\frac{{\pi}^{3}}{{\color{blue}{\left(\sqrt{\left(-s\right) \cdot \left(-s\right)}\right)}}^{3}}}}}} + -1\right) \]
    13. sqr-neg99.0%

      \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{\sqrt[3]{\frac{{\pi}^{3}}{{\left(\sqrt{\color{blue}{s \cdot s}}\right)}^{3}}}}}} + -1\right) \]
    14. sqrt-unprod99.0%

      \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{\sqrt[3]{\frac{{\pi}^{3}}{{\color{blue}{\left(\sqrt{s} \cdot \sqrt{s}\right)}}^{3}}}}}} + -1\right) \]
    15. add-sqr-sqrt99.0%

      \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{\sqrt[3]{\frac{{\pi}^{3}}{{\color{blue}{s}}^{3}}}}}} + -1\right) \]
  5. Applied egg-rr99.0%

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

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

Alternative 3: 98.9% accurate, 1.3× speedup?

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

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

    \[\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. Simplified99.0%

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

      \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{\color{blue}{\frac{1}{\frac{s}{\pi}}}}}} + -1\right) \]
    2. associate-/r/99.0%

      \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{\color{blue}{\frac{1}{s} \cdot \pi}}}} + -1\right) \]
  5. Applied egg-rr99.0%

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

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

Alternative 4: 98.9% accurate, 1.3× 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 99.0%

    \[\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. Simplified99.0%

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

    \[\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) \]
  5. Add Preprocessing

Alternative 5: 25.5% accurate, 1.4× speedup?

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

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

    \[\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. Simplified99.0%

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

      \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{\color{blue}{\frac{1}{\frac{s}{\pi}}}}}} + -1\right) \]
    2. associate-/r/99.0%

      \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{\color{blue}{\frac{1}{s} \cdot \pi}}}} + -1\right) \]
  5. Applied egg-rr99.0%

    \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{\color{blue}{\frac{1}{s} \cdot \pi}}}} + -1\right) \]
  6. Step-by-step derivation
    1. add-log-exp24.7%

      \[\leadsto \left(-s\right) \cdot \log \color{blue}{\log \left(e^{\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{\frac{1}{s} \cdot \pi}}} + -1}\right)} \]
    2. associate-*l/24.7%

      \[\leadsto \left(-s\right) \cdot \log \log \left(e^{\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{\color{blue}{\frac{1 \cdot \pi}{s}}}}} + -1}\right) \]
    3. *-un-lft-identity24.7%

      \[\leadsto \left(-s\right) \cdot \log \log \left(e^{\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{\frac{\color{blue}{\pi}}{s}}}} + -1}\right) \]
  7. Applied egg-rr24.7%

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

    \[\leadsto \left(-s\right) \cdot \log \log \color{blue}{\left(e^{1} + -4 \cdot \frac{e^{1} \cdot \left(0.25 \cdot \left(u \cdot \pi\right) - \left(-0.25 \cdot \left(u \cdot \pi\right) + 0.25 \cdot \pi\right)\right)}{s}\right)} \]
  9. Step-by-step derivation
    1. +-commutative25.4%

      \[\leadsto \left(-s\right) \cdot \log \log \color{blue}{\left(-4 \cdot \frac{e^{1} \cdot \left(0.25 \cdot \left(u \cdot \pi\right) - \left(-0.25 \cdot \left(u \cdot \pi\right) + 0.25 \cdot \pi\right)\right)}{s} + e^{1}\right)} \]
    2. fma-define25.4%

      \[\leadsto \left(-s\right) \cdot \log \log \color{blue}{\left(\mathsf{fma}\left(-4, \frac{e^{1} \cdot \left(0.25 \cdot \left(u \cdot \pi\right) - \left(-0.25 \cdot \left(u \cdot \pi\right) + 0.25 \cdot \pi\right)\right)}{s}, e^{1}\right)\right)} \]
  10. Simplified25.4%

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

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

Alternative 6: 25.1% accurate, 2.1× speedup?

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

\\
s \cdot \left(\log s - \log \pi\right)
\end{array}
Derivation
  1. Initial program 99.0%

    \[\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. Simplified99.0%

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

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

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

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

      \[\leadsto \left(-s\right) \cdot \log \left(\mathsf{fma}\left(-4, \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}, 1\right)\right) \]
    4. cancel-sign-sub-inv24.7%

      \[\leadsto \left(-s\right) \cdot \log \left(\mathsf{fma}\left(-4, \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}, 1\right)\right) \]
    5. distribute-rgt-out--24.7%

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

      \[\leadsto \left(-s\right) \cdot \log \left(\mathsf{fma}\left(-4, \frac{\color{blue}{\left(\pi \cdot u\right)} \cdot \left(0.25 - -0.25\right) + \left(-0.25\right) \cdot \pi}{s}, 1\right)\right) \]
    7. metadata-eval24.7%

      \[\leadsto \left(-s\right) \cdot \log \left(\mathsf{fma}\left(-4, \frac{\left(\pi \cdot u\right) \cdot \color{blue}{0.5} + \left(-0.25\right) \cdot \pi}{s}, 1\right)\right) \]
    8. metadata-eval24.7%

      \[\leadsto \left(-s\right) \cdot \log \left(\mathsf{fma}\left(-4, \frac{\left(\pi \cdot u\right) \cdot 0.5 + \color{blue}{-0.25} \cdot \pi}{s}, 1\right)\right) \]
    9. *-commutative24.7%

      \[\leadsto \left(-s\right) \cdot \log \left(\mathsf{fma}\left(-4, \frac{\left(\pi \cdot u\right) \cdot 0.5 + \color{blue}{\pi \cdot -0.25}}{s}, 1\right)\right) \]
  6. Simplified24.7%

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

    \[\leadsto \color{blue}{-1 \cdot \left(s \cdot \log \left(1 + \frac{\pi}{s}\right)\right)} \]
  8. Step-by-step derivation
    1. mul-1-neg25.0%

      \[\leadsto \color{blue}{-s \cdot \log \left(1 + \frac{\pi}{s}\right)} \]
    2. log1p-define25.0%

      \[\leadsto -s \cdot \color{blue}{\mathsf{log1p}\left(\frac{\pi}{s}\right)} \]
    3. *-commutative25.0%

      \[\leadsto -\color{blue}{\mathsf{log1p}\left(\frac{\pi}{s}\right) \cdot s} \]
    4. distribute-rgt-neg-in25.0%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\frac{\pi}{s}\right) \cdot \left(-s\right)} \]
  9. Simplified25.0%

    \[\leadsto \color{blue}{\mathsf{log1p}\left(\frac{\pi}{s}\right) \cdot \left(-s\right)} \]
  10. Taylor expanded in s around 0 25.1%

    \[\leadsto \color{blue}{\left(\log \pi + -1 \cdot \log s\right)} \cdot \left(-s\right) \]
  11. Step-by-step derivation
    1. mul-1-neg25.1%

      \[\leadsto \left(\log \pi + \color{blue}{\left(-\log s\right)}\right) \cdot \left(-s\right) \]
    2. unsub-neg25.1%

      \[\leadsto \color{blue}{\left(\log \pi - \log s\right)} \cdot \left(-s\right) \]
  12. Simplified25.1%

    \[\leadsto \color{blue}{\left(\log \pi - \log s\right)} \cdot \left(-s\right) \]
  13. Final simplification25.1%

    \[\leadsto s \cdot \left(\log s - \log \pi\right) \]
  14. Add Preprocessing

Alternative 7: 25.0% accurate, 3.7× speedup?

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

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

    \[\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. Simplified99.0%

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

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

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

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

      \[\leadsto \left(-s\right) \cdot \log \left(\mathsf{fma}\left(-4, \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}, 1\right)\right) \]
    4. cancel-sign-sub-inv24.7%

      \[\leadsto \left(-s\right) \cdot \log \left(\mathsf{fma}\left(-4, \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}, 1\right)\right) \]
    5. distribute-rgt-out--24.7%

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

      \[\leadsto \left(-s\right) \cdot \log \left(\mathsf{fma}\left(-4, \frac{\color{blue}{\left(\pi \cdot u\right)} \cdot \left(0.25 - -0.25\right) + \left(-0.25\right) \cdot \pi}{s}, 1\right)\right) \]
    7. metadata-eval24.7%

      \[\leadsto \left(-s\right) \cdot \log \left(\mathsf{fma}\left(-4, \frac{\left(\pi \cdot u\right) \cdot \color{blue}{0.5} + \left(-0.25\right) \cdot \pi}{s}, 1\right)\right) \]
    8. metadata-eval24.7%

      \[\leadsto \left(-s\right) \cdot \log \left(\mathsf{fma}\left(-4, \frac{\left(\pi \cdot u\right) \cdot 0.5 + \color{blue}{-0.25} \cdot \pi}{s}, 1\right)\right) \]
    9. *-commutative24.7%

      \[\leadsto \left(-s\right) \cdot \log \left(\mathsf{fma}\left(-4, \frac{\left(\pi \cdot u\right) \cdot 0.5 + \color{blue}{\pi \cdot -0.25}}{s}, 1\right)\right) \]
  6. Simplified24.7%

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

    \[\leadsto \color{blue}{-1 \cdot \left(s \cdot \log \left(1 + \frac{\pi}{s}\right)\right) + 2 \cdot \frac{u \cdot \pi}{1 + \frac{\pi}{s}}} \]
  8. Step-by-step derivation
    1. +-commutative25.0%

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

      \[\leadsto 2 \cdot \frac{u \cdot \pi}{1 + \frac{\pi}{s}} + \color{blue}{\left(-s \cdot \log \left(1 + \frac{\pi}{s}\right)\right)} \]
    3. unsub-neg25.0%

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

      \[\leadsto \color{blue}{\frac{u \cdot \pi}{1 + \frac{\pi}{s}} \cdot 2} - s \cdot \log \left(1 + \frac{\pi}{s}\right) \]
    5. associate-/l*25.0%

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

      \[\leadsto \color{blue}{u \cdot \left(\frac{\pi}{1 + \frac{\pi}{s}} \cdot 2\right)} - s \cdot \log \left(1 + \frac{\pi}{s}\right) \]
    7. associate-*l/25.0%

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

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

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

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

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

Alternative 8: 25.0% accurate, 4.0× speedup?

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

\\
\left(-s\right) \cdot \mathsf{log1p}\left(\pi \cdot \frac{1}{s}\right)
\end{array}
Derivation
  1. Initial program 99.0%

    \[\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. Simplified99.0%

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

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

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

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

      \[\leadsto \left(-s\right) \cdot \log \left(\mathsf{fma}\left(-4, \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}, 1\right)\right) \]
    4. cancel-sign-sub-inv24.7%

      \[\leadsto \left(-s\right) \cdot \log \left(\mathsf{fma}\left(-4, \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}, 1\right)\right) \]
    5. distribute-rgt-out--24.7%

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

      \[\leadsto \left(-s\right) \cdot \log \left(\mathsf{fma}\left(-4, \frac{\color{blue}{\left(\pi \cdot u\right)} \cdot \left(0.25 - -0.25\right) + \left(-0.25\right) \cdot \pi}{s}, 1\right)\right) \]
    7. metadata-eval24.7%

      \[\leadsto \left(-s\right) \cdot \log \left(\mathsf{fma}\left(-4, \frac{\left(\pi \cdot u\right) \cdot \color{blue}{0.5} + \left(-0.25\right) \cdot \pi}{s}, 1\right)\right) \]
    8. metadata-eval24.7%

      \[\leadsto \left(-s\right) \cdot \log \left(\mathsf{fma}\left(-4, \frac{\left(\pi \cdot u\right) \cdot 0.5 + \color{blue}{-0.25} \cdot \pi}{s}, 1\right)\right) \]
    9. *-commutative24.7%

      \[\leadsto \left(-s\right) \cdot \log \left(\mathsf{fma}\left(-4, \frac{\left(\pi \cdot u\right) \cdot 0.5 + \color{blue}{\pi \cdot -0.25}}{s}, 1\right)\right) \]
  6. Simplified24.7%

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

    \[\leadsto \color{blue}{-1 \cdot \left(s \cdot \log \left(1 + \frac{\pi}{s}\right)\right)} \]
  8. Step-by-step derivation
    1. mul-1-neg25.0%

      \[\leadsto \color{blue}{-s \cdot \log \left(1 + \frac{\pi}{s}\right)} \]
    2. log1p-define25.0%

      \[\leadsto -s \cdot \color{blue}{\mathsf{log1p}\left(\frac{\pi}{s}\right)} \]
    3. *-commutative25.0%

      \[\leadsto -\color{blue}{\mathsf{log1p}\left(\frac{\pi}{s}\right) \cdot s} \]
    4. distribute-rgt-neg-in25.0%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\frac{\pi}{s}\right) \cdot \left(-s\right)} \]
  9. Simplified25.0%

    \[\leadsto \color{blue}{\mathsf{log1p}\left(\frac{\pi}{s}\right) \cdot \left(-s\right)} \]
  10. Step-by-step derivation
    1. clear-num99.0%

      \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{\color{blue}{\frac{1}{\frac{s}{\pi}}}}}} + -1\right) \]
    2. associate-/r/99.0%

      \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{\color{blue}{\frac{1}{s} \cdot \pi}}}} + -1\right) \]
  11. Applied egg-rr25.0%

    \[\leadsto \mathsf{log1p}\left(\color{blue}{\frac{1}{s} \cdot \pi}\right) \cdot \left(-s\right) \]
  12. Final simplification25.0%

    \[\leadsto \left(-s\right) \cdot \mathsf{log1p}\left(\pi \cdot \frac{1}{s}\right) \]
  13. Add Preprocessing

Alternative 9: 25.0% accurate, 4.1× speedup?

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

\\
\left(-s\right) \cdot \mathsf{log1p}\left(\frac{\pi}{s}\right)
\end{array}
Derivation
  1. Initial program 99.0%

    \[\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. Simplified99.0%

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

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

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

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

      \[\leadsto \left(-s\right) \cdot \log \left(\mathsf{fma}\left(-4, \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}, 1\right)\right) \]
    4. cancel-sign-sub-inv24.7%

      \[\leadsto \left(-s\right) \cdot \log \left(\mathsf{fma}\left(-4, \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}, 1\right)\right) \]
    5. distribute-rgt-out--24.7%

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

      \[\leadsto \left(-s\right) \cdot \log \left(\mathsf{fma}\left(-4, \frac{\color{blue}{\left(\pi \cdot u\right)} \cdot \left(0.25 - -0.25\right) + \left(-0.25\right) \cdot \pi}{s}, 1\right)\right) \]
    7. metadata-eval24.7%

      \[\leadsto \left(-s\right) \cdot \log \left(\mathsf{fma}\left(-4, \frac{\left(\pi \cdot u\right) \cdot \color{blue}{0.5} + \left(-0.25\right) \cdot \pi}{s}, 1\right)\right) \]
    8. metadata-eval24.7%

      \[\leadsto \left(-s\right) \cdot \log \left(\mathsf{fma}\left(-4, \frac{\left(\pi \cdot u\right) \cdot 0.5 + \color{blue}{-0.25} \cdot \pi}{s}, 1\right)\right) \]
    9. *-commutative24.7%

      \[\leadsto \left(-s\right) \cdot \log \left(\mathsf{fma}\left(-4, \frac{\left(\pi \cdot u\right) \cdot 0.5 + \color{blue}{\pi \cdot -0.25}}{s}, 1\right)\right) \]
  6. Simplified24.7%

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

    \[\leadsto \color{blue}{-1 \cdot \left(s \cdot \log \left(1 + \frac{\pi}{s}\right)\right)} \]
  8. Step-by-step derivation
    1. mul-1-neg25.0%

      \[\leadsto \color{blue}{-s \cdot \log \left(1 + \frac{\pi}{s}\right)} \]
    2. log1p-define25.0%

      \[\leadsto -s \cdot \color{blue}{\mathsf{log1p}\left(\frac{\pi}{s}\right)} \]
    3. *-commutative25.0%

      \[\leadsto -\color{blue}{\mathsf{log1p}\left(\frac{\pi}{s}\right) \cdot s} \]
    4. distribute-rgt-neg-in25.0%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\frac{\pi}{s}\right) \cdot \left(-s\right)} \]
  9. Simplified25.0%

    \[\leadsto \color{blue}{\mathsf{log1p}\left(\frac{\pi}{s}\right) \cdot \left(-s\right)} \]
  10. Final simplification25.0%

    \[\leadsto \left(-s\right) \cdot \mathsf{log1p}\left(\frac{\pi}{s}\right) \]
  11. Add Preprocessing

Alternative 10: 11.6% accurate, 39.4× speedup?

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

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

    \[\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. Simplified99.0%

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

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

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

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

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

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

      \[\leadsto -4 \cdot \left(\left(\color{blue}{\left(-0.25 \cdot u\right) \cdot \pi} + 0.25 \cdot \pi\right) + \left(-0.25\right) \cdot \left(u \cdot \pi\right)\right) \]
    6. distribute-rgt-out11.7%

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

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

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

      \[\leadsto -4 \cdot \left(\pi \cdot \left(u \cdot -0.25 + 0.25\right) + \color{blue}{\left(u \cdot \pi\right) \cdot -0.25}\right) \]
    10. associate-*l*11.7%

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

    \[\leadsto \color{blue}{-4 \cdot \left(\pi \cdot \left(u \cdot -0.25 + 0.25\right) + u \cdot \left(\pi \cdot -0.25\right)\right)} \]
  7. Step-by-step derivation
    1. add-cube-cbrt11.8%

      \[\leadsto -4 \cdot \left(\color{blue}{\left(\left(\sqrt[3]{\pi} \cdot \sqrt[3]{\pi}\right) \cdot \sqrt[3]{\pi}\right)} \cdot \left(u \cdot -0.25 + 0.25\right) + u \cdot \left(\pi \cdot -0.25\right)\right) \]
    2. pow311.8%

      \[\leadsto -4 \cdot \left(\color{blue}{{\left(\sqrt[3]{\pi}\right)}^{3}} \cdot \left(u \cdot -0.25 + 0.25\right) + u \cdot \left(\pi \cdot -0.25\right)\right) \]
  8. Applied egg-rr11.8%

    \[\leadsto -4 \cdot \left(\color{blue}{{\left(\sqrt[3]{\pi}\right)}^{3}} \cdot \left(u \cdot -0.25 + 0.25\right) + u \cdot \left(\pi \cdot -0.25\right)\right) \]
  9. Taylor expanded in u around inf 11.7%

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

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

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

      \[\leadsto -4 \cdot \left(u \cdot \left(\pi \cdot -0.5 + \frac{\color{blue}{\pi \cdot 0.25}}{u}\right)\right) \]
    4. associate-/l*11.7%

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

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

    \[\leadsto -4 \cdot \color{blue}{\left(u \cdot \left(\pi \cdot \left(-0.5 + \frac{0.25}{u}\right)\right)\right)} \]
  12. Final simplification11.7%

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

Alternative 11: 11.6% accurate, 48.1× speedup?

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

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

    \[\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. Simplified99.0%

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

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

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

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

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

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

      \[\leadsto -4 \cdot \left(\left(\color{blue}{\left(-0.25 \cdot u\right) \cdot \pi} + 0.25 \cdot \pi\right) + \left(-0.25\right) \cdot \left(u \cdot \pi\right)\right) \]
    6. distribute-rgt-out11.7%

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

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

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

      \[\leadsto -4 \cdot \left(\pi \cdot \left(u \cdot -0.25 + 0.25\right) + \color{blue}{\left(u \cdot \pi\right) \cdot -0.25}\right) \]
    10. associate-*l*11.7%

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

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

    \[\leadsto -4 \cdot \color{blue}{\left(-0.5 \cdot \left(u \cdot \pi\right) + 0.25 \cdot \pi\right)} \]
  8. Step-by-step derivation
    1. associate-*r*11.7%

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

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

      \[\leadsto -4 \cdot \left(\pi \cdot \left(\color{blue}{u \cdot -0.5} + 0.25\right)\right) \]
  9. Simplified11.7%

    \[\leadsto -4 \cdot \color{blue}{\left(\pi \cdot \left(u \cdot -0.5 + 0.25\right)\right)} \]
  10. Final simplification11.7%

    \[\leadsto -4 \cdot \left(\pi \cdot \left(0.25 + u \cdot -0.5\right)\right) \]
  11. Add Preprocessing

Alternative 12: 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 99.0%

    \[\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. Simplified99.0%

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

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

      \[\leadsto \color{blue}{-\pi} \]
  6. Simplified11.5%

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

    \[\leadsto -\pi \]
  8. Add Preprocessing

Reproduce

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