Sample trimmed logistic on [-pi, pi]

Percentage Accurate: 99.0% → 99.0%
Time: 16.8s
Alternatives: 10
Speedup: 1.0×

Specification

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

\\
\begin{array}{l}
t_0 := \frac{1}{1 + e^{\frac{\pi}{s}}}\\
\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\pi}{s}}} - t\_0\right) + t\_0} - 1\right)
\end{array}
\end{array}

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 10 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.0% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{1}{1 + e^{\frac{\pi}{s}}}\\
\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\pi}{s}}} - t\_0\right) + t\_0} - 1\right)
\end{array}
\end{array}

Alternative 1: 99.0% accurate, 1.0× speedup?

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

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

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

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

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

    \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\color{blue}{\mathsf{fma}\left(\frac{1}{1 + e^{-\frac{\pi}{s}}} + \frac{-1}{1 + e^{\frac{\pi}{s}}}, u, \frac{1}{1 + e^{\frac{\pi}{s}}}\right)}} - 1\right) \]
  5. 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{fma.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{neg.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(-1, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right), u, \mathsf{/.f32}\left(1, \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{fma.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{neg.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(-1, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right), u, \mathsf{/.f32}\left(1, \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{fma.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{neg.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(-1, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right), u, \mathsf{/.f32}\left(1, \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{fma.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{neg.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(-1, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right), u, \mathsf{/.f32}\left(1, \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.1%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(1, \mathsf{fma.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{neg.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(-1, \mathsf{+.f32}\left(1, \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right), u, \mathsf{/.f32}\left(1, \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) \]
  6. Applied egg-rr99.1%

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

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

Alternative 2: 99.0% accurate, 1.0× speedup?

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

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

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

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

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

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

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

Alternative 3: 98.7% accurate, 1.3× speedup?

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

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

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

    \[\leadsto \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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \color{blue}{\left(1 + -1 \cdot \frac{-1 \cdot \mathsf{PI}\left(\right) + \frac{-1}{2} \cdot \frac{{\mathsf{PI}\left(\right)}^{2}}{s}}{s}\right)}\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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. Step-by-step derivation
    1. mul-1-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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \left(1 + \left(\mathsf{neg}\left(\frac{-1 \cdot \mathsf{PI}\left(\right) + \frac{-1}{2} \cdot \frac{{\mathsf{PI}\left(\right)}^{2}}{s}}{s}\right)\right)\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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. unsub-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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \left(1 - \frac{-1 \cdot \mathsf{PI}\left(\right) + \frac{-1}{2} \cdot \frac{{\mathsf{PI}\left(\right)}^{2}}{s}}{s}\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(1, \left(\frac{-1 \cdot \mathsf{PI}\left(\right) + \frac{-1}{2} \cdot \frac{{\mathsf{PI}\left(\right)}^{2}}{s}}{s}\right)\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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. /-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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\left(-1 \cdot \mathsf{PI}\left(\right) + \frac{-1}{2} \cdot \frac{{\mathsf{PI}\left(\right)}^{2}}{s}\right), s\right)\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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. +-commutativeN/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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\left(\frac{-1}{2} \cdot \frac{{\mathsf{PI}\left(\right)}^{2}}{s} + -1 \cdot \mathsf{PI}\left(\right)\right), s\right)\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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) \]
    6. accelerator-lowering-fma.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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{fma.f32}\left(\frac{-1}{2}, \left(\frac{{\mathsf{PI}\left(\right)}^{2}}{s}\right), \left(-1 \cdot \mathsf{PI}\left(\right)\right)\right), s\right)\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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) \]
    7. /-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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{fma.f32}\left(\frac{-1}{2}, \mathsf{/.f32}\left(\left({\mathsf{PI}\left(\right)}^{2}\right), s\right), \left(-1 \cdot \mathsf{PI}\left(\right)\right)\right), s\right)\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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) \]
    8. unpow2N/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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{fma.f32}\left(\frac{-1}{2}, \mathsf{/.f32}\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right), s\right), \left(-1 \cdot \mathsf{PI}\left(\right)\right)\right), s\right)\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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) \]
    9. *-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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{fma.f32}\left(\frac{-1}{2}, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{PI}\left(\right), \mathsf{PI}\left(\right)\right), s\right), \left(-1 \cdot \mathsf{PI}\left(\right)\right)\right), s\right)\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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) \]
    10. PI-lowering-PI.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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{fma.f32}\left(\frac{-1}{2}, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI}\left(\right)\right), s\right), \left(-1 \cdot \mathsf{PI}\left(\right)\right)\right), s\right)\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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) \]
    11. PI-lowering-PI.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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{fma.f32}\left(\frac{-1}{2}, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right), s\right), \left(-1 \cdot \mathsf{PI}\left(\right)\right)\right), s\right)\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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) \]
    12. mul-1-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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{fma.f32}\left(\frac{-1}{2}, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right), s\right), \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right)\right), s\right)\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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) \]
    13. 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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{fma.f32}\left(\frac{-1}{2}, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right), s\right), \mathsf{neg.f32}\left(\mathsf{PI}\left(\right)\right)\right), s\right)\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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) \]
    14. PI-lowering-PI.f3297.2%

      \[\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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{fma.f32}\left(\frac{-1}{2}, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right), s\right), \mathsf{neg.f32}\left(\mathsf{PI.f32}\left(\right)\right)\right), s\right)\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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. Simplified97.2%

    \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\pi}{s}}} - \frac{1}{1 + \color{blue}{\left(1 - \frac{\mathsf{fma}\left(-0.5, \frac{\pi \cdot \pi}{s}, -\pi\right)}{s}\right)}}\right) + \frac{1}{1 + e^{\frac{\pi}{s}}}} - 1\right) \]
  6. Taylor expanded in s around 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(\color{blue}{\left(\frac{u}{1 + e^{-1 \cdot \frac{\mathsf{PI}\left(\right)}{s}}}\right)}, \mathsf{/.f32}\left(1, \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) \]
  7. 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(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(u, \left(1 + e^{-1 \cdot \frac{\mathsf{PI}\left(\right)}{s}}\right)\right), \mathsf{/.f32}\left(1, \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. +-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, \left(e^{-1 \cdot \frac{\mathsf{PI}\left(\right)}{s}}\right)\right)\right), \mathsf{/.f32}\left(1, \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. exp-lowering-exp.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(\left(-1 \cdot \frac{\mathsf{PI}\left(\right)}{s}\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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. mul-1-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(1, \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. neg-sub0N/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(0 - \frac{\mathsf{PI}\left(\right)}{s}\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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) \]
    6. --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(0, \left(\frac{\mathsf{PI}\left(\right)}{s}\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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) \]
    7. /-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(0, \mathsf{/.f32}\left(\mathsf{PI}\left(\right), s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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) \]
    8. PI-lowering-PI.f3298.8%

      \[\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(0, \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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) \]
  8. Simplified98.8%

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

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

Alternative 4: 85.5% accurate, 1.4× speedup?

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

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

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

    \[\leadsto \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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \color{blue}{\left(1 + -1 \cdot \frac{-1 \cdot \mathsf{PI}\left(\right) + \frac{-1}{2} \cdot \frac{{\mathsf{PI}\left(\right)}^{2}}{s}}{s}\right)}\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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. Step-by-step derivation
    1. mul-1-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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \left(1 + \left(\mathsf{neg}\left(\frac{-1 \cdot \mathsf{PI}\left(\right) + \frac{-1}{2} \cdot \frac{{\mathsf{PI}\left(\right)}^{2}}{s}}{s}\right)\right)\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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. unsub-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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \left(1 - \frac{-1 \cdot \mathsf{PI}\left(\right) + \frac{-1}{2} \cdot \frac{{\mathsf{PI}\left(\right)}^{2}}{s}}{s}\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(1, \left(\frac{-1 \cdot \mathsf{PI}\left(\right) + \frac{-1}{2} \cdot \frac{{\mathsf{PI}\left(\right)}^{2}}{s}}{s}\right)\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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. /-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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\left(-1 \cdot \mathsf{PI}\left(\right) + \frac{-1}{2} \cdot \frac{{\mathsf{PI}\left(\right)}^{2}}{s}\right), s\right)\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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. +-commutativeN/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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\left(\frac{-1}{2} \cdot \frac{{\mathsf{PI}\left(\right)}^{2}}{s} + -1 \cdot \mathsf{PI}\left(\right)\right), s\right)\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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) \]
    6. accelerator-lowering-fma.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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{fma.f32}\left(\frac{-1}{2}, \left(\frac{{\mathsf{PI}\left(\right)}^{2}}{s}\right), \left(-1 \cdot \mathsf{PI}\left(\right)\right)\right), s\right)\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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) \]
    7. /-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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{fma.f32}\left(\frac{-1}{2}, \mathsf{/.f32}\left(\left({\mathsf{PI}\left(\right)}^{2}\right), s\right), \left(-1 \cdot \mathsf{PI}\left(\right)\right)\right), s\right)\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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) \]
    8. unpow2N/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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{fma.f32}\left(\frac{-1}{2}, \mathsf{/.f32}\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right), s\right), \left(-1 \cdot \mathsf{PI}\left(\right)\right)\right), s\right)\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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) \]
    9. *-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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{fma.f32}\left(\frac{-1}{2}, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{PI}\left(\right), \mathsf{PI}\left(\right)\right), s\right), \left(-1 \cdot \mathsf{PI}\left(\right)\right)\right), s\right)\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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) \]
    10. PI-lowering-PI.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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{fma.f32}\left(\frac{-1}{2}, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI}\left(\right)\right), s\right), \left(-1 \cdot \mathsf{PI}\left(\right)\right)\right), s\right)\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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) \]
    11. PI-lowering-PI.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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{fma.f32}\left(\frac{-1}{2}, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right), s\right), \left(-1 \cdot \mathsf{PI}\left(\right)\right)\right), s\right)\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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) \]
    12. mul-1-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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{fma.f32}\left(\frac{-1}{2}, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right), s\right), \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right)\right), s\right)\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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) \]
    13. 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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{fma.f32}\left(\frac{-1}{2}, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right), s\right), \mathsf{neg.f32}\left(\mathsf{PI}\left(\right)\right)\right), s\right)\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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) \]
    14. PI-lowering-PI.f3297.2%

      \[\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(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{fma.f32}\left(\frac{-1}{2}, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right), s\right), \mathsf{neg.f32}\left(\mathsf{PI.f32}\left(\right)\right)\right), s\right)\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \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. Simplified97.2%

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

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

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{/.f32}\left(-1, \mathsf{/.f32}\left(1, s\right)\right), \mathsf{log.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(u, \mathsf{\_.f32}\left(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{fma.f32}\left(\frac{-1}{2}, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right), s\right), \mathsf{neg.f32}\left(\mathsf{PI.f32}\left(\right)\right)\right), s\right)\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{PI}\left(\right), s\right)\right)\right)\right)\right)\right), 1\right)\right)\right) \]
    3. PI-lowering-PI.f3284.1%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{/.f32}\left(-1, \mathsf{/.f32}\left(1, s\right)\right), \mathsf{log.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(u, \mathsf{\_.f32}\left(\mathsf{/.f32}\left(1, \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(1, \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{fma.f32}\left(\frac{-1}{2}, \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right), s\right), \mathsf{neg.f32}\left(\mathsf{PI.f32}\left(\right)\right)\right), s\right)\right)\right)\right)\right)\right), \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), s\right)\right)\right)\right)\right)\right), 1\right)\right)\right) \]
  9. Simplified84.1%

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

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

