Sample trimmed logistic on [-pi, pi]

Percentage Accurate: 98.9% → 98.9%
Time: 19.2s
Alternatives: 17
Speedup: N/A×

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 17 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.5× speedup?

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.9% accurate, 1.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 98.9% accurate, 1.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 25.3% accurate, 2.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \color{blue}{\left(\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)}\right) \]
  8. Step-by-step derivation
    1. +-lowering-+.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), u\right)\right), \mathsf{*.f32}\left(s, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{PI}\left(\right), \color{blue}{s}\right)\right)\right)\right)\right)\right) \]
    15. PI-lowering-PI.f3225.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{log.f32}\left(\mathsf{PI.f32}\left(\right)\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(u, -2\right), \mathsf{neg.f32}\left(\log s\right)\right)\right)\right) \]
    13. log-lowering-log.f3225.6%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{log.f32}\left(\mathsf{PI.f32}\left(\right)\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(u, -2\right), \mathsf{neg.f32}\left(\mathsf{log.f32}\left(s\right)\right)\right)\right)\right) \]
  12. Simplified25.6%

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

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

Alternative 5: 25.2% accurate, 3.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \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)} \]
  8. Step-by-step derivation
    1. +-lowering-+.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\left(-1 \cdot \left(s \cdot \log \left(1 + \frac{\mathsf{PI}\left(\right)}{s}\right)\right)\right), \color{blue}{\left(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)\right)}\right) \]
    2. associate-*r*N/A

      \[\leadsto \mathsf{+.f32}\left(\left(\left(-1 \cdot s\right) \cdot \log \left(1 + \frac{\mathsf{PI}\left(\right)}{s}\right)\right), \left(\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)\right)\right) \]
    3. *-lowering-*.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(\left(-1 \cdot s\right), \log \left(1 + \frac{\mathsf{PI}\left(\right)}{s}\right)\right), \left(\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)\right)\right) \]
    4. mul-1-negN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(\left(\mathsf{neg}\left(s\right)\right), \log \left(1 + \frac{\mathsf{PI}\left(\right)}{s}\right)\right), \left(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)\right)\right) \]
    5. neg-lowering-neg.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \log \left(1 + \frac{\mathsf{PI}\left(\right)}{s}\right)\right), \left(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)\right)\right) \]
    6. log1p-defineN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \left(\mathsf{log1p}\left(\frac{\mathsf{PI}\left(\right)}{s}\right)\right)\right), \left(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)\right)\right) \]
    7. log1p-lowering-log1p.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log1p.f32}\left(\left(\frac{\mathsf{PI}\left(\right)}{s}\right)\right)\right), \left(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)\right)\right) \]
    8. /-lowering-/.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{PI}\left(\right), s\right)\right)\right), \left(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)\right)\right) \]
    9. PI-lowering-PI.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right), \left(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)\right)\right) \]
    10. *-lowering-*.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right), \mathsf{*.f32}\left(u, \color{blue}{\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)}\right)\right) \]
    11. distribute-lft-outN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right), \mathsf{*.f32}\left(u, \left(2 \cdot \color{blue}{\left(\frac{\mathsf{PI}\left(\right)}{1 + \frac{\mathsf{PI}\left(\right)}{s}} + \frac{u \cdot {\mathsf{PI}\left(\right)}^{2}}{s \cdot {\left(1 + \frac{\mathsf{PI}\left(\right)}{s}\right)}^{2}}\right)}\right)\right)\right) \]
  9. Simplified25.4%

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

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

Alternative 6: 25.2% accurate, 3.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \color{blue}{\left(\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)}\right) \]
  8. Step-by-step derivation
    1. +-lowering-+.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), u\right)\right), \mathsf{*.f32}\left(s, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{PI}\left(\right), \color{blue}{s}\right)\right)\right)\right)\right)\right) \]
    15. PI-lowering-PI.f3225.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{*.f32}\left(u, \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{PI.f32}\left(\right)\right), \mathsf{*.f32}\left(s, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{PI}\left(\right), s\right)\right), u\right)\right)\right)\right) \]
    15. PI-lowering-PI.f3225.4%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{*.f32}\left(u, \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{PI.f32}\left(\right)\right), \mathsf{*.f32}\left(s, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right), \mathsf{/.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right), u\right)\right)\right)\right) \]
  12. Simplified25.4%

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

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

Alternative 7: 25.2% accurate, 3.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \color{blue}{\left(\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)}\right) \]
  8. Step-by-step derivation
    1. +-lowering-+.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), u\right)\right), \mathsf{*.f32}\left(s, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{PI}\left(\right), \color{blue}{s}\right)\right)\right)\right)\right)\right) \]
    15. PI-lowering-PI.f3225.4%

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f32}\left(u, \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\left(-1 \cdot s\right), \log \left(1 + \frac{\mathsf{PI}\left(\right)}{s}\right)\right), u\right), \left(2 \cdot \frac{\mathsf{PI}\left(\right)}{1 + \frac{\mathsf{PI}\left(\right)}{s}}\right)\right)\right) \]
    7. mul-1-negN/A

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

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

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

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

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

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

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

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

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

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

Alternative 8: 25.2% accurate, 3.7× speedup?

