
(FPCore (F l) :precision binary64 (- (* PI l) (* (/ 1.0 (* F F)) (tan (* PI l)))))
double code(double F, double l) {
return (((double) M_PI) * l) - ((1.0 / (F * F)) * tan((((double) M_PI) * l)));
}
public static double code(double F, double l) {
return (Math.PI * l) - ((1.0 / (F * F)) * Math.tan((Math.PI * l)));
}
def code(F, l): return (math.pi * l) - ((1.0 / (F * F)) * math.tan((math.pi * l)))
function code(F, l) return Float64(Float64(pi * l) - Float64(Float64(1.0 / Float64(F * F)) * tan(Float64(pi * l)))) end
function tmp = code(F, l) tmp = (pi * l) - ((1.0 / (F * F)) * tan((pi * l))); end
code[F_, l_] := N[(N[(Pi * l), $MachinePrecision] - N[(N[(1.0 / N[(F * F), $MachinePrecision]), $MachinePrecision] * N[Tan[N[(Pi * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (F l) :precision binary64 (- (* PI l) (* (/ 1.0 (* F F)) (tan (* PI l)))))
double code(double F, double l) {
return (((double) M_PI) * l) - ((1.0 / (F * F)) * tan((((double) M_PI) * l)));
}
public static double code(double F, double l) {
return (Math.PI * l) - ((1.0 / (F * F)) * Math.tan((Math.PI * l)));
}
def code(F, l): return (math.pi * l) - ((1.0 / (F * F)) * math.tan((math.pi * l)))
function code(F, l) return Float64(Float64(pi * l) - Float64(Float64(1.0 / Float64(F * F)) * tan(Float64(pi * l)))) end
function tmp = code(F, l) tmp = (pi * l) - ((1.0 / (F * F)) * tan((pi * l))); end
code[F_, l_] := N[(N[(Pi * l), $MachinePrecision] - N[(N[(1.0 / N[(F * F), $MachinePrecision]), $MachinePrecision] * N[Tan[N[(Pi * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right)
\end{array}
(FPCore (F l) :precision binary64 (if (or (<= (* PI l) -5e+23) (not (<= (* PI l) 10000000000000.0))) (+ (* PI l) -1.0) (- (* PI l) (/ (/ (tan (* PI l)) F) F))))
double code(double F, double l) {
double tmp;
if (((((double) M_PI) * l) <= -5e+23) || !((((double) M_PI) * l) <= 10000000000000.0)) {
tmp = (((double) M_PI) * l) + -1.0;
} else {
tmp = (((double) M_PI) * l) - ((tan((((double) M_PI) * l)) / F) / F);
}
return tmp;
}
public static double code(double F, double l) {
double tmp;
if (((Math.PI * l) <= -5e+23) || !((Math.PI * l) <= 10000000000000.0)) {
tmp = (Math.PI * l) + -1.0;
} else {
tmp = (Math.PI * l) - ((Math.tan((Math.PI * l)) / F) / F);
}
return tmp;
}
def code(F, l): tmp = 0 if ((math.pi * l) <= -5e+23) or not ((math.pi * l) <= 10000000000000.0): tmp = (math.pi * l) + -1.0 else: tmp = (math.pi * l) - ((math.tan((math.pi * l)) / F) / F) return tmp
function code(F, l) tmp = 0.0 if ((Float64(pi * l) <= -5e+23) || !(Float64(pi * l) <= 10000000000000.0)) tmp = Float64(Float64(pi * l) + -1.0); else tmp = Float64(Float64(pi * l) - Float64(Float64(tan(Float64(pi * l)) / F) / F)); end return tmp end
function tmp_2 = code(F, l) tmp = 0.0; if (((pi * l) <= -5e+23) || ~(((pi * l) <= 10000000000000.0))) tmp = (pi * l) + -1.0; else tmp = (pi * l) - ((tan((pi * l)) / F) / F); end tmp_2 = tmp; end
code[F_, l_] := If[Or[LessEqual[N[(Pi * l), $MachinePrecision], -5e+23], N[Not[LessEqual[N[(Pi * l), $MachinePrecision], 10000000000000.0]], $MachinePrecision]], N[(N[(Pi * l), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(Pi * l), $MachinePrecision] - N[(N[(N[Tan[N[(Pi * l), $MachinePrecision]], $MachinePrecision] / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\pi \cdot \ell \leq -5 \cdot 10^{+23} \lor \neg \left(\pi \cdot \ell \leq 10000000000000\right):\\
\;\;\;\;\pi \cdot \ell + -1\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell - \frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}\\
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < -4.9999999999999999e23 or 1e13 < (*.f64 (PI.f64) l) Initial program 62.3%
add-cbrt-cube56.8%
pow356.8%
inv-pow56.8%
unpow-prod-down56.8%
pow-prod-up56.8%
metadata-eval56.8%
pow-pow56.8%
metadata-eval56.8%
metadata-eval56.8%
metadata-eval56.8%
Applied egg-rr56.8%
Applied egg-rr54.9%
*-inverses99.5%
Simplified99.5%
if -4.9999999999999999e23 < (*.f64 (PI.f64) l) < 1e13Initial program 90.6%
associate-*l/90.7%
*-un-lft-identity90.7%
associate-/r*99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (F l) :precision binary64 (if (or (<= (* PI l) -5e+23) (not (<= (* PI l) 10000000000000.0))) (+ (* PI l) -1.0) (- (* PI l) (* (/ l F) (/ PI F)))))
double code(double F, double l) {
double tmp;
if (((((double) M_PI) * l) <= -5e+23) || !((((double) M_PI) * l) <= 10000000000000.0)) {
tmp = (((double) M_PI) * l) + -1.0;
} else {
tmp = (((double) M_PI) * l) - ((l / F) * (((double) M_PI) / F));
}
return tmp;
}
public static double code(double F, double l) {
double tmp;
if (((Math.PI * l) <= -5e+23) || !((Math.PI * l) <= 10000000000000.0)) {
tmp = (Math.PI * l) + -1.0;
} else {
tmp = (Math.PI * l) - ((l / F) * (Math.PI / F));
}
return tmp;
}
def code(F, l): tmp = 0 if ((math.pi * l) <= -5e+23) or not ((math.pi * l) <= 10000000000000.0): tmp = (math.pi * l) + -1.0 else: tmp = (math.pi * l) - ((l / F) * (math.pi / F)) return tmp
function code(F, l) tmp = 0.0 if ((Float64(pi * l) <= -5e+23) || !(Float64(pi * l) <= 10000000000000.0)) tmp = Float64(Float64(pi * l) + -1.0); else tmp = Float64(Float64(pi * l) - Float64(Float64(l / F) * Float64(pi / F))); end return tmp end
function tmp_2 = code(F, l) tmp = 0.0; if (((pi * l) <= -5e+23) || ~(((pi * l) <= 10000000000000.0))) tmp = (pi * l) + -1.0; else tmp = (pi * l) - ((l / F) * (pi / F)); end tmp_2 = tmp; end
code[F_, l_] := If[Or[LessEqual[N[(Pi * l), $MachinePrecision], -5e+23], N[Not[LessEqual[N[(Pi * l), $MachinePrecision], 10000000000000.0]], $MachinePrecision]], N[(N[(Pi * l), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(Pi * l), $MachinePrecision] - N[(N[(l / F), $MachinePrecision] * N[(Pi / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\pi \cdot \ell \leq -5 \cdot 10^{+23} \lor \neg \left(\pi \cdot \ell \leq 10000000000000\right):\\
\;\;\;\;\pi \cdot \ell + -1\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell - \frac{\ell}{F} \cdot \frac{\pi}{F}\\
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < -4.9999999999999999e23 or 1e13 < (*.f64 (PI.f64) l) Initial program 62.3%
add-cbrt-cube56.8%
pow356.8%
inv-pow56.8%
unpow-prod-down56.8%
pow-prod-up56.8%
metadata-eval56.8%
pow-pow56.8%
metadata-eval56.8%
metadata-eval56.8%
metadata-eval56.8%
Applied egg-rr56.8%
Applied egg-rr54.9%
*-inverses99.5%
Simplified99.5%
if -4.9999999999999999e23 < (*.f64 (PI.f64) l) < 1e13Initial program 90.6%
Taylor expanded in l around 0 88.2%
unpow288.2%
times-frac96.9%
Simplified96.9%
Final simplification98.1%
(FPCore (F l) :precision binary64 (if (or (<= (* PI l) -5e+23) (not (<= (* PI l) 10000000000000.0))) (+ (* PI l) -1.0) (- (* PI l) (/ PI (* F (/ F l))))))
double code(double F, double l) {
double tmp;
if (((((double) M_PI) * l) <= -5e+23) || !((((double) M_PI) * l) <= 10000000000000.0)) {
tmp = (((double) M_PI) * l) + -1.0;
} else {
tmp = (((double) M_PI) * l) - (((double) M_PI) / (F * (F / l)));
}
return tmp;
}
public static double code(double F, double l) {
double tmp;
if (((Math.PI * l) <= -5e+23) || !((Math.PI * l) <= 10000000000000.0)) {
tmp = (Math.PI * l) + -1.0;
} else {
tmp = (Math.PI * l) - (Math.PI / (F * (F / l)));
}
return tmp;
}
def code(F, l): tmp = 0 if ((math.pi * l) <= -5e+23) or not ((math.pi * l) <= 10000000000000.0): tmp = (math.pi * l) + -1.0 else: tmp = (math.pi * l) - (math.pi / (F * (F / l))) return tmp
function code(F, l) tmp = 0.0 if ((Float64(pi * l) <= -5e+23) || !(Float64(pi * l) <= 10000000000000.0)) tmp = Float64(Float64(pi * l) + -1.0); else tmp = Float64(Float64(pi * l) - Float64(pi / Float64(F * Float64(F / l)))); end return tmp end
function tmp_2 = code(F, l) tmp = 0.0; if (((pi * l) <= -5e+23) || ~(((pi * l) <= 10000000000000.0))) tmp = (pi * l) + -1.0; else tmp = (pi * l) - (pi / (F * (F / l))); end tmp_2 = tmp; end
code[F_, l_] := If[Or[LessEqual[N[(Pi * l), $MachinePrecision], -5e+23], N[Not[LessEqual[N[(Pi * l), $MachinePrecision], 10000000000000.0]], $MachinePrecision]], N[(N[(Pi * l), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(Pi * l), $MachinePrecision] - N[(Pi / N[(F * N[(F / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\pi \cdot \ell \leq -5 \cdot 10^{+23} \lor \neg \left(\pi \cdot \ell \leq 10000000000000\right):\\
\;\;\;\;\pi \cdot \ell + -1\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell - \frac{\pi}{F \cdot \frac{F}{\ell}}\\
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < -4.9999999999999999e23 or 1e13 < (*.f64 (PI.f64) l) Initial program 62.3%
add-cbrt-cube56.8%
pow356.8%
inv-pow56.8%
unpow-prod-down56.8%
pow-prod-up56.8%
metadata-eval56.8%
pow-pow56.8%
metadata-eval56.8%
metadata-eval56.8%
metadata-eval56.8%
Applied egg-rr56.8%
Applied egg-rr54.9%
*-inverses99.5%
Simplified99.5%
if -4.9999999999999999e23 < (*.f64 (PI.f64) l) < 1e13Initial program 90.6%
Taylor expanded in l around 0 88.2%
unpow288.2%
times-frac96.9%
Simplified96.9%
clear-num96.8%
frac-times97.0%
*-un-lft-identity97.0%
Applied egg-rr97.0%
Final simplification98.1%
(FPCore (F l) :precision binary64 (+ (* PI l) -1.0))
double code(double F, double l) {
return (((double) M_PI) * l) + -1.0;
}
public static double code(double F, double l) {
return (Math.PI * l) + -1.0;
}
def code(F, l): return (math.pi * l) + -1.0
function code(F, l) return Float64(Float64(pi * l) + -1.0) end
function tmp = code(F, l) tmp = (pi * l) + -1.0; end
code[F_, l_] := N[(N[(Pi * l), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\pi \cdot \ell + -1
\end{array}
Initial program 77.6%
add-cbrt-cube66.1%
pow366.1%
inv-pow66.1%
unpow-prod-down66.1%
pow-prod-up66.1%
metadata-eval66.1%
pow-pow66.1%
metadata-eval66.1%
metadata-eval66.1%
metadata-eval66.1%
Applied egg-rr66.1%
Applied egg-rr27.5%
*-inverses49.6%
Simplified49.6%
Final simplification49.6%
herbie shell --seed 2023273
(FPCore (F l)
:name "VandenBroeck and Keller, Equation (6)"
:precision binary64
(- (* PI l) (* (/ 1.0 (* F F)) (tan (* PI l)))))