VandenBroeck and Keller, Equation (20)

Percentage Accurate: 6.8% → 99.0%
Time: 8.8s
Alternatives: 6
Speedup: 4.9×

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}

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: 6.8% 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.0% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(0.25 \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(\frac{1}{e^{-\pi \cdot \left(-0.5 \cdot f\right)}}\right)\right)}{\pi} \end{array} \]
(FPCore (f)
 :precision binary64
 (/
  (*
   4.0
   (-
    (log (- (expm1 (* (* -2.0 (* 0.25 f)) PI))))
    (log1p (/ 1.0 (exp (- (* PI (* -0.5 f))))))))
  PI))
double code(double f) {
	return (4.0 * (log(-expm1(((-2.0 * (0.25 * f)) * ((double) M_PI)))) - log1p((1.0 / exp(-(((double) M_PI) * (-0.5 * f))))))) / ((double) M_PI);
}
public static double code(double f) {
	return (4.0 * (Math.log(-Math.expm1(((-2.0 * (0.25 * f)) * Math.PI))) - Math.log1p((1.0 / Math.exp(-(Math.PI * (-0.5 * f))))))) / Math.PI;
}
def code(f):
	return (4.0 * (math.log(-math.expm1(((-2.0 * (0.25 * f)) * math.pi))) - math.log1p((1.0 / math.exp(-(math.pi * (-0.5 * f))))))) / math.pi
function code(f)
	return Float64(Float64(4.0 * Float64(log(Float64(-expm1(Float64(Float64(-2.0 * Float64(0.25 * f)) * pi)))) - log1p(Float64(1.0 / exp(Float64(-Float64(pi * Float64(-0.5 * f)))))))) / pi)
