Sample trimmed logistic on [-pi, pi]

Percentage Accurate: 99.0% → 99.0%
Time: 22.3s
Alternatives: 19
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 19 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, 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 \log \left(\frac{1 + \frac{1}{t\_0}}{{t\_0}^{-2} + -1}\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 (/ (+ 1.0 (/ 1.0 t_0)) (+ (pow t_0 -2.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(((1.0f + (1.0f / t_0)) / (powf(t_0, -2.0f) + -1.0f)));
}
function code(u, s)
	t_0 = Float32(Float32(u / Float32(Float32(1.0) + exp(Float32(Float32(pi) / Float32(-s))))) + Float32(Float32(Float32(1.0) - u) / Float32(Float32(1.0) + exp(Float32(Float32(pi) / s)))))
	return Float32(s * log(Float32(Float32(Float32(1.0) + Float32(Float32(1.0) / t_0)) / Float32((t_0 ^ Float32(-2.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(((single(1.0) + (single(1.0) / t_0)) / ((t_0 ^ single(-2.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 \log \left(\frac{1 + \frac{1}{t\_0}}{{t\_0}^{-2} + -1}\right)
\end{array}
\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. Simplified98.9%

    \[\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-exp-log98.9%

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

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

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

    \[\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. Step-by-step derivation
    1. clear-num98.8%

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

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

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

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

Alternative 2: 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}}}\\ \left(-s\right) \cdot \log \left(\frac{{t\_0}^{-2} + -1}{\frac{1}{t\_0} - -1}\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(pi) / Float32(-s))))) + Float32(Float32(Float32(1.0) - u) / Float32(Float32(1.0) + exp(Float32(Float32(pi) / s)))))
	return Float32(Float32(-s) * 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}}}\\
\left(-s\right) \cdot \log \left(\frac{{t\_0}^{-2} + -1}{\frac{1}{t\_0} - -1}\right)
\end{array}
\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. Simplified98.9%

    \[\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-exp-log98.9%

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

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

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

    \[\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 simplification98.9%

    \[\leadsto \left(-s\right) \cdot \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) \]
  9. Add Preprocessing

Alternative 3: 98.9% accurate, 1.3× speedup?

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

\\
s \cdot \left(-\mathsf{log1p}\left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{\frac{\pi}{s}}}} + -2\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. Simplified98.9%

    \[\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-exp-log98.9%

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

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

      \[\leadsto \left(-s\right) \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\log \left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{e^{\log \left(\frac{\pi}{s}\right)}}}} + -1\right)\right)\right)} \]
    2. expm1-undefine98.9%

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

    \[\leadsto \left(-s\right) \cdot \color{blue}{\mathsf{log1p}\left(\left(\frac{1}{\frac{u}{1 + e^{\frac{\pi}{-s}}} + \frac{1 - u}{1 + e^{\frac{\pi}{s}}}} + -1\right) - 1\right)} \]
  8. Step-by-step derivation
    1. associate--l+98.9%

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

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

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

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

Alternative 4: 98.9% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \left(-s\right) \cdot \log \left(\frac{1}{\frac{u}{1 + e^{-\frac{\pi}{s}}} + \frac{1 - u}{1 + e^{\frac{\pi}{s}}}} + -1\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(Float32(-s) * log(Float32(Float32(Float32(1.0) / Float32(Float32(u / Float32(Float32(1.0) + exp(Float32(-Float32(Float32(pi) / s))))) + Float32(Float32(Float32(1.0) - u) / Float32(Float32(1.0) + 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}

\\
\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)
\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. Simplified98.9%

    \[\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 simplification98.9%

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

Alternative 5: 25.4% accurate, 1.9× speedup?

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

\\
u \cdot \left(s \cdot 2 + u \cdot \left(s \cdot 2 + 2.6666666666666665 \cdot \left(s \cdot u\right)\right)\right) + s \cdot \left(\log s - \log \pi\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. Simplified98.9%

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

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

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

      \[\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)} \]
  6. Simplified24.5%

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

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

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

    \[\leadsto u \cdot \left(s \cdot 2 + u \cdot \left(s \cdot 2 + 2.6666666666666665 \cdot \left(s \cdot u\right)\right)\right) + s \cdot \left(\log s - \log \pi\right) \]
  10. Add Preprocessing

Alternative 6: 25.4% accurate, 2.0× speedup?

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

\\
u \cdot \left(2 \cdot \left(s \cdot \left(1 + u\right)\right)\right) + s \cdot \left(\log s - \log \pi\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. Simplified98.9%

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

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

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

      \[\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)} \]
  6. Simplified24.5%

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

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

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

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

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

      \[\leadsto \color{blue}{u \cdot \left(2 \cdot s + 2 \cdot \left(s \cdot u\right)\right) - s \cdot \left(\log \pi + -1 \cdot \log s\right)} \]
    4. distribute-lft-out24.9%

      \[\leadsto u \cdot \color{blue}{\left(2 \cdot \left(s + s \cdot u\right)\right)} - s \cdot \left(\log \pi + -1 \cdot \log s\right) \]
    5. *-commutative24.9%

      \[\leadsto u \cdot \left(2 \cdot \left(s + \color{blue}{u \cdot s}\right)\right) - s \cdot \left(\log \pi + -1 \cdot \log s\right) \]
    6. distribute-rgt1-in24.9%

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

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

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

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

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

Alternative 7: 25.3% accurate, 2.1× speedup?

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

\\
2 \cdot \left(s \cdot u\right) + s \cdot \left(\log s - \log \pi\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. Simplified98.9%

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

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

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

      \[\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)} \]
  6. Simplified24.5%

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

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

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

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

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

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

      \[\leadsto 2 \cdot \left(s \cdot u\right) - s \cdot \left(\log \pi + \color{blue}{\left(-\log s\right)}\right) \]
    5. unsub-neg24.9%

      \[\leadsto 2 \cdot \left(s \cdot u\right) - s \cdot \color{blue}{\left(\log \pi - \log s\right)} \]
  10. Simplified24.9%

    \[\leadsto \color{blue}{2 \cdot \left(s \cdot u\right) - s \cdot \left(\log \pi - \log s\right)} \]
  11. Final simplification24.9%

    \[\leadsto 2 \cdot \left(s \cdot u\right) + s \cdot \left(\log s - \log \pi\right) \]
  12. Add Preprocessing

Alternative 8: 25.3% accurate, 2.1× speedup?

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

\\
s \cdot \left(\left(\log s - \frac{s}{\pi}\right) - \log \pi\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. Simplified98.9%

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

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

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

      \[\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)} \]
  6. Simplified24.5%

    \[\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 24.8%

    \[\leadsto \color{blue}{-1 \cdot \left(s \cdot \log \left(1 + \frac{\pi}{s}\right)\right)} \]
  8. Step-by-step derivation
    1. associate-*r*24.8%

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

      \[\leadsto \color{blue}{\left(-s\right)} \cdot \log \left(1 + \frac{\pi}{s}\right) \]
    3. log1p-define24.8%

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

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

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

      \[\leadsto \left(-s\right) \cdot \left(\log \pi + \left(\color{blue}{\left(-\log s\right)} + \frac{s}{\pi}\right)\right) \]
    2. +-commutative24.9%

      \[\leadsto \left(-s\right) \cdot \left(\log \pi + \color{blue}{\left(\frac{s}{\pi} + \left(-\log s\right)\right)}\right) \]
    3. unsub-neg24.9%

      \[\leadsto \left(-s\right) \cdot \left(\log \pi + \color{blue}{\left(\frac{s}{\pi} - \log s\right)}\right) \]
  12. Simplified24.9%

    \[\leadsto \left(-s\right) \cdot \color{blue}{\left(\log \pi + \left(\frac{s}{\pi} - \log s\right)\right)} \]
  13. Final simplification24.9%

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

Alternative 9: 25.3% 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 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. Simplified98.9%

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

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

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

      \[\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)} \]
  6. Simplified24.5%

    \[\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 24.8%

    \[\leadsto \color{blue}{-1 \cdot \left(s \cdot \log \left(1 + \frac{\pi}{s}\right)\right)} \]
  8. Step-by-step derivation
    1. associate-*r*24.8%

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

      \[\leadsto \color{blue}{\left(-s\right)} \cdot \log \left(1 + \frac{\pi}{s}\right) \]
    3. log1p-define24.8%

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

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

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

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

      \[\leadsto -\color{blue}{\left(\log \pi + -1 \cdot \log s\right) \cdot s} \]
    3. distribute-rgt-neg-in24.9%

      \[\leadsto \color{blue}{\left(\log \pi + -1 \cdot \log s\right) \cdot \left(-s\right)} \]
    4. neg-mul-124.9%

      \[\leadsto \left(\log \pi + \color{blue}{\left(-\log s\right)}\right) \cdot \left(-s\right) \]
    5. unsub-neg24.9%

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

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

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

Alternative 10: 25.2% accurate, 3.6× speedup?

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

\\
\begin{array}{l}
t_0 := 1 + \frac{\pi}{s}\\
u \cdot \left(2 \cdot \frac{\pi}{t\_0} - \frac{s \cdot \log t\_0}{u}\right)
\end{array}
\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. Simplified98.9%

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

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

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

      \[\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)} \]
  6. Simplified24.5%

    \[\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 24.8%

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

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

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

    \[\leadsto \left(-s\right) \cdot \color{blue}{\left(\mathsf{log1p}\left(\frac{\pi}{s}\right) + -2 \cdot \left(u \cdot \frac{\pi}{s \cdot \left(1 + \frac{\pi}{s}\right)}\right)\right)} \]
  10. Taylor expanded in u around inf 24.8%

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

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

Alternative 11: 25.2% accurate, 3.6× speedup?

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

\\
s \cdot \left(-2 \cdot \left(u \cdot \frac{\pi}{s \cdot \left(-1 - \frac{\pi}{s}\right)}\right) - \mathsf{log1p}\left(\frac{\pi}{s}\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. Simplified98.9%

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

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

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

      \[\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)} \]
  6. Simplified24.5%

    \[\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 24.8%

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

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

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

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

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

Alternative 12: 25.2% accurate, 3.7× speedup?

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

\\
2 \cdot \left(u \cdot \frac{\pi}{1 + \frac{\pi}{s}}\right) - s \cdot \mathsf{log1p}\left(\frac{\pi}{s}\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. Simplified98.9%

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

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

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

      \[\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)} \]
  6. Simplified24.5%

    \[\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 24.8%

    \[\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. +-commutative24.8%

      \[\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-neg24.8%

      \[\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-neg24.8%

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

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

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

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

Alternative 13: 25.2% accurate, 3.9× speedup?

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

\\
s \cdot \left(u \cdot \left(--2\right) - \mathsf{log1p}\left(\frac{\pi}{s}\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. Simplified98.9%

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

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

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

      \[\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)} \]
  6. Simplified24.5%

    \[\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 24.8%

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

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

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

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

    \[\leadsto \left(-s\right) \cdot \left(\mathsf{log1p}\left(\frac{\pi}{s}\right) + \color{blue}{-2 \cdot u}\right) \]
  11. Step-by-step derivation
    1. *-commutative24.8%

      \[\leadsto \left(-s\right) \cdot \left(\mathsf{log1p}\left(\frac{\pi}{s}\right) + \color{blue}{u \cdot -2}\right) \]
  12. Simplified24.8%

    \[\leadsto \left(-s\right) \cdot \left(\mathsf{log1p}\left(\frac{\pi}{s}\right) + \color{blue}{u \cdot -2}\right) \]
  13. Final simplification24.8%

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

Alternative 14: 25.2% 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 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. Simplified98.9%

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

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

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

      \[\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)} \]
  6. Simplified24.5%

    \[\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 24.8%

    \[\leadsto \color{blue}{-1 \cdot \left(s \cdot \log \left(1 + \frac{\pi}{s}\right)\right)} \]
  8. Step-by-step derivation
    1. associate-*r*24.8%

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

      \[\leadsto \color{blue}{\left(-s\right)} \cdot \log \left(1 + \frac{\pi}{s}\right) \]
    3. log1p-define24.8%

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

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

Alternative 15: 11.6% accurate, 22.8× speedup?

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

\\
-4 \cdot \left(u \cdot \left(\pi \cdot -0.25 + 0.25 \cdot \frac{\pi}{u}\right) + \pi \cdot \left(u \cdot -0.25\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. Simplified98.9%

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

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

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

      \[\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)} \]
    3. cancel-sign-sub-inv11.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 16: 11.6% accurate, 48.1× speedup?

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

\\
u \cdot \left(\pi \cdot 2 - \frac{\pi}{u}\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. Simplified98.9%

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

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

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

      \[\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)} \]
    3. cancel-sign-sub-inv11.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 17: 11.6% accurate, 61.9× speedup?

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

\\
\pi \cdot \left(u \cdot 2\right) - \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. Simplified98.9%

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

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

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

      \[\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)} \]
    3. cancel-sign-sub-inv11.0%

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-1 \cdot \pi + 2 \cdot \left(u \cdot \pi\right)} \]
  8. Step-by-step derivation
    1. neg-mul-111.0%

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

      \[\leadsto \color{blue}{2 \cdot \left(u \cdot \pi\right) + \left(-\pi\right)} \]
    3. unsub-neg11.0%

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

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

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

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

Alternative 18: 11.4% accurate, 72.2× speedup?

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

\\
\frac{s \cdot \pi}{-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. Simplified98.9%

    \[\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 10.8%

    \[\leadsto \left(-s\right) \cdot \color{blue}{\frac{\pi}{s}} \]
  5. Step-by-step derivation
    1. associate-*r/10.8%

      \[\leadsto \color{blue}{\frac{\left(-s\right) \cdot \pi}{s}} \]
  6. Applied egg-rr10.8%

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

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

Alternative 19: 11.4% accurate, 216.5× speedup?

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

\\
-\pi
\end{array}
Derivation
  1. Initial program 98.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. Simplified98.9%

    \[\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 10.8%

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

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

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

Reproduce

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