VandenBroeck and Keller, Equation (20)

Percentage Accurate: 6.6% → 96.4%
Time: 56.6s
Alternatives: 7
Speedup: 3.4×

Specification

?
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\pi}{4} \cdot f\\ t_1 := e^{t_0}\\ t_2 := e^{-t_0}\\ -\frac{1}{\frac{\pi}{4}} \cdot \log \left(\frac{t_1 + t_2}{t_1 - t_2}\right) \end{array} \end{array} \]
(FPCore (f)
 :precision binary64
 (let* ((t_0 (* (/ PI 4.0) f)) (t_1 (exp t_0)) (t_2 (exp (- t_0))))
   (- (* (/ 1.0 (/ PI 4.0)) (log (/ (+ t_1 t_2) (- t_1 t_2)))))))
double code(double f) {
	double t_0 = (((double) M_PI) / 4.0) * f;
	double t_1 = exp(t_0);
	double t_2 = exp(-t_0);
	return -((1.0 / (((double) M_PI) / 4.0)) * log(((t_1 + t_2) / (t_1 - t_2))));
}
public static double code(double f) {
	double t_0 = (Math.PI / 4.0) * f;
	double t_1 = Math.exp(t_0);
	double t_2 = Math.exp(-t_0);
	return -((1.0 / (Math.PI / 4.0)) * Math.log(((t_1 + t_2) / (t_1 - t_2))));
}
def code(f):
	t_0 = (math.pi / 4.0) * f
	t_1 = math.exp(t_0)
	t_2 = math.exp(-t_0)
	return -((1.0 / (math.pi / 4.0)) * math.log(((t_1 + t_2) / (t_1 - t_2))))
function code(f)
	t_0 = Float64(Float64(pi / 4.0) * f)
	t_1 = exp(t_0)
	t_2 = exp(Float64(-t_0))
	return Float64(-Float64(Float64(1.0 / Float64(pi / 4.0)) * log(Float64(Float64(t_1 + t_2) / Float64(t_1 - t_2)))))
end
function tmp = code(f)
	t_0 = (pi / 4.0) * f;
	t_1 = exp(t_0);
	t_2 = exp(-t_0);
	tmp = -((1.0 / (pi / 4.0)) * log(((t_1 + t_2) / (t_1 - t_2))));