Alternative 5: 25.0% accurate, 3.8× speedup?

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

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

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

    \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\mathsf{\_.f32}\left(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\color{blue}{\left(\frac{u \cdot \left(\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}{s}\right)}, \mathsf{/.f32}\left(1, \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. 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(\mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(\left(u \cdot \left(\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)\right), s\right), \mathsf{/.f32}\left(1, \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-rgt-out--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(\left(u \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{4} - \frac{-1}{4}\right)\right)\right), s\right), \mathsf{/.f32}\left(1, \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. metadata-evalN/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(\left(u \cdot \left(\mathsf{PI}\left(\right) \cdot \frac{1}{2}\right)\right), s\right), \mathsf{/.f32}\left(1, \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. *-commutativeN/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(\left(u \cdot \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right)\right), s\right), \mathsf{/.f32}\left(1, \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. *-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(\mathsf{*.f32}\left(u, \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right)\right), s\right), \mathsf{/.f32}\left(1, \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) \]
    6. *-commutativeN/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(\mathsf{*.f32}\left(u, \left(\mathsf{PI}\left(\right) \cdot \frac{1}{2}\right)\right), s\right), \mathsf{/.f32}\left(1, \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) \]
    7. *-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(\mathsf{*.f32}\left(u, \mathsf{*.f32}\left(\mathsf{PI}\left(\right), \frac{1}{2}\right)\right), s\right), \mathsf{/.f32}\left(1, \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) \]
    8. PI-lowering-PI.f325.1%

      \[\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(\mathsf{*.f32}\left(u, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right), s\right), \mathsf{/.f32}\left(1, \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. Simplified5.1%

    \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\color{blue}{\frac{u \cdot \left(\pi \cdot 0.5\right)}{s}} + \frac{1}{1 + e^{\frac{\pi}{s}}}} - 1\right) \]
  6. 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}{2} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)}{s}\right)}\right)\right) \]
  7. Step-by-step derivation
    1. associate-*r/N/A

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

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

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{neg.f32}\left(s\right), \mathsf{log.f32}\left(\mathsf{fma.f32}\left(4, \mathsf{/.f32}\left(\left(\frac{-1}{2} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right), s\right), 1\right)\right)\right) \]
    6. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

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

