Sample trimmed logistic on [-pi, pi]

Percentage Accurate: 98.9% → 98.9%
Time: 18.0s
Alternatives: 14
Speedup: 1.0×

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

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\frac{\pi}{s}}\\ t_1 := \frac{u}{1 + e^{-\frac{\pi}{s}}} + \left(\frac{u}{-1 - t\_0} + \frac{1}{1 + t\_0}\right)\\ t_2 := \frac{1}{t\_1}\\ \left(-s\right) \cdot \log \left(\frac{-1 + {t\_1}^{-3}}{\mathsf{fma}\left(t\_2, 1 + t\_2, 1\right)}\right) \end{array} \end{array} \]
(FPCore (u s)
 :precision binary32
 (let* ((t_0 (exp (/ PI s)))
        (t_1
         (+
          (/ u (+ 1.0 (exp (- (/ PI s)))))
          (+ (/ u (- -1.0 t_0)) (/ 1.0 (+ 1.0 t_0)))))
        (t_2 (/ 1.0 t_1)))
   (* (- s) (log (/ (+ -1.0 (pow t_1 -3.0)) (fma t_2 (+ 1.0 t_2) 1.0))))))
float code(float u, float s) {
	float t_0 = expf((((float) M_PI) / s));
	float t_1 = (u / (1.0f + expf(-(((float) M_PI) / s)))) + ((u / (-1.0f - t_0)) + (1.0f / (1.0f + t_0)));
	float t_2 = 1.0f / t_1;
	return -s * logf(((-1.0f + powf(t_1, -3.0f)) / fmaf(t_2, (1.0f + t_2), 1.0f)));
}
function code(u, s)
	t_0 = exp(Float32(Float32(pi) / s))
	t_1 = Float32(Float32(u / Float32(Float32(1.0) + exp(Float32(-Float32(Float32(pi) / s))))) + Float32(Float32(u / Float32(Float32(-1.0) - t_0)) + Float32(Float32(1.0) / Float32(Float32(1.0) + t_0))))
	t_2 = Float32(Float32(1.0) / t_1)
	return Float32(Float32(-s) * log(Float32(Float32(Float32(-1.0) + (t_1 ^ Float32(-3.0))) / fma(t_2, Float32(Float32(1.0) + t_2), Float32(1.0)))))
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{\frac{\pi}{s}}\\
t_1 := \frac{u}{1 + e^{-\frac{\pi}{s}}} + \left(\frac{u}{-1 - t\_0} + \frac{1}{1 + t\_0}\right)\\
t_2 := \frac{1}{t\_1}\\
\left(-s\right) \cdot \log \left(\frac{-1 + {t\_1}^{-3}}{\mathsf{fma}\left(t\_2, 1 + t\_2, 1\right)}\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. Add Preprocessing
  3. Applied rewrites98.9%

    \[\leadsto \left(-s\right) \cdot \log \color{blue}{\left(\frac{{\left(\mathsf{fma}\left(u, \frac{1}{1 + e^{\frac{\pi}{-s}}} + \frac{-1}{1 + e^{\frac{\pi}{s}}}, \frac{1}{1 + e^{\frac{\pi}{s}}}\right)\right)}^{-2} + -1}{\frac{1}{\mathsf{fma}\left(u, \frac{1}{1 + e^{\frac{\pi}{-s}}} + \frac{-1}{1 + e^{\frac{\pi}{s}}}, \frac{1}{1 + e^{\frac{\pi}{s}}}\right)} - -1}\right)} \]
  4. Step-by-step derivation
    1. Applied rewrites99.0%

      \[\leadsto \left(-s\right) \cdot \log \left(\frac{{\color{blue}{\left(\frac{u}{1 + e^{\frac{\pi}{-s}}} + \left(\frac{u}{-\left(1 + e^{\frac{\pi}{s}}\right)} + \frac{1}{1 + e^{\frac{\pi}{s}}}\right)\right)}}^{-2} + -1}{\frac{1}{\mathsf{fma}\left(u, \frac{1}{1 + e^{\frac{\pi}{-s}}} + \frac{-1}{1 + e^{\frac{\pi}{s}}}, \frac{1}{1 + e^{\frac{\pi}{s}}}\right)} - -1}\right) \]
    2. Applied rewrites98.8%

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

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

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

    Alternative 2: 98.9% accurate, 0.5× speedup?

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

      \[\leadsto \left(-s\right) \cdot \log \color{blue}{\left(\frac{{\left(\mathsf{fma}\left(u, \frac{1}{1 + e^{\frac{\pi}{-s}}} + \frac{-1}{1 + e^{\frac{\pi}{s}}}, \frac{1}{1 + e^{\frac{\pi}{s}}}\right)\right)}^{-2} + -1}{\frac{1}{\mathsf{fma}\left(u, \frac{1}{1 + e^{\frac{\pi}{-s}}} + \frac{-1}{1 + e^{\frac{\pi}{s}}}, \frac{1}{1 + e^{\frac{\pi}{s}}}\right)} - -1}\right)} \]
    4. Step-by-step derivation
      1. Applied rewrites99.0%

        \[\leadsto \left(-s\right) \cdot \log \left(\frac{{\color{blue}{\left(\frac{u}{1 + e^{\frac{\pi}{-s}}} + \left(\frac{u}{-\left(1 + e^{\frac{\pi}{s}}\right)} + \frac{1}{1 + e^{\frac{\pi}{s}}}\right)\right)}}^{-2} + -1}{\frac{1}{\mathsf{fma}\left(u, \frac{1}{1 + e^{\frac{\pi}{-s}}} + \frac{-1}{1 + e^{\frac{\pi}{s}}}, \frac{1}{1 + e^{\frac{\pi}{s}}}\right)} - -1}\right) \]
      2. Applied rewrites98.8%

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

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

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

      Alternative 3: 98.9% accurate, 0.5× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\frac{\pi}{s}}\\ t_1 := -1 - t\_0\\ t_2 := \frac{u}{1 + e^{-\frac{\pi}{s}}}\\ \left(-s\right) \cdot \log \left(\mathsf{fma}\left(\frac{1}{{\left(t\_2 + \frac{u}{t\_1}\right)}^{2} - {\left(1 + t\_0\right)}^{-2}}, t\_2 + \frac{u - -1}{t\_1}, -1\right)\right) \end{array} \end{array} \]
      (FPCore (u s)
       :precision binary32
       (let* ((t_0 (exp (/ PI s)))
              (t_1 (- -1.0 t_0))
              (t_2 (/ u (+ 1.0 (exp (- (/ PI s)))))))
         (*
          (- s)
          (log
           (fma
            (/ 1.0 (- (pow (+ t_2 (/ u t_1)) 2.0) (pow (+ 1.0 t_0) -2.0)))
            (+ t_2 (/ (- u -1.0) t_1))
            -1.0)))))
      float code(float u, float s) {
      	float t_0 = expf((((float) M_PI) / s));
      	float t_1 = -1.0f - t_0;
      	float t_2 = u / (1.0f + expf(-(((float) M_PI) / s)));
      	return -s * logf(fmaf((1.0f / (powf((t_2 + (u / t_1)), 2.0f) - powf((1.0f + t_0), -2.0f))), (t_2 + ((u - -1.0f) / t_1)), -1.0f));
      }
      
      function code(u, s)
      	t_0 = exp(Float32(Float32(pi) / s))
      	t_1 = Float32(Float32(-1.0) - t_0)
      	t_2 = Float32(u / Float32(Float32(1.0) + exp(Float32(-Float32(Float32(pi) / s)))))
      	return Float32(Float32(-s) * log(fma(Float32(Float32(1.0) / Float32((Float32(t_2 + Float32(u / t_1)) ^ Float32(2.0)) - (Float32(Float32(1.0) + t_0) ^ Float32(-2.0)))), Float32(t_2 + Float32(Float32(u - Float32(-1.0)) / t_1)), Float32(-1.0))))
      end
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := e^{\frac{\pi}{s}}\\
      t_1 := -1 - t\_0\\
      t_2 := \frac{u}{1 + e^{-\frac{\pi}{s}}}\\
      \left(-s\right) \cdot \log \left(\mathsf{fma}\left(\frac{1}{{\left(t\_2 + \frac{u}{t\_1}\right)}^{2} - {\left(1 + t\_0\right)}^{-2}}, t\_2 + \frac{u - -1}{t\_1}, -1\right)\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. Add Preprocessing
      3. Applied rewrites98.9%

        \[\leadsto \left(-s\right) \cdot \log \color{blue}{\left(\frac{{\left(\mathsf{fma}\left(u, \frac{1}{1 + e^{\frac{\pi}{-s}}} + \frac{-1}{1 + e^{\frac{\pi}{s}}}, \frac{1}{1 + e^{\frac{\pi}{s}}}\right)\right)}^{-2} + -1}{\frac{1}{\mathsf{fma}\left(u, \frac{1}{1 + e^{\frac{\pi}{-s}}} + \frac{-1}{1 + e^{\frac{\pi}{s}}}, \frac{1}{1 + e^{\frac{\pi}{s}}}\right)} - -1}\right)} \]
      4. Step-by-step derivation
        1. Applied rewrites99.0%

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

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

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

        Alternative 4: 98.9% accurate, 1.0× speedup?

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

          \[\leadsto \left(-s\right) \cdot \log \color{blue}{\left(\frac{{\left(\mathsf{fma}\left(u, \frac{1}{1 + e^{\frac{\pi}{-s}}} + \frac{-1}{1 + e^{\frac{\pi}{s}}}, \frac{1}{1 + e^{\frac{\pi}{s}}}\right)\right)}^{-2} + -1}{\frac{1}{\mathsf{fma}\left(u, \frac{1}{1 + e^{\frac{\pi}{-s}}} + \frac{-1}{1 + e^{\frac{\pi}{s}}}, \frac{1}{1 + e^{\frac{\pi}{s}}}\right)} - -1}\right)} \]
        4. Step-by-step derivation
          1. Applied rewrites99.0%

            \[\leadsto \left(-s\right) \cdot \log \left(\frac{{\color{blue}{\left(\frac{u}{1 + e^{\frac{\pi}{-s}}} + \left(\frac{u}{-\left(1 + e^{\frac{\pi}{s}}\right)} + \frac{1}{1 + e^{\frac{\pi}{s}}}\right)\right)}}^{-2} + -1}{\frac{1}{\mathsf{fma}\left(u, \frac{1}{1 + e^{\frac{\pi}{-s}}} + \frac{-1}{1 + e^{\frac{\pi}{s}}}, \frac{1}{1 + e^{\frac{\pi}{s}}}\right)} - -1}\right) \]
          2. Applied rewrites98.8%

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

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

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

          Alternative 5: 98.9% accurate, 1.0× speedup?

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

            \[\leadsto \left(-s\right) \cdot \log \color{blue}{\left(\frac{{\left(\mathsf{fma}\left(u, \frac{1}{1 + e^{\frac{\pi}{-s}}} + \frac{-1}{1 + e^{\frac{\pi}{s}}}, \frac{1}{1 + e^{\frac{\pi}{s}}}\right)\right)}^{-2} + -1}{\frac{1}{\mathsf{fma}\left(u, \frac{1}{1 + e^{\frac{\pi}{-s}}} + \frac{-1}{1 + e^{\frac{\pi}{s}}}, \frac{1}{1 + e^{\frac{\pi}{s}}}\right)} - -1}\right)} \]
          4. Step-by-step derivation
            1. Applied rewrites99.0%

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

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

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

            Alternative 6: 97.4% accurate, 1.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \left(\mathsf{neg}\left(s\right)\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{\mathsf{neg}\left(s\right)}}} + \color{blue}{\frac{\mathsf{neg}\left(1\right)}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}}\right)} - 1\right) \]
            5. Applied rewrites98.4%

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

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

            Alternative 7: 25.3% accurate, 2.3× speedup?

            \[\begin{array}{l} \\ s \cdot \left(\left(-\log \pi\right) - \mathsf{fma}\left(u, -2, -\log s\right)\right) \end{array} \]
            (FPCore (u s)
             :precision binary32
             (* s (- (- (log PI)) (fma u -2.0 (- (log s))))))
            float code(float u, float s) {
            	return s * (-logf(((float) M_PI)) - fmaf(u, -2.0f, -logf(s)));
            }
            
            function code(u, s)
            	return Float32(s * Float32(Float32(-log(Float32(pi))) - fma(u, Float32(-2.0), Float32(-log(s)))))
            end
            
            \begin{array}{l}
            
            \\
            s \cdot \left(\left(-\log \pi\right) - \mathsf{fma}\left(u, -2, -\log 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. Add Preprocessing
            3. Taylor expanded in s around inf

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

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

                \[\leadsto \left(\mathsf{neg}\left(s\right)\right) \cdot \log \color{blue}{\left(\mathsf{fma}\left(-4, \frac{u \cdot \left(\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)}{s}, 1\right)\right)} \]
            5. Applied rewrites24.5%

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

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

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

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

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

                \[\leadsto \left(\mathsf{neg}\left(s\right)\right) \cdot \mathsf{fma}\left(-2, \color{blue}{u \cdot \frac{\mathsf{PI}\left(\right)}{s \cdot \left(1 + \frac{\mathsf{PI}\left(\right)}{s}\right)}}, \log \left(1 + \frac{\mathsf{PI}\left(\right)}{s}\right)\right) \]
              5. lower-/.f32N/A

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

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

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

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

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

                \[\leadsto \left(\mathsf{neg}\left(s\right)\right) \cdot \mathsf{fma}\left(-2, u \cdot \frac{\mathsf{PI}\left(\right)}{s \cdot \left(1 + \frac{\color{blue}{\mathsf{PI}\left(\right)}}{s}\right)}, \log \left(1 + \frac{\mathsf{PI}\left(\right)}{s}\right)\right) \]
              11. lower-log1p.f32N/A

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

                \[\leadsto \left(\mathsf{neg}\left(s\right)\right) \cdot \mathsf{fma}\left(-2, u \cdot \frac{\mathsf{PI}\left(\right)}{s \cdot \left(1 + \frac{\mathsf{PI}\left(\right)}{s}\right)}, \mathsf{log1p}\left(\color{blue}{\frac{\mathsf{PI}\left(\right)}{s}}\right)\right) \]
              13. lower-PI.f3224.7

                \[\leadsto \left(-s\right) \cdot \mathsf{fma}\left(-2, u \cdot \frac{\pi}{s \cdot \left(1 + \frac{\pi}{s}\right)}, \mathsf{log1p}\left(\frac{\color{blue}{\pi}}{s}\right)\right) \]
            8. Applied rewrites24.7%

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

              \[\leadsto \left(\mathsf{neg}\left(s\right)\right) \cdot \color{blue}{\left(\log \mathsf{PI}\left(\right) + \left(-2 \cdot u + -1 \cdot \log s\right)\right)} \]
            10. Step-by-step derivation
              1. lower-+.f32N/A

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

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

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

                \[\leadsto \left(\mathsf{neg}\left(s\right)\right) \cdot \left(\log \mathsf{PI}\left(\right) + \left(\color{blue}{u \cdot -2} + -1 \cdot \log s\right)\right) \]
              5. lower-fma.f32N/A

                \[\leadsto \left(\mathsf{neg}\left(s\right)\right) \cdot \left(\log \mathsf{PI}\left(\right) + \color{blue}{\mathsf{fma}\left(u, -2, -1 \cdot \log s\right)}\right) \]
              6. mul-1-negN/A

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

                \[\leadsto \left(\mathsf{neg}\left(s\right)\right) \cdot \left(\log \mathsf{PI}\left(\right) + \mathsf{fma}\left(u, -2, \color{blue}{\mathsf{neg}\left(\log s\right)}\right)\right) \]
              8. lower-log.f3225.1

                \[\leadsto \left(-s\right) \cdot \left(\log \pi + \mathsf{fma}\left(u, -2, -\color{blue}{\log s}\right)\right) \]
            11. Applied rewrites25.1%

              \[\leadsto \left(-s\right) \cdot \color{blue}{\left(\log \pi + \mathsf{fma}\left(u, -2, -\log s\right)\right)} \]
            12. Final simplification25.1%

              \[\leadsto s \cdot \left(\left(-\log \pi\right) - \mathsf{fma}\left(u, -2, -\log s\right)\right) \]
            13. Add Preprocessing

            Alternative 8: 25.1% accurate, 2.4× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + \frac{\pi}{s}\\ \mathsf{fma}\left(u, 2 \cdot \mathsf{fma}\left(u, \frac{\pi \cdot \pi}{s \cdot \left(t\_0 \cdot t\_0\right)}, \frac{\pi}{t\_0}\right), \left(-s\right) \cdot \mathsf{log1p}\left(\frac{\pi}{s}\right)\right) \end{array} \end{array} \]
            (FPCore (u s)
             :precision binary32
             (let* ((t_0 (+ 1.0 (/ PI s))))
               (fma
                u
                (* 2.0 (fma u (/ (* PI PI) (* s (* t_0 t_0))) (/ PI t_0)))
                (* (- s) (log1p (/ PI s))))))
            float code(float u, float s) {
            	float t_0 = 1.0f + (((float) M_PI) / s);
            	return fmaf(u, (2.0f * fmaf(u, ((((float) M_PI) * ((float) M_PI)) / (s * (t_0 * t_0))), (((float) M_PI) / t_0))), (-s * log1pf((((float) M_PI) / s))));
            }
            
            function code(u, s)
            	t_0 = Float32(Float32(1.0) + Float32(Float32(pi) / s))
            	return fma(u, Float32(Float32(2.0) * fma(u, Float32(Float32(Float32(pi) * Float32(pi)) / Float32(s * Float32(t_0 * t_0))), Float32(Float32(pi) / t_0))), Float32(Float32(-s) * log1p(Float32(Float32(pi) / s))))
            end
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            t_0 := 1 + \frac{\pi}{s}\\
            \mathsf{fma}\left(u, 2 \cdot \mathsf{fma}\left(u, \frac{\pi \cdot \pi}{s \cdot \left(t\_0 \cdot t\_0\right)}, \frac{\pi}{t\_0}\right), \left(-s\right) \cdot \mathsf{log1p}\left(\frac{\pi}{s}\right)\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. Add Preprocessing
            3. Taylor expanded in s around inf

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

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

                \[\leadsto \left(\mathsf{neg}\left(s\right)\right) \cdot \log \color{blue}{\left(\mathsf{fma}\left(-4, \frac{u \cdot \left(\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)}{s}, 1\right)\right)} \]
            5. Applied rewrites24.5%

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

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

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(u, 2 \cdot \frac{\mathsf{PI}\left(\right)}{1 + \frac{\mathsf{PI}\left(\right)}{s}} + 2 \cdot \frac{u \cdot {\mathsf{PI}\left(\right)}^{2}}{s \cdot {\left(1 + \frac{\mathsf{PI}\left(\right)}{s}\right)}^{2}}, -1 \cdot \left(s \cdot \log \left(1 + \frac{\mathsf{PI}\left(\right)}{s}\right)\right)\right)} \]
            8. Applied rewrites24.8%

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

            Alternative 9: 25.1% accurate, 3.6× speedup?

            \[\begin{array}{l} \\ \left(-s\right) \cdot \mathsf{fma}\left(-2, u \cdot \frac{\pi}{\pi}, \mathsf{log1p}\left(\frac{\pi}{s}\right)\right) \end{array} \]
            (FPCore (u s)
             :precision binary32
             (* (- s) (fma -2.0 (* u (/ PI PI)) (log1p (/ PI s)))))
            float code(float u, float s) {
            	return -s * fmaf(-2.0f, (u * (((float) M_PI) / ((float) M_PI))), log1pf((((float) M_PI) / s)));
            }
            
            function code(u, s)
            	return Float32(Float32(-s) * fma(Float32(-2.0), Float32(u * Float32(Float32(pi) / Float32(pi))), log1p(Float32(Float32(pi) / s))))
            end
            
            \begin{array}{l}
            
            \\
            \left(-s\right) \cdot \mathsf{fma}\left(-2, u \cdot \frac{\pi}{\pi}, \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. Add Preprocessing
            3. Taylor expanded in s around inf

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

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

                \[\leadsto \left(\mathsf{neg}\left(s\right)\right) \cdot \log \color{blue}{\left(\mathsf{fma}\left(-4, \frac{u \cdot \left(\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)}{s}, 1\right)\right)} \]
            5. Applied rewrites24.5%

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

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

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

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

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

                \[\leadsto \left(\mathsf{neg}\left(s\right)\right) \cdot \mathsf{fma}\left(-2, \color{blue}{u \cdot \frac{\mathsf{PI}\left(\right)}{s \cdot \left(1 + \frac{\mathsf{PI}\left(\right)}{s}\right)}}, \log \left(1 + \frac{\mathsf{PI}\left(\right)}{s}\right)\right) \]
              5. lower-/.f32N/A

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

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

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

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

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

                \[\leadsto \left(\mathsf{neg}\left(s\right)\right) \cdot \mathsf{fma}\left(-2, u \cdot \frac{\mathsf{PI}\left(\right)}{s \cdot \left(1 + \frac{\color{blue}{\mathsf{PI}\left(\right)}}{s}\right)}, \log \left(1 + \frac{\mathsf{PI}\left(\right)}{s}\right)\right) \]
              11. lower-log1p.f32N/A

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

                \[\leadsto \left(\mathsf{neg}\left(s\right)\right) \cdot \mathsf{fma}\left(-2, u \cdot \frac{\mathsf{PI}\left(\right)}{s \cdot \left(1 + \frac{\mathsf{PI}\left(\right)}{s}\right)}, \mathsf{log1p}\left(\color{blue}{\frac{\mathsf{PI}\left(\right)}{s}}\right)\right) \]
              13. lower-PI.f3224.7

                \[\leadsto \left(-s\right) \cdot \mathsf{fma}\left(-2, u \cdot \frac{\pi}{s \cdot \left(1 + \frac{\pi}{s}\right)}, \mathsf{log1p}\left(\frac{\color{blue}{\pi}}{s}\right)\right) \]
            8. Applied rewrites24.7%

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

              \[\leadsto \left(\mathsf{neg}\left(s\right)\right) \cdot \mathsf{fma}\left(-2, u \cdot \frac{\mathsf{PI}\left(\right)}{\color{blue}{\mathsf{PI}\left(\right)}}, \mathsf{log1p}\left(\frac{\mathsf{PI}\left(\right)}{s}\right)\right) \]
            10. Step-by-step derivation
              1. lower-PI.f3224.8

                \[\leadsto \left(-s\right) \cdot \mathsf{fma}\left(-2, u \cdot \frac{\pi}{\color{blue}{\pi}}, \mathsf{log1p}\left(\frac{\pi}{s}\right)\right) \]
            11. Applied rewrites24.8%

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

            Alternative 10: 25.1% accurate, 4.3× 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. Add Preprocessing
            3. Taylor expanded in s around inf

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

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

                \[\leadsto \left(\mathsf{neg}\left(s\right)\right) \cdot \log \color{blue}{\left(\mathsf{fma}\left(-4, \frac{u \cdot \left(\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)}{s}, 1\right)\right)} \]
            5. Applied rewrites24.5%

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

              \[\leadsto \left(\mathsf{neg}\left(s\right)\right) \cdot \color{blue}{\log \left(1 + \frac{\mathsf{PI}\left(\right)}{s}\right)} \]
            7. Step-by-step derivation
              1. lower-log1p.f32N/A

                \[\leadsto \left(\mathsf{neg}\left(s\right)\right) \cdot \color{blue}{\mathsf{log1p}\left(\frac{\mathsf{PI}\left(\right)}{s}\right)} \]
              2. lower-/.f32N/A

                \[\leadsto \left(\mathsf{neg}\left(s\right)\right) \cdot \mathsf{log1p}\left(\color{blue}{\frac{\mathsf{PI}\left(\right)}{s}}\right) \]
              3. lower-PI.f3224.7

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

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

            Alternative 11: 11.8% accurate, 20.4× speedup?

            \[\begin{array}{l} \\ u \cdot \mathsf{fma}\left(\pi, 2, -\frac{\pi}{u}\right) \end{array} \]
            (FPCore (u s) :precision binary32 (* u (fma PI 2.0 (- (/ PI u)))))
            float code(float u, float s) {
            	return u * fmaf(((float) M_PI), 2.0f, -(((float) M_PI) / u));
            }
            
            function code(u, s)
            	return Float32(u * fma(Float32(pi), Float32(2.0), Float32(-Float32(Float32(pi) / u))))
            end
            
            \begin{array}{l}
            
            \\
            u \cdot \mathsf{fma}\left(\pi, 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. Add Preprocessing
            3. Taylor expanded in s around inf

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

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

                \[\leadsto \left(\mathsf{neg}\left(s\right)\right) \cdot \log \color{blue}{\left(\mathsf{fma}\left(-4, \frac{u \cdot \left(\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)}{s}, 1\right)\right)} \]
            5. Applied rewrites24.5%

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

              \[\leadsto \color{blue}{4 \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) + \frac{1}{2} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right)\right)} \]
            7. Step-by-step derivation
              1. lower-*.f32N/A

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

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

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

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

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

                \[\leadsto 4 \cdot \left(\color{blue}{\mathsf{PI}\left(\right)} \cdot \left(\frac{1}{2} \cdot u + \frac{-1}{4}\right)\right) \]
              7. lower-fma.f3211.0

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

              \[\leadsto \color{blue}{4 \cdot \left(\pi \cdot \mathsf{fma}\left(0.5, u, -0.25\right)\right)} \]
            9. Taylor expanded in u around inf

              \[\leadsto \color{blue}{u \cdot \left(-1 \cdot \frac{\mathsf{PI}\left(\right)}{u} + 2 \cdot \mathsf{PI}\left(\right)\right)} \]
            10. Step-by-step derivation
              1. lower-*.f32N/A

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

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

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

                \[\leadsto u \cdot \color{blue}{\mathsf{fma}\left(\mathsf{PI}\left(\right), 2, -1 \cdot \frac{\mathsf{PI}\left(\right)}{u}\right)} \]
              5. lower-PI.f32N/A

                \[\leadsto u \cdot \mathsf{fma}\left(\color{blue}{\mathsf{PI}\left(\right)}, 2, -1 \cdot \frac{\mathsf{PI}\left(\right)}{u}\right) \]
              6. mul-1-negN/A

                \[\leadsto u \cdot \mathsf{fma}\left(\mathsf{PI}\left(\right), 2, \color{blue}{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{u}\right)}\right) \]
              7. lower-neg.f32N/A

                \[\leadsto u \cdot \mathsf{fma}\left(\mathsf{PI}\left(\right), 2, \color{blue}{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{u}\right)}\right) \]
              8. lower-/.f32N/A

                \[\leadsto u \cdot \mathsf{fma}\left(\mathsf{PI}\left(\right), 2, \mathsf{neg}\left(\color{blue}{\frac{\mathsf{PI}\left(\right)}{u}}\right)\right) \]
              9. lower-PI.f3211.0

                \[\leadsto u \cdot \mathsf{fma}\left(\pi, 2, -\frac{\color{blue}{\pi}}{u}\right) \]
            11. Applied rewrites11.0%

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

            Alternative 12: 11.8% accurate, 36.4× speedup?

            \[\begin{array}{l} \\ \mathsf{fma}\left(2, u \cdot \pi, -\pi\right) \end{array} \]
            (FPCore (u s) :precision binary32 (fma 2.0 (* u PI) (- PI)))
            float code(float u, float s) {
            	return fmaf(2.0f, (u * ((float) M_PI)), -((float) M_PI));
            }
            
            function code(u, s)
            	return fma(Float32(2.0), Float32(u * Float32(pi)), Float32(-Float32(pi)))
            end
            
            \begin{array}{l}
            
            \\
            \mathsf{fma}\left(2, u \cdot \pi, -\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. Add Preprocessing
            3. Taylor expanded in s around inf

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

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

                \[\leadsto \left(\mathsf{neg}\left(s\right)\right) \cdot \log \color{blue}{\left(\mathsf{fma}\left(-4, \frac{u \cdot \left(\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)}{s}, 1\right)\right)} \]
            5. Applied rewrites24.5%

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

              \[\leadsto \color{blue}{4 \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) + \frac{1}{2} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right)\right)} \]
            7. Step-by-step derivation
              1. lower-*.f32N/A

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

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

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

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

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

                \[\leadsto 4 \cdot \left(\color{blue}{\mathsf{PI}\left(\right)} \cdot \left(\frac{1}{2} \cdot u + \frac{-1}{4}\right)\right) \]
              7. lower-fma.f3211.0

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

              \[\leadsto \color{blue}{4 \cdot \left(\pi \cdot \mathsf{fma}\left(0.5, u, -0.25\right)\right)} \]
            9. Taylor expanded in u around 0

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

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(2, u \cdot \mathsf{PI}\left(\right), -1 \cdot \mathsf{PI}\left(\right)\right)} \]
              3. *-commutativeN/A

                \[\leadsto \mathsf{fma}\left(2, \color{blue}{\mathsf{PI}\left(\right) \cdot u}, -1 \cdot \mathsf{PI}\left(\right)\right) \]
              4. lower-*.f32N/A

                \[\leadsto \mathsf{fma}\left(2, \color{blue}{\mathsf{PI}\left(\right) \cdot u}, -1 \cdot \mathsf{PI}\left(\right)\right) \]
              5. lower-PI.f32N/A

                \[\leadsto \mathsf{fma}\left(2, \color{blue}{\mathsf{PI}\left(\right)} \cdot u, -1 \cdot \mathsf{PI}\left(\right)\right) \]
              6. mul-1-negN/A

                \[\leadsto \mathsf{fma}\left(2, \mathsf{PI}\left(\right) \cdot u, \color{blue}{\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)}\right) \]
              7. lower-neg.f32N/A

                \[\leadsto \mathsf{fma}\left(2, \mathsf{PI}\left(\right) \cdot u, \color{blue}{\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)}\right) \]
              8. lower-PI.f3211.0

                \[\leadsto \mathsf{fma}\left(2, \pi \cdot u, -\color{blue}{\pi}\right) \]
            11. Applied rewrites11.0%

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

              \[\leadsto \mathsf{fma}\left(2, u \cdot \pi, -\pi\right) \]
            13. Add Preprocessing

            Alternative 13: 11.6% accurate, 170.0× 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. Add Preprocessing
            3. Taylor expanded in u around 0

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

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

                \[\leadsto \color{blue}{\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)} \]
              3. lower-PI.f3210.7

                \[\leadsto -\color{blue}{\pi} \]
            5. Applied rewrites10.7%

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

            Alternative 14: 10.3% accurate, 510.0× speedup?

            \[\begin{array}{l} \\ 0 \end{array} \]
            (FPCore (u s) :precision binary32 0.0)
            float code(float u, float s) {
            	return 0.0f;
            }
            
            real(4) function code(u, s)
                real(4), intent (in) :: u
                real(4), intent (in) :: s
                code = 0.0e0
            end function
            
            function code(u, s)
            	return Float32(0.0)
            end
            
            function tmp = code(u, s)
            	tmp = single(0.0);
            end
            
            \begin{array}{l}
            
            \\
            0
            \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. Add Preprocessing
            3. Taylor expanded in s around inf

              \[\leadsto \left(\mathsf{neg}\left(s\right)\right) \cdot \log \color{blue}{1} \]
            4. Step-by-step derivation
              1. Applied rewrites10.2%

                \[\leadsto \left(-s\right) \cdot \log \color{blue}{1} \]
              2. Step-by-step derivation
                1. lift-neg.f32N/A

                  \[\leadsto \color{blue}{\left(\mathsf{neg}\left(s\right)\right)} \cdot \log 1 \]
                2. metadata-evalN/A

                  \[\leadsto \left(\mathsf{neg}\left(s\right)\right) \cdot \color{blue}{0} \]
                3. mul0-rgt10.2

                  \[\leadsto \color{blue}{0} \]
              3. Applied rewrites10.2%

                \[\leadsto \color{blue}{0} \]
              4. Add Preprocessing

              Reproduce

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