VandenBroeck and Keller, Equation (20)

Percentage Accurate: 6.6% → 99.1%
Time: 21.0s
Alternatives: 11
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 11 alternatives:

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

Initial Program: 6.6% accurate, 1.0× speedup?

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

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

Alternative 1: 99.1% accurate, 1.0× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{\log \left(\frac{1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot 0.5\right)\right)} + \frac{-1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot -0.5\right)\right)}\right)}{\frac{\pi}{-4}}} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. clear-numN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{+.f64}\left(\left(\frac{1}{\frac{e^{\mathsf{PI}\left(\right) \cdot \left(f \cdot \frac{1}{2}\right)} - 1}{1}}\right), \mathsf{/.f64}\left(-1, \mathsf{expm1.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(f, \frac{-1}{2}\right)\right)\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    2. inv-powN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{+.f64}\left(\left({\left(\frac{e^{\mathsf{PI}\left(\right) \cdot \left(f \cdot \frac{1}{2}\right)} - 1}{1}\right)}^{-1}\right), \mathsf{/.f64}\left(-1, \mathsf{expm1.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(f, \frac{-1}{2}\right)\right)\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    3. sqr-powN/A

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

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{+.f64}\left(\mathsf{pow.f64}\left(\left({\left(\frac{e^{\mathsf{PI}\left(\right) \cdot \left(f \cdot \frac{1}{2}\right)} - 1}{1}\right)}^{\left(\frac{-1}{2}\right)}\right), 2\right), \mathsf{/.f64}\left(-1, \mathsf{expm1.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(f, \frac{-1}{2}\right)\right)\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(\mathsf{pow.f64}\left(\left({\left(\frac{e^{\mathsf{PI}\left(\right) \cdot \left(f \cdot \frac{1}{2}\right)} - 1}{1}\right)}^{\frac{-1}{2}}\right), 2\right), \mathsf{/.f64}\left(-1, \mathsf{expm1.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(f, \frac{-1}{2}\right)\right)\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    7. pow-lowering-pow.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{pow.f64}\left(\left(\frac{e^{\mathsf{PI}\left(\right) \cdot \left(f \cdot \frac{1}{2}\right)} - 1}{1}\right), \frac{-1}{2}\right), 2\right), \mathsf{/.f64}\left(-1, \mathsf{expm1.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(f, \frac{-1}{2}\right)\right)\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    8. /-rgt-identityN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{pow.f64}\left(\left(e^{\mathsf{PI}\left(\right) \cdot \left(f \cdot \frac{1}{2}\right)} - 1\right), \frac{-1}{2}\right), 2\right), \mathsf{/.f64}\left(-1, \mathsf{expm1.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(f, \frac{-1}{2}\right)\right)\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    9. accelerator-lowering-expm1.f64N/A

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

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{pow.f64}\left(\mathsf{expm1.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \left(f \cdot \frac{1}{2}\right)\right)\right), \frac{-1}{2}\right), 2\right), \mathsf{/.f64}\left(-1, \mathsf{expm1.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(f, \frac{-1}{2}\right)\right)\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    12. *-lowering-*.f6499.1%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{pow.f64}\left(\mathsf{expm1.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(f, \frac{1}{2}\right)\right)\right), \frac{-1}{2}\right), 2\right), \mathsf{/.f64}\left(-1, \mathsf{expm1.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(f, \frac{-1}{2}\right)\right)\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
  5. Applied egg-rr99.1%

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

Alternative 2: 99.1% accurate, 1.7× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{\log \left(\frac{1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot 0.5\right)\right)} + \frac{-1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot -0.5\right)\right)}\right)}{\frac{\pi}{-4}}} \]
  3. Add Preprocessing
  4. Final simplification99.1%

    \[\leadsto \frac{\log \left(\frac{-1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot -0.5\right)\right)} + \frac{1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot 0.5\right)\right)}\right)}{\frac{\pi}{-4}} \]
  5. Add Preprocessing

Alternative 3: 99.0% accurate, 1.7× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{\log \left(\frac{1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot 0.5\right)\right)} + \frac{-1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot -0.5\right)\right)}\right)}{\frac{\pi}{-4}}} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. associate-/r/N/A

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{-4}{\frac{\pi}{\log \left(\frac{1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot 0.5\right)\right)} + \frac{-1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot -0.5\right)\right)}\right)}}} \]
  6. Final simplification99.0%

    \[\leadsto \frac{-4}{\frac{\pi}{\log \left(\frac{-1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot -0.5\right)\right)} + \frac{1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot 0.5\right)\right)}\right)}} \]
  7. Add Preprocessing

Alternative 4: 98.4% accurate, 2.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;f \leq 230:\\ \;\;\;\;\frac{\frac{1}{\frac{1}{\left(\log \left(\frac{4}{\pi}\right) + 0.25 \cdot \left(f \cdot \left(f \cdot \left(\pi \cdot \left(\pi \cdot 0.08333333333333333\right)\right)\right)\right)\right) - \log f}}}{\frac{\pi}{-4}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-4 \cdot \log \left(\frac{-1}{\mathsf{expm1}\left(f \cdot \left(\pi \cdot -0.5\right)\right)}\right)}{\pi}\\ \end{array} \end{array} \]
(FPCore (f)
 :precision binary64
 (if (<= f 230.0)
   (/
    (/
     1.0
     (/
      1.0
      (-
       (+
        (log (/ 4.0 PI))
        (* 0.25 (* f (* f (* PI (* PI 0.08333333333333333))))))
       (log f))))
    (/ PI -4.0))
   (/ (* -4.0 (log (/ -1.0 (expm1 (* f (* PI -0.5)))))) PI)))