Alternative 6: 11.5% accurate, 15.0× speedup?

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

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

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

    \[\leadsto \color{blue}{-4 \cdot \left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right) + \frac{-1}{2} \cdot \frac{-16 \cdot {\left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}^{2} + -2 \cdot \left(-8 \cdot {\left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}^{2} + -4 \cdot \left(\frac{-1}{8} \cdot {\mathsf{PI}\left(\right)}^{2} + \frac{1}{8} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)}{s}} \]
  4. Simplified10.2%

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

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

      \[\leadsto \mathsf{/.f32}\left(\left(-4 \cdot \left(s \cdot \left(\frac{-1}{2} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)\right) + \frac{-1}{2} \cdot \left(-16 \cdot {\left(\frac{-1}{2} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)}^{2} + 16 \cdot {\left(\frac{-1}{2} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)}^{2}\right)\right), \color{blue}{s}\right) \]
  7. Simplified12.9%

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

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

Alternative 7: 11.5% accurate, 20.4× speedup?

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

\\
\mathsf{fma}\left(\pi, -2, \frac{\pi}{u}\right) \cdot \left(-u\right)
\end{array}
Derivation
  1. Initial program 99.1%

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

    \[\leadsto \color{blue}{-4 \cdot \left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right) + \frac{-1}{2} \cdot \frac{-16 \cdot {\left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}^{2} + -2 \cdot \left(-8 \cdot {\left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}^{2} + -4 \cdot \left(\frac{-1}{8} \cdot {\mathsf{PI}\left(\right)}^{2} + \frac{1}{8} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)}{s}} \]
  4. Simplified10.2%

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

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

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

      \[\leadsto \mathsf{neg}\left(u \cdot \left(-2 \cdot \mathsf{PI}\left(\right) + \frac{\mathsf{PI}\left(\right)}{u}\right)\right) \]
    2. neg-sub0N/A

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

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

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

      \[\leadsto \mathsf{\_.f32}\left(0, \mathsf{*.f32}\left(u, \left(\mathsf{PI}\left(\right) \cdot -2 + \frac{\color{blue}{\mathsf{PI}\left(\right)}}{u}\right)\right)\right) \]
    6. accelerator-lowering-fma.f32N/A

      \[\leadsto \mathsf{\_.f32}\left(0, \mathsf{*.f32}\left(u, \mathsf{fma.f32}\left(\mathsf{PI}\left(\right), \color{blue}{-2}, \left(\frac{\mathsf{PI}\left(\right)}{u}\right)\right)\right)\right) \]
    7. PI-lowering-PI.f32N/A

      \[\leadsto \mathsf{\_.f32}\left(0, \mathsf{*.f32}\left(u, \mathsf{fma.f32}\left(\mathsf{PI.f32}\left(\right), -2, \left(\frac{\mathsf{PI}\left(\right)}{u}\right)\right)\right)\right) \]
    8. /-lowering-/.f32N/A

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

      \[\leadsto \mathsf{\_.f32}\left(0, \mathsf{*.f32}\left(u, \mathsf{fma.f32}\left(\mathsf{PI.f32}\left(\right), -2, \mathsf{/.f32}\left(\mathsf{PI.f32}\left(\right), u\right)\right)\right)\right) \]
  8. Simplified12.9%

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

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