\[\begin{array}{l} \\ \frac{2 \cdot \left(u \cdot \pi\right)}{1 + \frac{\pi}{s}} - 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(Float32(2.0) * Float32(u * Float32(pi))) / Float32(Float32(1.0) + Float32(Float32(pi) / s))) - Float32(s * log1p(Float32(Float32(pi) / s))))
end
\begin{array}{l}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), u\right)\right), \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{PI}\left(\right), \color{blue}{s}\right)\right)\right)\right) \]
    18. PI-lowering-PI.f3225.4%

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

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

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

Alternative 9: 25.2% accurate, 3.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \color{blue}{\left(\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)}\right) \]
  8. Step-by-step derivation
    1. +-lowering-+.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), u\right)\right), \mathsf{*.f32}\left(s, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{PI}\left(\right), \color{blue}{s}\right)\right)\right)\right)\right)\right) \]
    15. PI-lowering-PI.f3225.4%

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

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

    \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), u\right)\right), \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
  11. Step-by-step derivation
    1. PI-lowering-PI.f3225.4%

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

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

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

Alternative 10: 25.1% accurate, 3.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \left(-s\right) \cdot \log \left(1 + \color{blue}{\left(\pi \cdot -0.25\right)} \cdot \frac{-4}{s}\right) \]
  10. Add Preprocessing

Alternative 11: 25.2% accurate, 4.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{PI}\left(\right), s\right)\right)\right)\right) \]
    2. PI-lowering-PI.f3225.4%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right) \]
  9. Simplified25.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log1p.f32}\left(\left(\frac{\mathsf{PI}\left(\right)}{s}\right)\right)\right) \]
    3. /-lowering-/.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{PI}\left(\right), s\right)\right)\right) \]
    4. PI-lowering-PI.f3225.4%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right) \]
  9. Simplified25.4%

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

Alternative 13: 13.9% accurate, 39.4× speedup?

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

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

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

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

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

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

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

    \[\leadsto \left(-s\right) \cdot \color{blue}{\frac{\pi}{s}} \]
  7. Step-by-step derivation
    1. neg-sub0N/A

      \[\leadsto \mathsf{*.f32}\left(\left(0 - s\right), \mathsf{/.f32}\left(\color{blue}{\mathsf{PI.f32}\left(\right)}, s\right)\right) \]
    2. flip--N/A

      \[\leadsto \mathsf{*.f32}\left(\left(\frac{0 \cdot 0 - s \cdot s}{0 + s}\right), \mathsf{/.f32}\left(\color{blue}{\mathsf{PI.f32}\left(\right)}, s\right)\right) \]
    3. metadata-evalN/A

      \[\leadsto \mathsf{*.f32}\left(\left(\frac{0 - s \cdot s}{0 + s}\right), \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right) \]
    4. neg-sub0N/A

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{/.f32}\left(\left(\mathsf{neg}\left(s \cdot s\right)\right), \left(0 + s\right)\right), \mathsf{/.f32}\left(\color{blue}{\mathsf{PI.f32}\left(\right)}, s\right)\right) \]
    6. neg-sub0N/A

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{/.f32}\left(\mathsf{\_.f32}\left(0, \left(s \cdot s\right)\right), \left(0 + s\right)\right), \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right) \]
    8. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{/.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{*.f32}\left(s, s\right)\right), \left(0 + s\right)\right), \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right) \]
    9. +-lowering-+.f3213.2%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{/.f32}\left(\mathsf{\_.f32}\left(0, \mathsf{*.f32}\left(s, s\right)\right), \mathsf{+.f32}\left(0, s\right)\right), \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right) \]
  8. Applied egg-rr13.2%

    \[\leadsto \color{blue}{\frac{0 - s \cdot s}{0 + s}} \cdot \frac{\pi}{s} \]
  9. Final simplification13.2%

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

Alternative 14: 11.6% accurate, 61.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \color{blue}{\left(\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)}\right) \]
  8. Step-by-step derivation
    1. +-lowering-+.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{+.f32}\left(\mathsf{log1p.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), u\right)\right), \mathsf{*.f32}\left(s, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{PI}\left(\right), \color{blue}{s}\right)\right)\right)\right)\right)\right) \]
    15. PI-lowering-PI.f3225.4%

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{+.f32}\left(\mathsf{neg.f32}\left(\mathsf{PI.f32}\left(\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI}\left(\right), \color{blue}{u}\right)\right)\right) \]
    8. PI-lowering-PI.f3211.0%

      \[\leadsto \mathsf{+.f32}\left(\mathsf{neg.f32}\left(\mathsf{PI.f32}\left(\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), u\right)\right)\right) \]
  12. Simplified11.0%

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

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

Alternative 15: 11.3% accurate, 61.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{/.f32}\left(1, s\right), \left(\mathsf{neg}\left(\color{blue}{s}\right)\right)\right)\right) \]
    8. neg-lowering-neg.f3210.9%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{/.f32}\left(1, s\right), \mathsf{neg.f32}\left(s\right)\right)\right) \]
  8. Applied egg-rr10.9%

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

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

Alternative 16: 11.3% accurate, 216.5× speedup?

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

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

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

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

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

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

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

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

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

Alternative 17: 10.3% accurate, 433.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 99.0%

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

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

    \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\color{blue}{1}\right)\right) \]
  5. Step-by-step derivation
    1. Simplified10.3%

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

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

        \[\leadsto 0 \]
    3. Applied egg-rr10.3%

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

    Reproduce

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