
(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:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
(FPCore (f)
:precision binary64
(let* ((t_0 (pow (* PI 0.5) 2.0)))
(if (<= (* (/ PI 4.0) f) 200.0)
(-
(fma
2.0
(* (/ f PI) (* PI 0.0))
(fma
2.0
(*
(/ (pow f 2.0) PI)
(fma
(* PI 0.5)
(fma
0.0625
(/ (pow PI 2.0) (* PI 0.5))
(* (/ (pow PI 3.0) (/ t_0 0.005208333333333333)) -2.0))
(* 0.0 t_0)))
(/ 4.0 (/ PI (log (/ (/ 2.0 (* PI 0.5)) f)))))))
(* (/ f (/ PI 0.0)) (- 2.0)))))
double code(double f) {
double t_0 = pow((((double) M_PI) * 0.5), 2.0);
double tmp;
if (((((double) M_PI) / 4.0) * f) <= 200.0) {
tmp = -fma(2.0, ((f / ((double) M_PI)) * (((double) M_PI) * 0.0)), fma(2.0, ((pow(f, 2.0) / ((double) M_PI)) * fma((((double) M_PI) * 0.5), fma(0.0625, (pow(((double) M_PI), 2.0) / (((double) M_PI) * 0.5)), ((pow(((double) M_PI), 3.0) / (t_0 / 0.005208333333333333)) * -2.0)), (0.0 * t_0))), (4.0 / (((double) M_PI) / log(((2.0 / (((double) M_PI) * 0.5)) / f))))));
} else {
tmp = (f / (((double) M_PI) / 0.0)) * -2.0;
}
return tmp;
}
function code(f) t_0 = Float64(pi * 0.5) ^ 2.0 tmp = 0.0 if (Float64(Float64(pi / 4.0) * f) <= 200.0) tmp = Float64(-fma(2.0, Float64(Float64(f / pi) * Float64(pi * 0.0)), fma(2.0, Float64(Float64((f ^ 2.0) / pi) * fma(Float64(pi * 0.5), fma(0.0625, Float64((pi ^ 2.0) / Float64(pi * 0.5)), Float64(Float64((pi ^ 3.0) / Float64(t_0 / 0.005208333333333333)) * -2.0)), Float64(0.0 * t_0))), Float64(4.0 / Float64(pi / log(Float64(Float64(2.0 / Float64(pi * 0.5)) / f))))))); else tmp = Float64(Float64(f / Float64(pi / 0.0)) * Float64(-2.0)); end return tmp end
code[f_] := Block[{t$95$0 = N[Power[N[(Pi * 0.5), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[N[(N[(Pi / 4.0), $MachinePrecision] * f), $MachinePrecision], 200.0], (-N[(2.0 * N[(N[(f / Pi), $MachinePrecision] * N[(Pi * 0.0), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(N[(N[Power[f, 2.0], $MachinePrecision] / Pi), $MachinePrecision] * N[(N[(Pi * 0.5), $MachinePrecision] * N[(0.0625 * N[(N[Power[Pi, 2.0], $MachinePrecision] / N[(Pi * 0.5), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[Pi, 3.0], $MachinePrecision] / N[(t$95$0 / 0.005208333333333333), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision] + N[(0.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(4.0 / N[(Pi / N[Log[N[(N[(2.0 / N[(Pi * 0.5), $MachinePrecision]), $MachinePrecision] / f), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), N[(N[(f / N[(Pi / 0.0), $MachinePrecision]), $MachinePrecision] * (-2.0)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\pi \cdot 0.5\right)}^{2}\\
\mathbf{if}\;\frac{\pi}{4} \cdot f \leq 200:\\
\;\;\;\;-\mathsf{fma}\left(2, \frac{f}{\pi} \cdot \left(\pi \cdot 0\right), \mathsf{fma}\left(2, \frac{{f}^{2}}{\pi} \cdot \mathsf{fma}\left(\pi \cdot 0.5, \mathsf{fma}\left(0.0625, \frac{{\pi}^{2}}{\pi \cdot 0.5}, \frac{{\pi}^{3}}{\frac{t_0}{0.005208333333333333}} \cdot -2\right), 0 \cdot t_0\right), \frac{4}{\frac{\pi}{\log \left(\frac{\frac{2}{\pi \cdot 0.5}}{f}\right)}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{f}{\frac{\pi}{0}} \cdot \left(-2\right)\\
\end{array}
\end{array}
if (*.f64 (/.f64 (PI.f64) 4) f) < 200Initial program 6.1%
Taylor expanded in f around 0 98.3%
Simplified98.2%
diff-log98.3%
Applied egg-rr98.3%
if 200 < (*.f64 (/.f64 (PI.f64) 4) f) Initial program 0.0%
Applied egg-rr1.6%
Taylor expanded in f around 0 100.0%
associate-/l*100.0%
distribute-rgt-out100.0%
metadata-eval100.0%
mul0-rgt100.0%
Simplified100.0%
Final simplification98.3%
(FPCore (f)
:precision binary64
(if (<= (* (/ PI 4.0) f) 200.0)
(*
(/ 1.0 (/ PI 4.0))
(-
(log f)
(fma
(pow f 2.0)
(*
0.5
(fma
PI
(* 0.5 (fma (* PI 0.020833333333333332) -2.0 (* 0.0625 (/ PI 0.5))))
0.0))
(log (/ (/ 2.0 PI) 0.5)))))
(* (/ f (/ PI 0.0)) (- 2.0))))
double code(double f) {
double tmp;
if (((((double) M_PI) / 4.0) * f) <= 200.0) {
tmp = (1.0 / (((double) M_PI) / 4.0)) * (log(f) - fma(pow(f, 2.0), (0.5 * fma(((double) M_PI), (0.5 * fma((((double) M_PI) * 0.020833333333333332), -2.0, (0.0625 * (((double) M_PI) / 0.5)))), 0.0)), log(((2.0 / ((double) M_PI)) / 0.5))));
} else {
tmp = (f / (((double) M_PI) / 0.0)) * -2.0;
}
return tmp;
}
function code(f) tmp = 0.0 if (Float64(Float64(pi / 4.0) * f) <= 200.0) tmp = Float64(Float64(1.0 / Float64(pi / 4.0)) * Float64(log(f) - fma((f ^ 2.0), Float64(0.5 * fma(pi, Float64(0.5 * fma(Float64(pi * 0.020833333333333332), -2.0, Float64(0.0625 * Float64(pi / 0.5)))), 0.0)), log(Float64(Float64(2.0 / pi) / 0.5))))); else tmp = Float64(Float64(f / Float64(pi / 0.0)) * Float64(-2.0)); end return tmp end
code[f_] := If[LessEqual[N[(N[(Pi / 4.0), $MachinePrecision] * f), $MachinePrecision], 200.0], N[(N[(1.0 / N[(Pi / 4.0), $MachinePrecision]), $MachinePrecision] * N[(N[Log[f], $MachinePrecision] - N[(N[Power[f, 2.0], $MachinePrecision] * N[(0.5 * N[(Pi * N[(0.5 * N[(N[(Pi * 0.020833333333333332), $MachinePrecision] * -2.0 + N[(0.0625 * N[(Pi / 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 0.0), $MachinePrecision]), $MachinePrecision] + N[Log[N[(N[(2.0 / Pi), $MachinePrecision] / 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(f / N[(Pi / 0.0), $MachinePrecision]), $MachinePrecision] * (-2.0)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\pi}{4} \cdot f \leq 200:\\
\;\;\;\;\frac{1}{\frac{\pi}{4}} \cdot \left(\log f - \mathsf{fma}\left({f}^{2}, 0.5 \cdot \mathsf{fma}\left(\pi, 0.5 \cdot \mathsf{fma}\left(\pi \cdot 0.020833333333333332, -2, 0.0625 \cdot \frac{\pi}{0.5}\right), 0\right), \log \left(\frac{\frac{2}{\pi}}{0.5}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{f}{\frac{\pi}{0}} \cdot \left(-2\right)\\
\end{array}
\end{array}
if (*.f64 (/.f64 (PI.f64) 4) f) < 200Initial program 6.1%
Taylor expanded in f around 0 98.2%
Simplified98.2%
expm1-log1p-u98.2%
expm1-udef98.2%
pow-div98.2%
metadata-eval98.2%
pow198.2%
Applied egg-rr98.2%
expm1-def98.2%
expm1-log1p98.2%
Simplified98.2%
if 200 < (*.f64 (/.f64 (PI.f64) 4) f) Initial program 0.0%
Applied egg-rr1.6%
Taylor expanded in f around 0 100.0%
associate-/l*100.0%
distribute-rgt-out100.0%
metadata-eval100.0%
mul0-rgt100.0%
Simplified100.0%
Final simplification98.2%
(FPCore (f)
:precision binary64
(if (<= (* (/ PI 4.0) f) 200.0)
(*
(log
(fma
f
(fma
(* 0.020833333333333332 (/ (pow PI 3.0) (pow PI 2.0)))
-2.0
(* 0.0625 (/ PI 0.5)))
(* 4.0 (/ (/ 1.0 f) PI))))
(/ -1.0 (/ PI 4.0)))
(* (/ f (/ PI 0.0)) (- 2.0))))
double code(double f) {
double tmp;
if (((((double) M_PI) / 4.0) * f) <= 200.0) {
tmp = log(fma(f, fma((0.020833333333333332 * (pow(((double) M_PI), 3.0) / pow(((double) M_PI), 2.0))), -2.0, (0.0625 * (((double) M_PI) / 0.5))), (4.0 * ((1.0 / f) / ((double) M_PI))))) * (-1.0 / (((double) M_PI) / 4.0));
} else {
tmp = (f / (((double) M_PI) / 0.0)) * -2.0;
}
return tmp;
}
function code(f) tmp = 0.0 if (Float64(Float64(pi / 4.0) * f) <= 200.0) tmp = Float64(log(fma(f, fma(Float64(0.020833333333333332 * Float64((pi ^ 3.0) / (pi ^ 2.0))), -2.0, Float64(0.0625 * Float64(pi / 0.5))), Float64(4.0 * Float64(Float64(1.0 / f) / pi)))) * Float64(-1.0 / Float64(pi / 4.0))); else tmp = Float64(Float64(f / Float64(pi / 0.0)) * Float64(-2.0)); end return tmp end
code[f_] := If[LessEqual[N[(N[(Pi / 4.0), $MachinePrecision] * f), $MachinePrecision], 200.0], N[(N[Log[N[(f * N[(N[(0.020833333333333332 * N[(N[Power[Pi, 3.0], $MachinePrecision] / N[Power[Pi, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -2.0 + N[(0.0625 * N[(Pi / 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(4.0 * N[(N[(1.0 / f), $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / N[(Pi / 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(f / N[(Pi / 0.0), $MachinePrecision]), $MachinePrecision] * (-2.0)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\pi}{4} \cdot f \leq 200:\\
\;\;\;\;\log \left(\mathsf{fma}\left(f, \mathsf{fma}\left(0.020833333333333332 \cdot \frac{{\pi}^{3}}{{\pi}^{2}}, -2, 0.0625 \cdot \frac{\pi}{0.5}\right), 4 \cdot \frac{\frac{1}{f}}{\pi}\right)\right) \cdot \frac{-1}{\frac{\pi}{4}}\\
\mathbf{else}:\\
\;\;\;\;\frac{f}{\frac{\pi}{0}} \cdot \left(-2\right)\\
\end{array}
\end{array}
if (*.f64 (/.f64 (PI.f64) 4) f) < 200Initial program 6.1%
Taylor expanded in f around 0 98.2%
Simplified98.2%
if 200 < (*.f64 (/.f64 (PI.f64) 4) f) Initial program 0.0%
Applied egg-rr1.6%
Taylor expanded in f around 0 100.0%
associate-/l*100.0%
distribute-rgt-out100.0%
metadata-eval100.0%
mul0-rgt100.0%
Simplified100.0%
Final simplification98.2%
(FPCore (f)
:precision binary64
(if (<= (* (/ PI 4.0) f) 200.0)
(/
(- (log (* 2.0 (/ (cosh (* f (* PI 0.25))) (* f (* PI 0.5))))))
(* PI 0.25))
(* (/ f (/ PI 0.0)) (- 2.0))))
double code(double f) {
double tmp;
if (((((double) M_PI) / 4.0) * f) <= 200.0) {
tmp = -log((2.0 * (cosh((f * (((double) M_PI) * 0.25))) / (f * (((double) M_PI) * 0.5))))) / (((double) M_PI) * 0.25);
} else {
tmp = (f / (((double) M_PI) / 0.0)) * -2.0;
}
return tmp;
}
public static double code(double f) {
double tmp;
if (((Math.PI / 4.0) * f) <= 200.0) {
tmp = -Math.log((2.0 * (Math.cosh((f * (Math.PI * 0.25))) / (f * (Math.PI * 0.5))))) / (Math.PI * 0.25);
} else {
tmp = (f / (Math.PI / 0.0)) * -2.0;
}
return tmp;
}
def code(f): tmp = 0 if ((math.pi / 4.0) * f) <= 200.0: tmp = -math.log((2.0 * (math.cosh((f * (math.pi * 0.25))) / (f * (math.pi * 0.5))))) / (math.pi * 0.25) else: tmp = (f / (math.pi / 0.0)) * -2.0 return tmp
function code(f) tmp = 0.0 if (Float64(Float64(pi / 4.0) * f) <= 200.0) tmp = Float64(Float64(-log(Float64(2.0 * Float64(cosh(Float64(f * Float64(pi * 0.25))) / Float64(f * Float64(pi * 0.5)))))) / Float64(pi * 0.25)); else tmp = Float64(Float64(f / Float64(pi / 0.0)) * Float64(-2.0)); end return tmp end
function tmp_2 = code(f) tmp = 0.0; if (((pi / 4.0) * f) <= 200.0) tmp = -log((2.0 * (cosh((f * (pi * 0.25))) / (f * (pi * 0.5))))) / (pi * 0.25); else tmp = (f / (pi / 0.0)) * -2.0; end tmp_2 = tmp; end
code[f_] := If[LessEqual[N[(N[(Pi / 4.0), $MachinePrecision] * f), $MachinePrecision], 200.0], N[((-N[Log[N[(2.0 * N[(N[Cosh[N[(f * N[(Pi * 0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(f * N[(Pi * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(Pi * 0.25), $MachinePrecision]), $MachinePrecision], N[(N[(f / N[(Pi / 0.0), $MachinePrecision]), $MachinePrecision] * (-2.0)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\pi}{4} \cdot f \leq 200:\\
\;\;\;\;\frac{-\log \left(2 \cdot \frac{\cosh \left(f \cdot \left(\pi \cdot 0.25\right)\right)}{f \cdot \left(\pi \cdot 0.5\right)}\right)}{\pi \cdot 0.25}\\
\mathbf{else}:\\
\;\;\;\;\frac{f}{\frac{\pi}{0}} \cdot \left(-2\right)\\
\end{array}
\end{array}
if (*.f64 (/.f64 (PI.f64) 4) f) < 200Initial program 6.1%
Taylor expanded in f around 0 97.5%
distribute-rgt-out--97.5%
metadata-eval97.5%
Simplified97.5%
associate-*l/97.7%
Applied egg-rr97.7%
if 200 < (*.f64 (/.f64 (PI.f64) 4) f) Initial program 0.0%
Applied egg-rr1.6%
Taylor expanded in f around 0 100.0%
associate-/l*100.0%
distribute-rgt-out100.0%
metadata-eval100.0%
mul0-rgt100.0%
Simplified100.0%
Final simplification97.8%
(FPCore (f) :precision binary64 (if (<= f 230.0) (- (fabs (* 4.0 (/ (log (/ 2.0 (* PI (* f 0.5)))) PI)))) (* (/ f (/ PI 0.0)) (- 2.0))))
double code(double f) {
double tmp;
if (f <= 230.0) {
tmp = -fabs((4.0 * (log((2.0 / (((double) M_PI) * (f * 0.5)))) / ((double) M_PI))));
} else {
tmp = (f / (((double) M_PI) / 0.0)) * -2.0;
}
return tmp;
}
public static double code(double f) {
double tmp;
if (f <= 230.0) {
tmp = -Math.abs((4.0 * (Math.log((2.0 / (Math.PI * (f * 0.5)))) / Math.PI)));
} else {
tmp = (f / (Math.PI / 0.0)) * -2.0;
}
return tmp;
}
def code(f): tmp = 0 if f <= 230.0: tmp = -math.fabs((4.0 * (math.log((2.0 / (math.pi * (f * 0.5)))) / math.pi))) else: tmp = (f / (math.pi / 0.0)) * -2.0 return tmp
function code(f) tmp = 0.0 if (f <= 230.0) tmp = Float64(-abs(Float64(4.0 * Float64(log(Float64(2.0 / Float64(pi * Float64(f * 0.5)))) / pi)))); else tmp = Float64(Float64(f / Float64(pi / 0.0)) * Float64(-2.0)); end return tmp end
function tmp_2 = code(f) tmp = 0.0; if (f <= 230.0) tmp = -abs((4.0 * (log((2.0 / (pi * (f * 0.5)))) / pi))); else tmp = (f / (pi / 0.0)) * -2.0; end tmp_2 = tmp; end
code[f_] := If[LessEqual[f, 230.0], (-N[Abs[N[(4.0 * N[(N[Log[N[(2.0 / N[(Pi * N[(f * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), N[(N[(f / N[(Pi / 0.0), $MachinePrecision]), $MachinePrecision] * (-2.0)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;f \leq 230:\\
\;\;\;\;-\left|4 \cdot \frac{\log \left(\frac{2}{\pi \cdot \left(f \cdot 0.5\right)}\right)}{\pi}\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{f}{\frac{\pi}{0}} \cdot \left(-2\right)\\
\end{array}
\end{array}
if f < 230Initial program 6.1%
Taylor expanded in f around 0 97.5%
associate-/r*97.5%
distribute-rgt-out--97.5%
metadata-eval97.5%
Simplified97.5%
add-sqr-sqrt97.1%
sqrt-unprod97.5%
pow297.5%
associate-*l/97.7%
*-un-lft-identity97.7%
associate-/l/97.7%
div-inv97.7%
metadata-eval97.7%
Applied egg-rr97.7%
unpow297.7%
rem-sqrt-square97.7%
associate-/r*97.7%
*-lft-identity97.7%
*-commutative97.7%
times-frac97.7%
metadata-eval97.7%
associate-/r*97.7%
associate-*l*97.7%
Simplified97.7%
if 230 < f Initial program 0.0%
Applied egg-rr1.6%
Taylor expanded in f around 0 100.0%
associate-/l*100.0%
distribute-rgt-out100.0%
metadata-eval100.0%
mul0-rgt100.0%
Simplified100.0%
Final simplification97.7%
(FPCore (f) :precision binary64 (if (<= f 1.25) (/ (- (log (/ 2.0 (* f (* PI 0.5))))) (* PI 0.25)) (* (/ f (/ PI 0.0)) (- 2.0))))
double code(double f) {
double tmp;
if (f <= 1.25) {
tmp = -log((2.0 / (f * (((double) M_PI) * 0.5)))) / (((double) M_PI) * 0.25);
} else {
tmp = (f / (((double) M_PI) / 0.0)) * -2.0;
}
return tmp;
}
public static double code(double f) {
double tmp;
if (f <= 1.25) {
tmp = -Math.log((2.0 / (f * (Math.PI * 0.5)))) / (Math.PI * 0.25);
} else {
tmp = (f / (Math.PI / 0.0)) * -2.0;
}
return tmp;
}
def code(f): tmp = 0 if f <= 1.25: tmp = -math.log((2.0 / (f * (math.pi * 0.5)))) / (math.pi * 0.25) else: tmp = (f / (math.pi / 0.0)) * -2.0 return tmp
function code(f) tmp = 0.0 if (f <= 1.25) tmp = Float64(Float64(-log(Float64(2.0 / Float64(f * Float64(pi * 0.5))))) / Float64(pi * 0.25)); else tmp = Float64(Float64(f / Float64(pi / 0.0)) * Float64(-2.0)); end return tmp end
function tmp_2 = code(f) tmp = 0.0; if (f <= 1.25) tmp = -log((2.0 / (f * (pi * 0.5)))) / (pi * 0.25); else tmp = (f / (pi / 0.0)) * -2.0; end tmp_2 = tmp; end
code[f_] := If[LessEqual[f, 1.25], N[((-N[Log[N[(2.0 / N[(f * N[(Pi * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(Pi * 0.25), $MachinePrecision]), $MachinePrecision], N[(N[(f / N[(Pi / 0.0), $MachinePrecision]), $MachinePrecision] * (-2.0)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;f \leq 1.25:\\
\;\;\;\;\frac{-\log \left(\frac{2}{f \cdot \left(\pi \cdot 0.5\right)}\right)}{\pi \cdot 0.25}\\
\mathbf{else}:\\
\;\;\;\;\frac{f}{\frac{\pi}{0}} \cdot \left(-2\right)\\
\end{array}
\end{array}
if f < 1.25Initial program 6.1%
Taylor expanded in f around 0 98.2%
associate-/r*98.2%
distribute-rgt-out--98.2%
metadata-eval98.2%
Simplified98.2%
associate-*l/98.4%
*-un-lft-identity98.4%
associate-/l/98.4%
div-inv98.4%
metadata-eval98.4%
Applied egg-rr98.4%
if 1.25 < f Initial program 0.9%
Applied egg-rr2.8%
Taylor expanded in f around 0 75.9%
associate-/l*75.9%
distribute-rgt-out75.9%
metadata-eval75.9%
mul0-rgt75.9%
Simplified75.9%
Final simplification97.7%
(FPCore (f) :precision binary64 (if (<= f 1.25) (/ (- 4.0) (/ (- PI) (log (* PI (* f 0.25))))) (* (/ f (/ PI 0.0)) (- 2.0))))
double code(double f) {
double tmp;
if (f <= 1.25) {
tmp = -4.0 / (-((double) M_PI) / log((((double) M_PI) * (f * 0.25))));
} else {
tmp = (f / (((double) M_PI) / 0.0)) * -2.0;
}
return tmp;
}
public static double code(double f) {
double tmp;
if (f <= 1.25) {
tmp = -4.0 / (-Math.PI / Math.log((Math.PI * (f * 0.25))));
} else {
tmp = (f / (Math.PI / 0.0)) * -2.0;
}
return tmp;
}
def code(f): tmp = 0 if f <= 1.25: tmp = -4.0 / (-math.pi / math.log((math.pi * (f * 0.25)))) else: tmp = (f / (math.pi / 0.0)) * -2.0 return tmp
function code(f) tmp = 0.0 if (f <= 1.25) tmp = Float64(Float64(-4.0) / Float64(Float64(-pi) / log(Float64(pi * Float64(f * 0.25))))); else tmp = Float64(Float64(f / Float64(pi / 0.0)) * Float64(-2.0)); end return tmp end
function tmp_2 = code(f) tmp = 0.0; if (f <= 1.25) tmp = -4.0 / (-pi / log((pi * (f * 0.25)))); else tmp = (f / (pi / 0.0)) * -2.0; end tmp_2 = tmp; end
code[f_] := If[LessEqual[f, 1.25], N[((-4.0) / N[((-Pi) / N[Log[N[(Pi * N[(f * 0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(f / N[(Pi / 0.0), $MachinePrecision]), $MachinePrecision] * (-2.0)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;f \leq 1.25:\\
\;\;\;\;\frac{-4}{\frac{-\pi}{\log \left(\pi \cdot \left(f \cdot 0.25\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{f}{\frac{\pi}{0}} \cdot \left(-2\right)\\
\end{array}
\end{array}
if f < 1.25Initial program 6.1%
Taylor expanded in f around 0 98.4%
associate-*r/98.4%
associate-/l*98.3%
mul-1-neg98.3%
unsub-neg98.3%
distribute-rgt-out--98.3%
metadata-eval98.3%
Simplified98.3%
add-exp-log97.2%
diff-log97.2%
Applied egg-rr97.2%
rem-exp-log98.4%
div-inv98.2%
frac-2neg98.2%
metadata-eval98.2%
neg-log98.2%
clear-num98.2%
*-un-lft-identity98.2%
associate-/r*98.2%
div-inv98.2%
metadata-eval98.2%
times-frac98.2%
clear-num98.2%
div-inv98.2%
metadata-eval98.2%
Applied egg-rr98.2%
*-commutative98.2%
associate-*l/98.4%
neg-mul-198.4%
associate-*r/98.4%
*-commutative98.4%
associate-*r*98.4%
*-commutative98.4%
associate-/l*98.4%
metadata-eval98.4%
associate-/l*98.4%
*-lft-identity98.4%
associate-/l*98.4%
associate-/r*98.4%
*-commutative98.4%
associate-/r/98.4%
metadata-eval98.4%
*-commutative98.4%
associate-*r*98.4%
*-commutative98.4%
*-commutative98.4%
Simplified98.4%
if 1.25 < f Initial program 0.9%
Applied egg-rr2.8%
Taylor expanded in f around 0 75.9%
associate-/l*75.9%
distribute-rgt-out75.9%
metadata-eval75.9%
mul0-rgt75.9%
Simplified75.9%
Final simplification97.7%
(FPCore (f) :precision binary64 (if (<= f 1.25) (* (log (/ 4.0 (* PI f))) (/ (- 4.0) PI)) (* (/ f (/ PI 0.0)) (- 2.0))))
double code(double f) {
double tmp;
if (f <= 1.25) {
tmp = log((4.0 / (((double) M_PI) * f))) * (-4.0 / ((double) M_PI));
} else {
tmp = (f / (((double) M_PI) / 0.0)) * -2.0;
}
return tmp;
}
public static double code(double f) {
double tmp;
if (f <= 1.25) {
tmp = Math.log((4.0 / (Math.PI * f))) * (-4.0 / Math.PI);
} else {
tmp = (f / (Math.PI / 0.0)) * -2.0;
}
return tmp;
}
def code(f): tmp = 0 if f <= 1.25: tmp = math.log((4.0 / (math.pi * f))) * (-4.0 / math.pi) else: tmp = (f / (math.pi / 0.0)) * -2.0 return tmp
function code(f) tmp = 0.0 if (f <= 1.25) tmp = Float64(log(Float64(4.0 / Float64(pi * f))) * Float64(Float64(-4.0) / pi)); else tmp = Float64(Float64(f / Float64(pi / 0.0)) * Float64(-2.0)); end return tmp end
function tmp_2 = code(f) tmp = 0.0; if (f <= 1.25) tmp = log((4.0 / (pi * f))) * (-4.0 / pi); else tmp = (f / (pi / 0.0)) * -2.0; end tmp_2 = tmp; end
code[f_] := If[LessEqual[f, 1.25], N[(N[Log[N[(4.0 / N[(Pi * f), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-4.0) / Pi), $MachinePrecision]), $MachinePrecision], N[(N[(f / N[(Pi / 0.0), $MachinePrecision]), $MachinePrecision] * (-2.0)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;f \leq 1.25:\\
\;\;\;\;\log \left(\frac{4}{\pi \cdot f}\right) \cdot \frac{-4}{\pi}\\
\mathbf{else}:\\
\;\;\;\;\frac{f}{\frac{\pi}{0}} \cdot \left(-2\right)\\
\end{array}
\end{array}
if f < 1.25Initial program 6.1%
Taylor expanded in f around 0 98.4%
associate-*r/98.4%
associate-/l*98.3%
mul-1-neg98.3%
unsub-neg98.3%
distribute-rgt-out--98.3%
metadata-eval98.3%
Simplified98.3%
associate-/r/98.3%
diff-log98.2%
Applied egg-rr98.2%
Taylor expanded in f around 0 98.2%
*-commutative98.2%
Simplified98.2%
if 1.25 < f Initial program 0.9%
Applied egg-rr2.8%
Taylor expanded in f around 0 75.9%
associate-/l*75.9%
distribute-rgt-out75.9%
metadata-eval75.9%
mul0-rgt75.9%
Simplified75.9%
Final simplification97.5%
(FPCore (f) :precision binary64 (* (/ f (/ PI 0.0)) (- 2.0)))
double code(double f) {
return (f / (((double) M_PI) / 0.0)) * -2.0;
}
public static double code(double f) {
return (f / (Math.PI / 0.0)) * -2.0;
}
def code(f): return (f / (math.pi / 0.0)) * -2.0
function code(f) return Float64(Float64(f / Float64(pi / 0.0)) * Float64(-2.0)) end
function tmp = code(f) tmp = (f / (pi / 0.0)) * -2.0; end
code[f_] := N[(N[(f / N[(Pi / 0.0), $MachinePrecision]), $MachinePrecision] * (-2.0)), $MachinePrecision]
\begin{array}{l}
\\
\frac{f}{\frac{\pi}{0}} \cdot \left(-2\right)
\end{array}
Initial program 6.0%
Applied egg-rr3.4%
Taylor expanded in f around 0 5.4%
associate-/l*5.4%
distribute-rgt-out5.4%
metadata-eval5.4%
mul0-rgt5.4%
Simplified5.4%
Final simplification5.4%
herbie shell --seed 2023313
(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)))))))))