VandenBroeck and Keller, Equation (20)

Percentage Accurate: 7.1% → 99.2%
Time: 31.6s
Alternatives: 6
Speedup: 4.8×

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 6 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: 7.1% 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: 99.2% accurate, 2.5× speedup?

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

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

    \[-\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. Add Preprocessing
  3. Taylor expanded in f around inf 5.4%

    \[\leadsto -\color{blue}{4 \cdot \frac{\log \left(\frac{e^{-0.25 \cdot \left(f \cdot \pi\right)} + e^{0.25 \cdot \left(f \cdot \pi\right)}}{e^{0.25 \cdot \left(f \cdot \pi\right)} - e^{-0.25 \cdot \left(f \cdot \pi\right)}}\right)}{\pi}} \]
  4. Step-by-step derivation
    1. expm1-log1p-u5.5%

      \[\leadsto -4 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\log \left(\frac{e^{-0.25 \cdot \left(f \cdot \pi\right)} + e^{0.25 \cdot \left(f \cdot \pi\right)}}{e^{0.25 \cdot \left(f \cdot \pi\right)} - e^{-0.25 \cdot \left(f \cdot \pi\right)}}\right)}{\pi}\right)\right)} \]
    2. expm1-udef5.4%

      \[\leadsto -4 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\log \left(\frac{e^{-0.25 \cdot \left(f \cdot \pi\right)} + e^{0.25 \cdot \left(f \cdot \pi\right)}}{e^{0.25 \cdot \left(f \cdot \pi\right)} - e^{-0.25 \cdot \left(f \cdot \pi\right)}}\right)}{\pi}\right)} - 1\right)} \]
  5. Applied egg-rr98.0%

    \[\leadsto -4 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{-\log \tanh \left(0.25 \cdot \left(\pi \cdot f\right)\right)}{\pi}\right)} - 1\right)} \]
  6. Step-by-step derivation
    1. expm1-def97.9%

      \[\leadsto -4 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{-\log \tanh \left(0.25 \cdot \left(\pi \cdot f\right)\right)}{\pi}\right)\right)} \]
    2. expm1-log1p99.2%

      \[\leadsto -4 \cdot \color{blue}{\frac{-\log \tanh \left(0.25 \cdot \left(\pi \cdot f\right)\right)}{\pi}} \]
    3. associate-*r*99.2%

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

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

    \[\leadsto -4 \cdot \color{blue}{\frac{-\log \tanh \left(\left(\pi \cdot 0.25\right) \cdot f\right)}{\pi}} \]
  8. Final simplification99.2%

    \[\leadsto 4 \cdot \frac{\log \tanh \left(\left(\pi \cdot 0.25\right) \cdot f\right)}{\pi} \]
  9. Add Preprocessing

Alternative 2: 98.0% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;f \leq 1.52:\\ \;\;\;\;\frac{\log \left(\frac{\frac{4}{f}}{\pi}\right) \cdot \left(-4\right)}{\pi}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \tanh \left(\frac{\pi}{\frac{4}{f}}\right)}{\pi} \cdot \left(-4\right)\\ \end{array} \end{array} \]
(FPCore (f)
 :precision binary64
 (if (<= f 1.52)
   (/ (* (log (/ (/ 4.0 f) PI)) (- 4.0)) PI)
   (* (/ (log (tanh (/ PI (/ 4.0 f)))) PI) (- 4.0))))
double code(double f) {
	double tmp;
	if (f <= 1.52) {
		tmp = (log(((4.0 / f) / ((double) M_PI))) * -4.0) / ((double) M_PI);
	} else {
		tmp = (log(tanh((((double) M_PI) / (4.0 / f)))) / ((double) M_PI)) * -4.0;
	}
	return tmp;
}
public static double code(double f) {
	double tmp;
	if (f <= 1.52) {
		tmp = (Math.log(((4.0 / f) / Math.PI)) * -4.0) / Math.PI;
	} else {
		tmp = (Math.log(Math.tanh((Math.PI / (4.0 / f)))) / Math.PI) * -4.0;
	}
	return tmp;
}
def code(f):
	tmp = 0
	if f <= 1.52:
		tmp = (math.log(((4.0 / f) / math.pi)) * -4.0) / math.pi
	else:
		tmp = (math.log(math.tanh((math.pi / (4.0 / f)))) / math.pi) * -4.0
	return tmp
function code(f)
	tmp = 0.0
	if (f <= 1.52)
		tmp = Float64(Float64(log(Float64(Float64(4.0 / f) / pi)) * Float64(-4.0)) / pi);
	else
		tmp = Float64(Float64(log(tanh(Float64(pi / Float64(4.0 / f)))) / pi) * Float64(-4.0));
	end
	return tmp