end
code[f_] := Block[{t$95$0 = N[(N[(Pi / 4.0), $MachinePrecision] * f), $MachinePrecision]}, Block[{t$95$1 = N[Exp[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[Exp[(-t$95$0)], $MachinePrecision]}, (-N[(N[(1.0 / N[(Pi / 4.0), $MachinePrecision]), $MachinePrecision] * N[Log[N[(N[(t$95$1 + t$95$2), $MachinePrecision] / N[(t$95$1 - t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision])]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\pi}{4} \cdot f\\
t_1 := e^{t_0}\\
t_2 := e^{-t_0}\\
-\frac{1}{\frac{\pi}{4}} \cdot \log \left(\frac{t_1 + t_2}{t_1 - t_2}\right)
\end{array}
\end{array}

Sampling outcomes in binary64 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 7 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: 6.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\pi}{4} \cdot f\\ t_1 := e^{t_0}\\ t_2 := e^{-t_0}\\ -\frac{1}{\frac{\pi}{4}} \cdot \log \left(\frac{t_1 + t_2}{t_1 - t_2}\right) \end{array} \end{array} \]
(FPCore (f)
 :precision binary64
 (let* ((t_0 (* (/ PI 4.0) f)) (t_1 (exp t_0)) (t_2 (exp (- t_0))))
   (- (* (/ 1.0 (/ PI 4.0)) (log (/ (+ t_1 t_2) (- t_1 t_2)))))))
double code(double f) {
	double t_0 = (((double) M_PI) / 4.0) * f;
	double t_1 = exp(t_0);
	double t_2 = exp(-t_0);
	return -((1.0 / (((double) M_PI) / 4.0)) * log(((t_1 + t_2) / (t_1 - t_2))));
}
public static double code(double f) {
	double t_0 = (Math.PI / 4.0) * f;
	double t_1 = Math.exp(t_0);
	double t_2 = Math.exp(-t_0);
	return -((1.0 / (Math.PI / 4.0)) * Math.log(((t_1 + t_2) / (t_1 - t_2))));
}
def code(f):
	t_0 = (math.pi / 4.0) * f
	t_1 = math.exp(t_0)
	t_2 = math.exp(-t_0)
	return -((1.0 / (math.pi / 4.0)) * math.log(((t_1 + t_2) / (t_1 - t_2))))
function code(f)
	t_0 = Float64(Float64(pi / 4.0) * f)
	t_1 = exp(t_0)
	t_2 = exp(Float64(-t_0))
	return Float64(-Float64(Float64(1.0 / Float64(pi / 4.0)) * log(Float64(Float64(t_1 + t_2) / Float64(t_1 - t_2)))))
end
function tmp = code(f)
	t_0 = (pi / 4.0) * f;
	t_1 = exp(t_0);
	t_2 = exp(-t_0);
	tmp = -((1.0 / (pi / 4.0)) * log(((t_1 + t_2) / (t_1 - t_2))));
end
code[f_] := Block[{t$95$0 = N[(N[(Pi / 4.0), $MachinePrecision] * f), $MachinePrecision]}, Block[{t$95$1 = N[Exp[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[Exp[(-t$95$0)], $MachinePrecision]}, (-N[(N[(1.0 / N[(Pi / 4.0), $MachinePrecision]), $MachinePrecision] * N[Log[N[(N[(t$95$1 + t$95$2), $MachinePrecision] / N[(t$95$1 - t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision])]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\pi}{4} \cdot f\\
t_1 := e^{t_0}\\
t_2 := e^{-t_0}\\
-\frac{1}{\frac{\pi}{4}} \cdot \log \left(\frac{t_1 + t_2}{t_1 - t_2}\right)
\end{array}
\end{array}

Alternative 1: 96.4% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(0.5, \mathsf{fma}\left(\pi \cdot -0.041666666666666664 + 0.0625 \cdot \left(\pi \cdot 2\right), \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \log \left(\frac{4}{\pi}\right) - \log f\right) \cdot \frac{-1}{\frac{\pi}{4}} \end{array} \]
(FPCore (f)
 :precision binary64
 (*
  (fma
   0.5
   (fma
    (+ (* PI -0.041666666666666664) (* 0.0625 (* PI 2.0)))
    (* (* PI 0.5) (* f f))
    0.0)
   (- (log (/ 4.0 PI)) (log f)))
  (/ -1.0 (/ PI 4.0))))
double code(double f) {
	return fma(0.5, fma(((((double) M_PI) * -0.041666666666666664) + (0.0625 * (((double) M_PI) * 2.0))), ((((double) M_PI) * 0.5) * (f * f)), 0.0), (log((4.0 / ((double) M_PI))) - log(f))) * (-1.0 / (((double) M_PI) / 4.0));
}
function code(f)
	return Float64(fma(0.5, fma(Float64(Float64(pi * -0.041666666666666664) + Float64(0.0625 * Float64(pi * 2.0))), Float64(Float64(pi * 0.5) * Float64(f * f)), 0.0), Float64(log(Float64(4.0 / pi)) - log(f))) * Float64(-1.0 / Float64(pi / 4.0)))
end
code[f_] := N[(N[(0.5 * N[(N[(N[(Pi * -0.041666666666666664), $MachinePrecision] + N[(0.0625 * N[(Pi * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(Pi * 0.5), $MachinePrecision] * N[(f * f), $MachinePrecision]), $MachinePrecision] + 0.0), $MachinePrecision] + N[(N[Log[N[(4.0 / Pi), $MachinePrecision]], $MachinePrecision] - N[Log[f], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[(Pi / 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(0.5, \mathsf{fma}\left(\pi \cdot -0.041666666666666664 + 0.0625 \cdot \left(\pi \cdot 2\right), \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \log \left(\frac{4}{\pi}\right) - \log f\right) \cdot \frac{-1}{\frac{\pi}{4}}
\end{array}
Derivation
  1. Initial program 7.9%

    \[-\frac{1}{\frac{\pi}{4}} \cdot \log \left(\frac{e^{\frac{\pi}{4} \cdot f} + e^{-\frac{\pi}{4} \cdot f}}{e^{\frac{\pi}{4} \cdot f} - e^{-\frac{\pi}{4} \cdot f}}\right) \]
  2. Taylor expanded in f around 0 96.2%

    \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \color{blue}{\left(\log \left(\frac{2}{0.25 \cdot \pi - -0.25 \cdot \pi}\right) + \left(-1 \cdot \log f + \left(0.5 \cdot \left(f \cdot \left(\left(-0.25 \cdot \frac{\pi}{0.25 \cdot \pi - -0.25 \cdot \pi} + 0.25 \cdot \frac{\pi}{0.25 \cdot \pi - -0.25 \cdot \pi}\right) \cdot \left(0.25 \cdot \pi - -0.25 \cdot \pi\right)\right)\right) + 0.5 \cdot \left({f}^{2} \cdot \left(-0.25 \cdot \left({\left(-0.25 \cdot \frac{\pi}{0.25 \cdot \pi - -0.25 \cdot \pi} + 0.25 \cdot \frac{\pi}{0.25 \cdot \pi - -0.25 \cdot \pi}\right)}^{2} \cdot {\left(0.25 \cdot \pi - -0.25 \cdot \pi\right)}^{2}\right) + \left(0.0625 \cdot \frac{{\pi}^{2}}{0.25 \cdot \pi - -0.25 \cdot \pi} - 2 \cdot \frac{0.0026041666666666665 \cdot {\pi}^{3} - -0.0026041666666666665 \cdot {\pi}^{3}}{{\left(0.25 \cdot \pi - -0.25 \cdot \pi\right)}^{2}}\right) \cdot \left(0.25 \cdot \pi - -0.25 \cdot \pi\right)\right)\right)\right)\right)\right)} \]
  3. Simplified96.2%

    \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \color{blue}{\mathsf{fma}\left(0.5, \mathsf{fma}\left(\mathsf{fma}\left(\frac{{\pi}^{3}}{{\pi}^{2}} \cdot 0.020833333333333332, -2, 0.0625 \cdot \left(\frac{\pi}{0.5} \cdot 1\right)\right), \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \log \left(\frac{\frac{2}{\pi}}{0.5}\right) - \log f\right)} \]
  4. Step-by-step derivation
    1. fma-udef96.2%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(\color{blue}{\left(\frac{{\pi}^{3}}{{\pi}^{2}} \cdot 0.020833333333333332\right) \cdot -2 + 0.0625 \cdot \left(\frac{\pi}{0.5} \cdot 1\right)}, \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \log \left(\frac{\frac{2}{\pi}}{0.5}\right) - \log f\right) \]
    2. pow-div96.2%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(\left(\color{blue}{{\pi}^{\left(3 - 2\right)}} \cdot 0.020833333333333332\right) \cdot -2 + 0.0625 \cdot \left(\frac{\pi}{0.5} \cdot 1\right), \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \log \left(\frac{\frac{2}{\pi}}{0.5}\right) - \log f\right) \]
    3. metadata-eval96.2%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(\left({\pi}^{\color{blue}{1}} \cdot 0.020833333333333332\right) \cdot -2 + 0.0625 \cdot \left(\frac{\pi}{0.5} \cdot 1\right), \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \log \left(\frac{\frac{2}{\pi}}{0.5}\right) - \log f\right) \]
    4. pow196.2%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(\left(\color{blue}{\pi} \cdot 0.020833333333333332\right) \cdot -2 + 0.0625 \cdot \left(\frac{\pi}{0.5} \cdot 1\right), \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \log \left(\frac{\frac{2}{\pi}}{0.5}\right) - \log f\right) \]
    5. *-rgt-identity96.2%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(\left(\pi \cdot 0.020833333333333332\right) \cdot -2 + 0.0625 \cdot \color{blue}{\frac{\pi}{0.5}}, \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \log \left(\frac{\frac{2}{\pi}}{0.5}\right) - \log f\right) \]
    6. div-inv96.2%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(\left(\pi \cdot 0.020833333333333332\right) \cdot -2 + 0.0625 \cdot \color{blue}{\left(\pi \cdot \frac{1}{0.5}\right)}, \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \log \left(\frac{\frac{2}{\pi}}{0.5}\right) - \log f\right) \]
    7. metadata-eval96.2%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(\left(\pi \cdot 0.020833333333333332\right) \cdot -2 + 0.0625 \cdot \left(\pi \cdot \color{blue}{2}\right), \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \log \left(\frac{\frac{2}{\pi}}{0.5}\right) - \log f\right) \]
  5. Applied egg-rr96.2%

    \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(\color{blue}{\left(\pi \cdot 0.020833333333333332\right) \cdot -2 + 0.0625 \cdot \left(\pi \cdot 2\right)}, \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \log \left(\frac{\frac{2}{\pi}}{0.5}\right) - \log f\right) \]
  6. Step-by-step derivation
    1. associate-*l*96.2%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(\color{blue}{\pi \cdot \left(0.020833333333333332 \cdot -2\right)} + 0.0625 \cdot \left(\pi \cdot 2\right), \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \log \left(\frac{\frac{2}{\pi}}{0.5}\right) - \log f\right) \]
    2. metadata-eval96.2%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(\pi \cdot \color{blue}{-0.041666666666666664} + 0.0625 \cdot \left(\pi \cdot 2\right), \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \log \left(\frac{\frac{2}{\pi}}{0.5}\right) - \log f\right) \]
  7. Simplified96.2%

    \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(\color{blue}{\pi \cdot -0.041666666666666664 + 0.0625 \cdot \left(\pi \cdot 2\right)}, \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \log \left(\frac{\frac{2}{\pi}}{0.5}\right) - \log f\right) \]
  8. Step-by-step derivation
    1. log-div96.2%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(\pi \cdot -0.041666666666666664 + 0.0625 \cdot \left(\pi \cdot 2\right), \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \color{blue}{\left(\log \left(\frac{2}{\pi}\right) - \log 0.5\right)} - \log f\right) \]
  9. Applied egg-rr96.2%

    \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(\pi \cdot -0.041666666666666664 + 0.0625 \cdot \left(\pi \cdot 2\right), \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \color{blue}{\left(\log \left(\frac{2}{\pi}\right) - \log 0.5\right)} - \log f\right) \]
  10. Step-by-step derivation
    1. log-div96.2%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(\pi \cdot -0.041666666666666664 + 0.0625 \cdot \left(\pi \cdot 2\right), \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \color{blue}{\log \left(\frac{\frac{2}{\pi}}{0.5}\right)} - \log f\right) \]
    2. associate-/r*96.2%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(\pi \cdot -0.041666666666666664 + 0.0625 \cdot \left(\pi \cdot 2\right), \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \log \color{blue}{\left(\frac{2}{\pi \cdot 0.5}\right)} - \log f\right) \]
    3. *-commutative96.2%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(\pi \cdot -0.041666666666666664 + 0.0625 \cdot \left(\pi \cdot 2\right), \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \log \left(\frac{2}{\color{blue}{0.5 \cdot \pi}}\right) - \log f\right) \]
    4. associate-/r*96.2%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(\pi \cdot -0.041666666666666664 + 0.0625 \cdot \left(\pi \cdot 2\right), \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \log \color{blue}{\left(\frac{\frac{2}{0.5}}{\pi}\right)} - \log f\right) \]
    5. metadata-eval96.2%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(\pi \cdot -0.041666666666666664 + 0.0625 \cdot \left(\pi \cdot 2\right), \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \log \left(\frac{\color{blue}{4}}{\pi}\right) - \log f\right) \]
  11. Simplified96.2%

    \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(\pi \cdot -0.041666666666666664 + 0.0625 \cdot \left(\pi \cdot 2\right), \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \color{blue}{\log \left(\frac{4}{\pi}\right)} - \log f\right) \]
  12. Final simplification96.2%

    \[\leadsto \mathsf{fma}\left(0.5, \mathsf{fma}\left(\pi \cdot -0.041666666666666664 + 0.0625 \cdot \left(\pi \cdot 2\right), \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \log \left(\frac{4}{\pi}\right) - \log f\right) \cdot \frac{-1}{\frac{\pi}{4}} \]

Alternative 2: 96.3% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \log \left(\mathsf{fma}\left(f, \pi \cdot -0.041666666666666664 + 0.0625 \cdot \left(\pi \cdot 2\right), 4 \cdot \frac{\frac{1}{f}}{\pi}\right)\right) \cdot \frac{-1}{\frac{\pi}{4}} \end{array} \]
(FPCore (f)
 :precision binary64
 (*
  (log
   (fma
    f
    (+ (* PI -0.041666666666666664) (* 0.0625 (* PI 2.0)))
    (* 4.0 (/ (/ 1.0 f) PI))))
  (/ -1.0 (/ PI 4.0))))
double code(double f) {
	return log(fma(f, ((((double) M_PI) * -0.041666666666666664) + (0.0625 * (((double) M_PI) * 2.0))), (4.0 * ((1.0 / f) / ((double) M_PI))))) * (-1.0 / (((double) M_PI) / 4.0));
}
function code(f)
	return Float64(log(fma(f, Float64(Float64(pi * -0.041666666666666664) + Float64(0.0625 * Float64(pi * 2.0))), Float64(4.0 * Float64(Float64(1.0 / f) / pi)))) * Float64(-1.0 / Float64(pi / 4.0)))
end
code[f_] := N[(N[Log[N[(f * N[(N[(Pi * -0.041666666666666664), $MachinePrecision] + N[(0.0625 * N[(Pi * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(4.0 * N[(N[(1.0 / f), $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / N[(Pi / 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\log \left(\mathsf{fma}\left(f, \pi \cdot -0.041666666666666664 + 0.0625 \cdot \left(\pi \cdot 2\right), 4 \cdot \frac{\frac{1}{f}}{\pi}\right)\right) \cdot \frac{-1}{\frac{\pi}{4}}
\end{array}
Derivation
  1. Initial program 7.9%

    \[-\frac{1}{\frac{\pi}{4}} \cdot \log \left(\frac{e^{\frac{\pi}{4} \cdot f} + e^{-\frac{\pi}{4} \cdot f}}{e^{\frac{\pi}{4} \cdot f} - e^{-\frac{\pi}{4} \cdot f}}\right) \]
  2. Taylor expanded in f around 0 95.8%

    \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \log \color{blue}{\left(-0.25 \cdot \frac{\pi}{0.25 \cdot \pi - -0.25 \cdot \pi} + \left(0.25 \cdot \frac{\pi}{0.25 \cdot \pi - -0.25 \cdot \pi} + \left(f \cdot \left(0.0625 \cdot \frac{{\pi}^{2}}{0.25 \cdot \pi - -0.25 \cdot \pi} - 2 \cdot \frac{0.0026041666666666665 \cdot {\pi}^{3} - -0.0026041666666666665 \cdot {\pi}^{3}}{{\left(0.25 \cdot \pi - -0.25 \cdot \pi\right)}^{2}}\right) + 2 \cdot \frac{1}{f \cdot \left(0.25 \cdot \pi - -0.25 \cdot \pi\right)}\right)\right)\right)} \]
  3. Simplified95.8%

    \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \log \color{blue}{\left(\mathsf{fma}\left(f, \mathsf{fma}\left(\frac{{\pi}^{3}}{{\pi}^{2}} \cdot 0.020833333333333332, -2, 0.0625 \cdot \left(\frac{\pi}{0.5} \cdot 1\right)\right), 4 \cdot \frac{\frac{1}{f}}{\pi}\right)\right)} \]
  4. Step-by-step derivation
    1. fma-udef96.2%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(\color{blue}{\left(\frac{{\pi}^{3}}{{\pi}^{2}} \cdot 0.020833333333333332\right) \cdot -2 + 0.0625 \cdot \left(\frac{\pi}{0.5} \cdot 1\right)}, \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \log \left(\frac{\frac{2}{\pi}}{0.5}\right) - \log f\right) \]
    2. pow-div96.2%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(\left(\color{blue}{{\pi}^{\left(3 - 2\right)}} \cdot 0.020833333333333332\right) \cdot -2 + 0.0625 \cdot \left(\frac{\pi}{0.5} \cdot 1\right), \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \log \left(\frac{\frac{2}{\pi}}{0.5}\right) - \log f\right) \]
    3. metadata-eval96.2%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(\left({\pi}^{\color{blue}{1}} \cdot 0.020833333333333332\right) \cdot -2 + 0.0625 \cdot \left(\frac{\pi}{0.5} \cdot 1\right), \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \log \left(\frac{\frac{2}{\pi}}{0.5}\right) - \log f\right) \]
    4. pow196.2%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(\left(\color{blue}{\pi} \cdot 0.020833333333333332\right) \cdot -2 + 0.0625 \cdot \left(\frac{\pi}{0.5} \cdot 1\right), \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \log \left(\frac{\frac{2}{\pi}}{0.5}\right) - \log f\right) \]
    5. *-rgt-identity96.2%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(\left(\pi \cdot 0.020833333333333332\right) \cdot -2 + 0.0625 \cdot \color{blue}{\frac{\pi}{0.5}}, \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \log \left(\frac{\frac{2}{\pi}}{0.5}\right) - \log f\right) \]
    6. div-inv96.2%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(\left(\pi \cdot 0.020833333333333332\right) \cdot -2 + 0.0625 \cdot \color{blue}{\left(\pi \cdot \frac{1}{0.5}\right)}, \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \log \left(\frac{\frac{2}{\pi}}{0.5}\right) - \log f\right) \]
    7. metadata-eval96.2%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(\left(\pi \cdot 0.020833333333333332\right) \cdot -2 + 0.0625 \cdot \left(\pi \cdot \color{blue}{2}\right), \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \log \left(\frac{\frac{2}{\pi}}{0.5}\right) - \log f\right) \]
  5. Applied egg-rr95.8%

    \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \log \left(\mathsf{fma}\left(f, \color{blue}{\left(\pi \cdot 0.020833333333333332\right) \cdot -2 + 0.0625 \cdot \left(\pi \cdot 2\right)}, 4 \cdot \frac{\frac{1}{f}}{\pi}\right)\right) \]
  6. Step-by-step derivation
    1. associate-*l*96.2%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(\color{blue}{\pi \cdot \left(0.020833333333333332 \cdot -2\right)} + 0.0625 \cdot \left(\pi \cdot 2\right), \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \log \left(\frac{\frac{2}{\pi}}{0.5}\right) - \log f\right) \]
    2. metadata-eval96.2%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(\pi \cdot \color{blue}{-0.041666666666666664} + 0.0625 \cdot \left(\pi \cdot 2\right), \left(\pi \cdot 0.5\right) \cdot \left(f \cdot f\right), 0\right), \log \left(\frac{\frac{2}{\pi}}{0.5}\right) - \log f\right) \]
  7. Simplified95.8%

    \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \log \left(\mathsf{fma}\left(f, \color{blue}{\pi \cdot -0.041666666666666664 + 0.0625 \cdot \left(\pi \cdot 2\right)}, 4 \cdot \frac{\frac{1}{f}}{\pi}\right)\right) \]
  8. Final simplification95.8%

    \[\leadsto \log \left(\mathsf{fma}\left(f, \pi \cdot -0.041666666666666664 + 0.0625 \cdot \left(\pi \cdot 2\right), 4 \cdot \frac{\frac{1}{f}}{\pi}\right)\right) \cdot \frac{-1}{\frac{\pi}{4}} \]

Alternative 3: 96.0% accurate, 2.5× speedup?

\[\begin{array}{l} \\ 4 \cdot \frac{\log f - \log \left(\frac{4}{\pi}\right)}{\pi} \end{array} \]
(FPCore (f) :precision binary64 (* 4.0 (/ (- (log f) (log (/ 4.0 PI))) PI)))
double code(double f) {
	return 4.0 * ((log(f) - log((4.0 / ((double) M_PI)))) / ((double) M_PI));
}
public static double code(double f) {
	return 4.0 * ((Math.log(f) - Math.log((4.0 / Math.PI))) / Math.PI);
}
def code(f):
	return 4.0 * ((math.log(f) - math.log((4.0 / math.pi))) / math.pi)
function code(f)
	return Float64(4.0 * Float64(Float64(log(f) - log(Float64(4.0 / pi))) / pi))
end
function tmp = code(f)
	tmp = 4.0 * ((log(f) - log((4.0 / pi))) / pi);
end
code[f_] := N[(4.0 * N[(N[(N[Log[f], $MachinePrecision] - N[Log[N[(4.0 / Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
4 \cdot \frac{\log f - \log \left(\frac{4}{\pi}\right)}{\pi}
\end{array}
Derivation
  1. Initial program 7.9%

    \[-\frac{1}{\frac{\pi}{4}} \cdot \log \left(\frac{e^{\frac{\pi}{4} \cdot f} + e^{-\frac{\pi}{4} \cdot f}}{e^{\frac{\pi}{4} \cdot f} - e^{-\frac{\pi}{4} \cdot f}}\right) \]
  2. Taylor expanded in f around 0 95.6%

    \[\leadsto -\color{blue}{4 \cdot \frac{\log \left(\frac{2}{0.25 \cdot \pi - -0.25 \cdot \pi}\right) + -1 \cdot \log f}{\pi}} \]
  3. Step-by-step derivation
    1. associate-*r/95.6%

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

      \[\leadsto -\color{blue}{\frac{4}{\frac{\pi}{\log \left(\frac{2}{0.25 \cdot \pi - -0.25 \cdot \pi}\right) + -1 \cdot \log f}}} \]
    3. mul-1-neg95.4%

      \[\leadsto -\frac{4}{\frac{\pi}{\log \left(\frac{2}{0.25 \cdot \pi - -0.25 \cdot \pi}\right) + \color{blue}{\left(-\log f\right)}}} \]
    4. unsub-neg95.4%

      \[\leadsto -\frac{4}{\frac{\pi}{\color{blue}{\log \left(\frac{2}{0.25 \cdot \pi - -0.25 \cdot \pi}\right) - \log f}}} \]
    5. distribute-rgt-out--95.4%

      \[\leadsto -\frac{4}{\frac{\pi}{\log \left(\frac{2}{\color{blue}{\pi \cdot \left(0.25 - -0.25\right)}}\right) - \log f}} \]
    6. metadata-eval95.4%

      \[\leadsto -\frac{4}{\frac{\pi}{\log \left(\frac{2}{\pi \cdot \color{blue}{0.5}}\right) - \log f}} \]
    7. associate-/r*95.4%

      \[\leadsto -\frac{4}{\frac{\pi}{\log \color{blue}{\left(\frac{\frac{2}{\pi}}{0.5}\right)} - \log f}} \]
  4. Simplified95.4%

    \[\leadsto -\color{blue}{\frac{4}{\frac{\pi}{\log \left(\frac{\frac{2}{\pi}}{0.5}\right) - \log f}}} \]
  5. Taylor expanded in f around 0 95.6%

    \[\leadsto -\color{blue}{4 \cdot \frac{\log \left(\frac{4}{\pi}\right) - \log f}{\pi}} \]
  6. Final simplification95.6%

    \[\leadsto 4 \cdot \frac{\log f - \log \left(\frac{4}{\pi}\right)}{\pi} \]

Alternative 4: 95.9% accurate, 3.3× speedup?

\[\begin{array}{l} \\ \frac{\log \left(\frac{\frac{4}{\pi}}{f}\right)}{\pi} \cdot \left(-4\right) \end{array} \]
(FPCore (f) :precision binary64 (* (/ (log (/ (/ 4.0 PI) f)) PI) (- 4.0)))
double code(double f) {
	return (log(((4.0 / ((double) M_PI)) / f)) / ((double) M_PI)) * -4.0;
}
public static double code(double f) {
	return (Math.log(((4.0 / Math.PI) / f)) / Math.PI) * -4.0;
}
def code(f):
	return (math.log(((4.0 / math.pi) / f)) / math.pi) * -4.0
function code(f)
	return Float64(Float64(log(Float64(Float64(4.0 / pi) / f)) / pi) * Float64(-4.0))
end
function tmp = code(f)
	tmp = (log(((4.0 / pi) / f)) / pi) * -4.0;
end
code[f_] := N[(N[(N[Log[N[(N[(4.0 / Pi), $MachinePrecision] / f), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision] * (-4.0)), $MachinePrecision]
\begin{array}{l}

\\
\frac{\log \left(\frac{\frac{4}{\pi}}{f}\right)}{\pi} \cdot \left(-4\right)
\end{array}
Derivation
  1. Initial program 7.9%

    \[-\frac{1}{\frac{\pi}{4}} \cdot \log \left(\frac{e^{\frac{\pi}{4} \cdot f} + e^{-\frac{\pi}{4} \cdot f}}{e^{\frac{\pi}{4} \cdot f} - e^{-\frac{\pi}{4} \cdot f}}\right) \]
  2. Taylor expanded in f around 0 95.0%

    \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \log \color{blue}{\left(\frac{2}{f \cdot \left(0.25 \cdot \pi - -0.25 \cdot \pi\right)}\right)} \]
  3. Step-by-step derivation
    1. *-commutative95.0%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \log \left(\frac{2}{\color{blue}{\left(0.25 \cdot \pi - -0.25 \cdot \pi\right) \cdot f}}\right) \]
    2. distribute-rgt-out--95.0%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \log \left(\frac{2}{\color{blue}{\left(\pi \cdot \left(0.25 - -0.25\right)\right)} \cdot f}\right) \]
    3. metadata-eval95.0%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \log \left(\frac{2}{\left(\pi \cdot \color{blue}{0.5}\right) \cdot f}\right) \]
    4. associate-*l*95.0%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \log \left(\frac{2}{\color{blue}{\pi \cdot \left(0.5 \cdot f\right)}}\right) \]
    5. *-commutative95.0%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \log \left(\frac{2}{\pi \cdot \color{blue}{\left(f \cdot 0.5\right)}}\right) \]
  4. Simplified95.0%

    \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \log \color{blue}{\left(\frac{2}{\pi \cdot \left(f \cdot 0.5\right)}\right)} \]
  5. Taylor expanded in f around 0 95.6%

    \[\leadsto -\color{blue}{4 \cdot \frac{\log \left(\frac{4}{\pi}\right) + -1 \cdot \log f}{\pi}} \]
  6. Step-by-step derivation
    1. associate-*r/95.6%

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

      \[\leadsto -\frac{4 \cdot \left(\log \left(\frac{4}{\pi}\right) + \color{blue}{\left(-\log f\right)}\right)}{\pi} \]
    3. sub-neg95.6%

      \[\leadsto -\frac{4 \cdot \color{blue}{\left(\log \left(\frac{4}{\pi}\right) - \log f\right)}}{\pi} \]
    4. remove-double-neg95.6%

      \[\leadsto -\frac{4 \cdot \left(\log \left(\frac{4}{\pi}\right) - \color{blue}{\left(-\left(-\log f\right)\right)}\right)}{\pi} \]
    5. log-rec95.2%

      \[\leadsto -\frac{4 \cdot \left(\log \left(\frac{4}{\pi}\right) - \left(-\color{blue}{\log \left(\frac{1}{f}\right)}\right)\right)}{\pi} \]
    6. mul-1-neg95.2%

      \[\leadsto -\frac{4 \cdot \left(\log \left(\frac{4}{\pi}\right) - \color{blue}{-1 \cdot \log \left(\frac{1}{f}\right)}\right)}{\pi} \]
    7. associate-*r/95.2%

      \[\leadsto -\color{blue}{4 \cdot \frac{\log \left(\frac{4}{\pi}\right) - -1 \cdot \log \left(\frac{1}{f}\right)}{\pi}} \]
    8. div-sub95.1%

      \[\leadsto -4 \cdot \color{blue}{\left(\frac{\log \left(\frac{4}{\pi}\right)}{\pi} - \frac{-1 \cdot \log \left(\frac{1}{f}\right)}{\pi}\right)} \]
    9. metadata-eval95.1%

      \[\leadsto -4 \cdot \left(\frac{\log \left(\frac{\color{blue}{\frac{2}{0.5}}}{\pi}\right)}{\pi} - \frac{-1 \cdot \log \left(\frac{1}{f}\right)}{\pi}\right) \]
    10. associate-/r*95.1%

      \[\leadsto -4 \cdot \left(\frac{\log \color{blue}{\left(\frac{2}{0.5 \cdot \pi}\right)}}{\pi} - \frac{-1 \cdot \log \left(\frac{1}{f}\right)}{\pi}\right) \]
  7. Simplified95.1%

    \[\leadsto -\color{blue}{4 \cdot \frac{\log \left(\frac{\frac{4}{\pi}}{f}\right)}{\pi}} \]
  8. Final simplification95.1%

    \[\leadsto \frac{\log \left(\frac{\frac{4}{\pi}}{f}\right)}{\pi} \cdot \left(-4\right) \]

Alternative 5: 95.9% accurate, 3.3× speedup?

\[\begin{array}{l} \\ \frac{-\log \left(\pi \cdot \left(f \cdot 0.25\right)\right)}{\pi \cdot -0.25} \end{array} \]
(FPCore (f) :precision binary64 (/ (- (log (* PI (* f 0.25)))) (* PI -0.25)))
double code(double f) {
	return -log((((double) M_PI) * (f * 0.25))) / (((double) M_PI) * -0.25);
}
public static double code(double f) {
	return -Math.log((Math.PI * (f * 0.25))) / (Math.PI * -0.25);
}
def code(f):
	return -math.log((math.pi * (f * 0.25))) / (math.pi * -0.25)
function code(f)
	return Float64(Float64(-log(Float64(pi * Float64(f * 0.25)))) / Float64(pi * -0.25))
end
function tmp = code(f)
	tmp = -log((pi * (f * 0.25))) / (pi * -0.25);
end
code[f_] := N[((-N[Log[N[(Pi * N[(f * 0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(Pi * -0.25), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{-\log \left(\pi \cdot \left(f \cdot 0.25\right)\right)}{\pi \cdot -0.25}
\end{array}
Derivation
  1. Initial program 7.9%

    \[-\frac{1}{\frac{\pi}{4}} \cdot \log \left(\frac{e^{\frac{\pi}{4} \cdot f} + e^{-\frac{\pi}{4} \cdot f}}{e^{\frac{\pi}{4} \cdot f} - e^{-\frac{\pi}{4} \cdot f}}\right) \]
  2. Taylor expanded in f around 0 95.5%

    \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \color{blue}{\left(\log \left(\frac{2}{0.25 \cdot \pi - -0.25 \cdot \pi}\right) + -1 \cdot \log f\right)} \]
  3. Step-by-step derivation
    1. mul-1-neg95.5%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \left(\log \left(\frac{2}{0.25 \cdot \pi - -0.25 \cdot \pi}\right) + \color{blue}{\left(-\log f\right)}\right) \]
    2. unsub-neg95.5%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \color{blue}{\left(\log \left(\frac{2}{0.25 \cdot \pi - -0.25 \cdot \pi}\right) - \log f\right)} \]
    3. distribute-rgt-out--95.5%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \left(\log \left(\frac{2}{\color{blue}{\pi \cdot \left(0.25 - -0.25\right)}}\right) - \log f\right) \]
    4. metadata-eval95.5%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \left(\log \left(\frac{2}{\pi \cdot \color{blue}{0.5}}\right) - \log f\right) \]
    5. associate-/r*95.5%

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \left(\log \color{blue}{\left(\frac{\frac{2}{\pi}}{0.5}\right)} - \log f\right) \]
  4. Simplified95.5%

    \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \color{blue}{\left(\log \left(\frac{\frac{2}{\pi}}{0.5}\right) - \log f\right)} \]
  5. Step-by-step derivation
    1. log1p-expm1-u74.5%

      \[\leadsto -\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{\frac{\pi}{4}} \cdot \left(\log \left(\frac{\frac{2}{\pi}}{0.5}\right) - \log f\right)\right)\right)} \]
    2. associate-*l/74.5%

      \[\leadsto -\mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\frac{1 \cdot \left(\log \left(\frac{\frac{2}{\pi}}{0.5}\right) - \log f\right)}{\frac{\pi}{4}}}\right)\right) \]
    3. *-un-lft-identity74.5%

      \[\leadsto -\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\color{blue}{\log \left(\frac{\frac{2}{\pi}}{0.5}\right) - \log f}}{\frac{\pi}{4}}\right)\right) \]
    4. diff-log74.5%

      \[\leadsto -\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\color{blue}{\log \left(\frac{\frac{\frac{2}{\pi}}{0.5}}{f}\right)}}{\frac{\pi}{4}}\right)\right) \]
    5. div-inv74.5%

      \[\leadsto -\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\log \left(\frac{\color{blue}{\frac{2}{\pi} \cdot \frac{1}{0.5}}}{f}\right)}{\frac{\pi}{4}}\right)\right) \]
    6. metadata-eval74.5%

      \[\leadsto -\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\log \left(\frac{\frac{2}{\pi} \cdot \color{blue}{2}}{f}\right)}{\frac{\pi}{4}}\right)\right) \]
    7. div-inv74.5%

      \[\leadsto -\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\log \left(\frac{\frac{2}{\pi} \cdot 2}{f}\right)}{\color{blue}{\pi \cdot \frac{1}{4}}}\right)\right) \]
    8. metadata-eval74.5%

      \[\leadsto -\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\log \left(\frac{\frac{2}{\pi} \cdot 2}{f}\right)}{\pi \cdot \color{blue}{0.25}}\right)\right) \]
  6. Applied egg-rr74.5%

    \[\leadsto -\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\log \left(\frac{\frac{2}{\pi} \cdot 2}{f}\right)}{\pi \cdot 0.25}\right)\right)} \]
  7. Step-by-step derivation
    1. log1p-expm1-u95.1%

      \[\leadsto -\color{blue}{\frac{\log \left(\frac{\frac{2}{\pi} \cdot 2}{f}\right)}{\pi \cdot 0.25}} \]
    2. *-un-lft-identity95.1%

      \[\leadsto -\color{blue}{1 \cdot \frac{\log \left(\frac{\frac{2}{\pi} \cdot 2}{f}\right)}{\pi \cdot 0.25}} \]
    3. *-commutative95.1%

      \[\leadsto -\color{blue}{\frac{\log \left(\frac{\frac{2}{\pi} \cdot 2}{f}\right)}{\pi \cdot 0.25} \cdot 1} \]
    4. frac-2neg95.1%

      \[\leadsto -\color{blue}{\frac{-\log \left(\frac{\frac{2}{\pi} \cdot 2}{f}\right)}{-\pi \cdot 0.25}} \cdot 1 \]
    5. neg-log95.1%

      \[\leadsto -\frac{\color{blue}{\log \left(\frac{1}{\frac{\frac{2}{\pi} \cdot 2}{f}}\right)}}{-\pi \cdot 0.25} \cdot 1 \]
    6. associate-*l/95.1%

      \[\leadsto -\frac{\log \left(\frac{1}{\frac{\color{blue}{\frac{2 \cdot 2}{\pi}}}{f}}\right)}{-\pi \cdot 0.25} \cdot 1 \]
    7. metadata-eval95.1%

      \[\leadsto -\frac{\log \left(\frac{1}{\frac{\frac{\color{blue}{4}}{\pi}}{f}}\right)}{-\pi \cdot 0.25} \cdot 1 \]
    8. associate-/r*95.1%

      \[\leadsto -\frac{\log \left(\frac{1}{\color{blue}{\frac{4}{\pi \cdot f}}}\right)}{-\pi \cdot 0.25} \cdot 1 \]
    9. associate-/l/95.1%

      \[\leadsto -\frac{\log \left(\frac{1}{\color{blue}{\frac{\frac{4}{f}}{\pi}}}\right)}{-\pi \cdot 0.25} \cdot 1 \]
    10. clear-num95.1%

      \[\leadsto -\frac{\log \color{blue}{\left(\frac{\pi}{\frac{4}{f}}\right)}}{-\pi \cdot 0.25} \cdot 1 \]
    11. div-inv95.1%

      \[\leadsto -\frac{\log \color{blue}{\left(\pi \cdot \frac{1}{\frac{4}{f}}\right)}}{-\pi \cdot 0.25} \cdot 1 \]
    12. clear-num95.5%

      \[\leadsto -\frac{\log \left(\pi \cdot \color{blue}{\frac{f}{4}}\right)}{-\pi \cdot 0.25} \cdot 1 \]
    13. div-inv95.5%

      \[\leadsto -\frac{\log \left(\pi \cdot \color{blue}{\left(f \cdot \frac{1}{4}\right)}\right)}{-\pi \cdot 0.25} \cdot 1 \]
    14. metadata-eval95.5%

      \[\leadsto -\frac{\log \left(\pi \cdot \left(f \cdot \color{blue}{0.25}\right)\right)}{-\pi \cdot 0.25} \cdot 1 \]
    15. distribute-rgt-neg-in95.5%

      \[\leadsto -\frac{\log \left(\pi \cdot \left(f \cdot 0.25\right)\right)}{\color{blue}{\pi \cdot \left(-0.25\right)}} \cdot 1 \]
    16. metadata-eval95.5%

      \[\leadsto -\frac{\log \left(\pi \cdot \left(f \cdot 0.25\right)\right)}{\pi \cdot \color{blue}{-0.25}} \cdot 1 \]
  8. Applied egg-rr95.5%

    \[\leadsto -\color{blue}{\frac{\log \left(\pi \cdot \left(f \cdot 0.25\right)\right)}{\pi \cdot -0.25} \cdot 1} \]
  9. Final simplification95.5%

    \[\leadsto \frac{-\log \left(\pi \cdot \left(f \cdot 0.25\right)\right)}{\pi \cdot -0.25} \]