end
code[f_] := N[(N[(4.0 * N[(N[Log[(-N[(Exp[N[(N[(-2.0 * N[(0.25 * f), $MachinePrecision]), $MachinePrecision] * Pi), $MachinePrecision]] - 1), $MachinePrecision])], $MachinePrecision] - N[Log[1 + N[(1.0 / N[Exp[(-N[(Pi * N[(-0.5 * f), $MachinePrecision]), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / Pi), $MachinePrecision]
\begin{array}{l}

\\
\frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(0.25 \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(\frac{1}{e^{-\pi \cdot \left(-0.5 \cdot f\right)}}\right)\right)}{\pi}
\end{array}
Derivation
  1. Initial program 6.8%

    \[-\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. Step-by-step derivation
    1. lift-neg.f64N/A

      \[\leadsto \color{blue}{\mathsf{neg}\left(\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)\right)} \]
    2. lift-*.f64N/A

      \[\leadsto \mathsf{neg}\left(\color{blue}{\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)}\right) \]
    3. distribute-rgt-neg-inN/A

      \[\leadsto \color{blue}{\frac{1}{\frac{\pi}{4}} \cdot \left(\mathsf{neg}\left(\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)\right)\right)} \]
    4. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{1}{\frac{\pi}{4}}} \cdot \left(\mathsf{neg}\left(\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)\right)\right) \]
    5. lift-/.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{\pi}{4}}} \cdot \left(\mathsf{neg}\left(\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)\right)\right) \]
    6. div-flip-revN/A

      \[\leadsto \color{blue}{\frac{4}{\pi}} \cdot \left(\mathsf{neg}\left(\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)\right)\right) \]
  3. Applied rewrites99.0%

    \[\leadsto \color{blue}{\frac{4 \cdot \log \tanh \left(f \cdot \left(0.25 \cdot \pi\right)\right)}{\pi}} \]
  4. Step-by-step derivation
    1. lift-log.f64N/A

      \[\leadsto \frac{4 \cdot \color{blue}{\log \tanh \left(f \cdot \left(\frac{1}{4} \cdot \pi\right)\right)}}{\pi} \]
    2. lift-tanh.f64N/A

      \[\leadsto \frac{4 \cdot \log \color{blue}{\tanh \left(f \cdot \left(\frac{1}{4} \cdot \pi\right)\right)}}{\pi} \]
    3. tanh-def-cN/A

      \[\leadsto \frac{4 \cdot \log \color{blue}{\left(\frac{1 - e^{-2 \cdot \left(f \cdot \left(\frac{1}{4} \cdot \pi\right)\right)}}{1 + e^{-2 \cdot \left(f \cdot \left(\frac{1}{4} \cdot \pi\right)\right)}}\right)}}{\pi} \]
    4. log-divN/A

      \[\leadsto \frac{4 \cdot \color{blue}{\left(\log \left(1 - e^{-2 \cdot \left(f \cdot \left(\frac{1}{4} \cdot \pi\right)\right)}\right) - \log \left(1 + e^{-2 \cdot \left(f \cdot \left(\frac{1}{4} \cdot \pi\right)\right)}\right)\right)}}{\pi} \]
    5. lower--.f64N/A

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

    \[\leadsto \frac{4 \cdot \color{blue}{\left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(0.25 \cdot f\right)\right) \cdot \pi\right)\right) - \log \left(e^{\left(-2 \cdot \left(0.25 \cdot f\right)\right) \cdot \pi} + 1\right)\right)}}{\pi} \]
  6. Step-by-step derivation
    1. lift-log.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \color{blue}{\log \left(e^{\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi} + 1\right)}\right)}{\pi} \]
    2. lift-+.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \log \color{blue}{\left(e^{\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi} + 1\right)}\right)}{\pi} \]
    3. +-commutativeN/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \log \color{blue}{\left(1 + e^{\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi}\right)}\right)}{\pi} \]
    4. lower-log1p.f6499.0

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(0.25 \cdot f\right)\right) \cdot \pi\right)\right) - \color{blue}{\mathsf{log1p}\left(e^{\left(-2 \cdot \left(0.25 \cdot f\right)\right) \cdot \pi}\right)}\right)}{\pi} \]
    5. lift-*.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(e^{\color{blue}{\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi}}\right)\right)}{\pi} \]
    6. *-commutativeN/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(e^{\color{blue}{\pi \cdot \left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right)}}\right)\right)}{\pi} \]
    7. lower-*.f6499.0

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(0.25 \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(e^{\color{blue}{\pi \cdot \left(-2 \cdot \left(0.25 \cdot f\right)\right)}}\right)\right)}{\pi} \]
    8. lift-*.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(e^{\pi \cdot \color{blue}{\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right)}}\right)\right)}{\pi} \]
    9. lift-*.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(e^{\pi \cdot \left(-2 \cdot \color{blue}{\left(\frac{1}{4} \cdot f\right)}\right)}\right)\right)}{\pi} \]
    10. associate-*r*N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(e^{\pi \cdot \color{blue}{\left(\left(-2 \cdot \frac{1}{4}\right) \cdot f\right)}}\right)\right)}{\pi} \]
    11. metadata-evalN/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(e^{\pi \cdot \left(\color{blue}{\frac{-1}{2}} \cdot f\right)}\right)\right)}{\pi} \]
    12. lower-*.f6499.0

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

    \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(0.25 \cdot f\right)\right) \cdot \pi\right)\right) - \color{blue}{\mathsf{log1p}\left(e^{\pi \cdot \left(-0.5 \cdot f\right)}\right)}\right)}{\pi} \]
  8. Step-by-step derivation
    1. lift-exp.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(\color{blue}{e^{\pi \cdot \left(\frac{-1}{2} \cdot f\right)}}\right)\right)}{\pi} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(e^{\color{blue}{\pi \cdot \left(\frac{-1}{2} \cdot f\right)}}\right)\right)}{\pi} \]
    3. lift-*.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(e^{\pi \cdot \color{blue}{\left(\frac{-1}{2} \cdot f\right)}}\right)\right)}{\pi} \]
    4. metadata-evalN/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(e^{\pi \cdot \left(\color{blue}{\left(-2 \cdot \frac{1}{4}\right)} \cdot f\right)}\right)\right)}{\pi} \]
    5. associate-*r*N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(e^{\pi \cdot \color{blue}{\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right)}}\right)\right)}{\pi} \]
    6. lift-*.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(e^{\pi \cdot \left(-2 \cdot \color{blue}{\left(\frac{1}{4} \cdot f\right)}\right)}\right)\right)}{\pi} \]
    7. lift-*.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(e^{\pi \cdot \color{blue}{\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right)}}\right)\right)}{\pi} \]
    8. *-commutativeN/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(e^{\color{blue}{\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi}}\right)\right)}{\pi} \]
    9. lift-*.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(e^{\color{blue}{\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi}}\right)\right)}{\pi} \]
    10. /-rgt-identityN/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(\color{blue}{\frac{e^{\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi}}{1}}\right)\right)}{\pi} \]
    11. div-flipN/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(\color{blue}{\frac{1}{\frac{1}{e^{\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi}}}}\right)\right)}{\pi} \]
    12. rec-expN/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(\frac{1}{\color{blue}{e^{\mathsf{neg}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)}}}\right)\right)}{\pi} \]
    13. lower-/.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(\color{blue}{\frac{1}{e^{\mathsf{neg}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)}}}\right)\right)}{\pi} \]
    14. lower-exp.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(\frac{1}{\color{blue}{e^{\mathsf{neg}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)}}}\right)\right)}{\pi} \]
    15. lower-neg.f6499.0

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(0.25 \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(\frac{1}{e^{\color{blue}{-\left(-2 \cdot \left(0.25 \cdot f\right)\right) \cdot \pi}}}\right)\right)}{\pi} \]
    16. lift-*.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(\frac{1}{e^{-\color{blue}{\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi}}}\right)\right)}{\pi} \]
    17. *-commutativeN/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(\frac{1}{e^{-\color{blue}{\pi \cdot \left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right)}}}\right)\right)}{\pi} \]
    18. lift-*.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(\frac{1}{e^{-\pi \cdot \color{blue}{\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right)}}}\right)\right)}{\pi} \]
    19. lift-*.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(\frac{1}{e^{-\pi \cdot \left(-2 \cdot \color{blue}{\left(\frac{1}{4} \cdot f\right)}\right)}}\right)\right)}{\pi} \]
    20. associate-*r*N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(\frac{1}{e^{-\pi \cdot \color{blue}{\left(\left(-2 \cdot \frac{1}{4}\right) \cdot f\right)}}}\right)\right)}{\pi} \]
    21. metadata-evalN/A

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

    \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(0.25 \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(\color{blue}{\frac{1}{e^{-\pi \cdot \left(-0.5 \cdot f\right)}}}\right)\right)}{\pi} \]
  10. Add Preprocessing

