
(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+16) (not (<= (* PI l) 40000000.0))) (* PI l) (- (* PI l) (/ (/ (tan (* PI l)) F) F))))
double code(double F, double l) {
double tmp;
if (((((double) M_PI) * l) <= -2e+16) || !((((double) M_PI) * l) <= 40000000.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+16) || !((Math.PI * l) <= 40000000.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+16) or not ((math.pi * l) <= 40000000.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+16) || !(Float64(pi * l) <= 40000000.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+16) || ~(((pi * l) <= 40000000.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+16], N[Not[LessEqual[N[(Pi * l), $MachinePrecision], 40000000.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^{+16} \lor \neg \left(\pi \cdot \ell \leq 40000000\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) < -2e16 or 4e7 < (*.f64 (PI.f64) l) Initial program 64.5%
associate-*l/64.5%
*-lft-identity64.5%
Simplified64.5%
Taylor expanded in l around 0 50.1%
unpow250.1%
Simplified50.1%
Taylor expanded in F around inf 99.6%
if -2e16 < (*.f64 (PI.f64) l) < 4e7Initial program 90.2%
associate-*l/90.4%
*-un-lft-identity90.4%
associate-/r*98.7%
Applied egg-rr98.7%
Final simplification99.1%
(FPCore (F l) :precision binary64 (if (or (<= (* PI l) -100000000000.0) (not (<= (* PI l) 40000000.0))) (* PI l) (- (* PI l) (* (/ PI F) (/ l F)))))
double code(double F, double l) {
double tmp;
if (((((double) M_PI) * l) <= -100000000000.0) || !((((double) M_PI) * l) <= 40000000.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) <= -100000000000.0) || !((Math.PI * l) <= 40000000.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) <= -100000000000.0) or not ((math.pi * l) <= 40000000.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) <= -100000000000.0) || !(Float64(pi * l) <= 40000000.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) <= -100000000000.0) || ~(((pi * l) <= 40000000.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], -100000000000.0], N[Not[LessEqual[N[(Pi * l), $MachinePrecision], 40000000.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 -100000000000 \lor \neg \left(\pi \cdot \ell \leq 40000000\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) < -1e11 or 4e7 < (*.f64 (PI.f64) l) Initial program 64.3%
associate-*l/64.3%
*-lft-identity64.3%
Simplified64.3%
Taylor expanded in l around 0 49.7%
unpow249.7%
Simplified49.7%
Taylor expanded in F around inf 98.8%
if -1e11 < (*.f64 (PI.f64) l) < 4e7Initial program 90.6%
inv-pow90.6%
unpow-prod-down90.5%
inv-pow90.5%
inv-pow90.5%
Applied egg-rr90.5%
Taylor expanded in l around 0 90.0%
*-commutative90.0%
unpow290.0%
times-frac98.4%
Simplified98.4%
Final simplification98.6%
(FPCore (F l) :precision binary64 (if (or (<= l -1450000000.0) (not (<= l 1e+15))) (* PI l) (- (* PI l) (* PI (/ l (* F F))))))
double code(double F, double l) {
double tmp;
if ((l <= -1450000000.0) || !(l <= 1e+15)) {
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 ((l <= -1450000000.0) || !(l <= 1e+15)) {
tmp = Math.PI * l;
} else {
tmp = (Math.PI * l) - (Math.PI * (l / (F * F)));
}
return tmp;
}
def code(F, l): tmp = 0 if (l <= -1450000000.0) or not (l <= 1e+15): tmp = math.pi * l else: tmp = (math.pi * l) - (math.pi * (l / (F * F))) return tmp
function code(F, l) tmp = 0.0 if ((l <= -1450000000.0) || !(l <= 1e+15)) tmp = Float64(pi * l); else tmp = Float64(Float64(pi * l) - Float64(pi * Float64(l / Float64(F * F)))); end return tmp end
function tmp_2 = code(F, l) tmp = 0.0; if ((l <= -1450000000.0) || ~((l <= 1e+15))) tmp = pi * l; else tmp = (pi * l) - (pi * (l / (F * F))); end tmp_2 = tmp; end
code[F_, l_] := If[Or[LessEqual[l, -1450000000.0], N[Not[LessEqual[l, 1e+15]], $MachinePrecision]], N[(Pi * l), $MachinePrecision], N[(N[(Pi * l), $MachinePrecision] - N[(Pi * N[(l / N[(F * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1450000000 \lor \neg \left(\ell \leq 10^{+15}\right):\\
\;\;\;\;\pi \cdot \ell\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell - \pi \cdot \frac{\ell}{F \cdot F}\\
\end{array}
\end{array}
if l < -1.45e9 or 1e15 < l Initial program 64.3%
associate-*l/64.3%
*-lft-identity64.3%
Simplified64.3%
Taylor expanded in l around 0 49.7%
unpow249.7%
Simplified49.7%
Taylor expanded in F around inf 98.8%
if -1.45e9 < l < 1e15Initial program 90.6%
Taylor expanded in l around 0 90.0%
associate-/l*90.0%
associate-/r/90.0%
unpow290.0%
Simplified90.0%
Final simplification94.0%
(FPCore (F l) :precision binary64 (if (or (<= l -1450000000.0) (not (<= l 1e+15))) (* PI l) (* l (* PI (- 1.0 (pow F -2.0))))))
double code(double F, double l) {
double tmp;
if ((l <= -1450000000.0) || !(l <= 1e+15)) {
tmp = ((double) M_PI) * l;
} else {
tmp = l * (((double) M_PI) * (1.0 - pow(F, -2.0)));
}
return tmp;
}
public static double code(double F, double l) {
double tmp;
if ((l <= -1450000000.0) || !(l <= 1e+15)) {
tmp = Math.PI * l;
} else {
tmp = l * (Math.PI * (1.0 - Math.pow(F, -2.0)));
}
return tmp;
}
def code(F, l): tmp = 0 if (l <= -1450000000.0) or not (l <= 1e+15): tmp = math.pi * l else: tmp = l * (math.pi * (1.0 - math.pow(F, -2.0))) return tmp
function code(F, l) tmp = 0.0 if ((l <= -1450000000.0) || !(l <= 1e+15)) tmp = Float64(pi * l); else tmp = Float64(l * Float64(pi * Float64(1.0 - (F ^ -2.0)))); end return tmp end
function tmp_2 = code(F, l) tmp = 0.0; if ((l <= -1450000000.0) || ~((l <= 1e+15))) tmp = pi * l; else tmp = l * (pi * (1.0 - (F ^ -2.0))); end tmp_2 = tmp; end
code[F_, l_] := If[Or[LessEqual[l, -1450000000.0], N[Not[LessEqual[l, 1e+15]], $MachinePrecision]], N[(Pi * l), $MachinePrecision], N[(l * N[(Pi * N[(1.0 - N[Power[F, -2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1450000000 \lor \neg \left(\ell \leq 10^{+15}\right):\\
\;\;\;\;\pi \cdot \ell\\
\mathbf{else}:\\
\;\;\;\;\ell \cdot \left(\pi \cdot \left(1 - {F}^{-2}\right)\right)\\
\end{array}
\end{array}
if l < -1.45e9 or 1e15 < l Initial program 64.3%
associate-*l/64.3%
*-lft-identity64.3%
Simplified64.3%
Taylor expanded in l around 0 49.7%
unpow249.7%
Simplified49.7%
Taylor expanded in F around inf 98.8%
if -1.45e9 < l < 1e15Initial program 90.6%
associate-*l/90.8%
*-lft-identity90.8%
Simplified90.8%
Taylor expanded in l around 0 88.4%
unpow288.4%
Simplified88.4%
sub-neg88.4%
distribute-lft-in88.4%
*-commutative88.4%
div-inv88.4%
metadata-eval88.4%
frac-times88.4%
distribute-rgt-neg-in88.4%
inv-pow88.4%
inv-pow88.4%
pow-prod-up88.4%
metadata-eval88.4%
Applied egg-rr88.4%
*-commutative88.4%
distribute-rgt-out88.4%
distribute-rgt-neg-out88.4%
sub-neg88.4%
*-rgt-identity88.4%
distribute-lft-out--88.4%
Simplified88.4%
Final simplification93.1%
(FPCore (F l)
:precision binary64
(if (or (<= l -0.008)
(not (or (<= l -3e-106) (and (not (<= l 3.5e-138)) (<= l 1.2e-27)))))
(* PI l)
(* PI (/ (- l) (* F F)))))
double code(double F, double l) {
double tmp;
if ((l <= -0.008) || !((l <= -3e-106) || (!(l <= 3.5e-138) && (l <= 1.2e-27)))) {
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 <= -0.008) || !((l <= -3e-106) || (!(l <= 3.5e-138) && (l <= 1.2e-27)))) {
tmp = Math.PI * l;
} else {
tmp = Math.PI * (-l / (F * F));
}
return tmp;
}
def code(F, l): tmp = 0 if (l <= -0.008) or not ((l <= -3e-106) or (not (l <= 3.5e-138) and (l <= 1.2e-27))): tmp = math.pi * l else: tmp = math.pi * (-l / (F * F)) return tmp
function code(F, l) tmp = 0.0 if ((l <= -0.008) || !((l <= -3e-106) || (!(l <= 3.5e-138) && (l <= 1.2e-27)))) 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 <= -0.008) || ~(((l <= -3e-106) || (~((l <= 3.5e-138)) && (l <= 1.2e-27))))) tmp = pi * l; else tmp = pi * (-l / (F * F)); end tmp_2 = tmp; end
code[F_, l_] := If[Or[LessEqual[l, -0.008], N[Not[Or[LessEqual[l, -3e-106], And[N[Not[LessEqual[l, 3.5e-138]], $MachinePrecision], LessEqual[l, 1.2e-27]]]], $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 -0.008 \lor \neg \left(\ell \leq -3 \cdot 10^{-106} \lor \neg \left(\ell \leq 3.5 \cdot 10^{-138}\right) \land \ell \leq 1.2 \cdot 10^{-27}\right):\\
\;\;\;\;\pi \cdot \ell\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \frac{-\ell}{F \cdot F}\\
\end{array}
\end{array}
if l < -0.0080000000000000002 or -3.00000000000000019e-106 < l < 3.4999999999999999e-138 or 1.20000000000000001e-27 < l Initial program 74.7%
associate-*l/74.8%
*-lft-identity74.8%
Simplified74.8%
Taylor expanded in l around 0 65.4%
unpow265.4%
Simplified65.4%
Taylor expanded in F around inf 80.1%
if -0.0080000000000000002 < l < -3.00000000000000019e-106 or 3.4999999999999999e-138 < l < 1.20000000000000001e-27Initial program 99.7%
associate-*l/99.6%
*-lft-identity99.6%
Simplified99.6%
Taylor expanded in l around 0 99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in F around 0 71.4%
mul-1-neg71.4%
unpow271.4%
Simplified71.4%
associate-/l*71.5%
associate-/r/71.4%
Applied egg-rr71.4%
Final simplification78.7%
(FPCore (F l)
:precision binary64
(if (or (<= F -1.4e-27)
(and (not (<= F -1.15e-162))
(or (<= F -1.75e-205) (not (<= F 2.5e-111)))))
(* PI l)
(* (/ PI F) (/ (- l) F))))
double code(double F, double l) {
double tmp;
if ((F <= -1.4e-27) || (!(F <= -1.15e-162) && ((F <= -1.75e-205) || !(F <= 2.5e-111)))) {
tmp = ((double) M_PI) * l;
} else {
tmp = (((double) M_PI) / F) * (-l / F);
}
return tmp;
}
public static double code(double F, double l) {
double tmp;
if ((F <= -1.4e-27) || (!(F <= -1.15e-162) && ((F <= -1.75e-205) || !(F <= 2.5e-111)))) {
tmp = Math.PI * l;
} else {
tmp = (Math.PI / F) * (-l / F);
}
return tmp;
}
def code(F, l): tmp = 0 if (F <= -1.4e-27) or (not (F <= -1.15e-162) and ((F <= -1.75e-205) or not (F <= 2.5e-111))): tmp = math.pi * l else: tmp = (math.pi / F) * (-l / F) return tmp
function code(F, l) tmp = 0.0 if ((F <= -1.4e-27) || (!(F <= -1.15e-162) && ((F <= -1.75e-205) || !(F <= 2.5e-111)))) tmp = Float64(pi * l); else tmp = Float64(Float64(pi / F) * Float64(Float64(-l) / F)); end return tmp end
function tmp_2 = code(F, l) tmp = 0.0; if ((F <= -1.4e-27) || (~((F <= -1.15e-162)) && ((F <= -1.75e-205) || ~((F <= 2.5e-111))))) tmp = pi * l; else tmp = (pi / F) * (-l / F); end tmp_2 = tmp; end
code[F_, l_] := If[Or[LessEqual[F, -1.4e-27], And[N[Not[LessEqual[F, -1.15e-162]], $MachinePrecision], Or[LessEqual[F, -1.75e-205], N[Not[LessEqual[F, 2.5e-111]], $MachinePrecision]]]], N[(Pi * l), $MachinePrecision], N[(N[(Pi / F), $MachinePrecision] * N[((-l) / F), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \leq -1.4 \cdot 10^{-27} \lor \neg \left(F \leq -1.15 \cdot 10^{-162}\right) \land \left(F \leq -1.75 \cdot 10^{-205} \lor \neg \left(F \leq 2.5 \cdot 10^{-111}\right)\right):\\
\;\;\;\;\pi \cdot \ell\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi}{F} \cdot \frac{-\ell}{F}\\
\end{array}
\end{array}
if F < -1.4e-27 or -1.1499999999999999e-162 < F < -1.75e-205 or 2.5000000000000001e-111 < F Initial program 91.9%
associate-*l/91.9%
*-lft-identity91.9%
Simplified91.9%
Taylor expanded in l around 0 83.0%
unpow283.0%
Simplified83.0%
Taylor expanded in F around inf 93.7%
if -1.4e-27 < F < -1.1499999999999999e-162 or -1.75e-205 < F < 2.5000000000000001e-111Initial program 55.5%
associate-*l/55.8%
*-lft-identity55.8%
Simplified55.8%
Taylor expanded in l around 0 49.6%
unpow249.6%
Simplified49.6%
Taylor expanded in F around 0 52.0%
mul-1-neg52.0%
unpow252.0%
Simplified52.0%
*-commutative52.0%
times-frac63.7%
Applied egg-rr63.7%
Final simplification82.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 78.7%
associate-*l/78.8%
*-lft-identity78.8%
Simplified78.8%
Taylor expanded in l around 0 70.9%
unpow270.9%
Simplified70.9%
Taylor expanded in F around inf 72.1%
Final simplification72.1%
herbie shell --seed 2023175
(FPCore (F l)
:name "VandenBroeck and Keller, Equation (6)"
:precision binary64
(- (* PI l) (* (/ 1.0 (* F F)) (tan (* PI l)))))