Alternative 8: 11.5% accurate, 42.5× speedup?

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

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

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

    \[\leadsto \color{blue}{-4 \cdot \left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right) + \frac{-1}{2} \cdot \frac{-16 \cdot {\left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}^{2} + -2 \cdot \left(-8 \cdot {\left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}^{2} + -4 \cdot \left(\frac{-1}{8} \cdot {\mathsf{PI}\left(\right)}^{2} + \frac{1}{8} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)}{s}} \]
  4. Simplified10.2%

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \left(\color{blue}{2 \cdot u} + -1\right)\right) \]
    6. accelerator-lowering-fma.f3212.9%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{fma.f32}\left(2, \color{blue}{u}, -1\right)\right) \]
  8. Simplified12.9%

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

Alternative 9: 11.3% accurate, 170.0× speedup?

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

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

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

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

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

      \[\leadsto \mathsf{neg.f32}\left(\mathsf{PI.f32}\left(\right)\right) \]
  5. Simplified12.8%

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

Alternative 10: 10.3% accurate, 510.0× speedup?

\[\begin{array}{l} \\ 0 \end{array} \]
(FPCore (u s) :precision binary32 0.0)
float code(float u, float s) {
	return 0.0f;
}
real(4) function code(u, s)
    real(4), intent (in) :: u
    real(4), intent (in) :: s
    code = 0.0e0