Alternative 2: 99.0% accurate, 1.7× speedup?

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

\\
\frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(\pi \cdot f\right) \cdot -0.5\right)\right) - \mathsf{log1p}\left(e^{\pi \cdot \left(-0.5 \cdot f\right)}\right)\right)}{\pi}
\end{array}
Derivation
  1. Initial program 6.8%

    \[-\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. Step-by-step derivation
    1. lift-neg.f64N/A

      \[\leadsto \color{blue}{\mathsf{neg}\left(\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)\right)} \]
    2. lift-*.f64N/A

      \[\leadsto \mathsf{neg}\left(\color{blue}{\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)}\right) \]
    3. distribute-rgt-neg-inN/A

      \[\leadsto \color{blue}{\frac{1}{\frac{\pi}{4}} \cdot \left(\mathsf{neg}\left(\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)\right)\right)} \]
    4. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{1}{\frac{\pi}{4}}} \cdot \left(\mathsf{neg}\left(\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)\right)\right) \]
    5. lift-/.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{\pi}{4}}} \cdot \left(\mathsf{neg}\left(\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)\right)\right) \]
    6. div-flip-revN/A

      \[\leadsto \color{blue}{\frac{4}{\pi}} \cdot \left(\mathsf{neg}\left(\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)\right)\right) \]
  3. Applied rewrites99.0%

    \[\leadsto \color{blue}{\frac{4 \cdot \log \tanh \left(f \cdot \left(0.25 \cdot \pi\right)\right)}{\pi}} \]
  4. Step-by-step derivation
    1. lift-log.f64N/A

      \[\leadsto \frac{4 \cdot \color{blue}{\log \tanh \left(f \cdot \left(\frac{1}{4} \cdot \pi\right)\right)}}{\pi} \]
    2. lift-tanh.f64N/A

      \[\leadsto \frac{4 \cdot \log \color{blue}{\tanh \left(f \cdot \left(\frac{1}{4} \cdot \pi\right)\right)}}{\pi} \]
    3. tanh-def-cN/A

      \[\leadsto \frac{4 \cdot \log \color{blue}{\left(\frac{1 - e^{-2 \cdot \left(f \cdot \left(\frac{1}{4} \cdot \pi\right)\right)}}{1 + e^{-2 \cdot \left(f \cdot \left(\frac{1}{4} \cdot \pi\right)\right)}}\right)}}{\pi} \]
    4. log-divN/A

      \[\leadsto \frac{4 \cdot \color{blue}{\left(\log \left(1 - e^{-2 \cdot \left(f \cdot \left(\frac{1}{4} \cdot \pi\right)\right)}\right) - \log \left(1 + e^{-2 \cdot \left(f \cdot \left(\frac{1}{4} \cdot \pi\right)\right)}\right)\right)}}{\pi} \]
    5. lower--.f64N/A

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

    \[\leadsto \frac{4 \cdot \color{blue}{\left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(0.25 \cdot f\right)\right) \cdot \pi\right)\right) - \log \left(e^{\left(-2 \cdot \left(0.25 \cdot f\right)\right) \cdot \pi} + 1\right)\right)}}{\pi} \]
  6. Step-by-step derivation
    1. lift-log.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \color{blue}{\log \left(e^{\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi} + 1\right)}\right)}{\pi} \]
    2. lift-+.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \log \color{blue}{\left(e^{\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi} + 1\right)}\right)}{\pi} \]
    3. +-commutativeN/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \log \color{blue}{\left(1 + e^{\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi}\right)}\right)}{\pi} \]
    4. lower-log1p.f6499.0

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(0.25 \cdot f\right)\right) \cdot \pi\right)\right) - \color{blue}{\mathsf{log1p}\left(e^{\left(-2 \cdot \left(0.25 \cdot f\right)\right) \cdot \pi}\right)}\right)}{\pi} \]
    5. lift-*.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(e^{\color{blue}{\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi}}\right)\right)}{\pi} \]
    6. *-commutativeN/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(e^{\color{blue}{\pi \cdot \left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right)}}\right)\right)}{\pi} \]
    7. lower-*.f6499.0

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(0.25 \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(e^{\color{blue}{\pi \cdot \left(-2 \cdot \left(0.25 \cdot f\right)\right)}}\right)\right)}{\pi} \]
    8. lift-*.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(e^{\pi \cdot \color{blue}{\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right)}}\right)\right)}{\pi} \]
    9. lift-*.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(e^{\pi \cdot \left(-2 \cdot \color{blue}{\left(\frac{1}{4} \cdot f\right)}\right)}\right)\right)}{\pi} \]
    10. associate-*r*N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(e^{\pi \cdot \color{blue}{\left(\left(-2 \cdot \frac{1}{4}\right) \cdot f\right)}}\right)\right)}{\pi} \]
    11. metadata-evalN/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi\right)\right) - \mathsf{log1p}\left(e^{\pi \cdot \left(\color{blue}{\frac{-1}{2}} \cdot f\right)}\right)\right)}{\pi} \]
    12. lower-*.f6499.0

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

    \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\left(-2 \cdot \left(0.25 \cdot f\right)\right) \cdot \pi\right)\right) - \color{blue}{\mathsf{log1p}\left(e^{\pi \cdot \left(-0.5 \cdot f\right)}\right)}\right)}{\pi} \]
  8. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\color{blue}{\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right) \cdot \pi}\right)\right) - \mathsf{log1p}\left(e^{\pi \cdot \left(\frac{-1}{2} \cdot f\right)}\right)\right)}{\pi} \]
    2. *-commutativeN/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\color{blue}{\pi \cdot \left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right)}\right)\right) - \mathsf{log1p}\left(e^{\pi \cdot \left(\frac{-1}{2} \cdot f\right)}\right)\right)}{\pi} \]
    3. lift-*.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\pi \cdot \color{blue}{\left(-2 \cdot \left(\frac{1}{4} \cdot f\right)\right)}\right)\right) - \mathsf{log1p}\left(e^{\pi \cdot \left(\frac{-1}{2} \cdot f\right)}\right)\right)}{\pi} \]
    4. lift-*.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\pi \cdot \left(-2 \cdot \color{blue}{\left(\frac{1}{4} \cdot f\right)}\right)\right)\right) - \mathsf{log1p}\left(e^{\pi \cdot \left(\frac{-1}{2} \cdot f\right)}\right)\right)}{\pi} \]
    5. associate-*r*N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\pi \cdot \color{blue}{\left(\left(-2 \cdot \frac{1}{4}\right) \cdot f\right)}\right)\right) - \mathsf{log1p}\left(e^{\pi \cdot \left(\frac{-1}{2} \cdot f\right)}\right)\right)}{\pi} \]
    6. metadata-evalN/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\pi \cdot \left(\color{blue}{\frac{-1}{2}} \cdot f\right)\right)\right) - \mathsf{log1p}\left(e^{\pi \cdot \left(\frac{-1}{2} \cdot f\right)}\right)\right)}{\pi} \]
    7. *-commutativeN/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\pi \cdot \color{blue}{\left(f \cdot \frac{-1}{2}\right)}\right)\right) - \mathsf{log1p}\left(e^{\pi \cdot \left(\frac{-1}{2} \cdot f\right)}\right)\right)}{\pi} \]
    8. associate-*r*N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\color{blue}{\left(\pi \cdot f\right) \cdot \frac{-1}{2}}\right)\right) - \mathsf{log1p}\left(e^{\pi \cdot \left(\frac{-1}{2} \cdot f\right)}\right)\right)}{\pi} \]
    9. lift-*.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\color{blue}{\left(\pi \cdot f\right)} \cdot \frac{-1}{2}\right)\right) - \mathsf{log1p}\left(e^{\pi \cdot \left(\frac{-1}{2} \cdot f\right)}\right)\right)}{\pi} \]
    10. lower-*.f6499.0

      \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\color{blue}{\left(\pi \cdot f\right) \cdot -0.5}\right)\right) - \mathsf{log1p}\left(e^{\pi \cdot \left(-0.5 \cdot f\right)}\right)\right)}{\pi} \]
  9. Applied rewrites99.0%

    \[\leadsto \frac{4 \cdot \left(\log \left(-\mathsf{expm1}\left(\color{blue}{\left(\pi \cdot f\right) \cdot -0.5}\right)\right) - \mathsf{log1p}\left(e^{\pi \cdot \left(-0.5 \cdot f\right)}\right)\right)}{\pi} \]
  10. Add Preprocessing

