
(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) -1e+27) (not (<= (* PI l) 10000000000.0))) (* PI l) (+ (* PI l) (/ (/ (* (sin (* PI l)) (/ -1.0 (cos (* PI l)))) F) F))))
double code(double F, double l) {
double tmp;
if (((((double) M_PI) * l) <= -1e+27) || !((((double) M_PI) * l) <= 10000000000.0)) {
tmp = ((double) M_PI) * l;
} else {
tmp = (((double) M_PI) * l) + (((sin((((double) M_PI) * l)) * (-1.0 / cos((((double) M_PI) * l)))) / F) / F);
}
return tmp;
}
public static double code(double F, double l) {
double tmp;
if (((Math.PI * l) <= -1e+27) || !((Math.PI * l) <= 10000000000.0)) {
tmp = Math.PI * l;
} else {
tmp = (Math.PI * l) + (((Math.sin((Math.PI * l)) * (-1.0 / Math.cos((Math.PI * l)))) / F) / F);
}
return tmp;
}
def code(F, l): tmp = 0 if ((math.pi * l) <= -1e+27) or not ((math.pi * l) <= 10000000000.0): tmp = math.pi * l else: tmp = (math.pi * l) + (((math.sin((math.pi * l)) * (-1.0 / math.cos((math.pi * l)))) / F) / F) return tmp
function code(F, l) tmp = 0.0 if ((Float64(pi * l) <= -1e+27) || !(Float64(pi * l) <= 10000000000.0)) tmp = Float64(pi * l); else tmp = Float64(Float64(pi * l) + Float64(Float64(Float64(sin(Float64(pi * l)) * Float64(-1.0 / cos(Float64(pi * l)))) / F) / F)); end return tmp end
function tmp_2 = code(F, l) tmp = 0.0; if (((pi * l) <= -1e+27) || ~(((pi * l) <= 10000000000.0))) tmp = pi * l; else tmp = (pi * l) + (((sin((pi * l)) * (-1.0 / cos((pi * l)))) / F) / F); end tmp_2 = tmp; end
code[F_, l_] := If[Or[LessEqual[N[(Pi * l), $MachinePrecision], -1e+27], N[Not[LessEqual[N[(Pi * l), $MachinePrecision], 10000000000.0]], $MachinePrecision]], N[(Pi * l), $MachinePrecision], N[(N[(Pi * l), $MachinePrecision] + N[(N[(N[(N[Sin[N[(Pi * l), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / N[Cos[N[(Pi * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\pi \cdot \ell \leq -1 \cdot 10^{+27} \lor \neg \left(\pi \cdot \ell \leq 10000000000\right):\\
\;\;\;\;\pi \cdot \ell\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell + \frac{\frac{\sin \left(\pi \cdot \ell\right) \cdot \frac{-1}{\cos \left(\pi \cdot \ell\right)}}{F}}{F}\\
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < -1e27 or 1e10 < (*.f64 (PI.f64) l) Initial program 71.4%
associate-*l/71.4%
*-lft-identity71.4%
Simplified71.4%
Taylor expanded in l around 0 57.1%
unpow257.1%
Simplified57.1%
Taylor expanded in F around inf 99.6%
if -1e27 < (*.f64 (PI.f64) l) < 1e10Initial program 88.2%
associate-*l/88.9%
*-un-lft-identity88.9%
associate-/r*99.0%
Applied egg-rr99.0%
tan-quot99.0%
div-inv99.0%
Applied egg-rr99.0%
Final simplification99.2%
(FPCore (F l) :precision binary64 (if (or (<= (* PI l) -1e+27) (not (<= (* PI l) 10000000000.0))) (* PI l) (- (* PI l) (/ (/ (tan (* PI l)) F) F))))
double code(double F, double l) {
double tmp;
if (((((double) M_PI) * l) <= -1e+27) || !((((double) M_PI) * l) <= 10000000000.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) <= -1e+27) || !((Math.PI * l) <= 10000000000.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) <= -1e+27) or not ((math.pi * l) <= 10000000000.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) <= -1e+27) || !(Float64(pi * l) <= 10000000000.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) <= -1e+27) || ~(((pi * l) <= 10000000000.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], -1e+27], N[Not[LessEqual[N[(Pi * l), $MachinePrecision], 10000000000.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 -1 \cdot 10^{+27} \lor \neg \left(\pi \cdot \ell \leq 10000000000\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) < -1e27 or 1e10 < (*.f64 (PI.f64) l) Initial program 71.4%
associate-*l/71.4%
*-lft-identity71.4%
Simplified71.4%
Taylor expanded in l around 0 57.1%
unpow257.1%
Simplified57.1%
Taylor expanded in F around inf 99.6%
if -1e27 < (*.f64 (PI.f64) l) < 1e10Initial program 88.2%
associate-*l/88.9%
*-un-lft-identity88.9%
associate-/r*99.0%
Applied egg-rr99.0%
Final simplification99.2%
(FPCore (F l) :precision binary64 (if (or (<= (* PI l) -10000000000000.0) (not (<= (* PI l) 100000000.0))) (* PI l) (- (* PI l) (* PI (/ (/ l F) F)))))
double code(double F, double l) {
double tmp;
if (((((double) M_PI) * l) <= -10000000000000.0) || !((((double) M_PI) * l) <= 100000000.0)) {
tmp = ((double) M_PI) * l;
} else {
tmp = (((double) M_PI) * l) - (((double) M_PI) * ((l / F) / F));
}
return tmp;
}
public static double code(double F, double l) {
double tmp;
if (((Math.PI * l) <= -10000000000000.0) || !((Math.PI * l) <= 100000000.0)) {
tmp = Math.PI * l;
} else {
tmp = (Math.PI * l) - (Math.PI * ((l / F) / F));
}
return tmp;
}
def code(F, l): tmp = 0 if ((math.pi * l) <= -10000000000000.0) or not ((math.pi * l) <= 100000000.0): tmp = math.pi * l else: tmp = (math.pi * l) - (math.pi * ((l / F) / F)) return tmp
function code(F, l) tmp = 0.0 if ((Float64(pi * l) <= -10000000000000.0) || !(Float64(pi * l) <= 100000000.0)) tmp = Float64(pi * l); else tmp = Float64(Float64(pi * l) - Float64(pi * Float64(Float64(l / F) / F))); end return tmp end
function tmp_2 = code(F, l) tmp = 0.0; if (((pi * l) <= -10000000000000.0) || ~(((pi * l) <= 100000000.0))) tmp = pi * l; else tmp = (pi * l) - (pi * ((l / F) / F)); end tmp_2 = tmp; end
code[F_, l_] := If[Or[LessEqual[N[(Pi * l), $MachinePrecision], -10000000000000.0], N[Not[LessEqual[N[(Pi * l), $MachinePrecision], 100000000.0]], $MachinePrecision]], N[(Pi * l), $MachinePrecision], N[(N[(Pi * l), $MachinePrecision] - N[(Pi * N[(N[(l / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\pi \cdot \ell \leq -10000000000000 \lor \neg \left(\pi \cdot \ell \leq 100000000\right):\\
\;\;\;\;\pi \cdot \ell\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell - \pi \cdot \frac{\frac{\ell}{F}}{F}\\
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < -1e13 or 1e8 < (*.f64 (PI.f64) l) Initial program 71.7%
associate-*l/71.7%
*-lft-identity71.7%
Simplified71.7%
Taylor expanded in l around 0 56.5%
unpow256.5%
Simplified56.5%
Taylor expanded in F around inf 97.9%
if -1e13 < (*.f64 (PI.f64) l) < 1e8Initial program 88.3%
associate-*l/89.0%
*-un-lft-identity89.0%
associate-/r*99.3%
Applied egg-rr99.3%
Taylor expanded in l around 0 98.9%
associate-/l*98.9%
associate-/r/98.9%
Simplified98.9%
associate-/l*99.0%
associate-/r/99.0%
Applied egg-rr99.0%
Final simplification98.5%
(FPCore (F l) :precision binary64 (if (or (<= l -3300000000000.0) (not (<= l 860000000.0))) (* PI l) (* PI (- l (/ l (* F F))))))
double code(double F, double l) {
double tmp;
if ((l <= -3300000000000.0) || !(l <= 860000000.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 <= -3300000000000.0) || !(l <= 860000000.0)) {
tmp = Math.PI * l;
} else {
tmp = Math.PI * (l - (l / (F * F)));
}
return tmp;
}
def code(F, l): tmp = 0 if (l <= -3300000000000.0) or not (l <= 860000000.0): tmp = math.pi * l else: tmp = math.pi * (l - (l / (F * F))) return tmp
function code(F, l) tmp = 0.0 if ((l <= -3300000000000.0) || !(l <= 860000000.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 <= -3300000000000.0) || ~((l <= 860000000.0))) tmp = pi * l; else tmp = pi * (l - (l / (F * F))); end tmp_2 = tmp; end
code[F_, l_] := If[Or[LessEqual[l, -3300000000000.0], N[Not[LessEqual[l, 860000000.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 -3300000000000 \lor \neg \left(\ell \leq 860000000\right):\\
\;\;\;\;\pi \cdot \ell\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \left(\ell - \frac{\ell}{F \cdot F}\right)\\
\end{array}
\end{array}
if l < -3.3e12 or 8.6e8 < l Initial program 71.7%
associate-*l/71.7%
*-lft-identity71.7%
Simplified71.7%
Taylor expanded in l around 0 56.5%
unpow256.5%
Simplified56.5%
Taylor expanded in F around inf 97.9%
if -3.3e12 < l < 8.6e8Initial program 88.3%
associate-*l/89.0%
*-un-lft-identity89.0%
associate-/r*99.3%
Applied egg-rr99.3%
Taylor expanded in l around 0 98.9%
associate-/l*98.9%
associate-/r/98.9%
Simplified98.9%
Taylor expanded in l around 0 88.0%
sub-neg88.0%
mul-1-neg88.0%
distribute-rgt-in88.0%
associate-*r/88.0%
unpow288.0%
times-frac87.9%
metadata-eval87.9%
distribute-neg-frac87.9%
associate-*r*98.9%
distribute-neg-frac98.9%
metadata-eval98.9%
associate-/r/98.9%
associate-/l*98.9%
times-frac88.6%
*-commutative88.6%
unpow288.6%
associate-*r/88.6%
Simplified88.6%
Final simplification92.7%
(FPCore (F l) :precision binary64 (if (<= (* F F) 2e-173) (/ (- l) (/ (* F F) PI)) (* PI l)))
double code(double F, double l) {
double tmp;
if ((F * F) <= 2e-173) {
tmp = -l / ((F * F) / ((double) M_PI));
} else {
tmp = ((double) M_PI) * l;
}
return tmp;
}
public static double code(double F, double l) {
double tmp;
if ((F * F) <= 2e-173) {
tmp = -l / ((F * F) / Math.PI);
} else {
tmp = Math.PI * l;
}
return tmp;
}
def code(F, l): tmp = 0 if (F * F) <= 2e-173: tmp = -l / ((F * F) / math.pi) else: tmp = math.pi * l return tmp
function code(F, l) tmp = 0.0 if (Float64(F * F) <= 2e-173) tmp = Float64(Float64(-l) / Float64(Float64(F * F) / pi)); else tmp = Float64(pi * l); end return tmp end
function tmp_2 = code(F, l) tmp = 0.0; if ((F * F) <= 2e-173) tmp = -l / ((F * F) / pi); else tmp = pi * l; end tmp_2 = tmp; end
code[F_, l_] := If[LessEqual[N[(F * F), $MachinePrecision], 2e-173], N[((-l) / N[(N[(F * F), $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], N[(Pi * l), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \cdot F \leq 2 \cdot 10^{-173}:\\
\;\;\;\;\frac{-\ell}{\frac{F \cdot F}{\pi}}\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell\\
\end{array}
\end{array}
if (*.f64 F F) < 2.0000000000000001e-173Initial program 49.3%
associate-*l/50.5%
*-lft-identity50.5%
Simplified50.5%
Taylor expanded in l around 0 47.1%
unpow247.1%
Simplified47.1%
Taylor expanded in F around 0 48.3%
mul-1-neg48.3%
unpow248.3%
associate-/l*48.1%
Simplified48.1%
if 2.0000000000000001e-173 < (*.f64 F F) Initial program 96.2%
associate-*l/96.2%
*-lft-identity96.2%
Simplified96.2%
Taylor expanded in l around 0 87.0%
unpow287.0%
Simplified87.0%
Taylor expanded in F around inf 89.6%
Final simplification76.2%
(FPCore (F l) :precision binary64 (if (<= (* F F) 2e-173) (* PI (/ (/ (- l) F) F)) (* PI l)))
double code(double F, double l) {
double tmp;
if ((F * F) <= 2e-173) {
tmp = ((double) M_PI) * ((-l / F) / F);
} else {
tmp = ((double) M_PI) * l;
}
return tmp;
}
public static double code(double F, double l) {
double tmp;
if ((F * F) <= 2e-173) {
tmp = Math.PI * ((-l / F) / F);
} else {
tmp = Math.PI * l;
}
return tmp;
}
def code(F, l): tmp = 0 if (F * F) <= 2e-173: tmp = math.pi * ((-l / F) / F) else: tmp = math.pi * l return tmp
function code(F, l) tmp = 0.0 if (Float64(F * F) <= 2e-173) tmp = Float64(pi * Float64(Float64(Float64(-l) / F) / F)); else tmp = Float64(pi * l); end return tmp end
function tmp_2 = code(F, l) tmp = 0.0; if ((F * F) <= 2e-173) tmp = pi * ((-l / F) / F); else tmp = pi * l; end tmp_2 = tmp; end
code[F_, l_] := If[LessEqual[N[(F * F), $MachinePrecision], 2e-173], N[(Pi * N[(N[((-l) / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision], N[(Pi * l), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \cdot F \leq 2 \cdot 10^{-173}:\\
\;\;\;\;\pi \cdot \frac{\frac{-\ell}{F}}{F}\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell\\
\end{array}
\end{array}
if (*.f64 F F) < 2.0000000000000001e-173Initial program 49.3%
associate-*l/50.5%
*-un-lft-identity50.5%
associate-/r*68.2%
Applied egg-rr68.2%
Taylor expanded in l around 0 66.0%
associate-/l*66.1%
associate-/r/66.1%
Simplified66.1%
Taylor expanded in F around 0 48.3%
mul-1-neg48.3%
associate-/l*48.1%
distribute-neg-frac48.1%
unpow248.1%
Simplified48.1%
frac-2neg48.1%
associate-/r/48.3%
add-sqr-sqrt18.9%
sqrt-prod12.4%
sqr-neg12.4%
sqrt-unprod2.1%
add-sqr-sqrt3.2%
frac-2neg3.2%
associate-/r*3.2%
add-sqr-sqrt2.1%
sqrt-unprod13.6%
sqr-neg13.6%
sqrt-prod24.1%
add-sqr-sqrt66.1%
Applied egg-rr66.1%
if 2.0000000000000001e-173 < (*.f64 F F) Initial program 96.2%
associate-*l/96.2%
*-lft-identity96.2%
Simplified96.2%
Taylor expanded in l around 0 87.0%
unpow287.0%
Simplified87.0%
Taylor expanded in F around inf 89.6%
Final simplification82.0%
(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 81.0%
associate-*l/81.4%
*-lft-identity81.4%
Simplified81.4%
Taylor expanded in l around 0 74.1%
unpow274.1%
Simplified74.1%
Taylor expanded in F around inf 71.4%
Final simplification71.4%
herbie shell --seed 2023207
(FPCore (F l)
:name "VandenBroeck and Keller, Equation (6)"
:precision binary64
(- (* PI l) (* (/ 1.0 (* F F)) (tan (* PI l)))))