double code(double f) {
	double tmp;
	if (f <= 230.0) {
		tmp = (1.0 / (1.0 / ((log((4.0 / ((double) M_PI))) + (0.25 * (f * (f * (((double) M_PI) * (((double) M_PI) * 0.08333333333333333)))))) - log(f)))) / (((double) M_PI) / -4.0);
	} else {
		tmp = (-4.0 * log((-1.0 / expm1((f * (((double) M_PI) * -0.5)))))) / ((double) M_PI);
	}
	return tmp;
}
public static double code(double f) {
	double tmp;
	if (f <= 230.0) {
		tmp = (1.0 / (1.0 / ((Math.log((4.0 / Math.PI)) + (0.25 * (f * (f * (Math.PI * (Math.PI * 0.08333333333333333)))))) - Math.log(f)))) / (Math.PI / -4.0);
	} else {
		tmp = (-4.0 * Math.log((-1.0 / Math.expm1((f * (Math.PI * -0.5)))))) / Math.PI;
	}
	return tmp;
}
def code(f):
	tmp = 0
	if f <= 230.0:
		tmp = (1.0 / (1.0 / ((math.log((4.0 / math.pi)) + (0.25 * (f * (f * (math.pi * (math.pi * 0.08333333333333333)))))) - math.log(f)))) / (math.pi / -4.0)
	else:
		tmp = (-4.0 * math.log((-1.0 / math.expm1((f * (math.pi * -0.5)))))) / math.pi
	return tmp
function code(f)
	tmp = 0.0
	if (f <= 230.0)
		tmp = Float64(Float64(1.0 / Float64(1.0 / Float64(Float64(log(Float64(4.0 / pi)) + Float64(0.25 * Float64(f * Float64(f * Float64(pi * Float64(pi * 0.08333333333333333)))))) - log(f)))) / Float64(pi / -4.0));
	else
		tmp = Float64(Float64(-4.0 * log(Float64(-1.0 / expm1(Float64(f * Float64(pi * -0.5)))))) / pi);
	end
	return tmp