Alternative 3: 99.0% accurate, 3.5× speedup?

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

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

    \[-\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. Step-by-step derivation
    1. lift-neg.f64N/A

      \[\leadsto \color{blue}{\mathsf{neg}\left(\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)\right)} \]
    2. lift-*.f64N/A

      \[\leadsto \mathsf{neg}\left(\color{blue}{\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)}\right) \]
    3. distribute-rgt-neg-inN/A

      \[\leadsto \color{blue}{\frac{1}{\frac{\pi}{4}} \cdot \left(\mathsf{neg}\left(\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)\right)\right)} \]
    4. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{1}{\frac{\pi}{4}}} \cdot \left(\mathsf{neg}\left(\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)\right)\right) \]
    5. lift-/.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{\pi}{4}}} \cdot \left(\mathsf{neg}\left(\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)\right)\right) \]
    6. div-flip-revN/A

      \[\leadsto \color{blue}{\frac{4}{\pi}} \cdot \left(\mathsf{neg}\left(\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)\right)\right) \]
  3. Applied rewrites99.0%

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

Alternative 4: 98.8% accurate, 3.5× speedup?

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

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

    \[-\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. Step-by-step derivation
    1. lift-neg.f64N/A

      \[\leadsto \color{blue}{\mathsf{neg}\left(\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)\right)} \]
    2. lift-*.f64N/A

      \[\leadsto \mathsf{neg}\left(\color{blue}{\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)}\right) \]
    3. *-commutativeN/A

      \[\leadsto \mathsf{neg}\left(\color{blue}{\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) \cdot \frac{1}{\frac{\pi}{4}}}\right) \]
    4. distribute-lft-neg-inN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\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)\right)\right) \cdot \frac{1}{\frac{\pi}{4}}} \]
    5. lower-*.f64N/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\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)\right)\right) \cdot \frac{1}{\frac{\pi}{4}}} \]
  3. Applied rewrites98.8%

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

