
(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 13 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 (* (/ PI 4.0) f)))
(t_1 (exp (* -0.25 (* PI f))))
(t_2 (exp (* (* PI f) 0.25)))
(t_3 (exp (* (/ PI 4.0) (- f)))))
(if (<= (/ (+ t_0 t_3) (- t_0 t_3)) 50.0)
(* -4.0 (/ (log (/ (+ t_1 t_2) (- t_2 t_1))) (cbrt (pow PI 3.0))))
(*
(+
(log (/ 4.0 PI))
(fma
0.5
(fma
f
0.0
(* (pow f 2.0) (fma 0.5 (* PI (* PI 0.08333333333333333)) 0.0)))
(- (log f))))
(/ -1.0 (/ PI 4.0))))))
double code(double f) {
double t_0 = exp(((((double) M_PI) / 4.0) * f));
double t_1 = exp((-0.25 * (((double) M_PI) * f)));
double t_2 = exp(((((double) M_PI) * f) * 0.25));
double t_3 = exp(((((double) M_PI) / 4.0) * -f));
double tmp;
if (((t_0 + t_3) / (t_0 - t_3)) <= 50.0) {
tmp = -4.0 * (log(((t_1 + t_2) / (t_2 - t_1))) / cbrt(pow(((double) M_PI), 3.0)));
} else {
tmp = (log((4.0 / ((double) M_PI))) + fma(0.5, fma(f, 0.0, (pow(f, 2.0) * fma(0.5, (((double) M_PI) * (((double) M_PI) * 0.08333333333333333)), 0.0))), -log(f))) * (-1.0 / (((double) M_PI) / 4.0));
}
return tmp;
}
function code(f) t_0 = exp(Float64(Float64(pi / 4.0) * f)) t_1 = exp(Float64(-0.25 * Float64(pi * f))) t_2 = exp(Float64(Float64(pi * f) * 0.25)) t_3 = exp(Float64(Float64(pi / 4.0) * Float64(-f))) tmp = 0.0 if (Float64(Float64(t_0 + t_3) / Float64(t_0 - t_3)) <= 50.0) tmp = Float64(-4.0 * Float64(log(Float64(Float64(t_1 + t_2) / Float64(t_2 - t_1))) / cbrt((pi ^ 3.0)))); else tmp = Float64(Float64(log(Float64(4.0 / pi)) + fma(0.5, fma(f, 0.0, Float64((f ^ 2.0) * fma(0.5, Float64(pi * Float64(pi * 0.08333333333333333)), 0.0))), Float64(-log(f)))) * Float64(-1.0 / Float64(pi / 4.0))); end return tmp end
code[f_] := Block[{t$95$0 = N[Exp[N[(N[(Pi / 4.0), $MachinePrecision] * f), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(-0.25 * N[(Pi * f), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Exp[N[(N[(Pi * f), $MachinePrecision] * 0.25), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Exp[N[(N[(Pi / 4.0), $MachinePrecision] * (-f)), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(t$95$0 + t$95$3), $MachinePrecision] / N[(t$95$0 - t$95$3), $MachinePrecision]), $MachinePrecision], 50.0], N[(-4.0 * N[(N[Log[N[(N[(t$95$1 + t$95$2), $MachinePrecision] / N[(t$95$2 - t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Power[N[Power[Pi, 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[N[(4.0 / Pi), $MachinePrecision]], $MachinePrecision] + N[(0.5 * N[(f * 0.0 + N[(N[Power[f, 2.0], $MachinePrecision] * N[(0.5 * N[(Pi * N[(Pi * 0.08333333333333333), $MachinePrecision]), $MachinePrecision] + 0.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + (-N[Log[f], $MachinePrecision])), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[(Pi / 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\pi}{4} \cdot f}\\
t_1 := e^{-0.25 \cdot \left(\pi \cdot f\right)}\\
t_2 := e^{\left(\pi \cdot f\right) \cdot 0.25}\\
t_3 := e^{\frac{\pi}{4} \cdot \left(-f\right)}\\
\mathbf{if}\;\frac{t_0 + t_3}{t_0 - t_3} \leq 50:\\
\;\;\;\;-4 \cdot \frac{\log \left(\frac{t_1 + t_2}{t_2 - t_1}\right)}{\sqrt[3]{{\pi}^{3}}}\\
\mathbf{else}:\\
\;\;\;\;\left(\log \left(\frac{4}{\pi}\right) + \mathsf{fma}\left(0.5, \mathsf{fma}\left(f, 0, {f}^{2} \cdot \mathsf{fma}\left(0.5, \pi \cdot \left(\pi \cdot 0.08333333333333333\right), 0\right)\right), -\log f\right)\right) \cdot \frac{-1}{\frac{\pi}{4}}\\
\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))))) < 50Initial program 75.2%
distribute-lft-neg-in75.2%
*-commutative75.2%
associate-/r/75.2%
associate-*l/75.2%
metadata-eval75.2%
distribute-neg-frac75.2%
Simplified75.6%
Taylor expanded in f around inf 75.2%
Taylor expanded in f around inf 75.3%
add-cbrt-cube75.8%
pow375.8%
Applied egg-rr75.8%
if 50 < (/.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.8%
Taylor expanded in f around 0 95.4%
fma-def95.4%
distribute-rgt-out--95.4%
metadata-eval95.4%
associate-+r+95.4%
+-commutative95.4%
Simplified95.4%
Taylor expanded in f around 0 95.9%
+-commutative95.9%
distribute-lft-out95.9%
fma-def95.9%
Simplified95.9%
Final simplification95.2%
(FPCore (f)
:precision binary64
(let* ((t_0 (exp (/ PI (/ -4.0 f))))
(t_1 (exp (* (/ PI 4.0) f)))
(t_2 (pow (exp (/ PI 4.0)) f))
(t_3 (exp (* (/ PI 4.0) (- f)))))
(if (<= (/ (+ t_1 t_3) (- t_1 t_3)) 50.0)
(* (log (/ (+ t_0 t_2) (- t_2 t_0))) (/ -4.0 PI))
(*
(+
(log (/ 4.0 PI))
(fma
0.5
(fma
f
0.0
(* (pow f 2.0) (fma 0.5 (* PI (* PI 0.08333333333333333)) 0.0)))
(- (log f))))
(/ -1.0 (/ PI 4.0))))))
double code(double f) {
double t_0 = exp((((double) M_PI) / (-4.0 / f)));
double t_1 = exp(((((double) M_PI) / 4.0) * f));
double t_2 = pow(exp((((double) M_PI) / 4.0)), f);
double t_3 = exp(((((double) M_PI) / 4.0) * -f));
double tmp;
if (((t_1 + t_3) / (t_1 - t_3)) <= 50.0) {
tmp = log(((t_0 + t_2) / (t_2 - t_0))) * (-4.0 / ((double) M_PI));
} else {
tmp = (log((4.0 / ((double) M_PI))) + fma(0.5, fma(f, 0.0, (pow(f, 2.0) * fma(0.5, (((double) M_PI) * (((double) M_PI) * 0.08333333333333333)), 0.0))), -log(f))) * (-1.0 / (((double) M_PI) / 4.0));
}
return tmp;
}
function code(f) t_0 = exp(Float64(pi / Float64(-4.0 / f))) t_1 = exp(Float64(Float64(pi / 4.0) * f)) t_2 = exp(Float64(pi / 4.0)) ^ f t_3 = exp(Float64(Float64(pi / 4.0) * Float64(-f))) tmp = 0.0 if (Float64(Float64(t_1 + t_3) / Float64(t_1 - t_3)) <= 50.0) tmp = Float64(log(Float64(Float64(t_0 + t_2) / Float64(t_2 - t_0))) * Float64(-4.0 / pi)); else tmp = Float64(Float64(log(Float64(4.0 / pi)) + fma(0.5, fma(f, 0.0, Float64((f ^ 2.0) * fma(0.5, Float64(pi * Float64(pi * 0.08333333333333333)), 0.0))), Float64(-log(f)))) * Float64(-1.0 / Float64(pi / 4.0))); end return tmp end
code[f_] := Block[{t$95$0 = N[Exp[N[(Pi / N[(-4.0 / f), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(N[(Pi / 4.0), $MachinePrecision] * f), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Exp[N[(Pi / 4.0), $MachinePrecision]], $MachinePrecision], f], $MachinePrecision]}, Block[{t$95$3 = N[Exp[N[(N[(Pi / 4.0), $MachinePrecision] * (-f)), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(t$95$1 + t$95$3), $MachinePrecision] / N[(t$95$1 - t$95$3), $MachinePrecision]), $MachinePrecision], 50.0], N[(N[Log[N[(N[(t$95$0 + t$95$2), $MachinePrecision] / N[(t$95$2 - t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-4.0 / Pi), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[N[(4.0 / Pi), $MachinePrecision]], $MachinePrecision] + N[(0.5 * N[(f * 0.0 + N[(N[Power[f, 2.0], $MachinePrecision] * N[(0.5 * N[(Pi * N[(Pi * 0.08333333333333333), $MachinePrecision]), $MachinePrecision] + 0.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + (-N[Log[f], $MachinePrecision])), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[(Pi / 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\pi}{\frac{-4}{f}}}\\
t_1 := e^{\frac{\pi}{4} \cdot f}\\
t_2 := {\left(e^{\frac{\pi}{4}}\right)}^{f}\\
t_3 := e^{\frac{\pi}{4} \cdot \left(-f\right)}\\
\mathbf{if}\;\frac{t_1 + t_3}{t_1 - t_3} \leq 50:\\
\;\;\;\;\log \left(\frac{t_0 + t_2}{t_2 - t_0}\right) \cdot \frac{-4}{\pi}\\
\mathbf{else}:\\
\;\;\;\;\left(\log \left(\frac{4}{\pi}\right) + \mathsf{fma}\left(0.5, \mathsf{fma}\left(f, 0, {f}^{2} \cdot \mathsf{fma}\left(0.5, \pi \cdot \left(\pi \cdot 0.08333333333333333\right), 0\right)\right), -\log f\right)\right) \cdot \frac{-1}{\frac{\pi}{4}}\\
\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))))) < 50Initial program 75.2%
distribute-lft-neg-in75.2%
*-commutative75.2%
associate-/r/75.2%
associate-*l/75.2%
metadata-eval75.2%
distribute-neg-frac75.2%
Simplified75.6%
if 50 < (/.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.8%
Taylor expanded in f around 0 95.4%
fma-def95.4%
distribute-rgt-out--95.4%
metadata-eval95.4%
associate-+r+95.4%
+-commutative95.4%
Simplified95.4%
Taylor expanded in f around 0 95.9%
+-commutative95.9%
distribute-lft-out95.9%
fma-def95.9%
Simplified95.9%
Final simplification95.2%
(FPCore (f)
:precision binary64
(*
(log
(/
(+ (exp (* (/ PI 4.0) f)) (exp (* (/ PI 4.0) (- f))))
(fma
f
(* PI 0.5)
(fma
(pow f 5.0)
(* (pow PI 5.0) 1.6276041666666666e-5)
(fma
(pow f 3.0)
(* (pow PI 3.0) 0.005208333333333333)
(* (pow f 7.0) (* (pow PI 7.0) 2.422030009920635e-8)))))))
(/ -1.0 (/ PI 4.0))))
double code(double f) {
return log(((exp(((((double) M_PI) / 4.0) * f)) + exp(((((double) M_PI) / 4.0) * -f))) / fma(f, (((double) M_PI) * 0.5), fma(pow(f, 5.0), (pow(((double) M_PI), 5.0) * 1.6276041666666666e-5), fma(pow(f, 3.0), (pow(((double) M_PI), 3.0) * 0.005208333333333333), (pow(f, 7.0) * (pow(((double) M_PI), 7.0) * 2.422030009920635e-8))))))) * (-1.0 / (((double) M_PI) / 4.0));
}
function code(f) return Float64(log(Float64(Float64(exp(Float64(Float64(pi / 4.0) * f)) + exp(Float64(Float64(pi / 4.0) * Float64(-f)))) / fma(f, Float64(pi * 0.5), fma((f ^ 5.0), Float64((pi ^ 5.0) * 1.6276041666666666e-5), fma((f ^ 3.0), Float64((pi ^ 3.0) * 0.005208333333333333), Float64((f ^ 7.0) * Float64((pi ^ 7.0) * 2.422030009920635e-8))))))) * Float64(-1.0 / Float64(pi / 4.0))) end
code[f_] := N[(N[Log[N[(N[(N[Exp[N[(N[(Pi / 4.0), $MachinePrecision] * f), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(N[(Pi / 4.0), $MachinePrecision] * (-f)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(f * N[(Pi * 0.5), $MachinePrecision] + N[(N[Power[f, 5.0], $MachinePrecision] * N[(N[Power[Pi, 5.0], $MachinePrecision] * 1.6276041666666666e-5), $MachinePrecision] + N[(N[Power[f, 3.0], $MachinePrecision] * N[(N[Power[Pi, 3.0], $MachinePrecision] * 0.005208333333333333), $MachinePrecision] + N[(N[Power[f, 7.0], $MachinePrecision] * N[(N[Power[Pi, 7.0], $MachinePrecision] * 2.422030009920635e-8), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / N[(Pi / 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\log \left(\frac{e^{\frac{\pi}{4} \cdot f} + e^{\frac{\pi}{4} \cdot \left(-f\right)}}{\mathsf{fma}\left(f, \pi \cdot 0.5, \mathsf{fma}\left({f}^{5}, {\pi}^{5} \cdot 1.6276041666666666 \cdot 10^{-5}, \mathsf{fma}\left({f}^{3}, {\pi}^{3} \cdot 0.005208333333333333, {f}^{7} \cdot \left({\pi}^{7} \cdot 2.422030009920635 \cdot 10^{-8}\right)\right)\right)\right)}\right) \cdot \frac{-1}{\frac{\pi}{4}}
\end{array}
Initial program 7.3%
Taylor expanded in f around 0 93.9%
fma-def93.9%
distribute-rgt-out--93.9%
metadata-eval93.9%
associate-+r+93.9%
+-commutative93.9%
Simplified93.9%
Final simplification93.9%
(FPCore (f)
:precision binary64
(let* ((t_0 (exp (* (/ PI 4.0) f)))
(t_1 (exp (* -0.25 (* PI f))))
(t_2 (exp (* (* PI f) 0.25)))
(t_3 (exp (* (/ PI 4.0) (- f)))))
(if (<= (/ (+ t_0 t_3) (- t_0 t_3)) 50.0)
(* -4.0 (/ (log (/ (+ t_1 t_2) (- t_2 t_1))) PI))
(*
(+
(log (/ 4.0 PI))
(fma
0.5
(fma
f
0.0
(* (pow f 2.0) (fma 0.5 (* PI (* PI 0.08333333333333333)) 0.0)))
(- (log f))))
(/ -1.0 (/ PI 4.0))))))
double code(double f) {
double t_0 = exp(((((double) M_PI) / 4.0) * f));
double t_1 = exp((-0.25 * (((double) M_PI) * f)));
double t_2 = exp(((((double) M_PI) * f) * 0.25));
double t_3 = exp(((((double) M_PI) / 4.0) * -f));
double tmp;
if (((t_0 + t_3) / (t_0 - t_3)) <= 50.0) {
tmp = -4.0 * (log(((t_1 + t_2) / (t_2 - t_1))) / ((double) M_PI));
} else {
tmp = (log((4.0 / ((double) M_PI))) + fma(0.5, fma(f, 0.0, (pow(f, 2.0) * fma(0.5, (((double) M_PI) * (((double) M_PI) * 0.08333333333333333)), 0.0))), -log(f))) * (-1.0 / (((double) M_PI) / 4.0));
}
return tmp;
}
function code(f) t_0 = exp(Float64(Float64(pi / 4.0) * f)) t_1 = exp(Float64(-0.25 * Float64(pi * f))) t_2 = exp(Float64(Float64(pi * f) * 0.25)) t_3 = exp(Float64(Float64(pi / 4.0) * Float64(-f))) tmp = 0.0 if (Float64(Float64(t_0 + t_3) / Float64(t_0 - t_3)) <= 50.0) tmp = Float64(-4.0 * Float64(log(Float64(Float64(t_1 + t_2) / Float64(t_2 - t_1))) / pi)); else tmp = Float64(Float64(log(Float64(4.0 / pi)) + fma(0.5, fma(f, 0.0, Float64((f ^ 2.0) * fma(0.5, Float64(pi * Float64(pi * 0.08333333333333333)), 0.0))), Float64(-log(f)))) * Float64(-1.0 / Float64(pi / 4.0))); end return tmp end
code[f_] := Block[{t$95$0 = N[Exp[N[(N[(Pi / 4.0), $MachinePrecision] * f), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(-0.25 * N[(Pi * f), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Exp[N[(N[(Pi * f), $MachinePrecision] * 0.25), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Exp[N[(N[(Pi / 4.0), $MachinePrecision] * (-f)), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(t$95$0 + t$95$3), $MachinePrecision] / N[(t$95$0 - t$95$3), $MachinePrecision]), $MachinePrecision], 50.0], N[(-4.0 * N[(N[Log[N[(N[(t$95$1 + t$95$2), $MachinePrecision] / N[(t$95$2 - t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[N[(4.0 / Pi), $MachinePrecision]], $MachinePrecision] + N[(0.5 * N[(f * 0.0 + N[(N[Power[f, 2.0], $MachinePrecision] * N[(0.5 * N[(Pi * N[(Pi * 0.08333333333333333), $MachinePrecision]), $MachinePrecision] + 0.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + (-N[Log[f], $MachinePrecision])), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[(Pi / 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\pi}{4} \cdot f}\\
t_1 := e^{-0.25 \cdot \left(\pi \cdot f\right)}\\
t_2 := e^{\left(\pi \cdot f\right) \cdot 0.25}\\
t_3 := e^{\frac{\pi}{4} \cdot \left(-f\right)}\\
\mathbf{if}\;\frac{t_0 + t_3}{t_0 - t_3} \leq 50:\\
\;\;\;\;-4 \cdot \frac{\log \left(\frac{t_1 + t_2}{t_2 - t_1}\right)}{\pi}\\
\mathbf{else}:\\
\;\;\;\;\left(\log \left(\frac{4}{\pi}\right) + \mathsf{fma}\left(0.5, \mathsf{fma}\left(f, 0, {f}^{2} \cdot \mathsf{fma}\left(0.5, \pi \cdot \left(\pi \cdot 0.08333333333333333\right), 0\right)\right), -\log f\right)\right) \cdot \frac{-1}{\frac{\pi}{4}}\\
\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))))) < 50Initial program 75.2%
distribute-lft-neg-in75.2%
*-commutative75.2%
associate-/r/75.2%
associate-*l/75.2%
metadata-eval75.2%
distribute-neg-frac75.2%
Simplified75.6%
Taylor expanded in f around inf 75.2%
Taylor expanded in f around inf 75.3%
if 50 < (/.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.8%
Taylor expanded in f around 0 95.4%
fma-def95.4%
distribute-rgt-out--95.4%
metadata-eval95.4%
associate-+r+95.4%
+-commutative95.4%
Simplified95.4%
Taylor expanded in f around 0 95.9%
+-commutative95.9%
distribute-lft-out95.9%
fma-def95.9%
Simplified95.9%
Final simplification95.2%
(FPCore (f)
:precision binary64
(let* ((t_0 (* (/ PI 4.0) f)) (t_1 (/ -1.0 (/ PI 4.0))))
(if (<= t_0 5e-6)
(*
(+
(log (/ 4.0 PI))
(fma
0.5
(fma
f
0.0
(* (pow f 2.0) (fma 0.5 (* PI (* PI 0.08333333333333333)) 0.0)))
(- (log f))))
t_1)
(if (<= t_0 200.0)
(*
(/ 1.0 (/ PI 4.0))
(log
(/
(- (pow (exp 0.25) (* PI f)) (pow (exp -0.25) (* PI f)))
(* 2.0 (cosh (/ (* PI f) 4.0))))))
(* (log (/ (+ (exp (* (/ PI 4.0) (- f))) 1.0) 0.5)) t_1)))))
double code(double f) {
double t_0 = (((double) M_PI) / 4.0) * f;
double t_1 = -1.0 / (((double) M_PI) / 4.0);
double tmp;
if (t_0 <= 5e-6) {
tmp = (log((4.0 / ((double) M_PI))) + fma(0.5, fma(f, 0.0, (pow(f, 2.0) * fma(0.5, (((double) M_PI) * (((double) M_PI) * 0.08333333333333333)), 0.0))), -log(f))) * t_1;
} else if (t_0 <= 200.0) {
tmp = (1.0 / (((double) M_PI) / 4.0)) * log(((pow(exp(0.25), (((double) M_PI) * f)) - pow(exp(-0.25), (((double) M_PI) * f))) / (2.0 * cosh(((((double) M_PI) * f) / 4.0)))));
} else {
tmp = log(((exp(((((double) M_PI) / 4.0) * -f)) + 1.0) / 0.5)) * t_1;
}
return tmp;
}
function code(f) t_0 = Float64(Float64(pi / 4.0) * f) t_1 = Float64(-1.0 / Float64(pi / 4.0)) tmp = 0.0 if (t_0 <= 5e-6) tmp = Float64(Float64(log(Float64(4.0 / pi)) + fma(0.5, fma(f, 0.0, Float64((f ^ 2.0) * fma(0.5, Float64(pi * Float64(pi * 0.08333333333333333)), 0.0))), Float64(-log(f)))) * t_1); elseif (t_0 <= 200.0) tmp = Float64(Float64(1.0 / Float64(pi / 4.0)) * log(Float64(Float64((exp(0.25) ^ Float64(pi * f)) - (exp(-0.25) ^ Float64(pi * f))) / Float64(2.0 * cosh(Float64(Float64(pi * f) / 4.0)))))); else tmp = Float64(log(Float64(Float64(exp(Float64(Float64(pi / 4.0) * Float64(-f))) + 1.0) / 0.5)) * t_1); end return tmp end
code[f_] := Block[{t$95$0 = N[(N[(Pi / 4.0), $MachinePrecision] * f), $MachinePrecision]}, Block[{t$95$1 = N[(-1.0 / N[(Pi / 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e-6], N[(N[(N[Log[N[(4.0 / Pi), $MachinePrecision]], $MachinePrecision] + N[(0.5 * N[(f * 0.0 + N[(N[Power[f, 2.0], $MachinePrecision] * N[(0.5 * N[(Pi * N[(Pi * 0.08333333333333333), $MachinePrecision]), $MachinePrecision] + 0.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + (-N[Log[f], $MachinePrecision])), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[t$95$0, 200.0], N[(N[(1.0 / N[(Pi / 4.0), $MachinePrecision]), $MachinePrecision] * N[Log[N[(N[(N[Power[N[Exp[0.25], $MachinePrecision], N[(Pi * f), $MachinePrecision]], $MachinePrecision] - N[Power[N[Exp[-0.25], $MachinePrecision], N[(Pi * f), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * N[Cosh[N[(N[(Pi * f), $MachinePrecision] / 4.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Log[N[(N[(N[Exp[N[(N[(Pi / 4.0), $MachinePrecision] * (-f)), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision] / 0.5), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\pi}{4} \cdot f\\
t_1 := \frac{-1}{\frac{\pi}{4}}\\
\mathbf{if}\;t_0 \leq 5 \cdot 10^{-6}:\\
\;\;\;\;\left(\log \left(\frac{4}{\pi}\right) + \mathsf{fma}\left(0.5, \mathsf{fma}\left(f, 0, {f}^{2} \cdot \mathsf{fma}\left(0.5, \pi \cdot \left(\pi \cdot 0.08333333333333333\right), 0\right)\right), -\log f\right)\right) \cdot t_1\\
\mathbf{elif}\;t_0 \leq 200:\\
\;\;\;\;\frac{1}{\frac{\pi}{4}} \cdot \log \left(\frac{{\left(e^{0.25}\right)}^{\left(\pi \cdot f\right)} - {\left(e^{-0.25}\right)}^{\left(\pi \cdot f\right)}}{2 \cdot \cosh \left(\frac{\pi \cdot f}{4}\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(\frac{e^{\frac{\pi}{4} \cdot \left(-f\right)} + 1}{0.5}\right) \cdot t_1\\
\end{array}
\end{array}
if (*.f64 (/.f64 (PI.f64) 4) f) < 5.00000000000000041e-6Initial program 5.0%
Taylor expanded in f around 0 99.0%
fma-def99.0%
distribute-rgt-out--99.0%
metadata-eval99.0%
associate-+r+99.0%
+-commutative99.0%
Simplified99.0%
Taylor expanded in f around 0 99.4%
+-commutative99.4%
distribute-lft-out99.4%
fma-def99.4%
Simplified99.4%
if 5.00000000000000041e-6 < (*.f64 (/.f64 (PI.f64) 4) f) < 200Initial program 75.2%
Taylor expanded in f around inf 75.2%
distribute-lft-neg-in75.2%
metadata-eval75.2%
exp-prod73.4%
exp-prod73.4%
Simplified73.4%
clear-num73.3%
log-div73.5%
metadata-eval73.5%
*-commutative73.5%
*-commutative73.5%
cosh-undef73.6%
Applied egg-rr73.6%
neg-sub073.6%
Simplified73.6%
if 200 < (*.f64 (/.f64 (PI.f64) 4) f) Initial program 0.0%
Applied egg-rr1.6%
Taylor expanded in f around 0 3.1%
Final simplification95.2%
(FPCore (f)
:precision binary64
(if (<= (* (/ PI 4.0) f) 2e-7)
(* -4.0 (/ (- (log (/ 4.0 PI)) (log f)) PI))
(*
(/ 1.0 (/ PI 4.0))
(log
(/
(- (pow (exp 0.25) (* PI f)) (pow (exp -0.25) (* PI f)))
(* 2.0 (cosh (/ (* PI f) 4.0))))))))
double code(double f) {
double tmp;
if (((((double) M_PI) / 4.0) * f) <= 2e-7) {
tmp = -4.0 * ((log((4.0 / ((double) M_PI))) - log(f)) / ((double) M_PI));
} else {
tmp = (1.0 / (((double) M_PI) / 4.0)) * log(((pow(exp(0.25), (((double) M_PI) * f)) - pow(exp(-0.25), (((double) M_PI) * f))) / (2.0 * cosh(((((double) M_PI) * f) / 4.0)))));
}
return tmp;
}
public static double code(double f) {
double tmp;
if (((Math.PI / 4.0) * f) <= 2e-7) {
tmp = -4.0 * ((Math.log((4.0 / Math.PI)) - Math.log(f)) / Math.PI);
} else {
tmp = (1.0 / (Math.PI / 4.0)) * Math.log(((Math.pow(Math.exp(0.25), (Math.PI * f)) - Math.pow(Math.exp(-0.25), (Math.PI * f))) / (2.0 * Math.cosh(((Math.PI * f) / 4.0)))));
}
return tmp;
}
def code(f): tmp = 0 if ((math.pi / 4.0) * f) <= 2e-7: tmp = -4.0 * ((math.log((4.0 / math.pi)) - math.log(f)) / math.pi) else: tmp = (1.0 / (math.pi / 4.0)) * math.log(((math.pow(math.exp(0.25), (math.pi * f)) - math.pow(math.exp(-0.25), (math.pi * f))) / (2.0 * math.cosh(((math.pi * f) / 4.0))))) return tmp
function code(f) tmp = 0.0 if (Float64(Float64(pi / 4.0) * f) <= 2e-7) tmp = Float64(-4.0 * Float64(Float64(log(Float64(4.0 / pi)) - log(f)) / pi)); else tmp = Float64(Float64(1.0 / Float64(pi / 4.0)) * log(Float64(Float64((exp(0.25) ^ Float64(pi * f)) - (exp(-0.25) ^ Float64(pi * f))) / Float64(2.0 * cosh(Float64(Float64(pi * f) / 4.0)))))); end return tmp end
function tmp_2 = code(f) tmp = 0.0; if (((pi / 4.0) * f) <= 2e-7) tmp = -4.0 * ((log((4.0 / pi)) - log(f)) / pi); else tmp = (1.0 / (pi / 4.0)) * log((((exp(0.25) ^ (pi * f)) - (exp(-0.25) ^ (pi * f))) / (2.0 * cosh(((pi * f) / 4.0))))); end tmp_2 = tmp; end
code[f_] := If[LessEqual[N[(N[(Pi / 4.0), $MachinePrecision] * f), $MachinePrecision], 2e-7], N[(-4.0 * N[(N[(N[Log[N[(4.0 / Pi), $MachinePrecision]], $MachinePrecision] - N[Log[f], $MachinePrecision]), $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(Pi / 4.0), $MachinePrecision]), $MachinePrecision] * N[Log[N[(N[(N[Power[N[Exp[0.25], $MachinePrecision], N[(Pi * f), $MachinePrecision]], $MachinePrecision] - N[Power[N[Exp[-0.25], $MachinePrecision], N[(Pi * f), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * N[Cosh[N[(N[(Pi * f), $MachinePrecision] / 4.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\pi}{4} \cdot f \leq 2 \cdot 10^{-7}:\\
\;\;\;\;-4 \cdot \frac{\log \left(\frac{4}{\pi}\right) - \log f}{\pi}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\pi}{4}} \cdot \log \left(\frac{{\left(e^{0.25}\right)}^{\left(\pi \cdot f\right)} - {\left(e^{-0.25}\right)}^{\left(\pi \cdot f\right)}}{2 \cdot \cosh \left(\frac{\pi \cdot f}{4}\right)}\right)\\
\end{array}
\end{array}
if (*.f64 (/.f64 (PI.f64) 4) f) < 1.9999999999999999e-7Initial program 4.6%
distribute-lft-neg-in4.6%
*-commutative4.6%
associate-/r/4.6%
associate-*l/4.6%
metadata-eval4.6%
distribute-neg-frac4.6%
Simplified4.6%
Taylor expanded in f around inf 4.6%
Taylor expanded in f around inf 4.6%
Taylor expanded in f around 0 99.5%
mul-1-neg99.5%
distribute-rgt-out--99.5%
metadata-eval99.5%
*-commutative99.5%
associate-/r*99.5%
metadata-eval99.5%
unsub-neg99.5%
Simplified99.5%
if 1.9999999999999999e-7 < (*.f64 (/.f64 (PI.f64) 4) f) Initial program 40.1%
Taylor expanded in f around inf 40.1%
distribute-lft-neg-in40.1%
metadata-eval40.1%
exp-prod39.2%
exp-prod39.2%
Simplified39.2%
clear-num39.2%
log-div39.3%
metadata-eval39.3%
*-commutative39.3%
*-commutative39.3%
cosh-undef39.3%
Applied egg-rr39.3%
neg-sub039.3%
Simplified39.3%
Final simplification95.0%
(FPCore (f)
:precision binary64
(if (<= (* (/ PI 4.0) f) 2e-7)
(* -4.0 (/ (- (log (/ 4.0 PI)) (log f)) PI))
(/
(-
(log
(/
2.0
(/
(- (pow (exp 0.25) (* PI f)) (pow (exp -0.25) (* PI f)))
(cosh (/ PI (/ 4.0 f)))))))
(* PI 0.25))))
double code(double f) {
double tmp;
if (((((double) M_PI) / 4.0) * f) <= 2e-7) {
tmp = -4.0 * ((log((4.0 / ((double) M_PI))) - log(f)) / ((double) M_PI));
} else {
tmp = -log((2.0 / ((pow(exp(0.25), (((double) M_PI) * f)) - pow(exp(-0.25), (((double) M_PI) * f))) / cosh((((double) M_PI) / (4.0 / f)))))) / (((double) M_PI) * 0.25);
}
return tmp;
}
public static double code(double f) {
double tmp;
if (((Math.PI / 4.0) * f) <= 2e-7) {
tmp = -4.0 * ((Math.log((4.0 / Math.PI)) - Math.log(f)) / Math.PI);
} else {
tmp = -Math.log((2.0 / ((Math.pow(Math.exp(0.25), (Math.PI * f)) - Math.pow(Math.exp(-0.25), (Math.PI * f))) / Math.cosh((Math.PI / (4.0 / f)))))) / (Math.PI * 0.25);
}
return tmp;
}
def code(f): tmp = 0 if ((math.pi / 4.0) * f) <= 2e-7: tmp = -4.0 * ((math.log((4.0 / math.pi)) - math.log(f)) / math.pi) else: tmp = -math.log((2.0 / ((math.pow(math.exp(0.25), (math.pi * f)) - math.pow(math.exp(-0.25), (math.pi * f))) / math.cosh((math.pi / (4.0 / f)))))) / (math.pi * 0.25) return tmp
function code(f) tmp = 0.0 if (Float64(Float64(pi / 4.0) * f) <= 2e-7) tmp = Float64(-4.0 * Float64(Float64(log(Float64(4.0 / pi)) - log(f)) / pi)); else tmp = Float64(Float64(-log(Float64(2.0 / Float64(Float64((exp(0.25) ^ Float64(pi * f)) - (exp(-0.25) ^ Float64(pi * f))) / cosh(Float64(pi / Float64(4.0 / f))))))) / Float64(pi * 0.25)); end return tmp end
function tmp_2 = code(f) tmp = 0.0; if (((pi / 4.0) * f) <= 2e-7) tmp = -4.0 * ((log((4.0 / pi)) - log(f)) / pi); else tmp = -log((2.0 / (((exp(0.25) ^ (pi * f)) - (exp(-0.25) ^ (pi * f))) / cosh((pi / (4.0 / f)))))) / (pi * 0.25); end tmp_2 = tmp; end
code[f_] := If[LessEqual[N[(N[(Pi / 4.0), $MachinePrecision] * f), $MachinePrecision], 2e-7], N[(-4.0 * N[(N[(N[Log[N[(4.0 / Pi), $MachinePrecision]], $MachinePrecision] - N[Log[f], $MachinePrecision]), $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], N[((-N[Log[N[(2.0 / N[(N[(N[Power[N[Exp[0.25], $MachinePrecision], N[(Pi * f), $MachinePrecision]], $MachinePrecision] - N[Power[N[Exp[-0.25], $MachinePrecision], N[(Pi * f), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Cosh[N[(Pi / N[(4.0 / f), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(Pi * 0.25), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\pi}{4} \cdot f \leq 2 \cdot 10^{-7}:\\
\;\;\;\;-4 \cdot \frac{\log \left(\frac{4}{\pi}\right) - \log f}{\pi}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\log \left(\frac{2}{\frac{{\left(e^{0.25}\right)}^{\left(\pi \cdot f\right)} - {\left(e^{-0.25}\right)}^{\left(\pi \cdot f\right)}}{\cosh \left(\frac{\pi}{\frac{4}{f}}\right)}}\right)}{\pi \cdot 0.25}\\
\end{array}
\end{array}
if (*.f64 (/.f64 (PI.f64) 4) f) < 1.9999999999999999e-7Initial program 4.6%
distribute-lft-neg-in4.6%
*-commutative4.6%
associate-/r/4.6%
associate-*l/4.6%
metadata-eval4.6%
distribute-neg-frac4.6%
Simplified4.6%
Taylor expanded in f around inf 4.6%
Taylor expanded in f around inf 4.6%
Taylor expanded in f around 0 99.5%
mul-1-neg99.5%
distribute-rgt-out--99.5%
metadata-eval99.5%
*-commutative99.5%
associate-/r*99.5%
metadata-eval99.5%
unsub-neg99.5%
Simplified99.5%
if 1.9999999999999999e-7 < (*.f64 (/.f64 (PI.f64) 4) f) Initial program 40.1%
Taylor expanded in f around inf 40.1%
distribute-lft-neg-in40.1%
metadata-eval40.1%
exp-prod39.2%
exp-prod39.2%
Simplified39.2%
expm1-log1p-u39.2%
expm1-udef39.3%
Applied egg-rr39.3%
expm1-def39.3%
expm1-log1p39.3%
associate-/l*39.3%
associate-/l*39.3%
Simplified39.3%
Final simplification95.0%
(FPCore (f)
:precision binary64
(if (<= (* (/ PI 4.0) f) 2e-7)
(* -4.0 (/ (- (log (/ 4.0 PI)) (log f)) PI))
(/
(-
(log
(/
(* 2.0 (cosh (/ (* PI f) 4.0)))
(- (pow (exp 0.25) (* PI f)) (pow (exp -0.25) (* PI f))))))
(* PI 0.25))))
double code(double f) {
double tmp;
if (((((double) M_PI) / 4.0) * f) <= 2e-7) {
tmp = -4.0 * ((log((4.0 / ((double) M_PI))) - log(f)) / ((double) M_PI));
} else {
tmp = -log(((2.0 * cosh(((((double) M_PI) * f) / 4.0))) / (pow(exp(0.25), (((double) M_PI) * f)) - pow(exp(-0.25), (((double) M_PI) * f))))) / (((double) M_PI) * 0.25);
}
return tmp;
}
public static double code(double f) {
double tmp;
if (((Math.PI / 4.0) * f) <= 2e-7) {
tmp = -4.0 * ((Math.log((4.0 / Math.PI)) - Math.log(f)) / Math.PI);
} else {
tmp = -Math.log(((2.0 * Math.cosh(((Math.PI * f) / 4.0))) / (Math.pow(Math.exp(0.25), (Math.PI * f)) - Math.pow(Math.exp(-0.25), (Math.PI * f))))) / (Math.PI * 0.25);
}
return tmp;
}
def code(f): tmp = 0 if ((math.pi / 4.0) * f) <= 2e-7: tmp = -4.0 * ((math.log((4.0 / math.pi)) - math.log(f)) / math.pi) else: tmp = -math.log(((2.0 * math.cosh(((math.pi * f) / 4.0))) / (math.pow(math.exp(0.25), (math.pi * f)) - math.pow(math.exp(-0.25), (math.pi * f))))) / (math.pi * 0.25) return tmp
function code(f) tmp = 0.0 if (Float64(Float64(pi / 4.0) * f) <= 2e-7) tmp = Float64(-4.0 * Float64(Float64(log(Float64(4.0 / pi)) - log(f)) / pi)); else tmp = Float64(Float64(-log(Float64(Float64(2.0 * cosh(Float64(Float64(pi * f) / 4.0))) / Float64((exp(0.25) ^ Float64(pi * f)) - (exp(-0.25) ^ Float64(pi * f)))))) / Float64(pi * 0.25)); end return tmp end
function tmp_2 = code(f) tmp = 0.0; if (((pi / 4.0) * f) <= 2e-7) tmp = -4.0 * ((log((4.0 / pi)) - log(f)) / pi); else tmp = -log(((2.0 * cosh(((pi * f) / 4.0))) / ((exp(0.25) ^ (pi * f)) - (exp(-0.25) ^ (pi * f))))) / (pi * 0.25); end tmp_2 = tmp; end
code[f_] := If[LessEqual[N[(N[(Pi / 4.0), $MachinePrecision] * f), $MachinePrecision], 2e-7], N[(-4.0 * N[(N[(N[Log[N[(4.0 / Pi), $MachinePrecision]], $MachinePrecision] - N[Log[f], $MachinePrecision]), $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], N[((-N[Log[N[(N[(2.0 * N[Cosh[N[(N[(Pi * f), $MachinePrecision] / 4.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Power[N[Exp[0.25], $MachinePrecision], N[(Pi * f), $MachinePrecision]], $MachinePrecision] - N[Power[N[Exp[-0.25], $MachinePrecision], N[(Pi * f), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(Pi * 0.25), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\pi}{4} \cdot f \leq 2 \cdot 10^{-7}:\\
\;\;\;\;-4 \cdot \frac{\log \left(\frac{4}{\pi}\right) - \log f}{\pi}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\log \left(\frac{2 \cdot \cosh \left(\frac{\pi \cdot f}{4}\right)}{{\left(e^{0.25}\right)}^{\left(\pi \cdot f\right)} - {\left(e^{-0.25}\right)}^{\left(\pi \cdot f\right)}}\right)}{\pi \cdot 0.25}\\
\end{array}
\end{array}
if (*.f64 (/.f64 (PI.f64) 4) f) < 1.9999999999999999e-7Initial program 4.6%
distribute-lft-neg-in4.6%
*-commutative4.6%
associate-/r/4.6%
associate-*l/4.6%
metadata-eval4.6%
distribute-neg-frac4.6%
Simplified4.6%
Taylor expanded in f around inf 4.6%
Taylor expanded in f around inf 4.6%
Taylor expanded in f around 0 99.5%
mul-1-neg99.5%
distribute-rgt-out--99.5%
metadata-eval99.5%
*-commutative99.5%
associate-/r*99.5%
metadata-eval99.5%
unsub-neg99.5%
Simplified99.5%
if 1.9999999999999999e-7 < (*.f64 (/.f64 (PI.f64) 4) f) Initial program 40.1%
Taylor expanded in f around inf 40.1%
distribute-lft-neg-in40.1%
metadata-eval40.1%
exp-prod39.2%
exp-prod39.2%
Simplified39.2%
associate-*l/39.3%
Applied egg-rr39.3%
Final simplification95.0%
(FPCore (f) :precision binary64 (* -4.0 (/ (- (log (/ 4.0 (pow (sqrt PI) 2.0))) (log f)) PI)))
double code(double f) {
return -4.0 * ((log((4.0 / pow(sqrt(((double) M_PI)), 2.0))) - log(f)) / ((double) M_PI));
}
public static double code(double f) {
return -4.0 * ((Math.log((4.0 / Math.pow(Math.sqrt(Math.PI), 2.0))) - Math.log(f)) / Math.PI);
}
def code(f): return -4.0 * ((math.log((4.0 / math.pow(math.sqrt(math.pi), 2.0))) - math.log(f)) / math.pi)
function code(f) return Float64(-4.0 * Float64(Float64(log(Float64(4.0 / (sqrt(pi) ^ 2.0))) - log(f)) / pi)) end
function tmp = code(f) tmp = -4.0 * ((log((4.0 / (sqrt(pi) ^ 2.0))) - log(f)) / pi); end
code[f_] := N[(-4.0 * N[(N[(N[Log[N[(4.0 / N[Power[N[Sqrt[Pi], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Log[f], $MachinePrecision]), $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-4 \cdot \frac{\log \left(\frac{4}{{\left(\sqrt{\pi}\right)}^{2}}\right) - \log f}{\pi}
\end{array}
Initial program 7.3%
distribute-lft-neg-in7.3%
*-commutative7.3%
associate-/r/7.3%
associate-*l/7.3%
metadata-eval7.3%
distribute-neg-frac7.3%
Simplified7.3%
Taylor expanded in f around inf 7.3%
Taylor expanded in f around inf 7.3%
Taylor expanded in f around 0 93.2%
mul-1-neg93.2%
distribute-rgt-out--93.2%
metadata-eval93.2%
*-commutative93.2%
associate-/r*93.2%
metadata-eval93.2%
unsub-neg93.2%
Simplified93.2%
add-sqr-sqrt93.2%
pow293.2%
Applied egg-rr93.2%
Final simplification93.2%
(FPCore (f) :precision binary64 (* -4.0 (/ (- (log (/ 4.0 PI)) (log f)) PI)))
double code(double f) {
return -4.0 * ((log((4.0 / ((double) M_PI))) - log(f)) / ((double) M_PI));
}
public static double code(double f) {
return -4.0 * ((Math.log((4.0 / Math.PI)) - Math.log(f)) / Math.PI);
}
def code(f): return -4.0 * ((math.log((4.0 / math.pi)) - math.log(f)) / math.pi)
function code(f) return Float64(-4.0 * Float64(Float64(log(Float64(4.0 / pi)) - log(f)) / pi)) end
function tmp = code(f) tmp = -4.0 * ((log((4.0 / pi)) - log(f)) / pi); end
code[f_] := N[(-4.0 * N[(N[(N[Log[N[(4.0 / Pi), $MachinePrecision]], $MachinePrecision] - N[Log[f], $MachinePrecision]), $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-4 \cdot \frac{\log \left(\frac{4}{\pi}\right) - \log f}{\pi}
\end{array}
Initial program 7.3%
distribute-lft-neg-in7.3%
*-commutative7.3%
associate-/r/7.3%
associate-*l/7.3%
metadata-eval7.3%
distribute-neg-frac7.3%
Simplified7.3%
Taylor expanded in f around inf 7.3%
Taylor expanded in f around inf 7.3%
Taylor expanded in f around 0 93.2%
mul-1-neg93.2%
distribute-rgt-out--93.2%
metadata-eval93.2%
*-commutative93.2%
associate-/r*93.2%
metadata-eval93.2%
unsub-neg93.2%
Simplified93.2%
Final simplification93.2%
(FPCore (f) :precision binary64 (* (/ 1.0 (/ PI 4.0)) (log (* f (/ (* PI 0.5) 2.0)))))
double code(double f) {
return (1.0 / (((double) M_PI) / 4.0)) * log((f * ((((double) M_PI) * 0.5) / 2.0)));
}
public static double code(double f) {
return (1.0 / (Math.PI / 4.0)) * Math.log((f * ((Math.PI * 0.5) / 2.0)));
}
def code(f): return (1.0 / (math.pi / 4.0)) * math.log((f * ((math.pi * 0.5) / 2.0)))
function code(f) return Float64(Float64(1.0 / Float64(pi / 4.0)) * log(Float64(f * Float64(Float64(pi * 0.5) / 2.0)))) end
function tmp = code(f) tmp = (1.0 / (pi / 4.0)) * log((f * ((pi * 0.5) / 2.0))); end
code[f_] := N[(N[(1.0 / N[(Pi / 4.0), $MachinePrecision]), $MachinePrecision] * N[Log[N[(f * N[(N[(Pi * 0.5), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{\pi}{4}} \cdot \log \left(f \cdot \frac{\pi \cdot 0.5}{2}\right)
\end{array}
Initial program 7.3%
Taylor expanded in f around 0 92.7%
associate-/r*92.7%
distribute-rgt-out--92.7%
metadata-eval92.7%
Simplified92.7%
clear-num92.7%
log-div92.7%
metadata-eval92.7%
Applied egg-rr92.7%
neg-sub092.7%
metadata-eval92.7%
distribute-rgt-out--92.7%
associate-/r/93.1%
distribute-rgt-out--93.1%
metadata-eval93.1%
Simplified93.1%
Final simplification93.1%
(FPCore (f) :precision binary64 (* -4.0 (/ (log (/ (/ 4.0 PI) f)) PI)))
double code(double f) {
return -4.0 * (log(((4.0 / ((double) M_PI)) / f)) / ((double) M_PI));
}
public static double code(double f) {
return -4.0 * (Math.log(((4.0 / Math.PI) / f)) / Math.PI);
}
def code(f): return -4.0 * (math.log(((4.0 / math.pi) / f)) / math.pi)
function code(f) return Float64(-4.0 * Float64(log(Float64(Float64(4.0 / pi) / f)) / pi)) end
function tmp = code(f) tmp = -4.0 * (log(((4.0 / pi) / f)) / pi); end
code[f_] := N[(-4.0 * N[(N[Log[N[(N[(4.0 / Pi), $MachinePrecision] / f), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-4 \cdot \frac{\log \left(\frac{\frac{4}{\pi}}{f}\right)}{\pi}
\end{array}
Initial program 7.3%
distribute-lft-neg-in7.3%
*-commutative7.3%
associate-/r/7.3%
associate-*l/7.3%
metadata-eval7.3%
distribute-neg-frac7.3%
Simplified7.3%
Taylor expanded in f around inf 7.3%
Taylor expanded in f around inf 7.3%
Taylor expanded in f around 0 93.2%
mul-1-neg93.2%
distribute-rgt-out--93.2%
metadata-eval93.2%
*-commutative93.2%
associate-/r*93.2%
metadata-eval93.2%
unsub-neg93.2%
Simplified93.2%
diff-log92.9%
Applied egg-rr92.9%
Final simplification92.9%
(FPCore (f) :precision binary64 (* (/ (log 0.25) PI) (- -4.0)))
double code(double f) {
return (log(0.25) / ((double) M_PI)) * -(-4.0);
}
public static double code(double f) {
return (Math.log(0.25) / Math.PI) * -(-4.0);
}
def code(f): return (math.log(0.25) / math.pi) * -(-4.0)
function code(f) return Float64(Float64(log(0.25) / pi) * Float64(-(-4.0))) end
function tmp = code(f) tmp = (log(0.25) / pi) * -(-4.0); end
code[f_] := N[(N[(N[Log[0.25], $MachinePrecision] / Pi), $MachinePrecision] * (--4.0)), $MachinePrecision]
\begin{array}{l}
\\
\frac{\log 0.25}{\pi} \cdot \left(--4\right)
\end{array}
Initial program 7.3%
Applied egg-rr13.8%
clear-num13.8%
log-div13.8%
metadata-eval13.8%
cosh-undef13.8%
associate-*l/13.8%
Applied egg-rr13.8%
neg-sub013.8%
associate-/r*13.8%
metadata-eval13.8%
Simplified13.8%
Taylor expanded in f around 0 13.9%
Final simplification13.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)))))))))