end
code[f_] := If[LessEqual[f, 230.0], N[(N[(1.0 / N[(1.0 / N[(N[(N[Log[N[(4.0 / Pi), $MachinePrecision]], $MachinePrecision] + N[(0.25 * N[(f * N[(f * N[(Pi * N[(Pi * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Log[f], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(Pi / -4.0), $MachinePrecision]), $MachinePrecision], N[(N[(-4.0 * N[Log[N[(-1.0 / N[(Exp[N[(f * N[(Pi * -0.5), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / Pi), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;f \leq 230:\\
\;\;\;\;\frac{\frac{1}{\frac{1}{\left(\log \left(\frac{4}{\pi}\right) + 0.25 \cdot \left(f \cdot \left(f \cdot \left(\pi \cdot \left(\pi \cdot 0.08333333333333333\right)\right)\right)\right)\right) - \log f}}}{\frac{\pi}{-4}}\\

\mathbf{else}:\\
\;\;\;\;\frac{-4 \cdot \log \left(\frac{-1}{\mathsf{expm1}\left(f \cdot \left(\pi \cdot -0.5\right)\right)}\right)}{\pi}\\


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

    1. Initial program 6.3%

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

      \[\leadsto \color{blue}{\frac{\log \left(\frac{1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot 0.5\right)\right)} + \frac{-1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot -0.5\right)\right)}\right)}{\frac{\pi}{-4}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. /-rgt-identityN/A

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{\frac{1}{\log \left(\frac{1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot 0.5\right)\right)} + \frac{-1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot -0.5\right)\right)}\right)}}}}{\frac{\pi}{-4}} \]
    6. Taylor expanded in f around 0

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(\left(\log \left(\frac{4}{\mathsf{PI}\left(\right)}\right) + \frac{1}{4} \cdot \left({f}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\left(\frac{-1}{12} \cdot \mathsf{PI}\left(\right) + \frac{1}{8} \cdot \mathsf{PI}\left(\right)\right) - \left(\frac{-1}{8} \cdot \mathsf{PI}\left(\right) + \frac{1}{12} \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right), \log f\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    8. Simplified98.6%

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

    if 230 < f

    1. Initial program 0.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. Simplified100.0%

      \[\leadsto \color{blue}{\frac{\log \left(\frac{1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot 0.5\right)\right)} + \frac{-1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot -0.5\right)\right)}\right)}{\frac{\pi}{-4}}} \]
    3. Add Preprocessing
    4. Taylor expanded in f around 0

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(2, \left(f \cdot \mathsf{PI}\left(\right)\right)\right), \mathsf{/.f64}\left(-1, \mathsf{expm1.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(f, \frac{-1}{2}\right)\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(\mathsf{/.f64}\left(2, \left(\mathsf{PI}\left(\right) \cdot f\right)\right), \mathsf{/.f64}\left(-1, \mathsf{expm1.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(f, \frac{-1}{2}\right)\right)\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), f\right)\right), \mathsf{/.f64}\left(-1, \mathsf{expm1.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(f, \frac{-1}{2}\right)\right)\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
      4. PI-lowering-PI.f643.2%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), f\right)\right), \mathsf{/.f64}\left(-1, \mathsf{expm1.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(f, \frac{-1}{2}\right)\right)\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    6. Simplified3.2%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;f \leq 230:\\ \;\;\;\;\frac{\frac{1}{\frac{1}{\left(\log \left(\frac{4}{\pi}\right) + 0.25 \cdot \left(f \cdot \left(f \cdot \left(\pi \cdot \left(\pi \cdot 0.08333333333333333\right)\right)\right)\right)\right) - \log f}}}{\frac{\pi}{-4}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-4 \cdot \log \left(\frac{-1}{\mathsf{expm1}\left(f \cdot \left(\pi \cdot -0.5\right)\right)}\right)}{\pi}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 98.6% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;f \leq 2.3:\\ \;\;\;\;\frac{\log \left(\frac{\frac{4}{\pi} + \left(f \cdot f\right) \cdot \left(\pi \cdot 0.08333333333333333 + f \cdot \left(f \cdot \left(2 \cdot \left(\pi \cdot \left(\left(\pi \cdot 0\right) \cdot \frac{\pi}{4} - \pi \cdot \left(\pi \cdot 0.00017361111111111112\right)\right)\right)\right)\right)\right)}{f}\right)}{\frac{\pi}{-4}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-4 \cdot \log \left(\frac{-1}{\mathsf{expm1}\left(f \cdot \left(\pi \cdot -0.5\right)\right)}\right)}{\pi}\\ \end{array} \end{array} \]
(FPCore (f)
 :precision binary64
 (if (<= f 2.3)
   (/
    (log
     (/
      (+
       (/ 4.0 PI)
       (*
        (* f f)
        (+
         (* PI 0.08333333333333333)
         (*
          f
          (*
           f
           (*
            2.0
            (*
             PI
             (-
              (* (* PI 0.0) (/ PI 4.0))
              (* PI (* PI 0.00017361111111111112))))))))))
      f))
    (/ PI -4.0))
   (/ (* -4.0 (log (/ -1.0 (expm1 (* f (* PI -0.5)))))) PI)))
double code(double f) {
	double tmp;
	if (f <= 2.3) {
		tmp = log((((4.0 / ((double) M_PI)) + ((f * f) * ((((double) M_PI) * 0.08333333333333333) + (f * (f * (2.0 * (((double) M_PI) * (((((double) M_PI) * 0.0) * (((double) M_PI) / 4.0)) - (((double) M_PI) * (((double) M_PI) * 0.00017361111111111112)))))))))) / f)) / (((double) M_PI) / -4.0);
	} else {
		tmp = (-4.0 * log((-1.0 / expm1((f * (((double) M_PI) * -0.5)))))) / ((double) M_PI);
	}
	return tmp;
}
public static double code(double f) {
	double tmp;
	if (f <= 2.3) {
		tmp = Math.log((((4.0 / Math.PI) + ((f * f) * ((Math.PI * 0.08333333333333333) + (f * (f * (2.0 * (Math.PI * (((Math.PI * 0.0) * (Math.PI / 4.0)) - (Math.PI * (Math.PI * 0.00017361111111111112)))))))))) / f)) / (Math.PI / -4.0);
	} else {
		tmp = (-4.0 * Math.log((-1.0 / Math.expm1((f * (Math.PI * -0.5)))))) / Math.PI;
	}
	return tmp;
}
def code(f):
	tmp = 0
	if f <= 2.3:
		tmp = math.log((((4.0 / math.pi) + ((f * f) * ((math.pi * 0.08333333333333333) + (f * (f * (2.0 * (math.pi * (((math.pi * 0.0) * (math.pi / 4.0)) - (math.pi * (math.pi * 0.00017361111111111112)))))))))) / f)) / (math.pi / -4.0)
	else:
		tmp = (-4.0 * math.log((-1.0 / math.expm1((f * (math.pi * -0.5)))))) / math.pi
	return tmp
function code(f)
	tmp = 0.0
	if (f <= 2.3)
		tmp = Float64(log(Float64(Float64(Float64(4.0 / pi) + Float64(Float64(f * f) * Float64(Float64(pi * 0.08333333333333333) + Float64(f * Float64(f * Float64(2.0 * Float64(pi * Float64(Float64(Float64(pi * 0.0) * Float64(pi / 4.0)) - Float64(pi * Float64(pi * 0.00017361111111111112)))))))))) / f)) / Float64(pi / -4.0));
	else
		tmp = Float64(Float64(-4.0 * log(Float64(-1.0 / expm1(Float64(f * Float64(pi * -0.5)))))) / pi);
	end
	return tmp
end
code[f_] := If[LessEqual[f, 2.3], N[(N[Log[N[(N[(N[(4.0 / Pi), $MachinePrecision] + N[(N[(f * f), $MachinePrecision] * N[(N[(Pi * 0.08333333333333333), $MachinePrecision] + N[(f * N[(f * N[(2.0 * N[(Pi * N[(N[(N[(Pi * 0.0), $MachinePrecision] * N[(Pi / 4.0), $MachinePrecision]), $MachinePrecision] - N[(Pi * N[(Pi * 0.00017361111111111112), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / f), $MachinePrecision]], $MachinePrecision] / N[(Pi / -4.0), $MachinePrecision]), $MachinePrecision], N[(N[(-4.0 * N[Log[N[(-1.0 / N[(Exp[N[(f * N[(Pi * -0.5), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / Pi), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;f \leq 2.3:\\
\;\;\;\;\frac{\log \left(\frac{\frac{4}{\pi} + \left(f \cdot f\right) \cdot \left(\pi \cdot 0.08333333333333333 + f \cdot \left(f \cdot \left(2 \cdot \left(\pi \cdot \left(\left(\pi \cdot 0\right) \cdot \frac{\pi}{4} - \pi \cdot \left(\pi \cdot 0.00017361111111111112\right)\right)\right)\right)\right)\right)}{f}\right)}{\frac{\pi}{-4}}\\

\mathbf{else}:\\
\;\;\;\;\frac{-4 \cdot \log \left(\frac{-1}{\mathsf{expm1}\left(f \cdot \left(\pi \cdot -0.5\right)\right)}\right)}{\pi}\\


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

    1. Initial program 6.3%

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

      \[\leadsto \color{blue}{\frac{\log \left(\frac{1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot 0.5\right)\right)} + \frac{-1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot -0.5\right)\right)}\right)}{\frac{\pi}{-4}}} \]
    3. Add Preprocessing
    4. Taylor expanded in f around 0

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\color{blue}{\left(\frac{{f}^{2} \cdot \left(\left(\frac{-1}{12} \cdot \mathsf{PI}\left(\right) + \left(\frac{1}{8} \cdot \mathsf{PI}\left(\right) + f \cdot \left(\left(\frac{1}{4} \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\frac{-1}{12} \cdot \mathsf{PI}\left(\right) + \frac{1}{8} \cdot \mathsf{PI}\left(\right)\right)\right) + f \cdot \left(\left(\frac{-1}{24} \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot \left(\frac{-1}{12} \cdot \mathsf{PI}\left(\right) + \frac{1}{8} \cdot \mathsf{PI}\left(\right)\right)\right) + \left(\frac{-1}{960} \cdot {\mathsf{PI}\left(\right)}^{3} + \left(\frac{1}{384} \cdot {\mathsf{PI}\left(\right)}^{3} + \frac{1}{4} \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\frac{-1}{48} \cdot {\mathsf{PI}\left(\right)}^{2} + \left(\frac{1}{96} \cdot {\mathsf{PI}\left(\right)}^{2} + \frac{1}{4} \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\frac{-1}{12} \cdot \mathsf{PI}\left(\right) + \frac{1}{8} \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right)\right)\right)\right) - \left(\frac{-1}{4} \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\frac{-1}{4} \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\frac{-1}{8} \cdot \mathsf{PI}\left(\right) + \frac{1}{12} \cdot \mathsf{PI}\left(\right)\right)\right) + \left(\frac{-1}{48} \cdot {\mathsf{PI}\left(\right)}^{2} + \frac{1}{96} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)\right) + \left(\frac{-1}{24} \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot \left(\frac{-1}{8} \cdot \mathsf{PI}\left(\right) + \frac{1}{12} \cdot \mathsf{PI}\left(\right)\right)\right) + \left(\frac{-1}{384} \cdot {\mathsf{PI}\left(\right)}^{3} + \frac{1}{960} \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right)\right)\right)\right) - \frac{-1}{4} \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\frac{-1}{8} \cdot \mathsf{PI}\left(\right) + \frac{1}{12} \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right) - \left(\frac{-1}{8} \cdot \mathsf{PI}\left(\right) + \frac{1}{12} \cdot \mathsf{PI}\left(\right)\right)\right) + 4 \cdot \frac{1}{\mathsf{PI}\left(\right)}}{f}\right)}\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    5. Simplified98.5%

      \[\leadsto \frac{\log \color{blue}{\left(\frac{\frac{4}{\pi} + \left(f \cdot f\right) \cdot \left(\pi \cdot 0.08333333333333333 + f \cdot \left(f \cdot \left(\left(\left(\pi \cdot \left(\left(\pi \cdot -0.041666666666666664\right) \cdot -0.25 + \pi \cdot -0.010416666666666666\right)\right) \cdot \left(\pi \cdot 0.25\right) - \left(\pi \cdot \pi\right) \cdot \left(\left(\pi \cdot -0.041666666666666664\right) \cdot -0.041666666666666664 + \pi \cdot -0.0015625\right)\right) + \left(\left(\pi \cdot \left(\left(\pi \cdot -0.041666666666666664\right) \cdot -0.25 + \pi \cdot -0.010416666666666666\right)\right) \cdot \left(\pi \cdot 0.25\right) - \left(\pi \cdot \pi\right) \cdot \left(\left(\pi \cdot -0.041666666666666664\right) \cdot -0.041666666666666664 + \pi \cdot -0.0015625\right)\right)\right)\right)\right)}{f}\right)}}{\frac{\pi}{-4}} \]
    6. Step-by-step derivation
      1. count-2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(4, \mathsf{PI.f64}\left(\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(f, f\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \frac{1}{12}\right), \mathsf{*.f64}\left(f, \mathsf{*.f64}\left(f, \left(2 \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \frac{-1}{24}\right) \cdot \frac{-1}{4} + \mathsf{PI}\left(\right) \cdot \frac{-1}{96}\right)\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \frac{1}{4}\right) - \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \frac{-1}{24}\right) \cdot \frac{-1}{24} + \mathsf{PI}\left(\right) \cdot \frac{-1}{640}\right)\right)\right)\right)\right)\right)\right)\right), f\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(\mathsf{+.f64}\left(\mathsf{/.f64}\left(4, \mathsf{PI.f64}\left(\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(f, f\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \frac{1}{12}\right), \mathsf{*.f64}\left(f, \mathsf{*.f64}\left(f, \left(\left(\left(\mathsf{PI}\left(\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \frac{-1}{24}\right) \cdot \frac{-1}{4} + \mathsf{PI}\left(\right) \cdot \frac{-1}{96}\right)\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \frac{1}{4}\right) - \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \frac{-1}{24}\right) \cdot \frac{-1}{24} + \mathsf{PI}\left(\right) \cdot \frac{-1}{640}\right)\right) \cdot 2\right)\right)\right)\right)\right)\right), f\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(4, \mathsf{PI.f64}\left(\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(f, f\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \frac{1}{12}\right), \mathsf{*.f64}\left(f, \mathsf{*.f64}\left(f, \mathsf{*.f64}\left(\left(\left(\mathsf{PI}\left(\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \frac{-1}{24}\right) \cdot \frac{-1}{4} + \mathsf{PI}\left(\right) \cdot \frac{-1}{96}\right)\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \frac{1}{4}\right) - \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \frac{-1}{24}\right) \cdot \frac{-1}{24} + \mathsf{PI}\left(\right) \cdot \frac{-1}{640}\right)\right), 2\right)\right)\right)\right)\right)\right), f\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    7. Applied egg-rr98.5%

      \[\leadsto \frac{\log \left(\frac{\frac{4}{\pi} + \left(f \cdot f\right) \cdot \left(\pi \cdot 0.08333333333333333 + f \cdot \left(f \cdot \color{blue}{\left(\left(\pi \cdot \left(\left(\pi \cdot 0\right) \cdot \frac{\pi}{4} - \pi \cdot \left(\pi \cdot 0.00017361111111111112\right)\right)\right) \cdot 2\right)}\right)\right)}{f}\right)}{\frac{\pi}{-4}} \]

    if 2.2999999999999998 < f

    1. Initial program 0.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. Simplified100.0%

      \[\leadsto \color{blue}{\frac{\log \left(\frac{1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot 0.5\right)\right)} + \frac{-1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot -0.5\right)\right)}\right)}{\frac{\pi}{-4}}} \]
    3. Add Preprocessing
    4. Taylor expanded in f around 0

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(2, \left(f \cdot \mathsf{PI}\left(\right)\right)\right), \mathsf{/.f64}\left(-1, \mathsf{expm1.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(f, \frac{-1}{2}\right)\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(\mathsf{/.f64}\left(2, \left(\mathsf{PI}\left(\right) \cdot f\right)\right), \mathsf{/.f64}\left(-1, \mathsf{expm1.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(f, \frac{-1}{2}\right)\right)\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), f\right)\right), \mathsf{/.f64}\left(-1, \mathsf{expm1.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(f, \frac{-1}{2}\right)\right)\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
      4. PI-lowering-PI.f643.2%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), f\right)\right), \mathsf{/.f64}\left(-1, \mathsf{expm1.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(f, \frac{-1}{2}\right)\right)\right)\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    6. Simplified3.2%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;f \leq 2.3:\\ \;\;\;\;\frac{\log \left(\frac{\frac{4}{\pi} + \left(f \cdot f\right) \cdot \left(\pi \cdot 0.08333333333333333 + f \cdot \left(f \cdot \left(2 \cdot \left(\pi \cdot \left(\left(\pi \cdot 0\right) \cdot \frac{\pi}{4} - \pi \cdot \left(\pi \cdot 0.00017361111111111112\right)\right)\right)\right)\right)\right)}{f}\right)}{\frac{\pi}{-4}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-4 \cdot \log \left(\frac{-1}{\mathsf{expm1}\left(f \cdot \left(\pi \cdot -0.5\right)\right)}\right)}{\pi}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 96.6% accurate, 3.8× speedup?

\[\begin{array}{l} \\ \frac{\log \left(\frac{\frac{4}{\pi} + \left(f \cdot f\right) \cdot \left(\pi \cdot 0.08333333333333333 + f \cdot \left(f \cdot \left(2 \cdot \left(\pi \cdot \left(\left(\pi \cdot 0\right) \cdot \frac{\pi}{4} - \pi \cdot \left(\pi \cdot 0.00017361111111111112\right)\right)\right)\right)\right)\right)}{f}\right)}{\frac{\pi}{-4}} \end{array} \]
(FPCore (f)
 :precision binary64
 (/
  (log
   (/
    (+
     (/ 4.0 PI)
     (*
      (* f f)
      (+
       (* PI 0.08333333333333333)
       (*
        f
        (*
         f
         (*
          2.0
          (*
           PI
           (-
            (* (* PI 0.0) (/ PI 4.0))
            (* PI (* PI 0.00017361111111111112))))))))))
    f))
  (/ PI -4.0)))
double code(double f) {
	return log((((4.0 / ((double) M_PI)) + ((f * f) * ((((double) M_PI) * 0.08333333333333333) + (f * (f * (2.0 * (((double) M_PI) * (((((double) M_PI) * 0.0) * (((double) M_PI) / 4.0)) - (((double) M_PI) * (((double) M_PI) * 0.00017361111111111112)))))))))) / 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 * (f * (2.0 * (Math.PI * (((Math.PI * 0.0) * (Math.PI / 4.0)) - (Math.PI * (Math.PI * 0.00017361111111111112)))))))))) / f)) / (Math.PI / -4.0);
}
def code(f):
	return math.log((((4.0 / math.pi) + ((f * f) * ((math.pi * 0.08333333333333333) + (f * (f * (2.0 * (math.pi * (((math.pi * 0.0) * (math.pi / 4.0)) - (math.pi * (math.pi * 0.00017361111111111112)))))))))) / f)) / (math.pi / -4.0)
function code(f)
	return Float64(log(Float64(Float64(Float64(4.0 / pi) + Float64(Float64(f * f) * Float64(Float64(pi * 0.08333333333333333) + Float64(f * Float64(f * Float64(2.0 * Float64(pi * Float64(Float64(Float64(pi * 0.0) * Float64(pi / 4.0)) - Float64(pi * Float64(pi * 0.00017361111111111112)))))))))) / f)) / Float64(pi / -4.0))
end
function tmp = code(f)
	tmp = log((((4.0 / pi) + ((f * f) * ((pi * 0.08333333333333333) + (f * (f * (2.0 * (pi * (((pi * 0.0) * (pi / 4.0)) - (pi * (pi * 0.00017361111111111112)))))))))) / f)) / (pi / -4.0);
end
code[f_] := N[(N[Log[N[(N[(N[(4.0 / Pi), $MachinePrecision] + N[(N[(f * f), $MachinePrecision] * N[(N[(Pi * 0.08333333333333333), $MachinePrecision] + N[(f * N[(f * N[(2.0 * N[(Pi * N[(N[(N[(Pi * 0.0), $MachinePrecision] * N[(Pi / 4.0), $MachinePrecision]), $MachinePrecision] - N[(Pi * N[(Pi * 0.00017361111111111112), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / f), $MachinePrecision]], $MachinePrecision] / N[(Pi / -4.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

    \[\leadsto \color{blue}{\frac{\log \left(\frac{1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot 0.5\right)\right)} + \frac{-1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot -0.5\right)\right)}\right)}{\frac{\pi}{-4}}} \]
  3. Add Preprocessing
  4. Taylor expanded in f around 0

    \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\color{blue}{\left(\frac{{f}^{2} \cdot \left(\left(\frac{-1}{12} \cdot \mathsf{PI}\left(\right) + \left(\frac{1}{8} \cdot \mathsf{PI}\left(\right) + f \cdot \left(\left(\frac{1}{4} \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\frac{-1}{12} \cdot \mathsf{PI}\left(\right) + \frac{1}{8} \cdot \mathsf{PI}\left(\right)\right)\right) + f \cdot \left(\left(\frac{-1}{24} \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot \left(\frac{-1}{12} \cdot \mathsf{PI}\left(\right) + \frac{1}{8} \cdot \mathsf{PI}\left(\right)\right)\right) + \left(\frac{-1}{960} \cdot {\mathsf{PI}\left(\right)}^{3} + \left(\frac{1}{384} \cdot {\mathsf{PI}\left(\right)}^{3} + \frac{1}{4} \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\frac{-1}{48} \cdot {\mathsf{PI}\left(\right)}^{2} + \left(\frac{1}{96} \cdot {\mathsf{PI}\left(\right)}^{2} + \frac{1}{4} \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\frac{-1}{12} \cdot \mathsf{PI}\left(\right) + \frac{1}{8} \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right)\right)\right)\right) - \left(\frac{-1}{4} \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\frac{-1}{4} \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\frac{-1}{8} \cdot \mathsf{PI}\left(\right) + \frac{1}{12} \cdot \mathsf{PI}\left(\right)\right)\right) + \left(\frac{-1}{48} \cdot {\mathsf{PI}\left(\right)}^{2} + \frac{1}{96} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)\right) + \left(\frac{-1}{24} \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot \left(\frac{-1}{8} \cdot \mathsf{PI}\left(\right) + \frac{1}{12} \cdot \mathsf{PI}\left(\right)\right)\right) + \left(\frac{-1}{384} \cdot {\mathsf{PI}\left(\right)}^{3} + \frac{1}{960} \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right)\right)\right)\right) - \frac{-1}{4} \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\frac{-1}{8} \cdot \mathsf{PI}\left(\right) + \frac{1}{12} \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right) - \left(\frac{-1}{8} \cdot \mathsf{PI}\left(\right) + \frac{1}{12} \cdot \mathsf{PI}\left(\right)\right)\right) + 4 \cdot \frac{1}{\mathsf{PI}\left(\right)}}{f}\right)}\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
  5. Simplified96.6%

    \[\leadsto \frac{\log \color{blue}{\left(\frac{\frac{4}{\pi} + \left(f \cdot f\right) \cdot \left(\pi \cdot 0.08333333333333333 + f \cdot \left(f \cdot \left(\left(\left(\pi \cdot \left(\left(\pi \cdot -0.041666666666666664\right) \cdot -0.25 + \pi \cdot -0.010416666666666666\right)\right) \cdot \left(\pi \cdot 0.25\right) - \left(\pi \cdot \pi\right) \cdot \left(\left(\pi \cdot -0.041666666666666664\right) \cdot -0.041666666666666664 + \pi \cdot -0.0015625\right)\right) + \left(\left(\pi \cdot \left(\left(\pi \cdot -0.041666666666666664\right) \cdot -0.25 + \pi \cdot -0.010416666666666666\right)\right) \cdot \left(\pi \cdot 0.25\right) - \left(\pi \cdot \pi\right) \cdot \left(\left(\pi \cdot -0.041666666666666664\right) \cdot -0.041666666666666664 + \pi \cdot -0.0015625\right)\right)\right)\right)\right)}{f}\right)}}{\frac{\pi}{-4}} \]
  6. Step-by-step derivation
    1. count-2N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(4, \mathsf{PI.f64}\left(\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(f, f\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \frac{1}{12}\right), \mathsf{*.f64}\left(f, \mathsf{*.f64}\left(f, \left(2 \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \frac{-1}{24}\right) \cdot \frac{-1}{4} + \mathsf{PI}\left(\right) \cdot \frac{-1}{96}\right)\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \frac{1}{4}\right) - \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \frac{-1}{24}\right) \cdot \frac{-1}{24} + \mathsf{PI}\left(\right) \cdot \frac{-1}{640}\right)\right)\right)\right)\right)\right)\right)\right), f\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(\mathsf{+.f64}\left(\mathsf{/.f64}\left(4, \mathsf{PI.f64}\left(\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(f, f\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \frac{1}{12}\right), \mathsf{*.f64}\left(f, \mathsf{*.f64}\left(f, \left(\left(\left(\mathsf{PI}\left(\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \frac{-1}{24}\right) \cdot \frac{-1}{4} + \mathsf{PI}\left(\right) \cdot \frac{-1}{96}\right)\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \frac{1}{4}\right) - \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \frac{-1}{24}\right) \cdot \frac{-1}{24} + \mathsf{PI}\left(\right) \cdot \frac{-1}{640}\right)\right) \cdot 2\right)\right)\right)\right)\right)\right), f\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    3. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(4, \mathsf{PI.f64}\left(\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(f, f\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \frac{1}{12}\right), \mathsf{*.f64}\left(f, \mathsf{*.f64}\left(f, \mathsf{*.f64}\left(\left(\left(\mathsf{PI}\left(\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \frac{-1}{24}\right) \cdot \frac{-1}{4} + \mathsf{PI}\left(\right) \cdot \frac{-1}{96}\right)\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \frac{1}{4}\right) - \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \frac{-1}{24}\right) \cdot \frac{-1}{24} + \mathsf{PI}\left(\right) \cdot \frac{-1}{640}\right)\right), 2\right)\right)\right)\right)\right)\right), f\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
  7. Applied egg-rr96.6%

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

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

Alternative 7: 96.6% accurate, 3.9× speedup?

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

\\
\begin{array}{l}
t_0 := \pi \cdot \left(f \cdot f\right)\\
\frac{\log \left(\frac{\frac{\frac{16}{\pi \cdot \pi} - \left(t\_0 \cdot t\_0\right) \cdot 0.006944444444444444}{\frac{4}{\pi} - \pi \cdot \left(0.08333333333333333 \cdot \left(f \cdot f\right)\right)}}{f}\right)}{\frac{\pi}{-4}}
\end{array}
\end{array}
Derivation
  1. Initial program 6.2%

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

    \[\leadsto \color{blue}{\frac{\log \left(\frac{1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot 0.5\right)\right)} + \frac{-1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot -0.5\right)\right)}\right)}{\frac{\pi}{-4}}} \]
  3. Add Preprocessing
  4. Taylor expanded in f around 0

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\left({f}^{2} \cdot \left(\left(\frac{-1}{12} \cdot \mathsf{PI}\left(\right) + \frac{1}{8} \cdot \mathsf{PI}\left(\right)\right) - \left(\frac{-1}{8} \cdot \mathsf{PI}\left(\right) + \frac{1}{12} \cdot \mathsf{PI}\left(\right)\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) \]
  6. Simplified96.5%

    \[\leadsto \frac{\log \color{blue}{\left(\frac{\left(f \cdot f\right) \cdot \left(\pi \cdot 0.08333333333333333\right) + \frac{4}{\pi}}{f}\right)}}{\frac{\pi}{-4}} \]
  7. Step-by-step derivation
    1. +-commutativeN/A

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

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(\frac{4}{\mathsf{PI}\left(\right)} \cdot \frac{4}{\mathsf{PI}\left(\right)} - \left(\left(f \cdot f\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \frac{1}{12}\right)\right) \cdot \left(\left(f \cdot f\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \frac{1}{12}\right)\right)\right), \left(\frac{4}{\mathsf{PI}\left(\right)} - \left(f \cdot f\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \frac{1}{12}\right)\right)\right), f\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
  8. Applied egg-rr96.5%

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

Alternative 8: 96.6% accurate, 4.5× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{\log \left(\frac{1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot 0.5\right)\right)} + \frac{-1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot -0.5\right)\right)}\right)}{\frac{\pi}{-4}}} \]
  3. Add Preprocessing
  4. Taylor expanded in f around 0

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\left({f}^{2} \cdot \left(\left(\frac{-1}{12} \cdot \mathsf{PI}\left(\right) + \frac{1}{8} \cdot \mathsf{PI}\left(\right)\right) - \left(\frac{-1}{8} \cdot \mathsf{PI}\left(\right) + \frac{1}{12} \cdot \mathsf{PI}\left(\right)\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) \]
  6. Simplified96.5%

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

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

Alternative 9: 96.1% accurate, 4.9× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{\log \left(\frac{1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot 0.5\right)\right)} + \frac{-1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot -0.5\right)\right)}\right)}{\frac{\pi}{-4}}} \]
  3. Add Preprocessing
  4. Taylor expanded in f around 0

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(4, \left(f \cdot \mathsf{PI}\left(\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(4, \left(\mathsf{PI}\left(\right) \cdot f\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    3. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(4, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), f\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    4. PI-lowering-PI.f6496.0%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(4, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), f\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
  6. Simplified96.0%

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

      \[\leadsto \frac{\mathsf{neg}\left(\log \left(\frac{4}{\mathsf{PI}\left(\right) \cdot f}\right)\right)}{\color{blue}{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{-4}\right)}} \]
    2. div-invN/A

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

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

      \[\leadsto \left(\mathsf{neg}\left(\log \left(\frac{4}{\mathsf{PI}\left(\right) \cdot f}\right)\right)\right) \cdot \frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \]
    5. clear-numN/A

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

      \[\leadsto \mathsf{*.f64}\left(\left(\mathsf{neg}\left(\log \left(\frac{4}{\mathsf{PI}\left(\right) \cdot f}\right)\right)\right), \color{blue}{\left(\frac{4}{\mathsf{PI}\left(\right)}\right)}\right) \]
    7. neg-logN/A

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), f\right), 4\right)\right), \mathsf{/.f64}\left(4, \color{blue}{\mathsf{PI}\left(\right)}\right)\right) \]
    14. PI-lowering-PI.f6496.3%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), f\right), 4\right)\right), \mathsf{/.f64}\left(4, \mathsf{PI.f64}\left(\right)\right)\right) \]
  8. Applied egg-rr96.3%

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(4, \mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), f\right), 4\right)\right)\right), \mathsf{PI}\left(\right)\right) \]
    9. PI-lowering-PI.f6496.4%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(4, \mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), f\right), 4\right)\right)\right), \mathsf{PI.f64}\left(\right)\right) \]
  10. Applied egg-rr96.4%

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