Alternative 5: 95.8% accurate, 3.8× speedup?

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

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

    \[-\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. Step-by-step derivation
    1. lift-neg.f64N/A

      \[\leadsto \color{blue}{\mathsf{neg}\left(\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)\right)} \]
    2. lift-*.f64N/A

      \[\leadsto \mathsf{neg}\left(\color{blue}{\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)}\right) \]
    3. distribute-rgt-neg-inN/A

      \[\leadsto \color{blue}{\frac{1}{\frac{\pi}{4}} \cdot \left(\mathsf{neg}\left(\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)\right)\right)} \]
    4. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{1}{\frac{\pi}{4}}} \cdot \left(\mathsf{neg}\left(\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)\right)\right) \]
    5. lift-/.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{\pi}{4}}} \cdot \left(\mathsf{neg}\left(\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)\right)\right) \]
    6. div-flip-revN/A

      \[\leadsto \color{blue}{\frac{4}{\pi}} \cdot \left(\mathsf{neg}\left(\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)\right)\right) \]
  3. Applied rewrites99.0%

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

    \[\leadsto \frac{4 \cdot \color{blue}{\left(\log f + \log \left(\frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)\right)}}{\pi} \]
  5. Step-by-step derivation
    1. lower-+.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log f + \color{blue}{\log \left(\frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)}\right)}{\pi} \]
    2. lower-log.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log f + \log \color{blue}{\left(\frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)}\right)}{\pi} \]
    3. lower-log.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log f + \log \left(\frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)\right)}{\pi} \]
    4. lower-*.f64N/A

      \[\leadsto \frac{4 \cdot \left(\log f + \log \left(\frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)\right)}{\pi} \]
    5. lower-PI.f6495.8

      \[\leadsto \frac{4 \cdot \left(\log f + \log \left(0.25 \cdot \pi\right)\right)}{\pi} \]
  6. Applied rewrites95.8%

    \[\leadsto \frac{4 \cdot \color{blue}{\left(\log f + \log \left(0.25 \cdot \pi\right)\right)}}{\pi} \]
  7. Add Preprocessing

