VandenBroeck and Keller, Equation (20)

Percentage Accurate: 6.9% → 99.0%
Time: 19.9s
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}

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: 6.9% 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, 2.5× speedup?

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

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

    \[-\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. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \mathsf{neg}\left(\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}\right) \cdot \frac{1}{\frac{\mathsf{PI}\left(\right)}{4}}\right) \]
    2. un-div-invN/A

      \[\leadsto \mathsf{neg}\left(\frac{\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}\right)}{\frac{\mathsf{PI}\left(\right)}{4}}\right) \]
    3. distribute-neg-fracN/A

      \[\leadsto \frac{\mathsf{neg}\left(\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}\right)\right)}{\color{blue}{\frac{\mathsf{PI}\left(\right)}{4}}} \]
    4. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\left(\mathsf{neg}\left(\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}\right)\right)\right), \color{blue}{\left(\frac{\mathsf{PI}\left(\right)}{4}\right)}\right) \]
  4. Applied egg-rr99.2%

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

Alternative 2: 98.8% accurate, 2.5× speedup?

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

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

    \[-\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. Step-by-step derivation
    1. distribute-rgt-neg-inN/A

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

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}}\right), \color{blue}{\left(\mathsf{neg}\left(\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}\right)\right)\right)}\right) \]
    3. clear-numN/A

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{4}{\mathsf{PI}\left(\right)}\right), \left(\mathsf{neg}\left(\color{blue}{\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}\right)}\right)\right)\right) \]
    4. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(4, \mathsf{PI}\left(\right)\right), \left(\mathsf{neg}\left(\color{blue}{\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}\right)}\right)\right)\right) \]
    5. PI-lowering-PI.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(4, \mathsf{PI.f64}\left(\right)\right), \left(\mathsf{neg}\left(\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}\right)\right)\right)\right) \]
    6. neg-logN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(4, \mathsf{PI.f64}\left(\right)\right), \log \left(\frac{1}{\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}}\right)\right) \]
    7. clear-numN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(4, \mathsf{PI.f64}\left(\right)\right), \log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}\right)\right) \]
  4. Applied egg-rr99.2%

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

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

