
(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 5 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 (exp (* f (/ PI 4.0))))
(t_1 (exp (* -0.25 (* PI f))))
(t_2 (exp (* f (/ (- PI) 4.0))))
(t_3 (exp (* 0.25 (* PI f)))))
(if (<= (/ (+ t_0 t_2) (- t_0 t_2)) 400000.0)
(* -4.0 (/ (log (/ (+ t_1 t_3) (- t_3 t_1))) (cbrt (pow PI 3.0))))
(* (/ (log (* f (* PI 0.25))) PI) (- -4.0)))))
double code(double f) {
double t_0 = exp((f * (((double) M_PI) / 4.0)));
double t_1 = exp((-0.25 * (((double) M_PI) * f)));
double t_2 = exp((f * (-((double) M_PI) / 4.0)));
double t_3 = exp((0.25 * (((double) M_PI) * f)));
double tmp;
if (((t_0 + t_2) / (t_0 - t_2)) <= 400000.0) {
tmp = -4.0 * (log(((t_1 + t_3) / (t_3 - t_1))) / cbrt(pow(((double) M_PI), 3.0)));
} else {
tmp = (log((f * (((double) M_PI) * 0.25))) / ((double) M_PI)) * -(-4.0);
}
return tmp;
}
public static double code(double f) {
double t_0 = Math.exp((f * (Math.PI / 4.0)));
double t_1 = Math.exp((-0.25 * (Math.PI * f)));
double t_2 = Math.exp((f * (-Math.PI / 4.0)));
double t_3 = Math.exp((0.25 * (Math.PI * f)));
double tmp;
if (((t_0 + t_2) / (t_0 - t_2)) <= 400000.0) {
tmp = -4.0 * (Math.log(((t_1 + t_3) / (t_3 - t_1))) / Math.cbrt(Math.pow(Math.PI, 3.0)));
} else {
tmp = (Math.log((f * (Math.PI * 0.25))) / Math.PI) * -(-4.0);
}
return tmp;
}
function code(f) t_0 = exp(Float64(f * Float64(pi / 4.0))) t_1 = exp(Float64(-0.25 * Float64(pi * f))) t_2 = exp(Float64(f * Float64(Float64(-pi) / 4.0))) t_3 = exp(Float64(0.25 * Float64(pi * f))) tmp = 0.0 if (Float64(Float64(t_0 + t_2) / Float64(t_0 - t_2)) <= 400000.0) tmp = Float64(-4.0 * Float64(log(Float64(Float64(t_1 + t_3) / Float64(t_3 - t_1))) / cbrt((pi ^ 3.0)))); else tmp = Float64(Float64(log(Float64(f * Float64(pi * 0.25))) / pi) * Float64(-(-4.0))); end return tmp end
code[f_] := Block[{t$95$0 = N[Exp[N[(f * N[(Pi / 4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(-0.25 * N[(Pi * f), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Exp[N[(f * N[((-Pi) / 4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Exp[N[(0.25 * N[(Pi * f), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(t$95$0 + t$95$2), $MachinePrecision] / N[(t$95$0 - t$95$2), $MachinePrecision]), $MachinePrecision], 400000.0], N[(-4.0 * N[(N[Log[N[(N[(t$95$1 + t$95$3), $MachinePrecision] / N[(t$95$3 - t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Power[N[Power[Pi, 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[N[(f * N[(Pi * 0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision] * (--4.0)), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{f \cdot \frac{\pi}{4}}\\
t_1 := e^{-0.25 \cdot \left(\pi \cdot f\right)}\\
t_2 := e^{f \cdot \frac{-\pi}{4}}\\
t_3 := e^{0.25 \cdot \left(\pi \cdot f\right)}\\
\mathbf{if}\;\frac{t_0 + t_2}{t_0 - t_2} \leq 400000:\\
\;\;\;\;-4 \cdot \frac{\log \left(\frac{t_1 + t_3}{t_3 - t_1}\right)}{\sqrt[3]{{\pi}^{3}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\log \left(f \cdot \left(\pi \cdot 0.25\right)\right)}{\pi} \cdot \left(--4\right)\\
\end{array}
\end{array}
if (/.f64 (+.f64 (exp.f64 (*.f64 (/.f64 (PI.f64) 4) f)) (exp.f64 (neg.f64 (*.f64 (/.f64 (PI.f64) 4) f)))) (-.f64 (exp.f64 (*.f64 (/.f64 (PI.f64) 4) f)) (exp.f64 (neg.f64 (*.f64 (/.f64 (PI.f64) 4) f))))) < 4e5Initial program 76.2%
distribute-lft-neg-in76.2%
*-commutative76.2%
Simplified76.5%
Taylor expanded in f around inf 76.2%
rem-cbrt-cube76.7%
Applied egg-rr76.7%
if 4e5 < (/.f64 (+.f64 (exp.f64 (*.f64 (/.f64 (PI.f64) 4) f)) (exp.f64 (neg.f64 (*.f64 (/.f64 (PI.f64) 4) f)))) (-.f64 (exp.f64 (*.f64 (/.f64 (PI.f64) 4) f)) (exp.f64 (neg.f64 (*.f64 (/.f64 (PI.f64) 4) f))))) Initial program 4.5%
distribute-lft-neg-in4.5%
*-commutative4.5%
Simplified4.5%
Taylor expanded in f around 0 95.4%
expm1-log1p-u0.1%
expm1-udef0.1%
distribute-rgt-out--0.1%
metadata-eval0.1%
Applied egg-rr0.1%
expm1-def0.1%
expm1-log1p95.4%
associate-*r/95.6%
*-commutative95.6%
*-lft-identity95.6%
times-frac95.6%
metadata-eval95.6%
Simplified95.6%
associate-/l/95.6%
clear-num95.6%
metadata-eval95.6%
associate-/l*95.6%
associate-*r*95.6%
log-rec96.0%
clear-num95.6%
clear-num95.6%
associate-*r*95.6%
associate-/l*95.6%
metadata-eval95.6%
clear-num95.6%
associate-/l/95.6%
clear-num96.0%
div-inv96.0%
clear-num96.0%
div-inv96.0%
metadata-eval96.0%
Applied egg-rr96.0%
Final simplification95.3%
(FPCore (f)
:precision binary64
(*
(log
(/
(+ (exp (/ PI (/ -4.0 f))) (exp (* f (/ PI 4.0))))
(+
(* f (- (* PI 0.25) (* PI -0.25)))
(+
(*
(pow f 3.0)
(-
(* 0.0026041666666666665 (pow PI 3.0))
(* (pow PI 3.0) -0.0026041666666666665)))
(+
(*
(pow f 5.0)
(-
(* 8.138020833333333e-6 (pow PI 5.0))
(* (pow PI 5.0) -8.138020833333333e-6)))
(*
(pow f 7.0)
(-
(* 1.2110150049603175e-8 (pow PI 7.0))
(* (pow PI 7.0) -1.2110150049603175e-8))))))))
(/ -4.0 PI)))
double code(double f) {
return log(((exp((((double) M_PI) / (-4.0 / f))) + exp((f * (((double) M_PI) / 4.0)))) / ((f * ((((double) M_PI) * 0.25) - (((double) M_PI) * -0.25))) + ((pow(f, 3.0) * ((0.0026041666666666665 * pow(((double) M_PI), 3.0)) - (pow(((double) M_PI), 3.0) * -0.0026041666666666665))) + ((pow(f, 5.0) * ((8.138020833333333e-6 * pow(((double) M_PI), 5.0)) - (pow(((double) M_PI), 5.0) * -8.138020833333333e-6))) + (pow(f, 7.0) * ((1.2110150049603175e-8 * pow(((double) M_PI), 7.0)) - (pow(((double) M_PI), 7.0) * -1.2110150049603175e-8)))))))) * (-4.0 / ((double) M_PI));
}
public static double code(double f) {
return Math.log(((Math.exp((Math.PI / (-4.0 / f))) + Math.exp((f * (Math.PI / 4.0)))) / ((f * ((Math.PI * 0.25) - (Math.PI * -0.25))) + ((Math.pow(f, 3.0) * ((0.0026041666666666665 * Math.pow(Math.PI, 3.0)) - (Math.pow(Math.PI, 3.0) * -0.0026041666666666665))) + ((Math.pow(f, 5.0) * ((8.138020833333333e-6 * Math.pow(Math.PI, 5.0)) - (Math.pow(Math.PI, 5.0) * -8.138020833333333e-6))) + (Math.pow(f, 7.0) * ((1.2110150049603175e-8 * Math.pow(Math.PI, 7.0)) - (Math.pow(Math.PI, 7.0) * -1.2110150049603175e-8)))))))) * (-4.0 / Math.PI);
}
def code(f): return math.log(((math.exp((math.pi / (-4.0 / f))) + math.exp((f * (math.pi / 4.0)))) / ((f * ((math.pi * 0.25) - (math.pi * -0.25))) + ((math.pow(f, 3.0) * ((0.0026041666666666665 * math.pow(math.pi, 3.0)) - (math.pow(math.pi, 3.0) * -0.0026041666666666665))) + ((math.pow(f, 5.0) * ((8.138020833333333e-6 * math.pow(math.pi, 5.0)) - (math.pow(math.pi, 5.0) * -8.138020833333333e-6))) + (math.pow(f, 7.0) * ((1.2110150049603175e-8 * math.pow(math.pi, 7.0)) - (math.pow(math.pi, 7.0) * -1.2110150049603175e-8)))))))) * (-4.0 / math.pi)
function code(f) return Float64(log(Float64(Float64(exp(Float64(pi / Float64(-4.0 / f))) + exp(Float64(f * Float64(pi / 4.0)))) / Float64(Float64(f * Float64(Float64(pi * 0.25) - Float64(pi * -0.25))) + Float64(Float64((f ^ 3.0) * Float64(Float64(0.0026041666666666665 * (pi ^ 3.0)) - Float64((pi ^ 3.0) * -0.0026041666666666665))) + Float64(Float64((f ^ 5.0) * Float64(Float64(8.138020833333333e-6 * (pi ^ 5.0)) - Float64((pi ^ 5.0) * -8.138020833333333e-6))) + Float64((f ^ 7.0) * Float64(Float64(1.2110150049603175e-8 * (pi ^ 7.0)) - Float64((pi ^ 7.0) * -1.2110150049603175e-8)))))))) * Float64(-4.0 / pi)) end
function tmp = code(f) tmp = log(((exp((pi / (-4.0 / f))) + exp((f * (pi / 4.0)))) / ((f * ((pi * 0.25) - (pi * -0.25))) + (((f ^ 3.0) * ((0.0026041666666666665 * (pi ^ 3.0)) - ((pi ^ 3.0) * -0.0026041666666666665))) + (((f ^ 5.0) * ((8.138020833333333e-6 * (pi ^ 5.0)) - ((pi ^ 5.0) * -8.138020833333333e-6))) + ((f ^ 7.0) * ((1.2110150049603175e-8 * (pi ^ 7.0)) - ((pi ^ 7.0) * -1.2110150049603175e-8)))))))) * (-4.0 / pi); end
code[f_] := N[(N[Log[N[(N[(N[Exp[N[(Pi / N[(-4.0 / f), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(f * N[(Pi / 4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(f * N[(N[(Pi * 0.25), $MachinePrecision] - N[(Pi * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[f, 3.0], $MachinePrecision] * N[(N[(0.0026041666666666665 * N[Power[Pi, 3.0], $MachinePrecision]), $MachinePrecision] - N[(N[Power[Pi, 3.0], $MachinePrecision] * -0.0026041666666666665), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[f, 5.0], $MachinePrecision] * N[(N[(8.138020833333333e-6 * N[Power[Pi, 5.0], $MachinePrecision]), $MachinePrecision] - N[(N[Power[Pi, 5.0], $MachinePrecision] * -8.138020833333333e-6), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[f, 7.0], $MachinePrecision] * N[(N[(1.2110150049603175e-8 * N[Power[Pi, 7.0], $MachinePrecision]), $MachinePrecision] - N[(N[Power[Pi, 7.0], $MachinePrecision] * -1.2110150049603175e-8), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-4.0 / Pi), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\log \left(\frac{e^{\frac{\pi}{\frac{-4}{f}}} + e^{f \cdot \frac{\pi}{4}}}{f \cdot \left(\pi \cdot 0.25 - \pi \cdot -0.25\right) + \left({f}^{3} \cdot \left(0.0026041666666666665 \cdot {\pi}^{3} - {\pi}^{3} \cdot -0.0026041666666666665\right) + \left({f}^{5} \cdot \left(8.138020833333333 \cdot 10^{-6} \cdot {\pi}^{5} - {\pi}^{5} \cdot -8.138020833333333 \cdot 10^{-6}\right) + {f}^{7} \cdot \left(1.2110150049603175 \cdot 10^{-8} \cdot {\pi}^{7} - {\pi}^{7} \cdot -1.2110150049603175 \cdot 10^{-8}\right)\right)\right)}\right) \cdot \frac{-4}{\pi}
\end{array}
Initial program 7.3%
distribute-lft-neg-in7.3%
*-commutative7.3%
Simplified7.3%
Taylor expanded in f around 0 93.9%
Final simplification93.9%
(FPCore (f)
:precision binary64
(let* ((t_0 (exp (* f (/ PI 4.0))))
(t_1 (exp (* -0.25 (* PI f))))
(t_2 (exp (* f (/ (- PI) 4.0))))
(t_3 (exp (* 0.25 (* PI f)))))
(if (<= (/ (+ t_0 t_2) (- t_0 t_2)) 400000.0)
(* -4.0 (/ (log (/ (+ t_1 t_3) (- t_3 t_1))) PI))
(* (/ (log (* f (* PI 0.25))) PI) (- -4.0)))))
double code(double f) {
double t_0 = exp((f * (((double) M_PI) / 4.0)));
double t_1 = exp((-0.25 * (((double) M_PI) * f)));
double t_2 = exp((f * (-((double) M_PI) / 4.0)));
double t_3 = exp((0.25 * (((double) M_PI) * f)));
double tmp;
if (((t_0 + t_2) / (t_0 - t_2)) <= 400000.0) {
tmp = -4.0 * (log(((t_1 + t_3) / (t_3 - t_1))) / ((double) M_PI));
} else {
tmp = (log((f * (((double) M_PI) * 0.25))) / ((double) M_PI)) * -(-4.0);
}
return tmp;
}
public static double code(double f) {
double t_0 = Math.exp((f * (Math.PI / 4.0)));
double t_1 = Math.exp((-0.25 * (Math.PI * f)));
double t_2 = Math.exp((f * (-Math.PI / 4.0)));
double t_3 = Math.exp((0.25 * (Math.PI * f)));
double tmp;
if (((t_0 + t_2) / (t_0 - t_2)) <= 400000.0) {
tmp = -4.0 * (Math.log(((t_1 + t_3) / (t_3 - t_1))) / Math.PI);
} else {
tmp = (Math.log((f * (Math.PI * 0.25))) / Math.PI) * -(-4.0);
}
return tmp;
}
def code(f): t_0 = math.exp((f * (math.pi / 4.0))) t_1 = math.exp((-0.25 * (math.pi * f))) t_2 = math.exp((f * (-math.pi / 4.0))) t_3 = math.exp((0.25 * (math.pi * f))) tmp = 0 if ((t_0 + t_2) / (t_0 - t_2)) <= 400000.0: tmp = -4.0 * (math.log(((t_1 + t_3) / (t_3 - t_1))) / math.pi) else: tmp = (math.log((f * (math.pi * 0.25))) / math.pi) * -(-4.0) return tmp
function code(f) t_0 = exp(Float64(f * Float64(pi / 4.0))) t_1 = exp(Float64(-0.25 * Float64(pi * f))) t_2 = exp(Float64(f * Float64(Float64(-pi) / 4.0))) t_3 = exp(Float64(0.25 * Float64(pi * f))) tmp = 0.0 if (Float64(Float64(t_0 + t_2) / Float64(t_0 - t_2)) <= 400000.0) tmp = Float64(-4.0 * Float64(log(Float64(Float64(t_1 + t_3) / Float64(t_3 - t_1))) / pi)); else tmp = Float64(Float64(log(Float64(f * Float64(pi * 0.25))) / pi) * Float64(-(-4.0))); end return tmp end
function tmp_2 = code(f) t_0 = exp((f * (pi / 4.0))); t_1 = exp((-0.25 * (pi * f))); t_2 = exp((f * (-pi / 4.0))); t_3 = exp((0.25 * (pi * f))); tmp = 0.0; if (((t_0 + t_2) / (t_0 - t_2)) <= 400000.0) tmp = -4.0 * (log(((t_1 + t_3) / (t_3 - t_1))) / pi); else tmp = (log((f * (pi * 0.25))) / pi) * -(-4.0); end tmp_2 = tmp; end
code[f_] := Block[{t$95$0 = N[Exp[N[(f * N[(Pi / 4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(-0.25 * N[(Pi * f), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Exp[N[(f * N[((-Pi) / 4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Exp[N[(0.25 * N[(Pi * f), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(t$95$0 + t$95$2), $MachinePrecision] / N[(t$95$0 - t$95$2), $MachinePrecision]), $MachinePrecision], 400000.0], N[(-4.0 * N[(N[Log[N[(N[(t$95$1 + t$95$3), $MachinePrecision] / N[(t$95$3 - t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[N[(f * N[(Pi * 0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision] * (--4.0)), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{f \cdot \frac{\pi}{4}}\\
t_1 := e^{-0.25 \cdot \left(\pi \cdot f\right)}\\
t_2 := e^{f \cdot \frac{-\pi}{4}}\\
t_3 := e^{0.25 \cdot \left(\pi \cdot f\right)}\\
\mathbf{if}\;\frac{t_0 + t_2}{t_0 - t_2} \leq 400000:\\
\;\;\;\;-4 \cdot \frac{\log \left(\frac{t_1 + t_3}{t_3 - t_1}\right)}{\pi}\\
\mathbf{else}:\\
\;\;\;\;\frac{\log \left(f \cdot \left(\pi \cdot 0.25\right)\right)}{\pi} \cdot \left(--4\right)\\
\end{array}
\end{array}
if (/.f64 (+.f64 (exp.f64 (*.f64 (/.f64 (PI.f64) 4) f)) (exp.f64 (neg.f64 (*.f64 (/.f64 (PI.f64) 4) f)))) (-.f64 (exp.f64 (*.f64 (/.f64 (PI.f64) 4) f)) (exp.f64 (neg.f64 (*.f64 (/.f64 (PI.f64) 4) f))))) < 4e5Initial program 76.2%
distribute-lft-neg-in76.2%
*-commutative76.2%
Simplified76.5%
Taylor expanded in f around inf 76.2%
if 4e5 < (/.f64 (+.f64 (exp.f64 (*.f64 (/.f64 (PI.f64) 4) f)) (exp.f64 (neg.f64 (*.f64 (/.f64 (PI.f64) 4) f)))) (-.f64 (exp.f64 (*.f64 (/.f64 (PI.f64) 4) f)) (exp.f64 (neg.f64 (*.f64 (/.f64 (PI.f64) 4) f))))) Initial program 4.5%
distribute-lft-neg-in4.5%
*-commutative4.5%
Simplified4.5%
Taylor expanded in f around 0 95.4%
expm1-log1p-u0.1%
expm1-udef0.1%
distribute-rgt-out--0.1%
metadata-eval0.1%
Applied egg-rr0.1%
expm1-def0.1%
expm1-log1p95.4%
associate-*r/95.6%
*-commutative95.6%
*-lft-identity95.6%
times-frac95.6%
metadata-eval95.6%
Simplified95.6%
associate-/l/95.6%
clear-num95.6%
metadata-eval95.6%
associate-/l*95.6%
associate-*r*95.6%
log-rec96.0%
clear-num95.6%
clear-num95.6%
associate-*r*95.6%
associate-/l*95.6%
metadata-eval95.6%
clear-num95.6%
associate-/l/95.6%
clear-num96.0%
div-inv96.0%
clear-num96.0%
div-inv96.0%
metadata-eval96.0%
Applied egg-rr96.0%
Final simplification95.2%
(FPCore (f) :precision binary64 (* (/ (log (* f (* PI 0.25))) PI) (- -4.0)))
double code(double f) {
return (log((f * (((double) M_PI) * 0.25))) / ((double) M_PI)) * -(-4.0);
}
public static double code(double f) {
return (Math.log((f * (Math.PI * 0.25))) / Math.PI) * -(-4.0);
}
def code(f): return (math.log((f * (math.pi * 0.25))) / math.pi) * -(-4.0)
function code(f) return Float64(Float64(log(Float64(f * Float64(pi * 0.25))) / pi) * Float64(-(-4.0))) end
function tmp = code(f) tmp = (log((f * (pi * 0.25))) / pi) * -(-4.0); end
code[f_] := N[(N[(N[Log[N[(f * N[(Pi * 0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision] * (--4.0)), $MachinePrecision]
\begin{array}{l}
\\
\frac{\log \left(f \cdot \left(\pi \cdot 0.25\right)\right)}{\pi} \cdot \left(--4\right)
\end{array}
Initial program 7.3%
distribute-lft-neg-in7.3%
*-commutative7.3%
Simplified7.3%
Taylor expanded in f around 0 92.7%
expm1-log1p-u0.2%
expm1-udef0.2%
distribute-rgt-out--0.2%
metadata-eval0.2%
Applied egg-rr0.2%
expm1-def0.2%
expm1-log1p92.7%
associate-*r/92.9%
*-commutative92.9%
*-lft-identity92.9%
times-frac92.9%
metadata-eval92.9%
Simplified92.9%
associate-/l/92.9%
clear-num92.9%
metadata-eval92.9%
associate-/l*92.9%
associate-*r*92.9%
log-rec93.3%
clear-num92.9%
clear-num92.9%
associate-*r*92.9%
associate-/l*92.9%
metadata-eval92.9%
clear-num92.9%
associate-/l/92.9%
clear-num93.3%
div-inv93.3%
clear-num93.3%
div-inv93.3%
metadata-eval93.3%
Applied egg-rr93.3%
Final simplification93.3%
(FPCore (f) :precision binary64 (* -4.0 (/ (log (/ (/ 4.0 f) PI)) PI)))
double code(double f) {
return -4.0 * (log(((4.0 / f) / ((double) M_PI))) / ((double) M_PI));
}
public static double code(double f) {
return -4.0 * (Math.log(((4.0 / f) / Math.PI)) / Math.PI);
}
def code(f): return -4.0 * (math.log(((4.0 / f) / math.pi)) / math.pi)
function code(f) return Float64(-4.0 * Float64(log(Float64(Float64(4.0 / f) / pi)) / pi)) end
function tmp = code(f) tmp = -4.0 * (log(((4.0 / f) / pi)) / pi); end
code[f_] := N[(-4.0 * N[(N[Log[N[(N[(4.0 / f), $MachinePrecision] / Pi), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-4 \cdot \frac{\log \left(\frac{\frac{4}{f}}{\pi}\right)}{\pi}
\end{array}
Initial program 7.3%
distribute-lft-neg-in7.3%
*-commutative7.3%
Simplified7.3%
Taylor expanded in f around 0 92.7%
expm1-log1p-u0.2%
expm1-udef0.2%
distribute-rgt-out--0.2%
metadata-eval0.2%
Applied egg-rr0.2%
expm1-def0.2%
expm1-log1p92.7%
associate-*r/92.9%
*-commutative92.9%
*-lft-identity92.9%
times-frac92.9%
metadata-eval92.9%
Simplified92.9%
Taylor expanded in f around 0 92.9%
associate-/r*92.9%
Simplified92.9%
Final simplification92.9%
herbie shell --seed 2023314
(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)))))))))