Alternative 6: 95.8% accurate, 4.9× speedup?

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

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

    \[-\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. Step-by-step derivation
    1. lift-neg.f64N/A

      \[\leadsto \color{blue}{\mathsf{neg}\left(\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)\right)} \]
    2. lift-*.f64N/A

      \[\leadsto \mathsf{neg}\left(\color{blue}{\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)}\right) \]
    3. distribute-rgt-neg-inN/A

      \[\leadsto \color{blue}{\frac{1}{\frac{\pi}{4}} \cdot \left(\mathsf{neg}\left(\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)\right)\right)} \]
    4. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{1}{\frac{\pi}{4}}} \cdot \left(\mathsf{neg}\left(\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)\right)\right) \]
    5. lift-/.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{\pi}{4}}} \cdot \left(\mathsf{neg}\left(\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)\right)\right) \]
    6. div-flip-revN/A

      \[\leadsto \color{blue}{\frac{4}{\pi}} \cdot \left(\mathsf{neg}\left(\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)\right)\right) \]
  3. Applied rewrites99.0%

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

    \[\leadsto \frac{4 \cdot \log \color{blue}{\left(\frac{1}{4} \cdot \left(f \cdot \mathsf{PI}\left(\right)\right)\right)}}{\pi} \]
  5. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto \frac{4 \cdot \log \left(\frac{1}{4} \cdot \color{blue}{\left(f \cdot \mathsf{PI}\left(\right)\right)}\right)}{\pi} \]
    2. lower-*.f64N/A

      \[\leadsto \frac{4 \cdot \log \left(\frac{1}{4} \cdot \left(f \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right)}{\pi} \]
    3. lower-PI.f6495.8

      \[\leadsto \frac{4 \cdot \log \left(0.25 \cdot \left(f \cdot \pi\right)\right)}{\pi} \]
  6. Applied rewrites95.8%

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

Reproduce

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