Alternative 10: 96.0% accurate, 4.9× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{\log \left(\frac{1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot 0.5\right)\right)} + \frac{-1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot -0.5\right)\right)}\right)}{\frac{\pi}{-4}}} \]
  3. Add Preprocessing
  4. Taylor expanded in f around 0

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(4, \left(f \cdot \mathsf{PI}\left(\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(4, \left(\mathsf{PI}\left(\right) \cdot f\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    3. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(4, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), f\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
    4. PI-lowering-PI.f6496.0%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(4, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), f\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
  6. Simplified96.0%

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

      \[\leadsto \frac{\mathsf{neg}\left(\log \left(\frac{4}{\mathsf{PI}\left(\right) \cdot f}\right)\right)}{\color{blue}{\mathsf{neg}\left(\frac{\mathsf{PI}\left(\right)}{-4}\right)}} \]
    2. div-invN/A

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

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

      \[\leadsto \left(\mathsf{neg}\left(\log \left(\frac{4}{\mathsf{PI}\left(\right) \cdot f}\right)\right)\right) \cdot \frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \]
    5. clear-numN/A

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

      \[\leadsto \mathsf{*.f64}\left(\left(\mathsf{neg}\left(\log \left(\frac{4}{\mathsf{PI}\left(\right) \cdot f}\right)\right)\right), \color{blue}{\left(\frac{4}{\mathsf{PI}\left(\right)}\right)}\right) \]
    7. neg-logN/A

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), f\right), 4\right)\right), \mathsf{/.f64}\left(4, \color{blue}{\mathsf{PI}\left(\right)}\right)\right) \]
    14. PI-lowering-PI.f6496.3%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), f\right), 4\right)\right), \mathsf{/.f64}\left(4, \mathsf{PI.f64}\left(\right)\right)\right) \]
  8. Applied egg-rr96.3%

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

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

