
(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 7 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+26) (not (<= (* PI l) 5000000000000.0))) (* PI l) (- (* PI l) (/ (/ (tan (* PI l)) F) F))))
double code(double F, double l) {
double tmp;
if (((((double) M_PI) * l) <= -5e+26) || !((((double) M_PI) * l) <= 5000000000000.0)) {
tmp = ((double) M_PI) * l;
} 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+26) || !((Math.PI * l) <= 5000000000000.0)) {
tmp = Math.PI * l;
} 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+26) or not ((math.pi * l) <= 5000000000000.0): tmp = math.pi * l 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+26) || !(Float64(pi * l) <= 5000000000000.0)) tmp = Float64(pi * l); 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+26) || ~(((pi * l) <= 5000000000000.0))) tmp = pi * l; 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+26], N[Not[LessEqual[N[(Pi * l), $MachinePrecision], 5000000000000.0]], $MachinePrecision]], N[(Pi * l), $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^{+26} \lor \neg \left(\pi \cdot \ell \leq 5000000000000\right):\\
\;\;\;\;\pi \cdot \ell\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell - \frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}\\
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < -5.0000000000000001e26 or 5e12 < (*.f64 (PI.f64) l) Initial program 62.4%
associate-*l/62.4%
*-lft-identity62.4%
Simplified62.4%
Taylor expanded in l around 0 48.4%
unpow248.4%
Simplified48.4%
Taylor expanded in F around inf 99.5%
if -5.0000000000000001e26 < (*.f64 (PI.f64) l) < 5e12Initial program 88.2%
associate-*l/89.7%
*-un-lft-identity89.7%
associate-/r*98.1%
Applied egg-rr98.1%
Final simplification98.8%
(FPCore (F l) :precision binary64 (if (or (<= (* PI l) -5e+26) (not (<= (* PI l) 5000000.0))) (* PI l) (- (* PI l) (* (/ PI F) (/ l F)))))
double code(double F, double l) {
double tmp;
if (((((double) M_PI) * l) <= -5e+26) || !((((double) M_PI) * l) <= 5000000.0)) {
tmp = ((double) M_PI) * l;
} else {
tmp = (((double) M_PI) * l) - ((((double) M_PI) / F) * (l / F));
}
return tmp;
}
public static double code(double F, double l) {
double tmp;
if (((Math.PI * l) <= -5e+26) || !((Math.PI * l) <= 5000000.0)) {
tmp = Math.PI * l;
} else {
tmp = (Math.PI * l) - ((Math.PI / F) * (l / F));
}
return tmp;
}
def code(F, l): tmp = 0 if ((math.pi * l) <= -5e+26) or not ((math.pi * l) <= 5000000.0): tmp = math.pi * l else: tmp = (math.pi * l) - ((math.pi / F) * (l / F)) return tmp
function code(F, l) tmp = 0.0 if ((Float64(pi * l) <= -5e+26) || !(Float64(pi * l) <= 5000000.0)) tmp = Float64(pi * l); else tmp = Float64(Float64(pi * l) - Float64(Float64(pi / F) * Float64(l / F))); end return tmp end
function tmp_2 = code(F, l) tmp = 0.0; if (((pi * l) <= -5e+26) || ~(((pi * l) <= 5000000.0))) tmp = pi * l; else tmp = (pi * l) - ((pi / F) * (l / F)); end tmp_2 = tmp; end
code[F_, l_] := If[Or[LessEqual[N[(Pi * l), $MachinePrecision], -5e+26], N[Not[LessEqual[N[(Pi * l), $MachinePrecision], 5000000.0]], $MachinePrecision]], N[(Pi * l), $MachinePrecision], N[(N[(Pi * l), $MachinePrecision] - N[(N[(Pi / F), $MachinePrecision] * N[(l / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\pi \cdot \ell \leq -5 \cdot 10^{+26} \lor \neg \left(\pi \cdot \ell \leq 5000000\right):\\
\;\;\;\;\pi \cdot \ell\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell - \frac{\pi}{F} \cdot \frac{\ell}{F}\\
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < -5.0000000000000001e26 or 5e6 < (*.f64 (PI.f64) l) Initial program 62.7%
associate-*l/62.7%
*-lft-identity62.7%
Simplified62.7%
Taylor expanded in l around 0 48.1%
unpow248.1%
Simplified48.1%
Taylor expanded in F around inf 97.3%
if -5.0000000000000001e26 < (*.f64 (PI.f64) l) < 5e6Initial program 88.9%
associate-*l/90.5%
*-un-lft-identity90.5%
associate-/r*99.2%
Applied egg-rr99.2%
Taylor expanded in l around 0 89.3%
*-commutative89.3%
unpow289.3%
times-frac98.1%
Simplified98.1%
Final simplification97.7%
(FPCore (F l)
:precision binary64
(if (or (<= l -3500000.0)
(not
(or (<= l -1.4e-121) (and (not (<= l -1.06e-195)) (<= l 9e-202)))))
(* PI l)
(* PI (/ (/ (- l) F) F))))
double code(double F, double l) {
double tmp;
if ((l <= -3500000.0) || !((l <= -1.4e-121) || (!(l <= -1.06e-195) && (l <= 9e-202)))) {
tmp = ((double) M_PI) * l;
} else {
tmp = ((double) M_PI) * ((-l / F) / F);
}
return tmp;
}
public static double code(double F, double l) {
double tmp;
if ((l <= -3500000.0) || !((l <= -1.4e-121) || (!(l <= -1.06e-195) && (l <= 9e-202)))) {
tmp = Math.PI * l;
} else {
tmp = Math.PI * ((-l / F) / F);
}
return tmp;
}
def code(F, l): tmp = 0 if (l <= -3500000.0) or not ((l <= -1.4e-121) or (not (l <= -1.06e-195) and (l <= 9e-202))): tmp = math.pi * l else: tmp = math.pi * ((-l / F) / F) return tmp
function code(F, l) tmp = 0.0 if ((l <= -3500000.0) || !((l <= -1.4e-121) || (!(l <= -1.06e-195) && (l <= 9e-202)))) tmp = Float64(pi * l); else tmp = Float64(pi * Float64(Float64(Float64(-l) / F) / F)); end return tmp end
function tmp_2 = code(F, l) tmp = 0.0; if ((l <= -3500000.0) || ~(((l <= -1.4e-121) || (~((l <= -1.06e-195)) && (l <= 9e-202))))) tmp = pi * l; else tmp = pi * ((-l / F) / F); end tmp_2 = tmp; end
code[F_, l_] := If[Or[LessEqual[l, -3500000.0], N[Not[Or[LessEqual[l, -1.4e-121], And[N[Not[LessEqual[l, -1.06e-195]], $MachinePrecision], LessEqual[l, 9e-202]]]], $MachinePrecision]], N[(Pi * l), $MachinePrecision], N[(Pi * N[(N[((-l) / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3500000 \lor \neg \left(\ell \leq -1.4 \cdot 10^{-121} \lor \neg \left(\ell \leq -1.06 \cdot 10^{-195}\right) \land \ell \leq 9 \cdot 10^{-202}\right):\\
\;\;\;\;\pi \cdot \ell\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \frac{\frac{-\ell}{F}}{F}\\
\end{array}
\end{array}
if l < -3.5e6 or -1.4000000000000001e-121 < l < -1.06e-195 or 9.00000000000000078e-202 < l Initial program 71.9%
associate-*l/72.6%
*-lft-identity72.6%
Simplified72.6%
Taylor expanded in l around 0 61.8%
unpow261.8%
Simplified61.8%
Taylor expanded in F around inf 88.1%
if -3.5e6 < l < -1.4000000000000001e-121 or -1.06e-195 < l < 9.00000000000000078e-202Initial program 85.3%
associate-*l/86.4%
*-un-lft-identity86.4%
associate-/r*98.9%
Applied egg-rr98.9%
Taylor expanded in l around 0 84.1%
*-commutative84.1%
unpow284.1%
times-frac96.8%
Simplified96.8%
Taylor expanded in F around 0 50.4%
mul-1-neg50.4%
associate-*l/50.5%
distribute-lft-neg-in50.5%
unpow250.5%
associate-/r*63.1%
associate-/r*50.5%
Simplified50.5%
Taylor expanded in l around 0 50.4%
mul-1-neg50.4%
associate-/l*50.5%
associate-/r/50.5%
unpow250.5%
associate-/r*63.1%
*-rgt-identity63.1%
associate-*r/63.1%
*-rgt-identity63.1%
associate-*r/63.1%
associate-*r*49.4%
unpow-149.4%
unpow-149.4%
pow-sqr49.4%
metadata-eval49.4%
distribute-rgt-neg-in49.4%
Simplified63.1%
Final simplification81.4%
(FPCore (F l) :precision binary64 (if (or (<= l -2.9e+24) (not (<= l 3600000.0))) (* PI l) (* PI (- l (/ l (* F F))))))
double code(double F, double l) {
double tmp;
if ((l <= -2.9e+24) || !(l <= 3600000.0)) {
tmp = ((double) M_PI) * l;
} else {
tmp = ((double) M_PI) * (l - (l / (F * F)));
}
return tmp;
}
public static double code(double F, double l) {
double tmp;
if ((l <= -2.9e+24) || !(l <= 3600000.0)) {
tmp = Math.PI * l;
} else {
tmp = Math.PI * (l - (l / (F * F)));
}
return tmp;
}
def code(F, l): tmp = 0 if (l <= -2.9e+24) or not (l <= 3600000.0): tmp = math.pi * l else: tmp = math.pi * (l - (l / (F * F))) return tmp
function code(F, l) tmp = 0.0 if ((l <= -2.9e+24) || !(l <= 3600000.0)) tmp = Float64(pi * l); else tmp = Float64(pi * Float64(l - Float64(l / Float64(F * F)))); end return tmp end
function tmp_2 = code(F, l) tmp = 0.0; if ((l <= -2.9e+24) || ~((l <= 3600000.0))) tmp = pi * l; else tmp = pi * (l - (l / (F * F))); end tmp_2 = tmp; end
code[F_, l_] := If[Or[LessEqual[l, -2.9e+24], N[Not[LessEqual[l, 3600000.0]], $MachinePrecision]], N[(Pi * l), $MachinePrecision], N[(Pi * N[(l - N[(l / N[(F * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.9 \cdot 10^{+24} \lor \neg \left(\ell \leq 3600000\right):\\
\;\;\;\;\pi \cdot \ell\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \left(\ell - \frac{\ell}{F \cdot F}\right)\\
\end{array}
\end{array}
if l < -2.89999999999999979e24 or 3.6e6 < l Initial program 62.7%
associate-*l/62.7%
*-lft-identity62.7%
Simplified62.7%
Taylor expanded in l around 0 48.1%
unpow248.1%
Simplified48.1%
Taylor expanded in F around inf 97.3%
if -2.89999999999999979e24 < l < 3.6e6Initial program 88.9%
associate-*l/90.5%
*-un-lft-identity90.5%
associate-/r*99.2%
Applied egg-rr99.2%
Taylor expanded in l around 0 89.3%
*-commutative89.3%
unpow289.3%
times-frac98.1%
Simplified98.1%
Taylor expanded in l around 0 87.8%
distribute-rgt-out--87.8%
associate-*l/89.3%
*-commutative89.3%
associate-*l/89.3%
unpow289.3%
associate-/r*98.2%
*-commutative98.2%
distribute-rgt-out--98.2%
associate-/r*89.3%
Simplified89.3%
Final simplification93.4%
(FPCore (F l) :precision binary64 (if (or (<= l -3500000.0) (not (<= l -1.42e-117))) (* PI l) (* (/ PI (* F F)) (- l))))
double code(double F, double l) {
double tmp;
if ((l <= -3500000.0) || !(l <= -1.42e-117)) {
tmp = ((double) M_PI) * l;
} else {
tmp = (((double) M_PI) / (F * F)) * -l;
}
return tmp;
}
public static double code(double F, double l) {
double tmp;
if ((l <= -3500000.0) || !(l <= -1.42e-117)) {
tmp = Math.PI * l;
} else {
tmp = (Math.PI / (F * F)) * -l;
}
return tmp;
}
def code(F, l): tmp = 0 if (l <= -3500000.0) or not (l <= -1.42e-117): tmp = math.pi * l else: tmp = (math.pi / (F * F)) * -l return tmp
function code(F, l) tmp = 0.0 if ((l <= -3500000.0) || !(l <= -1.42e-117)) tmp = Float64(pi * l); else tmp = Float64(Float64(pi / Float64(F * F)) * Float64(-l)); end return tmp end
function tmp_2 = code(F, l) tmp = 0.0; if ((l <= -3500000.0) || ~((l <= -1.42e-117))) tmp = pi * l; else tmp = (pi / (F * F)) * -l; end tmp_2 = tmp; end
code[F_, l_] := If[Or[LessEqual[l, -3500000.0], N[Not[LessEqual[l, -1.42e-117]], $MachinePrecision]], N[(Pi * l), $MachinePrecision], N[(N[(Pi / N[(F * F), $MachinePrecision]), $MachinePrecision] * (-l)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3500000 \lor \neg \left(\ell \leq -1.42 \cdot 10^{-117}\right):\\
\;\;\;\;\pi \cdot \ell\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi}{F \cdot F} \cdot \left(-\ell\right)\\
\end{array}
\end{array}
if l < -3.5e6 or -1.42000000000000001e-117 < l Initial program 74.1%
associate-*l/74.7%
*-lft-identity74.7%
Simplified74.7%
Taylor expanded in l around 0 65.8%
unpow265.8%
Simplified65.8%
Taylor expanded in F around inf 80.1%
if -3.5e6 < l < -1.42000000000000001e-117Initial program 85.9%
associate-*l/88.4%
*-lft-identity88.4%
Simplified88.4%
Taylor expanded in l around 0 80.9%
unpow280.9%
Simplified80.9%
Taylor expanded in F around 0 54.2%
associate-*r/54.2%
neg-mul-154.2%
unpow254.2%
Simplified54.2%
Final simplification77.2%
(FPCore (F l) :precision binary64 (if (or (<= l -3500000.0) (not (<= l -1.85e-116))) (* PI l) (* PI (/ (- l) (* F F)))))
double code(double F, double l) {
double tmp;
if ((l <= -3500000.0) || !(l <= -1.85e-116)) {
tmp = ((double) M_PI) * l;
} else {
tmp = ((double) M_PI) * (-l / (F * F));
}
return tmp;
}
public static double code(double F, double l) {
double tmp;
if ((l <= -3500000.0) || !(l <= -1.85e-116)) {
tmp = Math.PI * l;
} else {
tmp = Math.PI * (-l / (F * F));
}
return tmp;
}
def code(F, l): tmp = 0 if (l <= -3500000.0) or not (l <= -1.85e-116): tmp = math.pi * l else: tmp = math.pi * (-l / (F * F)) return tmp
function code(F, l) tmp = 0.0 if ((l <= -3500000.0) || !(l <= -1.85e-116)) tmp = Float64(pi * l); else tmp = Float64(pi * Float64(Float64(-l) / Float64(F * F))); end return tmp end
function tmp_2 = code(F, l) tmp = 0.0; if ((l <= -3500000.0) || ~((l <= -1.85e-116))) tmp = pi * l; else tmp = pi * (-l / (F * F)); end tmp_2 = tmp; end
code[F_, l_] := If[Or[LessEqual[l, -3500000.0], N[Not[LessEqual[l, -1.85e-116]], $MachinePrecision]], N[(Pi * l), $MachinePrecision], N[(Pi * N[((-l) / N[(F * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3500000 \lor \neg \left(\ell \leq -1.85 \cdot 10^{-116}\right):\\
\;\;\;\;\pi \cdot \ell\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \frac{-\ell}{F \cdot F}\\
\end{array}
\end{array}
if l < -3.5e6 or -1.8500000000000001e-116 < l Initial program 74.1%
associate-*l/74.7%
*-lft-identity74.7%
Simplified74.7%
Taylor expanded in l around 0 65.8%
unpow265.8%
Simplified65.8%
Taylor expanded in F around inf 80.1%
if -3.5e6 < l < -1.8500000000000001e-116Initial program 85.9%
associate-*l/88.4%
*-un-lft-identity88.4%
associate-/r*98.4%
Applied egg-rr98.4%
Taylor expanded in l around 0 83.2%
*-commutative83.2%
unpow283.2%
times-frac93.3%
Simplified93.3%
Taylor expanded in F around 0 56.5%
mul-1-neg56.5%
associate-*l/56.5%
distribute-lft-neg-in56.5%
unpow256.5%
associate-/r*66.7%
associate-/r*56.5%
Simplified56.5%
Final simplification77.4%
(FPCore (F l) :precision binary64 (* PI l))
double code(double F, double l) {
return ((double) M_PI) * l;
}
public static double code(double F, double l) {
return Math.PI * l;
}
def code(F, l): return math.pi * l
function code(F, l) return Float64(pi * l) end
function tmp = code(F, l) tmp = pi * l; end
code[F_, l_] := N[(Pi * l), $MachinePrecision]
\begin{array}{l}
\\
\pi \cdot \ell
\end{array}
Initial program 75.5%
associate-*l/76.2%
*-lft-identity76.2%
Simplified76.2%
Taylor expanded in l around 0 67.5%
unpow267.5%
Simplified67.5%
Taylor expanded in F around inf 74.2%
Final simplification74.2%
herbie shell --seed 2023250
(FPCore (F l)
:name "VandenBroeck and Keller, Equation (6)"
:precision binary64
(- (* PI l) (* (/ 1.0 (* F F)) (tan (* PI l)))))