
(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 5 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}
l_m = (fabs.f64 l)
l_s = (copysign.f64 1 l)
(FPCore (l_s F l_m)
:precision binary64
(*
l_s
(if (<= (* PI l_m) 100000000000.0)
(- (* PI l_m) (/ (/ (tan (* PI l_m)) F) F))
(* PI l_m))))l_m = fabs(l);
l_s = copysign(1.0, l);
double code(double l_s, double F, double l_m) {
double tmp;
if ((((double) M_PI) * l_m) <= 100000000000.0) {
tmp = (((double) M_PI) * l_m) - ((tan((((double) M_PI) * l_m)) / F) / F);
} else {
tmp = ((double) M_PI) * l_m;
}
return l_s * tmp;
}
l_m = Math.abs(l);
l_s = Math.copySign(1.0, l);
public static double code(double l_s, double F, double l_m) {
double tmp;
if ((Math.PI * l_m) <= 100000000000.0) {
tmp = (Math.PI * l_m) - ((Math.tan((Math.PI * l_m)) / F) / F);
} else {
tmp = Math.PI * l_m;
}
return l_s * tmp;
}
l_m = math.fabs(l) l_s = math.copysign(1.0, l) def code(l_s, F, l_m): tmp = 0 if (math.pi * l_m) <= 100000000000.0: tmp = (math.pi * l_m) - ((math.tan((math.pi * l_m)) / F) / F) else: tmp = math.pi * l_m return l_s * tmp
l_m = abs(l) l_s = copysign(1.0, l) function code(l_s, F, l_m) tmp = 0.0 if (Float64(pi * l_m) <= 100000000000.0) tmp = Float64(Float64(pi * l_m) - Float64(Float64(tan(Float64(pi * l_m)) / F) / F)); else tmp = Float64(pi * l_m); end return Float64(l_s * tmp) end
l_m = abs(l); l_s = sign(l) * abs(1.0); function tmp_2 = code(l_s, F, l_m) tmp = 0.0; if ((pi * l_m) <= 100000000000.0) tmp = (pi * l_m) - ((tan((pi * l_m)) / F) / F); else tmp = pi * l_m; end tmp_2 = l_s * tmp; end
l_m = N[Abs[l], $MachinePrecision]
l_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[l]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[l$95$s_, F_, l$95$m_] := N[(l$95$s * If[LessEqual[N[(Pi * l$95$m), $MachinePrecision], 100000000000.0], N[(N[(Pi * l$95$m), $MachinePrecision] - N[(N[(N[Tan[N[(Pi * l$95$m), $MachinePrecision]], $MachinePrecision] / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision], N[(Pi * l$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
l_m = \left|\ell\right|
\\
l_s = \mathsf{copysign}\left(1, \ell\right)
\\
l_s \cdot \begin{array}{l}
\mathbf{if}\;\pi \cdot l_m \leq 100000000000:\\
\;\;\;\;\pi \cdot l_m - \frac{\frac{\tan \left(\pi \cdot l_m\right)}{F}}{F}\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot l_m\\
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < 1e11Initial program 80.8%
associate-*l/81.5%
*-un-lft-identity81.5%
associate-/r*88.2%
Applied egg-rr88.2%
if 1e11 < (*.f64 (PI.f64) l) Initial program 74.0%
sqr-neg74.0%
associate-*l/74.0%
sqr-neg74.0%
*-lft-identity74.0%
Simplified74.0%
Taylor expanded in l around 0 61.4%
Taylor expanded in F around inf 99.5%
Final simplification90.5%
l_m = (fabs.f64 l)
l_s = (copysign.f64 1 l)
(FPCore (l_s F l_m)
:precision binary64
(*
l_s
(if (<= (* PI l_m) 100000000000.0)
(- (* PI l_m) (* (/ PI F) (/ l_m F)))
(* PI l_m))))l_m = fabs(l);
l_s = copysign(1.0, l);
double code(double l_s, double F, double l_m) {
double tmp;
if ((((double) M_PI) * l_m) <= 100000000000.0) {
tmp = (((double) M_PI) * l_m) - ((((double) M_PI) / F) * (l_m / F));
} else {
tmp = ((double) M_PI) * l_m;
}
return l_s * tmp;
}
l_m = Math.abs(l);
l_s = Math.copySign(1.0, l);
public static double code(double l_s, double F, double l_m) {
double tmp;
if ((Math.PI * l_m) <= 100000000000.0) {
tmp = (Math.PI * l_m) - ((Math.PI / F) * (l_m / F));
} else {
tmp = Math.PI * l_m;
}
return l_s * tmp;
}
l_m = math.fabs(l) l_s = math.copysign(1.0, l) def code(l_s, F, l_m): tmp = 0 if (math.pi * l_m) <= 100000000000.0: tmp = (math.pi * l_m) - ((math.pi / F) * (l_m / F)) else: tmp = math.pi * l_m return l_s * tmp
l_m = abs(l) l_s = copysign(1.0, l) function code(l_s, F, l_m) tmp = 0.0 if (Float64(pi * l_m) <= 100000000000.0) tmp = Float64(Float64(pi * l_m) - Float64(Float64(pi / F) * Float64(l_m / F))); else tmp = Float64(pi * l_m); end return Float64(l_s * tmp) end
l_m = abs(l); l_s = sign(l) * abs(1.0); function tmp_2 = code(l_s, F, l_m) tmp = 0.0; if ((pi * l_m) <= 100000000000.0) tmp = (pi * l_m) - ((pi / F) * (l_m / F)); else tmp = pi * l_m; end tmp_2 = l_s * tmp; end
l_m = N[Abs[l], $MachinePrecision]
l_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[l]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[l$95$s_, F_, l$95$m_] := N[(l$95$s * If[LessEqual[N[(Pi * l$95$m), $MachinePrecision], 100000000000.0], N[(N[(Pi * l$95$m), $MachinePrecision] - N[(N[(Pi / F), $MachinePrecision] * N[(l$95$m / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(Pi * l$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
l_m = \left|\ell\right|
\\
l_s = \mathsf{copysign}\left(1, \ell\right)
\\
l_s \cdot \begin{array}{l}
\mathbf{if}\;\pi \cdot l_m \leq 100000000000:\\
\;\;\;\;\pi \cdot l_m - \frac{\pi}{F} \cdot \frac{l_m}{F}\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot l_m\\
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < 1e11Initial program 80.8%
sqr-neg80.8%
associate-*l/81.5%
sqr-neg81.5%
*-lft-identity81.5%
Simplified81.5%
Taylor expanded in l around 0 74.9%
*-commutative74.9%
times-frac81.7%
Applied egg-rr81.7%
if 1e11 < (*.f64 (PI.f64) l) Initial program 74.0%
sqr-neg74.0%
associate-*l/74.0%
sqr-neg74.0%
*-lft-identity74.0%
Simplified74.0%
Taylor expanded in l around 0 61.4%
Taylor expanded in F around inf 99.5%
Final simplification85.4%
l_m = (fabs.f64 l)
l_s = (copysign.f64 1 l)
(FPCore (l_s F l_m)
:precision binary64
(*
l_s
(if (or (<= F 2.4e-209) (not (<= F 2.4e-63)))
(* PI l_m)
(* (/ PI F) (/ (- l_m) F)))))l_m = fabs(l);
l_s = copysign(1.0, l);
double code(double l_s, double F, double l_m) {
double tmp;
if ((F <= 2.4e-209) || !(F <= 2.4e-63)) {
tmp = ((double) M_PI) * l_m;
} else {
tmp = (((double) M_PI) / F) * (-l_m / F);
}
return l_s * tmp;
}
l_m = Math.abs(l);
l_s = Math.copySign(1.0, l);
public static double code(double l_s, double F, double l_m) {
double tmp;
if ((F <= 2.4e-209) || !(F <= 2.4e-63)) {
tmp = Math.PI * l_m;
} else {
tmp = (Math.PI / F) * (-l_m / F);
}
return l_s * tmp;
}
l_m = math.fabs(l) l_s = math.copysign(1.0, l) def code(l_s, F, l_m): tmp = 0 if (F <= 2.4e-209) or not (F <= 2.4e-63): tmp = math.pi * l_m else: tmp = (math.pi / F) * (-l_m / F) return l_s * tmp
l_m = abs(l) l_s = copysign(1.0, l) function code(l_s, F, l_m) tmp = 0.0 if ((F <= 2.4e-209) || !(F <= 2.4e-63)) tmp = Float64(pi * l_m); else tmp = Float64(Float64(pi / F) * Float64(Float64(-l_m) / F)); end return Float64(l_s * tmp) end
l_m = abs(l); l_s = sign(l) * abs(1.0); function tmp_2 = code(l_s, F, l_m) tmp = 0.0; if ((F <= 2.4e-209) || ~((F <= 2.4e-63))) tmp = pi * l_m; else tmp = (pi / F) * (-l_m / F); end tmp_2 = l_s * tmp; end
l_m = N[Abs[l], $MachinePrecision]
l_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[l]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[l$95$s_, F_, l$95$m_] := N[(l$95$s * If[Or[LessEqual[F, 2.4e-209], N[Not[LessEqual[F, 2.4e-63]], $MachinePrecision]], N[(Pi * l$95$m), $MachinePrecision], N[(N[(Pi / F), $MachinePrecision] * N[((-l$95$m) / F), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
l_m = \left|\ell\right|
\\
l_s = \mathsf{copysign}\left(1, \ell\right)
\\
l_s \cdot \begin{array}{l}
\mathbf{if}\;F \leq 2.4 \cdot 10^{-209} \lor \neg \left(F \leq 2.4 \cdot 10^{-63}\right):\\
\;\;\;\;\pi \cdot l_m\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi}{F} \cdot \frac{-l_m}{F}\\
\end{array}
\end{array}
if F < 2.4000000000000001e-209 or 2.4000000000000001e-63 < F Initial program 82.0%
sqr-neg82.0%
associate-*l/82.4%
sqr-neg82.4%
*-lft-identity82.4%
Simplified82.4%
Taylor expanded in l around 0 74.9%
Taylor expanded in F around inf 80.2%
if 2.4000000000000001e-209 < F < 2.4000000000000001e-63Initial program 61.8%
sqr-neg61.8%
associate-*l/63.2%
sqr-neg63.2%
*-lft-identity63.2%
Simplified63.2%
Taylor expanded in l around 0 53.2%
Taylor expanded in F around 0 53.2%
mul-1-neg53.2%
associate-/l*53.1%
Simplified53.1%
associate-/l*53.2%
unpow253.2%
frac-times63.4%
*-commutative63.4%
Applied egg-rr63.4%
Final simplification78.1%
l_m = (fabs.f64 l)
l_s = (copysign.f64 1 l)
(FPCore (l_s F l_m)
:precision binary64
(*
l_s
(if (or (<= F 1.15e-206) (not (<= F 1.25e-64)))
(* PI l_m)
(/ (- PI) (* F (/ F l_m))))))l_m = fabs(l);
l_s = copysign(1.0, l);
double code(double l_s, double F, double l_m) {
double tmp;
if ((F <= 1.15e-206) || !(F <= 1.25e-64)) {
tmp = ((double) M_PI) * l_m;
} else {
tmp = -((double) M_PI) / (F * (F / l_m));
}
return l_s * tmp;
}
l_m = Math.abs(l);
l_s = Math.copySign(1.0, l);
public static double code(double l_s, double F, double l_m) {
double tmp;
if ((F <= 1.15e-206) || !(F <= 1.25e-64)) {
tmp = Math.PI * l_m;
} else {
tmp = -Math.PI / (F * (F / l_m));
}
return l_s * tmp;
}
l_m = math.fabs(l) l_s = math.copysign(1.0, l) def code(l_s, F, l_m): tmp = 0 if (F <= 1.15e-206) or not (F <= 1.25e-64): tmp = math.pi * l_m else: tmp = -math.pi / (F * (F / l_m)) return l_s * tmp
l_m = abs(l) l_s = copysign(1.0, l) function code(l_s, F, l_m) tmp = 0.0 if ((F <= 1.15e-206) || !(F <= 1.25e-64)) tmp = Float64(pi * l_m); else tmp = Float64(Float64(-pi) / Float64(F * Float64(F / l_m))); end return Float64(l_s * tmp) end
l_m = abs(l); l_s = sign(l) * abs(1.0); function tmp_2 = code(l_s, F, l_m) tmp = 0.0; if ((F <= 1.15e-206) || ~((F <= 1.25e-64))) tmp = pi * l_m; else tmp = -pi / (F * (F / l_m)); end tmp_2 = l_s * tmp; end
l_m = N[Abs[l], $MachinePrecision]
l_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[l]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[l$95$s_, F_, l$95$m_] := N[(l$95$s * If[Or[LessEqual[F, 1.15e-206], N[Not[LessEqual[F, 1.25e-64]], $MachinePrecision]], N[(Pi * l$95$m), $MachinePrecision], N[((-Pi) / N[(F * N[(F / l$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
l_m = \left|\ell\right|
\\
l_s = \mathsf{copysign}\left(1, \ell\right)
\\
l_s \cdot \begin{array}{l}
\mathbf{if}\;F \leq 1.15 \cdot 10^{-206} \lor \neg \left(F \leq 1.25 \cdot 10^{-64}\right):\\
\;\;\;\;\pi \cdot l_m\\
\mathbf{else}:\\
\;\;\;\;\frac{-\pi}{F \cdot \frac{F}{l_m}}\\
\end{array}
\end{array}
if F < 1.15e-206 or 1.25000000000000008e-64 < F Initial program 82.0%
sqr-neg82.0%
associate-*l/82.4%
sqr-neg82.4%
*-lft-identity82.4%
Simplified82.4%
Taylor expanded in l around 0 74.9%
Taylor expanded in F around inf 80.2%
if 1.15e-206 < F < 1.25000000000000008e-64Initial program 61.8%
sqr-neg61.8%
associate-*l/63.2%
sqr-neg63.2%
*-lft-identity63.2%
Simplified63.2%
Taylor expanded in l around 0 53.2%
Taylor expanded in F around 0 53.2%
*-commutative53.2%
unpow253.2%
times-frac63.4%
Applied egg-rr63.4%
*-commutative63.4%
clear-num63.4%
frac-times63.6%
*-un-lft-identity63.6%
Applied egg-rr63.6%
Final simplification78.1%
l_m = (fabs.f64 l) l_s = (copysign.f64 1 l) (FPCore (l_s F l_m) :precision binary64 (* l_s (* PI l_m)))
l_m = fabs(l);
l_s = copysign(1.0, l);
double code(double l_s, double F, double l_m) {
return l_s * (((double) M_PI) * l_m);
}
l_m = Math.abs(l);
l_s = Math.copySign(1.0, l);
public static double code(double l_s, double F, double l_m) {
return l_s * (Math.PI * l_m);
}
l_m = math.fabs(l) l_s = math.copysign(1.0, l) def code(l_s, F, l_m): return l_s * (math.pi * l_m)
l_m = abs(l) l_s = copysign(1.0, l) function code(l_s, F, l_m) return Float64(l_s * Float64(pi * l_m)) end
l_m = abs(l); l_s = sign(l) * abs(1.0); function tmp = code(l_s, F, l_m) tmp = l_s * (pi * l_m); end
l_m = N[Abs[l], $MachinePrecision]
l_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[l]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[l$95$s_, F_, l$95$m_] := N[(l$95$s * N[(Pi * l$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
l_m = \left|\ell\right|
\\
l_s = \mathsf{copysign}\left(1, \ell\right)
\\
l_s \cdot \left(\pi \cdot l_m\right)
\end{array}
Initial program 79.4%
sqr-neg79.4%
associate-*l/79.9%
sqr-neg79.9%
*-lft-identity79.9%
Simplified79.9%
Taylor expanded in l around 0 72.1%
Taylor expanded in F around inf 74.7%
Final simplification74.7%
herbie shell --seed 2023335
(FPCore (F l)
:name "VandenBroeck and Keller, Equation (6)"
:precision binary64
(- (* PI l) (* (/ 1.0 (* F F)) (tan (* PI l)))))