
(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) -2e+21) (not (<= (* PI l) 500000.0))) (* PI l) (+ (* PI l) (/ (* (tan (* PI l)) (/ -1.0 F)) F))))
double code(double F, double l) {
double tmp;
if (((((double) M_PI) * l) <= -2e+21) || !((((double) M_PI) * l) <= 500000.0)) {
tmp = ((double) M_PI) * l;
} else {
tmp = (((double) M_PI) * l) + ((tan((((double) M_PI) * l)) * (-1.0 / F)) / F);
}
return tmp;
}
public static double code(double F, double l) {
double tmp;
if (((Math.PI * l) <= -2e+21) || !((Math.PI * l) <= 500000.0)) {
tmp = Math.PI * l;
} else {
tmp = (Math.PI * l) + ((Math.tan((Math.PI * l)) * (-1.0 / F)) / F);
}
return tmp;
}
def code(F, l): tmp = 0 if ((math.pi * l) <= -2e+21) or not ((math.pi * l) <= 500000.0): tmp = math.pi * l else: tmp = (math.pi * l) + ((math.tan((math.pi * l)) * (-1.0 / F)) / F) return tmp
function code(F, l) tmp = 0.0 if ((Float64(pi * l) <= -2e+21) || !(Float64(pi * l) <= 500000.0)) tmp = Float64(pi * l); else tmp = Float64(Float64(pi * l) + Float64(Float64(tan(Float64(pi * l)) * Float64(-1.0 / F)) / F)); end return tmp end
function tmp_2 = code(F, l) tmp = 0.0; if (((pi * l) <= -2e+21) || ~(((pi * l) <= 500000.0))) tmp = pi * l; else tmp = (pi * l) + ((tan((pi * l)) * (-1.0 / F)) / F); end tmp_2 = tmp; end
code[F_, l_] := If[Or[LessEqual[N[(Pi * l), $MachinePrecision], -2e+21], N[Not[LessEqual[N[(Pi * l), $MachinePrecision], 500000.0]], $MachinePrecision]], N[(Pi * l), $MachinePrecision], N[(N[(Pi * l), $MachinePrecision] + N[(N[(N[Tan[N[(Pi * l), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / F), $MachinePrecision]), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\pi \cdot \ell \leq -2 \cdot 10^{+21} \lor \neg \left(\pi \cdot \ell \leq 500000\right):\\
\;\;\;\;\pi \cdot \ell\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell + \frac{\tan \left(\pi \cdot \ell\right) \cdot \frac{-1}{F}}{F}\\
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < -2e21 or 5e5 < (*.f64 (PI.f64) l) Initial program 62.5%
Taylor expanded in l around 0 51.4%
associate-/l*51.4%
associate-/r/51.4%
unpow251.4%
Simplified51.4%
*-commutative51.4%
clear-num51.4%
un-div-inv51.4%
associate-/l*51.4%
Applied egg-rr51.4%
Taylor expanded in F around inf 99.6%
if -2e21 < (*.f64 (PI.f64) l) < 5e5Initial program 85.9%
associate-/r*85.9%
metadata-eval85.9%
add-sqr-sqrt47.5%
sqrt-prod67.8%
sqrt-div67.8%
associate-*l/67.8%
sqrt-div69.8%
metadata-eval69.8%
sqrt-prod56.8%
add-sqr-sqrt99.1%
Applied egg-rr99.1%
Final simplification99.3%
(FPCore (F l) :precision binary64 (if (or (<= (* PI l) -2e+21) (not (<= (* PI l) 500000.0))) (* PI l) (- (* PI l) (/ (/ (tan (* PI l)) F) F))))
double code(double F, double l) {
double tmp;
if (((((double) M_PI) * l) <= -2e+21) || !((((double) M_PI) * l) <= 500000.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) <= -2e+21) || !((Math.PI * l) <= 500000.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) <= -2e+21) or not ((math.pi * l) <= 500000.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) <= -2e+21) || !(Float64(pi * l) <= 500000.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) <= -2e+21) || ~(((pi * l) <= 500000.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], -2e+21], N[Not[LessEqual[N[(Pi * l), $MachinePrecision], 500000.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 -2 \cdot 10^{+21} \lor \neg \left(\pi \cdot \ell \leq 500000\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) < -2e21 or 5e5 < (*.f64 (PI.f64) l) Initial program 62.5%
Taylor expanded in l around 0 51.4%
associate-/l*51.4%
associate-/r/51.4%
unpow251.4%
Simplified51.4%
*-commutative51.4%
clear-num51.4%
un-div-inv51.4%
associate-/l*51.4%
Applied egg-rr51.4%
Taylor expanded in F around inf 99.6%
if -2e21 < (*.f64 (PI.f64) l) < 5e5Initial program 85.9%
associate-*l/87.9%
*-un-lft-identity87.9%
associate-/r*99.1%
Applied egg-rr99.1%
Final simplification99.3%
(FPCore (F l) :precision binary64 (if (or (<= (* PI l) -2e+21) (not (<= (* PI l) 500000.0))) (* PI l) (- (* PI l) (* (/ PI F) (/ l F)))))
double code(double F, double l) {
double tmp;
if (((((double) M_PI) * l) <= -2e+21) || !((((double) M_PI) * l) <= 500000.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) <= -2e+21) || !((Math.PI * l) <= 500000.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) <= -2e+21) or not ((math.pi * l) <= 500000.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) <= -2e+21) || !(Float64(pi * l) <= 500000.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) <= -2e+21) || ~(((pi * l) <= 500000.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], -2e+21], N[Not[LessEqual[N[(Pi * l), $MachinePrecision], 500000.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 -2 \cdot 10^{+21} \lor \neg \left(\pi \cdot \ell \leq 500000\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) < -2e21 or 5e5 < (*.f64 (PI.f64) l) Initial program 62.5%
Taylor expanded in l around 0 51.4%
associate-/l*51.4%
associate-/r/51.4%
unpow251.4%
Simplified51.4%
*-commutative51.4%
clear-num51.4%
un-div-inv51.4%
associate-/l*51.4%
Applied egg-rr51.4%
Taylor expanded in F around inf 99.6%
if -2e21 < (*.f64 (PI.f64) l) < 5e5Initial program 85.9%
Taylor expanded in l around 0 86.6%
associate-/l*86.6%
associate-/r/86.6%
unpow286.6%
Simplified86.6%
Taylor expanded in l around 0 86.6%
unpow286.6%
*-commutative86.6%
times-frac97.9%
Simplified97.9%
Final simplification98.8%
(FPCore (F l) :precision binary64 (if (or (<= (* PI l) -2e+21) (not (<= (* PI l) 500000.0))) (* PI l) (- (* PI l) (/ PI (* F (/ F l))))))
double code(double F, double l) {
double tmp;
if (((((double) M_PI) * l) <= -2e+21) || !((((double) M_PI) * l) <= 500000.0)) {
tmp = ((double) M_PI) * l;
} 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) <= -2e+21) || !((Math.PI * l) <= 500000.0)) {
tmp = Math.PI * l;
} else {
tmp = (Math.PI * l) - (Math.PI / (F * (F / l)));
}
return tmp;
}
def code(F, l): tmp = 0 if ((math.pi * l) <= -2e+21) or not ((math.pi * l) <= 500000.0): tmp = math.pi * l else: tmp = (math.pi * l) - (math.pi / (F * (F / l))) return tmp
function code(F, l) tmp = 0.0 if ((Float64(pi * l) <= -2e+21) || !(Float64(pi * l) <= 500000.0)) tmp = Float64(pi * l); 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) <= -2e+21) || ~(((pi * l) <= 500000.0))) tmp = pi * l; else tmp = (pi * l) - (pi / (F * (F / l))); end tmp_2 = tmp; end
code[F_, l_] := If[Or[LessEqual[N[(Pi * l), $MachinePrecision], -2e+21], N[Not[LessEqual[N[(Pi * l), $MachinePrecision], 500000.0]], $MachinePrecision]], N[(Pi * l), $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 -2 \cdot 10^{+21} \lor \neg \left(\pi \cdot \ell \leq 500000\right):\\
\;\;\;\;\pi \cdot \ell\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell - \frac{\pi}{F \cdot \frac{F}{\ell}}\\
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < -2e21 or 5e5 < (*.f64 (PI.f64) l) Initial program 62.5%
Taylor expanded in l around 0 51.4%
associate-/l*51.4%
associate-/r/51.4%
unpow251.4%
Simplified51.4%
*-commutative51.4%
clear-num51.4%
un-div-inv51.4%
associate-/l*51.4%
Applied egg-rr51.4%
Taylor expanded in F around inf 99.6%
if -2e21 < (*.f64 (PI.f64) l) < 5e5Initial program 85.9%
Taylor expanded in l around 0 86.6%
associate-/l*86.6%
associate-/r/86.6%
unpow286.6%
Simplified86.6%
*-commutative86.6%
clear-num86.6%
un-div-inv86.6%
associate-/l*97.8%
Applied egg-rr97.8%
associate-/r/97.9%
Applied egg-rr97.9%
Final simplification98.8%
(FPCore (F l) :precision binary64 (if (or (<= (* PI l) -2e+21) (not (<= (* PI l) 500000.0))) (* PI l) (* PI (- l (/ l (* F F))))))
double code(double F, double l) {
double tmp;
if (((((double) M_PI) * l) <= -2e+21) || !((((double) M_PI) * l) <= 500000.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 (((Math.PI * l) <= -2e+21) || !((Math.PI * l) <= 500000.0)) {
tmp = Math.PI * l;
} else {
tmp = Math.PI * (l - (l / (F * F)));
}
return tmp;
}
def code(F, l): tmp = 0 if ((math.pi * l) <= -2e+21) or not ((math.pi * l) <= 500000.0): tmp = math.pi * l else: tmp = math.pi * (l - (l / (F * F))) return tmp
function code(F, l) tmp = 0.0 if ((Float64(pi * l) <= -2e+21) || !(Float64(pi * l) <= 500000.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 (((pi * l) <= -2e+21) || ~(((pi * l) <= 500000.0))) tmp = pi * l; else tmp = pi * (l - (l / (F * F))); end tmp_2 = tmp; end
code[F_, l_] := If[Or[LessEqual[N[(Pi * l), $MachinePrecision], -2e+21], N[Not[LessEqual[N[(Pi * l), $MachinePrecision], 500000.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}\;\pi \cdot \ell \leq -2 \cdot 10^{+21} \lor \neg \left(\pi \cdot \ell \leq 500000\right):\\
\;\;\;\;\pi \cdot \ell\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \left(\ell - \frac{\ell}{F \cdot F}\right)\\
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < -2e21 or 5e5 < (*.f64 (PI.f64) l) Initial program 62.5%
Taylor expanded in l around 0 51.4%
associate-/l*51.4%
associate-/r/51.4%
unpow251.4%
Simplified51.4%
*-commutative51.4%
clear-num51.4%
un-div-inv51.4%
associate-/l*51.4%
Applied egg-rr51.4%
Taylor expanded in F around inf 99.6%
if -2e21 < (*.f64 (PI.f64) l) < 5e5Initial program 85.9%
Taylor expanded in l around 0 86.6%
associate-/l*86.6%
associate-/r/86.6%
unpow286.6%
Simplified86.6%
*-commutative86.6%
clear-num86.6%
un-div-inv86.6%
associate-/l*97.8%
Applied egg-rr97.8%
Taylor expanded in F around 0 86.6%
mul-1-neg86.6%
associate-*l/86.6%
unpow286.6%
distribute-lft-neg-in86.6%
distribute-rgt-in86.6%
sub-neg86.6%
Simplified86.6%
Final simplification93.6%
(FPCore (F l) :precision binary64 (if (or (<= (* PI l) -1e-129) (not (<= (* PI l) 5e-295))) (* PI l) (* PI (/ (- l) (* F F)))))
double code(double F, double l) {
double tmp;
if (((((double) M_PI) * l) <= -1e-129) || !((((double) M_PI) * l) <= 5e-295)) {
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 (((Math.PI * l) <= -1e-129) || !((Math.PI * l) <= 5e-295)) {
tmp = Math.PI * l;
} else {
tmp = Math.PI * (-l / (F * F));
}
return tmp;
}
def code(F, l): tmp = 0 if ((math.pi * l) <= -1e-129) or not ((math.pi * l) <= 5e-295): tmp = math.pi * l else: tmp = math.pi * (-l / (F * F)) return tmp
function code(F, l) tmp = 0.0 if ((Float64(pi * l) <= -1e-129) || !(Float64(pi * l) <= 5e-295)) 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 (((pi * l) <= -1e-129) || ~(((pi * l) <= 5e-295))) tmp = pi * l; else tmp = pi * (-l / (F * F)); end tmp_2 = tmp; end
code[F_, l_] := If[Or[LessEqual[N[(Pi * l), $MachinePrecision], -1e-129], N[Not[LessEqual[N[(Pi * l), $MachinePrecision], 5e-295]], $MachinePrecision]], N[(Pi * l), $MachinePrecision], N[(Pi * N[((-l) / N[(F * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\pi \cdot \ell \leq -1 \cdot 10^{-129} \lor \neg \left(\pi \cdot \ell \leq 5 \cdot 10^{-295}\right):\\
\;\;\;\;\pi \cdot \ell\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \frac{-\ell}{F \cdot F}\\
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < -9.9999999999999993e-130 or 5.00000000000000008e-295 < (*.f64 (PI.f64) l) Initial program 72.0%
Taylor expanded in l around 0 65.6%
associate-/l*65.6%
associate-/r/65.6%
unpow265.6%
Simplified65.6%
*-commutative65.6%
clear-num65.6%
un-div-inv65.6%
associate-/l*69.4%
Applied egg-rr69.4%
Taylor expanded in F around inf 83.5%
if -9.9999999999999993e-130 < (*.f64 (PI.f64) l) < 5.00000000000000008e-295Initial program 83.4%
Taylor expanded in l around 0 83.4%
associate-/l*83.5%
associate-/r/83.4%
unpow283.4%
Simplified83.4%
*-commutative83.4%
clear-num83.2%
un-div-inv83.3%
associate-/l*99.4%
Applied egg-rr99.4%
Taylor expanded in F around 0 60.1%
*-commutative60.1%
associate-*r/60.1%
neg-mul-160.1%
distribute-rgt-neg-out60.1%
associate-*r/60.1%
unpow260.1%
Simplified60.1%
Final simplification80.8%
(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 73.3%
Taylor expanded in l around 0 67.6%
associate-/l*67.6%
associate-/r/67.6%
unpow267.6%
Simplified67.6%
*-commutative67.6%
clear-num67.6%
un-div-inv67.6%
associate-/l*72.8%
Applied egg-rr72.8%
Taylor expanded in F around inf 77.0%
Final simplification77.0%
herbie shell --seed 2023182
(FPCore (F l)
:name "VandenBroeck and Keller, Equation (6)"
:precision binary64
(- (* PI l) (* (/ 1.0 (* F F)) (tan (* PI l)))))