Alternative 3: 96.4% accurate, 4.5× speedup?

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

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

    \[-\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. distribute-lft-neg-inN/A

      \[\leadsto \left(\mathsf{neg}\left(\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}}\right)\right) \cdot \color{blue}{\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}\right)} \]
    2. distribute-neg-frac2N/A

      \[\leadsto \frac{1}{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4}\right)} \cdot \log \color{blue}{\left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}\right)} \]
    3. associate-*l/N/A

      \[\leadsto \frac{1 \cdot \log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}\right)}{\color{blue}{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4}\right)}} \]
    4. *-lft-identityN/A

      \[\leadsto \frac{\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}\right)}{\mathsf{neg}\left(\color{blue}{\frac{\mathsf{PI}\left(\right)}{4}}\right)} \]
    5. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}\right), \color{blue}{\left(\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4}\right)\right)}\right) \]
  3. Simplified8.0%

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

    \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\color{blue}{\left(\frac{f \cdot \left(\frac{-1}{4} \cdot \frac{\mathsf{PI}\left(\right)}{\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)} + \left(\frac{1}{4} \cdot \frac{\mathsf{PI}\left(\right)}{\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)} + f \cdot \left(\frac{1}{16} \cdot \frac{{\mathsf{PI}\left(\right)}^{2}}{\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)} - 2 \cdot \frac{\frac{1}{384} \cdot {\mathsf{PI}\left(\right)}^{3} - \frac{-1}{384} \cdot {\mathsf{PI}\left(\right)}^{3}}{{\left(\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}^{2}}\right)\right)\right) + 2 \cdot \frac{1}{\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)}}{f}\right)}\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
  6. Simplified95.3%

    \[\leadsto \frac{\log \color{blue}{\left(\frac{\frac{2}{\pi \cdot 0.5} + f \cdot \left(f \cdot \left(0.0625 \cdot \left(\pi \cdot 2\right) + -2 \cdot \left(\left(\pi \cdot \left(\pi \cdot 2\right)\right) \cdot \frac{0.010416666666666666}{\pi}\right)\right)\right)}{f}\right)}}{\frac{\pi}{-4}} \]
  7. Taylor expanded in f around 0

    \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\color{blue}{\left(\frac{{f}^{2} \cdot \left(\frac{-1}{24} \cdot \mathsf{PI}\left(\right) + \frac{1}{8} \cdot \mathsf{PI}\left(\right)\right) + 4 \cdot \frac{1}{\mathsf{PI}\left(\right)}}{f}\right)}\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
  8. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\left({f}^{2} \cdot \left(\frac{-1}{24} \cdot \mathsf{PI}\left(\right) + \frac{1}{8} \cdot \mathsf{PI}\left(\right)\right) + 4 \cdot \frac{1}{\mathsf{PI}\left(\right)}\right), f\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    2. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\left({f}^{2} \cdot \left(\frac{-1}{24} \cdot \mathsf{PI}\left(\right) + \frac{1}{8} \cdot \mathsf{PI}\left(\right)\right)\right), \left(4 \cdot \frac{1}{\mathsf{PI}\left(\right)}\right)\right), f\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    3. unpow2N/A

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(f \cdot \left(f \cdot \left(\frac{-1}{24} \cdot \mathsf{PI}\left(\right) + \frac{1}{8} \cdot \mathsf{PI}\left(\right)\right)\right)\right), \left(4 \cdot \frac{1}{\mathsf{PI}\left(\right)}\right)\right), f\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    5. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(f, \left(f \cdot \left(\frac{-1}{24} \cdot \mathsf{PI}\left(\right) + \frac{1}{8} \cdot \mathsf{PI}\left(\right)\right)\right)\right), \left(4 \cdot \frac{1}{\mathsf{PI}\left(\right)}\right)\right), f\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    6. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(f, \mathsf{*.f64}\left(f, \left(\frac{-1}{24} \cdot \mathsf{PI}\left(\right) + \frac{1}{8} \cdot \mathsf{PI}\left(\right)\right)\right)\right), \left(4 \cdot \frac{1}{\mathsf{PI}\left(\right)}\right)\right), f\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    7. distribute-rgt-outN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(f, \mathsf{*.f64}\left(f, \left(\mathsf{PI}\left(\right) \cdot \left(\frac{-1}{24} + \frac{1}{8}\right)\right)\right)\right), \left(4 \cdot \frac{1}{\mathsf{PI}\left(\right)}\right)\right), f\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    8. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(f, \mathsf{*.f64}\left(f, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), \left(\frac{-1}{24} + \frac{1}{8}\right)\right)\right)\right), \left(4 \cdot \frac{1}{\mathsf{PI}\left(\right)}\right)\right), f\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    9. PI-lowering-PI.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(f, \mathsf{*.f64}\left(f, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \left(\frac{-1}{24} + \frac{1}{8}\right)\right)\right)\right), \left(4 \cdot \frac{1}{\mathsf{PI}\left(\right)}\right)\right), f\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    10. metadata-evalN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(f, \mathsf{*.f64}\left(f, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \frac{1}{12}\right)\right)\right), \left(4 \cdot \frac{1}{\mathsf{PI}\left(\right)}\right)\right), f\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    11. associate-*r/N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(f, \mathsf{*.f64}\left(f, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \frac{1}{12}\right)\right)\right), \left(\frac{4 \cdot 1}{\mathsf{PI}\left(\right)}\right)\right), f\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    12. metadata-evalN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(f, \mathsf{*.f64}\left(f, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \frac{1}{12}\right)\right)\right), \left(\frac{4}{\mathsf{PI}\left(\right)}\right)\right), f\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    13. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(f, \mathsf{*.f64}\left(f, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \frac{1}{12}\right)\right)\right), \mathsf{/.f64}\left(4, \mathsf{PI}\left(\right)\right)\right), f\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    14. PI-lowering-PI.f6495.3%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(f, \mathsf{*.f64}\left(f, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \frac{1}{12}\right)\right)\right), \mathsf{/.f64}\left(4, \mathsf{PI.f64}\left(\right)\right)\right), f\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
  9. Simplified95.3%

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

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

Alternative 4: 95.8% accurate, 4.9× speedup?