Alternative 11: 4.2% accurate, 76.0× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{\log \left(\frac{1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot 0.5\right)\right)} + \frac{-1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot -0.5\right)\right)}\right)}{\frac{\pi}{-4}}} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. /-rgt-identityN/A

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{\frac{1}{\frac{1}{\log \left(\frac{1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot 0.5\right)\right)} + \frac{-1}{\mathsf{expm1}\left(\pi \cdot \left(f \cdot -0.5\right)\right)}\right)}}}}{\frac{\pi}{-4}} \]
  6. Taylor expanded in f around 0

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

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

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

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

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(\left(\log \left(\frac{4}{\mathsf{PI}\left(\right)}\right) + \frac{1}{4} \cdot \left({f}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\left(\frac{-1}{12} \cdot \mathsf{PI}\left(\right) + \frac{1}{8} \cdot \mathsf{PI}\left(\right)\right) - \left(\frac{-1}{8} \cdot \mathsf{PI}\left(\right) + \frac{1}{12} \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right), \log f\right)\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), -4\right)\right) \]
  8. Simplified96.8%

    \[\leadsto \frac{\frac{1}{\frac{1}{\color{blue}{\left(\log \left(\frac{4}{\pi}\right) + 0.25 \cdot \left(\left(\left(\pi \cdot \left(\pi \cdot 0.08333333333333333\right)\right) \cdot f\right) \cdot f\right)\right) - \log f}}}}{\frac{\pi}{-4}} \]
  9. Taylor expanded in f around inf

    \[\leadsto \color{blue}{\frac{-1}{12} \cdot \left({f}^{2} \cdot \mathsf{PI}\left(\right)\right)} \]
  10. Step-by-step derivation
    1. *-lowering-*.f64N/A

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

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

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

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

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

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

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

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

Reproduce

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