Alternative 6: 15.2% accurate, 3.4× speedup?

\[\begin{array}{l} \\ -\left|\frac{\log \left( 3.3881317890172014 \cdot 10^{-21} \right)}{\pi}\right| \end{array} \]
(FPCore (f) :precision binary64 (- (fabs (/ (log 3.3881317890172014e-21) PI))))
double code(double f) {
	return -fabs((log(3.3881317890172014e-21) / ((double) M_PI)));
}
public static double code(double f) {
	return -Math.abs((Math.log(3.3881317890172014e-21) / Math.PI));
}
def code(f):
	return -math.fabs((math.log(3.3881317890172014e-21) / math.pi))
function code(f)
	return Float64(-abs(Float64(log(3.3881317890172014e-21) / pi)))
end
function tmp = code(f)
	tmp = -abs((log(3.3881317890172014e-21) / pi));
end
code[f_] := (-N[Abs[N[(N[Log[3.3881317890172014e-21], $MachinePrecision] / Pi), $MachinePrecision]], $MachinePrecision])
\begin{array}{l}

\\
-\left|\frac{\log \left( 3.3881317890172014 \cdot 10^{-21} \right)}{\pi}\right|
\end{array}
Derivation
  1. Initial program 7.9%

    \[-\frac{1}{\frac{\pi}{4}} \cdot \log \left(\frac{e^{\frac{\pi}{4} \cdot f} + e^{-\frac{\pi}{4} \cdot f}}{e^{\frac{\pi}{4} \cdot f} - e^{-\frac{\pi}{4} \cdot f}}\right) \]
  2. Applied egg-rr1.6%

    \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \log \left(\frac{e^{\frac{\pi}{4} \cdot f} + e^{-\frac{\pi}{4} \cdot f}}{\color{blue}{262144}}\right) \]
  3. Taylor expanded in f around 0 1.6%

    \[\leadsto -\color{blue}{4 \cdot \frac{\log \left( 7.62939453125 \cdot 10^{-6} \right)}{\pi}} \]
  4. Step-by-step derivation
    1. associate-*r/1.6%

      \[\leadsto -\color{blue}{\frac{4 \cdot \log \left( 7.62939453125 \cdot 10^{-6} \right)}{\pi}} \]
  5. Simplified1.6%

    \[\leadsto -\color{blue}{\frac{4 \cdot \log \left( 7.62939453125 \cdot 10^{-6} \right)}{\pi}} \]
  6. Step-by-step derivation
    1. add-sqr-sqrt0.0%

      \[\leadsto -\color{blue}{\sqrt{\frac{4 \cdot \log \left( 7.62939453125 \cdot 10^{-6} \right)}{\pi}} \cdot \sqrt{\frac{4 \cdot \log \left( 7.62939453125 \cdot 10^{-6} \right)}{\pi}}} \]
    2. sqrt-unprod15.4%

      \[\leadsto -\color{blue}{\sqrt{\frac{4 \cdot \log \left( 7.62939453125 \cdot 10^{-6} \right)}{\pi} \cdot \frac{4 \cdot \log \left( 7.62939453125 \cdot 10^{-6} \right)}{\pi}}} \]
    3. pow215.4%

      \[\leadsto -\sqrt{\color{blue}{{\left(\frac{4 \cdot \log \left( 7.62939453125 \cdot 10^{-6} \right)}{\pi}\right)}^{2}}} \]
    4. add-log-exp15.4%

      \[\leadsto -\sqrt{{\left(\frac{\color{blue}{\log \left(e^{4 \cdot \log \left( 7.62939453125 \cdot 10^{-6} \right)}\right)}}{\pi}\right)}^{2}} \]
    5. *-commutative15.4%

      \[\leadsto -\sqrt{{\left(\frac{\log \left(e^{\color{blue}{\log \left( 7.62939453125 \cdot 10^{-6} \right) \cdot 4}}\right)}{\pi}\right)}^{2}} \]
    6. exp-to-pow15.4%

      \[\leadsto -\sqrt{{\left(\frac{\log \color{blue}{\left({\left( 7.62939453125 \cdot 10^{-6} \right)}^{4}\right)}}{\pi}\right)}^{2}} \]
    7. metadata-eval15.4%

      \[\leadsto -\sqrt{{\left(\frac{\log \color{blue}{\left( 3.3881317890172014 \cdot 10^{-21} \right)}}{\pi}\right)}^{2}} \]
  7. Applied egg-rr15.4%

    \[\leadsto -\color{blue}{\sqrt{{\left(\frac{\log \left( 3.3881317890172014 \cdot 10^{-21} \right)}{\pi}\right)}^{2}}} \]
  8. Step-by-step derivation
    1. unpow215.4%

      \[\leadsto -\sqrt{\color{blue}{\frac{\log \left( 3.3881317890172014 \cdot 10^{-21} \right)}{\pi} \cdot \frac{\log \left( 3.3881317890172014 \cdot 10^{-21} \right)}{\pi}}} \]
    2. rem-sqrt-square15.4%

      \[\leadsto -\color{blue}{\left|\frac{\log \left( 3.3881317890172014 \cdot 10^{-21} \right)}{\pi}\right|} \]
  9. Simplified15.4%

    \[\leadsto -\color{blue}{\left|\frac{\log \left( 3.3881317890172014 \cdot 10^{-21} \right)}{\pi}\right|} \]
  10. Final simplification15.4%

    \[\leadsto -\left|\frac{\log \left( 3.3881317890172014 \cdot 10^{-21} \right)}{\pi}\right| \]