\[\begin{array}{l} \\ \frac{\log \left(\frac{\frac{4}{\pi}}{f}\right)}{\frac{\pi}{-4}} \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(log(Float64(Float64(4.0 / pi) / f)) / Float64(pi / -4.0))
end
function tmp = code(f)
	tmp = log(((4.0 / pi) / f)) / (pi / -4.0);
end
code[f_] := N[(N[Log[N[(N[(4.0 / Pi), $MachinePrecision] / f), $MachinePrecision]], $MachinePrecision] / N[(Pi / -4.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

    \[-\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. distribute-lft-neg-inN/A

      \[\leadsto \left(\mathsf{neg}\left(\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}}\right)\right) \cdot \color{blue}{\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}\right)} \]
    2. distribute-neg-frac2N/A

      \[\leadsto \frac{1}{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4}\right)} \cdot \log \color{blue}{\left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}\right)} \]
    3. associate-*l/N/A

      \[\leadsto \frac{1 \cdot \log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}\right)}{\color{blue}{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4}\right)}} \]
    4. *-lft-identityN/A

      \[\leadsto \frac{\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}\right)}{\mathsf{neg}\left(\color{blue}{\frac{\mathsf{PI}\left(\right)}{4}}\right)} \]
    5. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}\right), \color{blue}{\left(\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4}\right)\right)}\right) \]
  3. Simplified8.0%

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

    \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\color{blue}{\left(\frac{2}{f \cdot \left(\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}\right)}\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
  6. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(2, \left(f \cdot \left(\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    2. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(2, \left(\left(\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right) \cdot f\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    3. distribute-rgt-out--N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(2, \left(\left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{4} - \frac{-1}{4}\right)\right) \cdot f\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    4. metadata-evalN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(2, \left(\left(\mathsf{PI}\left(\right) \cdot \frac{1}{2}\right) \cdot f\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    5. associate-*l*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(2, \left(\mathsf{PI}\left(\right) \cdot \left(\frac{1}{2} \cdot f\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    6. metadata-evalN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(2, \left(\mathsf{PI}\left(\right) \cdot \left(\left(1 \cdot \frac{1}{2}\right) \cdot f\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    7. *-inversesN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(2, \left(\mathsf{PI}\left(\right) \cdot \left(\left(\frac{\mathsf{PI}\left(\right)}{\mathsf{PI}\left(\right)} \cdot \frac{1}{2}\right) \cdot f\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    8. metadata-evalN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(2, \left(\mathsf{PI}\left(\right) \cdot \left(\left(\frac{\mathsf{PI}\left(\right)}{\mathsf{PI}\left(\right)} \cdot \frac{\frac{1}{4}}{\frac{1}{2}}\right) \cdot f\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    9. times-fracN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(2, \left(\mathsf{PI}\left(\right) \cdot \left(\frac{\mathsf{PI}\left(\right) \cdot \frac{1}{4}}{\mathsf{PI}\left(\right) \cdot \frac{1}{2}} \cdot f\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    10. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(2, \left(\mathsf{PI}\left(\right) \cdot \left(\frac{\frac{1}{4} \cdot \mathsf{PI}\left(\right)}{\mathsf{PI}\left(\right) \cdot \frac{1}{2}} \cdot f\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    11. metadata-evalN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(2, \left(\mathsf{PI}\left(\right) \cdot \left(\frac{\frac{1}{4} \cdot \mathsf{PI}\left(\right)}{\mathsf{PI}\left(\right) \cdot \left(\frac{1}{4} - \frac{-1}{4}\right)} \cdot f\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    12. distribute-rgt-out--N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(2, \left(\mathsf{PI}\left(\right) \cdot \left(\frac{\frac{1}{4} \cdot \mathsf{PI}\left(\right)}{\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)} \cdot f\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    13. associate-*r/N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(2, \left(\mathsf{PI}\left(\right) \cdot \left(\left(\frac{1}{4} \cdot \frac{\mathsf{PI}\left(\right)}{\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)}\right) \cdot f\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    14. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), \left(\left(\frac{1}{4} \cdot \frac{\mathsf{PI}\left(\right)}{\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)}\right) \cdot f\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    15. PI-lowering-PI.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \left(\left(\frac{1}{4} \cdot \frac{\mathsf{PI}\left(\right)}{\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)}\right) \cdot f\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
  7. Simplified94.7%

    \[\leadsto \frac{\log \color{blue}{\left(\frac{2}{\pi \cdot \left(f \cdot 0.5\right)}\right)}}{\frac{\pi}{-4}} \]
  8. Step-by-step derivation
    1. associate-/r*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\left(\frac{\frac{2}{\mathsf{PI}\left(\right)}}{f \cdot \frac{1}{2}}\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    2. associate-/l/N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\left(\frac{\frac{\frac{2}{\mathsf{PI}\left(\right)}}{\frac{1}{2}}}{f}\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    3. associate-/l/N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\left(\frac{\frac{2}{\frac{1}{2} \cdot \mathsf{PI}\left(\right)}}{f}\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    4. associate-/r*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\left(\frac{\frac{\frac{2}{\frac{1}{2}}}{\mathsf{PI}\left(\right)}}{f}\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    5. metadata-evalN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\left(\frac{\frac{4}{\mathsf{PI}\left(\right)}}{f}\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    6. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\left(\frac{4}{\mathsf{PI}\left(\right)}\right), f\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    7. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(4, \mathsf{PI}\left(\right)\right), f\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    8. PI-lowering-PI.f6494.7%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(4, \mathsf{PI.f64}\left(\right)\right), f\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
  9. Applied egg-rr94.7%

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

Alternative 5: 95.7% accurate, 4.9× speedup?

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

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

    \[-\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. Step-by-step derivation
    1. distribute-rgt-neg-inN/A

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

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}}\right), \color{blue}{\left(\mathsf{neg}\left(\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}\right)\right)\right)}\right) \]
    3. clear-numN/A

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{4}{\mathsf{PI}\left(\right)}\right), \left(\mathsf{neg}\left(\color{blue}{\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}\right)}\right)\right)\right) \]
    4. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(4, \mathsf{PI}\left(\right)\right), \left(\mathsf{neg}\left(\color{blue}{\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}\right)}\right)\right)\right) \]
    5. PI-lowering-PI.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(4, \mathsf{PI.f64}\left(\right)\right), \left(\mathsf{neg}\left(\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}\right)\right)\right)\right) \]
    6. neg-logN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(4, \mathsf{PI.f64}\left(\right)\right), \log \left(\frac{1}{\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}}\right)\right) \]
    7. clear-numN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(4, \mathsf{PI.f64}\left(\right)\right), \log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)}}\right)\right) \]
  4. Applied egg-rr99.2%

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

    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(4, \mathsf{PI.f64}\left(\right)\right), \mathsf{log.f64}\left(\color{blue}{\left(\frac{1}{4} \cdot \left(f \cdot \mathsf{PI}\left(\right)\right)\right)}\right)\right) \]
  6. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(4, \mathsf{PI.f64}\left(\right)\right), \mathsf{log.f64}\left(\left(\left(f \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{1}{4}\right)\right)\right) \]
    2. associate-*r*N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(4, \mathsf{PI.f64}\left(\right)\right), \mathsf{log.f64}\left(\left(f \cdot \left(\mathsf{PI}\left(\right) \cdot \frac{1}{4}\right)\right)\right)\right) \]
    3. *-commutativeN/A

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(4, \mathsf{PI.f64}\left(\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(f, \left(\frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
    5. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(4, \mathsf{PI.f64}\left(\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(f, \mathsf{*.f64}\left(\frac{1}{4}, \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
    6. PI-lowering-PI.f6494.7%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(4, \mathsf{PI.f64}\left(\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(f, \mathsf{*.f64}\left(\frac{1}{4}, \mathsf{PI.f64}\left(\right)\right)\right)\right)\right) \]
  7. Simplified94.7%

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

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

Alternative 6: 4.2% accurate, 76.0× speedup?

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

\\
f \cdot \left(-0.08333333333333333 \cdot \left(\pi \cdot f\right)\right)
\end{array}
Derivation
  1. Initial program 8.0%

    \[-\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

    \[\leadsto \color{blue}{f \cdot \left(-2 \cdot \frac{f \cdot \left(\frac{-1}{4} \cdot \left({\left(\frac{-1}{4} \cdot \frac{\mathsf{PI}\left(\right)}{\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)} + \frac{1}{4} \cdot \frac{\mathsf{PI}\left(\right)}{\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)}\right)}^{2} \cdot {\left(\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}^{2}\right) + \left(\frac{1}{16} \cdot \frac{{\mathsf{PI}\left(\right)}^{2}}{\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)} - 2 \cdot \frac{\frac{1}{384} \cdot {\mathsf{PI}\left(\right)}^{3} - \frac{-1}{384} \cdot {\mathsf{PI}\left(\right)}^{3}}{{\left(\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}^{2}}\right) \cdot \left(\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)\right)}{\mathsf{PI}\left(\right)} - 2 \cdot \frac{\left(\frac{-1}{4} \cdot \frac{\mathsf{PI}\left(\right)}{\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)} + \frac{1}{4} \cdot \frac{\mathsf{PI}\left(\right)}{\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)}\right) \cdot \left(\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}{\mathsf{PI}\left(\right)}\right) - 4 \cdot \frac{\log \left(\frac{2}{\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)}\right) + -1 \cdot \log f}{\mathsf{PI}\left(\right)}} \]
  4. Simplified95.2%

    \[\leadsto \color{blue}{\frac{-4 \cdot \left(\log \left(\frac{2}{\pi \cdot 0.5}\right) - \log f\right)}{\pi} + \frac{f \cdot \left(\left(\pi \cdot 0.5\right) \cdot \left(0.0625 \cdot \left(\pi \cdot 2\right) + -2 \cdot \left(\left(\pi \cdot \left(\pi \cdot 2\right)\right) \cdot \frac{0.010416666666666666}{\pi}\right)\right)\right)}{\pi} \cdot \left(-2 \cdot f\right)} \]
  5. Taylor expanded in f around inf

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

      \[\leadsto \mathsf{neg}\left({f}^{2} \cdot \left(\frac{-1}{24} \cdot \mathsf{PI}\left(\right) + \frac{1}{8} \cdot \mathsf{PI}\left(\right)\right)\right) \]
    2. distribute-rgt-outN/A

      \[\leadsto \mathsf{neg}\left({f}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\frac{-1}{24} + \frac{1}{8}\right)\right)\right) \]
    3. associate-*r*N/A

      \[\leadsto \mathsf{neg}\left(\left({f}^{2} \cdot \mathsf{PI}\left(\right)\right) \cdot \left(\frac{-1}{24} + \frac{1}{8}\right)\right) \]
    4. distribute-rgt-neg-inN/A

      \[\leadsto \left({f}^{2} \cdot \mathsf{PI}\left(\right)\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\left(\frac{-1}{24} + \frac{1}{8}\right)\right)\right)} \]
    5. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\left({f}^{2} \cdot \mathsf{PI}\left(\right)\right), \color{blue}{\left(\mathsf{neg}\left(\left(\frac{-1}{24} + \frac{1}{8}\right)\right)\right)}\right) \]
    6. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(\left(\mathsf{PI}\left(\right) \cdot {f}^{2}\right), \left(\mathsf{neg}\left(\color{blue}{\left(\frac{-1}{24} + \frac{1}{8}\right)}\right)\right)\right) \]
    7. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{PI}\left(\right), \left({f}^{2}\right)\right), \left(\mathsf{neg}\left(\color{blue}{\left(\frac{-1}{24} + \frac{1}{8}\right)}\right)\right)\right) \]
    8. PI-lowering-PI.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \left({f}^{2}\right)\right), \left(\mathsf{neg}\left(\left(\color{blue}{\frac{-1}{24}} + \frac{1}{8}\right)\right)\right)\right) \]
    9. unpow2N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \left(f \cdot f\right)\right), \left(\mathsf{neg}\left(\left(\frac{-1}{24} + \color{blue}{\frac{1}{8}}\right)\right)\right)\right) \]
    10. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(f, f\right)\right), \left(\mathsf{neg}\left(\left(\frac{-1}{24} + \color{blue}{\frac{1}{8}}\right)\right)\right)\right) \]
    11. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(f, f\right)\right), \left(\mathsf{neg}\left(\frac{1}{12}\right)\right)\right) \]
    12. metadata-eval4.2%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(f, f\right)\right), \frac{-1}{12}\right) \]
  7. Simplified4.2%

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{-1}{12} \cdot \left(\mathsf{PI}\left(\right) \cdot f\right)\right), \color{blue}{f}\right) \]
    5. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{12}, \left(\mathsf{PI}\left(\right) \cdot f\right)\right), f\right) \]
    6. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{12}, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), f\right)\right), f\right) \]
    7. PI-lowering-PI.f644.2%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{12}, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), f\right)\right), f\right) \]
  9. Applied egg-rr4.2%

    \[\leadsto \color{blue}{\left(-0.08333333333333333 \cdot \left(\pi \cdot f\right)\right) \cdot f} \]
  10. Final simplification4.2%

    \[\leadsto f \cdot \left(-0.08333333333333333 \cdot \left(\pi \cdot f\right)\right) \]
  11. Add Preprocessing

Reproduce

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