end function
function code(u, s)
	return Float32(0.0)
end
function tmp = code(u, s)
	tmp = single(0.0);
end
\begin{array}{l}

\\
0
\end{array}
Derivation
  1. Initial program 99.1%

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

    \[\leadsto \color{blue}{-4 \cdot \left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right) + \frac{-1}{2} \cdot \frac{-16 \cdot {\left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}^{2} + -2 \cdot \left(-8 \cdot {\left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}^{2} + -4 \cdot \left(\frac{-1}{8} \cdot {\mathsf{PI}\left(\right)}^{2} + \frac{1}{8} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)}{s}} \]
  4. Simplified10.2%

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

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

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

      \[\leadsto \frac{\frac{-1}{2} \cdot \left({\left(\frac{-1}{2} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)}^{2} \cdot \left(-16 + 16\right)\right)}{s} \]
    3. metadata-evalN/A

      \[\leadsto \frac{\frac{-1}{2} \cdot \left({\left(\frac{-1}{2} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)}^{2} \cdot 0\right)}{s} \]
    4. mul0-rgtN/A

      \[\leadsto \frac{\frac{-1}{2} \cdot 0}{s} \]
    5. metadata-evalN/A

      \[\leadsto \frac{0}{s} \]
    6. /-lowering-/.f3210.1%

      \[\leadsto \mathsf{/.f32}\left(0, \color{blue}{s}\right) \]
  7. Simplified10.1%

    \[\leadsto \color{blue}{\frac{0}{s}} \]
  8. Step-by-step derivation
    1. div010.1%

      \[\leadsto 0 \]
  9. Applied egg-rr10.1%

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

Reproduce

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