Alternative 7: 1.6% accurate, 5.1× speedup?

\[\begin{array}{l} \\ \frac{-\log \left( 3.3881317890172014 \cdot 10^{-21} \right)}{\pi} \end{array} \]
(FPCore (f) :precision binary64 (/ (- (log 3.3881317890172014e-21)) PI))
double code(double f) {
	return -log(3.3881317890172014e-21) / ((double) M_PI);
}
public static double code(double f) {
	return -Math.log(3.3881317890172014e-21) / Math.PI;
}
def code(f):
	return -math.log(3.3881317890172014e-21) / math.pi
function code(f)
	return Float64(Float64(-log(3.3881317890172014e-21)) / pi)
end
function tmp = code(f)
	tmp = -log(3.3881317890172014e-21) / pi;
end
code[f_] := N[((-N[Log[3.3881317890172014e-21], $MachinePrecision]) / Pi), $MachinePrecision]
\begin{array}{l}

\\
\frac{-\log \left( 3.3881317890172014 \cdot 10^{-21} \right)}{\pi}
\end{array}
Derivation
  1. Initial program 7.9%

    \[-\frac{1}{\frac{\pi}{4}} \cdot \log \left(\frac{e^{\frac{\pi}{4} \cdot f} + e^{-\frac{\pi}{4} \cdot f}}{e^{\frac{\pi}{4} \cdot f} - e^{-\frac{\pi}{4} \cdot f}}\right) \]
  2. Applied egg-rr1.6%

    \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \log \left(\frac{e^{\frac{\pi}{4} \cdot f} + e^{-\frac{\pi}{4} \cdot f}}{\color{blue}{262144}}\right) \]
  3. Taylor expanded in f around 0 1.6%

    \[\leadsto -\color{blue}{4 \cdot \frac{\log \left( 7.62939453125 \cdot 10^{-6} \right)}{\pi}} \]
  4. Step-by-step derivation
    1. associate-*r/1.6%

      \[\leadsto -\color{blue}{\frac{4 \cdot \log \left( 7.62939453125 \cdot 10^{-6} \right)}{\pi}} \]
  5. Simplified1.6%

    \[\leadsto -\color{blue}{\frac{4 \cdot \log \left( 7.62939453125 \cdot 10^{-6} \right)}{\pi}} \]
  6. Step-by-step derivation
    1. expm1-log1p-u0.0%

      \[\leadsto -\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{4 \cdot \log \left( 7.62939453125 \cdot 10^{-6} \right)}{\pi}\right)\right)} \]
    2. expm1-udef0.0%

      \[\leadsto -\color{blue}{\left(e^{\mathsf{log1p}\left(\frac{4 \cdot \log \left( 7.62939453125 \cdot 10^{-6} \right)}{\pi}\right)} - 1\right)} \]
    3. add-log-exp0.0%

      \[\leadsto -\left(e^{\mathsf{log1p}\left(\frac{\color{blue}{\log \left(e^{4 \cdot \log \left( 7.62939453125 \cdot 10^{-6} \right)}\right)}}{\pi}\right)} - 1\right) \]
    4. *-commutative0.0%

      \[\leadsto -\left(e^{\mathsf{log1p}\left(\frac{\log \left(e^{\color{blue}{\log \left( 7.62939453125 \cdot 10^{-6} \right) \cdot 4}}\right)}{\pi}\right)} - 1\right) \]
    5. exp-to-pow0.0%

      \[\leadsto -\left(e^{\mathsf{log1p}\left(\frac{\log \color{blue}{\left({\left( 7.62939453125 \cdot 10^{-6} \right)}^{4}\right)}}{\pi}\right)} - 1\right) \]
    6. metadata-eval0.0%

      \[\leadsto -\left(e^{\mathsf{log1p}\left(\frac{\log \color{blue}{\left( 3.3881317890172014 \cdot 10^{-21} \right)}}{\pi}\right)} - 1\right) \]
  7. Applied egg-rr0.0%

    \[\leadsto -\color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\log \left( 3.3881317890172014 \cdot 10^{-21} \right)}{\pi}\right)} - 1\right)} \]
  8. Step-by-step derivation
    1. expm1-def0.0%

      \[\leadsto -\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\log \left( 3.3881317890172014 \cdot 10^{-21} \right)}{\pi}\right)\right)} \]
    2. expm1-log1p1.6%

      \[\leadsto -\color{blue}{\frac{\log \left( 3.3881317890172014 \cdot 10^{-21} \right)}{\pi}} \]
  9. Simplified1.6%

    \[\leadsto -\color{blue}{\frac{\log \left( 3.3881317890172014 \cdot 10^{-21} \right)}{\pi}} \]
  10. Final simplification1.6%

    \[\leadsto \frac{-\log \left( 3.3881317890172014 \cdot 10^{-21} \right)}{\pi} \]

Reproduce

?
herbie shell --seed 2023279 
(FPCore (f)
  :name "VandenBroeck and Keller, Equation (20)"
  :precision binary64
  (- (* (/ 1.0 (/ PI 4.0)) (log (/ (+ (exp (* (/ PI 4.0) f)) (exp (- (* (/ PI 4.0) f)))) (- (exp (* (/ PI 4.0) f)) (exp (- (* (/ PI 4.0) f)))))))))