end
function tmp_2 = code(f)
	tmp = 0.0;
	if (f <= 1.52)
		tmp = (log(((4.0 / f) / pi)) * -4.0) / pi;
	else
		tmp = (log(tanh((pi / (4.0 / f)))) / pi) * -4.0;
	end
	tmp_2 = tmp;
end
code[f_] := If[LessEqual[f, 1.52], N[(N[(N[Log[N[(N[(4.0 / f), $MachinePrecision] / Pi), $MachinePrecision]], $MachinePrecision] * (-4.0)), $MachinePrecision] / Pi), $MachinePrecision], N[(N[(N[Log[N[Tanh[N[(Pi / N[(4.0 / f), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision] * (-4.0)), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;f \leq 1.52:\\
\;\;\;\;\frac{\log \left(\frac{\frac{4}{f}}{\pi}\right) \cdot \left(-4\right)}{\pi}\\

\mathbf{else}:\\
\;\;\;\;\frac{\log \tanh \left(\frac{\pi}{\frac{4}{f}}\right)}{\pi} \cdot \left(-4\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if f < 1.52

    1. Initial program 5.6%

      \[-\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. Add Preprocessing
    3. Taylor expanded in f around 0 99.3%

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

        \[\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. mul-1-neg99.3%

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

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

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

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

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

      \[\leadsto -\frac{4 \cdot \color{blue}{\left(\log \left(\frac{4}{\pi}\right) - \log f\right)}}{\pi} \]
    7. Step-by-step derivation
      1. log-div99.2%

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

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

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

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

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

    if 1.52 < f

    1. Initial program 0.5%

      \[-\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. Add Preprocessing
    3. Taylor expanded in f around inf 0.5%

      \[\leadsto -\color{blue}{4 \cdot \frac{\log \left(\frac{e^{-0.25 \cdot \left(f \cdot \pi\right)} + e^{0.25 \cdot \left(f \cdot \pi\right)}}{e^{0.25 \cdot \left(f \cdot \pi\right)} - e^{-0.25 \cdot \left(f \cdot \pi\right)}}\right)}{\pi}} \]
    4. Step-by-step derivation
      1. expm1-log1p-u0.5%

        \[\leadsto -4 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\log \left(\frac{e^{-0.25 \cdot \left(f \cdot \pi\right)} + e^{0.25 \cdot \left(f \cdot \pi\right)}}{e^{0.25 \cdot \left(f \cdot \pi\right)} - e^{-0.25 \cdot \left(f \cdot \pi\right)}}\right)}{\pi}\right)\right)} \]
      2. expm1-udef0.5%

        \[\leadsto -4 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\log \left(\frac{e^{-0.25 \cdot \left(f \cdot \pi\right)} + e^{0.25 \cdot \left(f \cdot \pi\right)}}{e^{0.25 \cdot \left(f \cdot \pi\right)} - e^{-0.25 \cdot \left(f \cdot \pi\right)}}\right)}{\pi}\right)} - 1\right)} \]
    5. Applied egg-rr86.2%

      \[\leadsto -4 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{-\log \tanh \left(0.25 \cdot \left(\pi \cdot f\right)\right)}{\pi}\right)} - 1\right)} \]
    6. Step-by-step derivation
      1. expm1-def86.2%

        \[\leadsto -4 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{-\log \tanh \left(0.25 \cdot \left(\pi \cdot f\right)\right)}{\pi}\right)\right)} \]
      2. expm1-log1p86.2%

        \[\leadsto -4 \cdot \color{blue}{\frac{-\log \tanh \left(0.25 \cdot \left(\pi \cdot f\right)\right)}{\pi}} \]
      3. associate-*r*86.2%

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

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

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

        \[\leadsto -4 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{-\log \tanh \left(\left(\pi \cdot 0.25\right) \cdot f\right)}{\pi}\right)\right)} \]
      2. expm1-udef86.2%

        \[\leadsto -4 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{-\log \tanh \left(\left(\pi \cdot 0.25\right) \cdot f\right)}{\pi}\right)} - 1\right)} \]
    9. Applied egg-rr86.2%

      \[\leadsto -4 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\log \tanh \left(\pi \cdot \left(f \cdot 0.25\right)\right)}{\pi}\right)} - 1\right)} \]
    10. Step-by-step derivation
      1. expm1-def86.2%

        \[\leadsto -4 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\log \tanh \left(\pi \cdot \left(f \cdot 0.25\right)\right)}{\pi}\right)\right)} \]
      2. expm1-log1p86.2%

        \[\leadsto -4 \cdot \color{blue}{\frac{\log \tanh \left(\pi \cdot \left(f \cdot 0.25\right)\right)}{\pi}} \]
      3. associate-*r*86.2%

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

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

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

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

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

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

        \[\leadsto -4 \cdot \frac{\log \tanh \color{blue}{\left(\frac{1 \cdot \pi}{\frac{4}{f}}\right)}}{\pi} \]
      10. *-lft-identity86.2%

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

      \[\leadsto -4 \cdot \color{blue}{\frac{\log \tanh \left(\frac{\pi}{\frac{4}{f}}\right)}{\pi}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;f \leq 1.52:\\ \;\;\;\;\frac{\log \left(\frac{\frac{4}{f}}{\pi}\right) \cdot \left(-4\right)}{\pi}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \tanh \left(\frac{\pi}{\frac{4}{f}}\right)}{\pi} \cdot \left(-4\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 98.0% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;f \leq 1.52:\\ \;\;\;\;\frac{4}{\pi} \cdot \left(\log f - \log \left(\frac{4}{\pi}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \tanh \left(\frac{\pi}{\frac{4}{f}}\right)}{\pi} \cdot \left(-4\right)\\ \end{array} \end{array} \]
(FPCore (f)
 :precision binary64
 (if (<= f 1.52)
   (* (/ 4.0 PI) (- (log f) (log (/ 4.0 PI))))
   (* (/ (log (tanh (/ PI (/ 4.0 f)))) PI) (- 4.0))))
double code(double f) {
	double tmp;
	if (f <= 1.52) {
		tmp = (4.0 / ((double) M_PI)) * (log(f) - log((4.0 / ((double) M_PI))));
	} else {
		tmp = (log(tanh((((double) M_PI) / (4.0 / f)))) / ((double) M_PI)) * -4.0;
	}
	return tmp;
}
public static double code(double f) {
	double tmp;
	if (f <= 1.52) {
		tmp = (4.0 / Math.PI) * (Math.log(f) - Math.log((4.0 / Math.PI)));
	} else {
		tmp = (Math.log(Math.tanh((Math.PI / (4.0 / f)))) / Math.PI) * -4.0;
	}
	return tmp;
}
def code(f):
	tmp = 0
	if f <= 1.52:
		tmp = (4.0 / math.pi) * (math.log(f) - math.log((4.0 / math.pi)))
	else:
		tmp = (math.log(math.tanh((math.pi / (4.0 / f)))) / math.pi) * -4.0
	return tmp
function code(f)
	tmp = 0.0
	if (f <= 1.52)
		tmp = Float64(Float64(4.0 / pi) * Float64(log(f) - log(Float64(4.0 / pi))));
	else
		tmp = Float64(Float64(log(tanh(Float64(pi / Float64(4.0 / f)))) / pi) * Float64(-4.0));
	end
	return tmp
end
function tmp_2 = code(f)
	tmp = 0.0;
	if (f <= 1.52)
		tmp = (4.0 / pi) * (log(f) - log((4.0 / pi)));
	else
		tmp = (log(tanh((pi / (4.0 / f)))) / pi) * -4.0;
	end
	tmp_2 = tmp;
end
code[f_] := If[LessEqual[f, 1.52], N[(N[(4.0 / Pi), $MachinePrecision] * N[(N[Log[f], $MachinePrecision] - N[Log[N[(4.0 / Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[N[Tanh[N[(Pi / N[(4.0 / f), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision] * (-4.0)), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;f \leq 1.52:\\
\;\;\;\;\frac{4}{\pi} \cdot \left(\log f - \log \left(\frac{4}{\pi}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{\log \tanh \left(\frac{\pi}{\frac{4}{f}}\right)}{\pi} \cdot \left(-4\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if f < 1.52

    1. Initial program 5.6%

      \[-\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. Add Preprocessing
    3. Taylor expanded in f around 0 99.3%

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

        \[\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*99.1%

        \[\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. associate-/r/99.2%

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

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

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

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

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

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

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

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

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

    if 1.52 < f

    1. Initial program 0.5%

      \[-\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. Add Preprocessing
    3. Taylor expanded in f around inf 0.5%

      \[\leadsto -\color{blue}{4 \cdot \frac{\log \left(\frac{e^{-0.25 \cdot \left(f \cdot \pi\right)} + e^{0.25 \cdot \left(f \cdot \pi\right)}}{e^{0.25 \cdot \left(f \cdot \pi\right)} - e^{-0.25 \cdot \left(f \cdot \pi\right)}}\right)}{\pi}} \]
    4. Step-by-step derivation
      1. expm1-log1p-u0.5%

        \[\leadsto -4 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\log \left(\frac{e^{-0.25 \cdot \left(f \cdot \pi\right)} + e^{0.25 \cdot \left(f \cdot \pi\right)}}{e^{0.25 \cdot \left(f \cdot \pi\right)} - e^{-0.25 \cdot \left(f \cdot \pi\right)}}\right)}{\pi}\right)\right)} \]
      2. expm1-udef0.5%

        \[\leadsto -4 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\log \left(\frac{e^{-0.25 \cdot \left(f \cdot \pi\right)} + e^{0.25 \cdot \left(f \cdot \pi\right)}}{e^{0.25 \cdot \left(f \cdot \pi\right)} - e^{-0.25 \cdot \left(f \cdot \pi\right)}}\right)}{\pi}\right)} - 1\right)} \]
    5. Applied egg-rr86.2%

      \[\leadsto -4 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{-\log \tanh \left(0.25 \cdot \left(\pi \cdot f\right)\right)}{\pi}\right)} - 1\right)} \]
    6. Step-by-step derivation
      1. expm1-def86.2%

        \[\leadsto -4 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{-\log \tanh \left(0.25 \cdot \left(\pi \cdot f\right)\right)}{\pi}\right)\right)} \]
      2. expm1-log1p86.2%

        \[\leadsto -4 \cdot \color{blue}{\frac{-\log \tanh \left(0.25 \cdot \left(\pi \cdot f\right)\right)}{\pi}} \]
      3. associate-*r*86.2%

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

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

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

        \[\leadsto -4 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{-\log \tanh \left(\left(\pi \cdot 0.25\right) \cdot f\right)}{\pi}\right)\right)} \]
      2. expm1-udef86.2%

        \[\leadsto -4 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{-\log \tanh \left(\left(\pi \cdot 0.25\right) \cdot f\right)}{\pi}\right)} - 1\right)} \]
    9. Applied egg-rr86.2%

      \[\leadsto -4 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\log \tanh \left(\pi \cdot \left(f \cdot 0.25\right)\right)}{\pi}\right)} - 1\right)} \]
    10. Step-by-step derivation
      1. expm1-def86.2%

        \[\leadsto -4 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\log \tanh \left(\pi \cdot \left(f \cdot 0.25\right)\right)}{\pi}\right)\right)} \]
      2. expm1-log1p86.2%

        \[\leadsto -4 \cdot \color{blue}{\frac{\log \tanh \left(\pi \cdot \left(f \cdot 0.25\right)\right)}{\pi}} \]
      3. associate-*r*86.2%

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

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

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

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

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

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

        \[\leadsto -4 \cdot \frac{\log \tanh \color{blue}{\left(\frac{1 \cdot \pi}{\frac{4}{f}}\right)}}{\pi} \]
      10. *-lft-identity86.2%

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

      \[\leadsto -4 \cdot \color{blue}{\frac{\log \tanh \left(\frac{\pi}{\frac{4}{f}}\right)}{\pi}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;f \leq 1.52:\\ \;\;\;\;\frac{4}{\pi} \cdot \left(\log f - \log \left(\frac{4}{\pi}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \tanh \left(\frac{\pi}{\frac{4}{f}}\right)}{\pi} \cdot \left(-4\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 1.6% accurate, 4.8× speedup?

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

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

    \[-\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. Add Preprocessing
  3. Taylor expanded in f around inf 5.4%

    \[\leadsto -\color{blue}{4 \cdot \frac{\log \left(\frac{e^{-0.25 \cdot \left(f \cdot \pi\right)} + e^{0.25 \cdot \left(f \cdot \pi\right)}}{e^{0.25 \cdot \left(f \cdot \pi\right)} - e^{-0.25 \cdot \left(f \cdot \pi\right)}}\right)}{\pi}} \]
  4. Step-by-step derivation
    1. expm1-log1p-u5.5%

      \[\leadsto -4 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\log \left(\frac{e^{-0.25 \cdot \left(f \cdot \pi\right)} + e^{0.25 \cdot \left(f \cdot \pi\right)}}{e^{0.25 \cdot \left(f \cdot \pi\right)} - e^{-0.25 \cdot \left(f \cdot \pi\right)}}\right)}{\pi}\right)\right)} \]
    2. expm1-udef5.4%

      \[\leadsto -4 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\log \left(\frac{e^{-0.25 \cdot \left(f \cdot \pi\right)} + e^{0.25 \cdot \left(f \cdot \pi\right)}}{e^{0.25 \cdot \left(f \cdot \pi\right)} - e^{-0.25 \cdot \left(f \cdot \pi\right)}}\right)}{\pi}\right)} - 1\right)} \]
  5. Applied egg-rr98.0%

    \[\leadsto -4 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{-\log \tanh \left(0.25 \cdot \left(\pi \cdot f\right)\right)}{\pi}\right)} - 1\right)} \]
  6. Step-by-step derivation
    1. expm1-def97.9%

      \[\leadsto -4 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{-\log \tanh \left(0.25 \cdot \left(\pi \cdot f\right)\right)}{\pi}\right)\right)} \]
    2. expm1-log1p99.2%

      \[\leadsto -4 \cdot \color{blue}{\frac{-\log \tanh \left(0.25 \cdot \left(\pi \cdot f\right)\right)}{\pi}} \]
    3. associate-*r*99.2%

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

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

    \[\leadsto -4 \cdot \color{blue}{\frac{-\log \tanh \left(\left(\pi \cdot 0.25\right) \cdot f\right)}{\pi}} \]
  8. Step-by-step derivation
    1. expm1-log1p-u97.9%

      \[\leadsto -4 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{-\log \tanh \left(\left(\pi \cdot 0.25\right) \cdot f\right)}{\pi}\right)\right)} \]
    2. expm1-udef98.0%

      \[\leadsto -4 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{-\log \tanh \left(\left(\pi \cdot 0.25\right) \cdot f\right)}{\pi}\right)} - 1\right)} \]
  9. Applied egg-rr2.4%

    \[\leadsto -4 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\log \tanh \left(\pi \cdot \left(f \cdot 0.25\right)\right)}{\pi}\right)} - 1\right)} \]
  10. Step-by-step derivation
    1. expm1-def2.4%

      \[\leadsto -4 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\log \tanh \left(\pi \cdot \left(f \cdot 0.25\right)\right)}{\pi}\right)\right)} \]
    2. expm1-log1p3.9%

      \[\leadsto -4 \cdot \color{blue}{\frac{\log \tanh \left(\pi \cdot \left(f \cdot 0.25\right)\right)}{\pi}} \]
    3. associate-*r*3.9%

      \[\leadsto -4 \cdot \frac{\log \tanh \color{blue}{\left(\left(\pi \cdot f\right) \cdot 0.25\right)}}{\pi} \]
    4. *-commutative3.9%

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

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

      \[\leadsto -4 \cdot \frac{\log \tanh \color{blue}{\left(\frac{1}{\frac{4}{\pi \cdot f}}\right)}}{\pi} \]
    7. *-commutative3.9%

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

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

      \[\leadsto -4 \cdot \frac{\log \tanh \color{blue}{\left(\frac{1 \cdot \pi}{\frac{4}{f}}\right)}}{\pi} \]
    10. *-lft-identity3.9%

      \[\leadsto -4 \cdot \frac{\log \tanh \left(\frac{\color{blue}{\pi}}{\frac{4}{f}}\right)}{\pi} \]
  11. Simplified3.9%

    \[\leadsto -4 \cdot \color{blue}{\frac{\log \tanh \left(\frac{\pi}{\frac{4}{f}}\right)}{\pi}} \]
  12. Taylor expanded in f around 0 1.6%

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

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

      \[\leadsto -4 \cdot \frac{\color{blue}{\log \left(f \cdot \left(\pi \cdot 0.25\right)\right)}}{\pi} \]
    3. *-commutative1.6%

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

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

    \[\leadsto \frac{\log \left(\left(\pi \cdot 0.25\right) \cdot f\right)}{\pi} \cdot \left(-4\right) \]
  16. Add Preprocessing

Alternative 5: 95.7% accurate, 4.8× speedup?

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

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

    \[-\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. Add Preprocessing
  3. Taylor expanded in f around 0 96.7%

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

      \[\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. mul-1-neg96.7%

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

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

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

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

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

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

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

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

Alternative 6: 95.9% accurate, 4.8× speedup?

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

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

    \[-\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. Add Preprocessing
  3. Taylor expanded in f around 0 96.7%

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

      \[\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. mul-1-neg96.7%

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

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

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

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

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

    \[\leadsto -\frac{4 \cdot \color{blue}{\left(\log \left(\frac{4}{\pi}\right) - \log f\right)}}{\pi} \]
  7. Step-by-step derivation
    1. log-div96.6%

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

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

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

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

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

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

Reproduce

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