
(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 8 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
(+
(* PI l)
(/
(/
(/ (sin (* PI l)) F)
(-
-1.0
(*
(pow l 2.0)
(+
(* -0.5 (pow PI 2.0))
(*
(pow l 2.0)
(+
(* -0.001388888888888889 (* (pow l 2.0) (pow PI 6.0)))
(* 0.041666666666666664 (pow PI 4.0))))))))
F)))
double code(double F, double l) {
return (((double) M_PI) * l) + (((sin((((double) M_PI) * l)) / F) / (-1.0 - (pow(l, 2.0) * ((-0.5 * pow(((double) M_PI), 2.0)) + (pow(l, 2.0) * ((-0.001388888888888889 * (pow(l, 2.0) * pow(((double) M_PI), 6.0))) + (0.041666666666666664 * pow(((double) M_PI), 4.0)))))))) / F);
}
public static double code(double F, double l) {
return (Math.PI * l) + (((Math.sin((Math.PI * l)) / F) / (-1.0 - (Math.pow(l, 2.0) * ((-0.5 * Math.pow(Math.PI, 2.0)) + (Math.pow(l, 2.0) * ((-0.001388888888888889 * (Math.pow(l, 2.0) * Math.pow(Math.PI, 6.0))) + (0.041666666666666664 * Math.pow(Math.PI, 4.0)))))))) / F);
}
def code(F, l): return (math.pi * l) + (((math.sin((math.pi * l)) / F) / (-1.0 - (math.pow(l, 2.0) * ((-0.5 * math.pow(math.pi, 2.0)) + (math.pow(l, 2.0) * ((-0.001388888888888889 * (math.pow(l, 2.0) * math.pow(math.pi, 6.0))) + (0.041666666666666664 * math.pow(math.pi, 4.0)))))))) / F)
function code(F, l) return Float64(Float64(pi * l) + Float64(Float64(Float64(sin(Float64(pi * l)) / F) / Float64(-1.0 - Float64((l ^ 2.0) * Float64(Float64(-0.5 * (pi ^ 2.0)) + Float64((l ^ 2.0) * Float64(Float64(-0.001388888888888889 * Float64((l ^ 2.0) * (pi ^ 6.0))) + Float64(0.041666666666666664 * (pi ^ 4.0)))))))) / F)) end
function tmp = code(F, l) tmp = (pi * l) + (((sin((pi * l)) / F) / (-1.0 - ((l ^ 2.0) * ((-0.5 * (pi ^ 2.0)) + ((l ^ 2.0) * ((-0.001388888888888889 * ((l ^ 2.0) * (pi ^ 6.0))) + (0.041666666666666664 * (pi ^ 4.0)))))))) / F); end
code[F_, l_] := N[(N[(Pi * l), $MachinePrecision] + N[(N[(N[(N[Sin[N[(Pi * l), $MachinePrecision]], $MachinePrecision] / F), $MachinePrecision] / N[(-1.0 - N[(N[Power[l, 2.0], $MachinePrecision] * N[(N[(-0.5 * N[Power[Pi, 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[Power[l, 2.0], $MachinePrecision] * N[(N[(-0.001388888888888889 * N[(N[Power[l, 2.0], $MachinePrecision] * N[Power[Pi, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.041666666666666664 * N[Power[Pi, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\pi \cdot \ell + \frac{\frac{\frac{\sin \left(\pi \cdot \ell\right)}{F}}{-1 - {\ell}^{2} \cdot \left(-0.5 \cdot {\pi}^{2} + {\ell}^{2} \cdot \left(-0.001388888888888889 \cdot \left({\ell}^{2} \cdot {\pi}^{6}\right) + 0.041666666666666664 \cdot {\pi}^{4}\right)\right)}}{F}
\end{array}
Initial program 74.6%
associate-*l/74.8%
*-un-lft-identity74.8%
associate-/r*81.5%
Applied egg-rr81.5%
add-cube-cbrt81.1%
pow381.0%
Applied egg-rr81.0%
Taylor expanded in l around inf 81.5%
associate-/r*81.5%
Simplified81.5%
Taylor expanded in l around 0 95.4%
Final simplification95.4%
(FPCore (F l)
:precision binary64
(+
(* PI l)
(/
(/
(/ (sin (* PI l)) F)
(-
-1.0
(*
(pow l 2.0)
(+
(* -0.5 (pow PI 2.0))
(* 0.041666666666666664 (* (pow l 2.0) (pow PI 4.0)))))))
F)))
double code(double F, double l) {
return (((double) M_PI) * l) + (((sin((((double) M_PI) * l)) / F) / (-1.0 - (pow(l, 2.0) * ((-0.5 * pow(((double) M_PI), 2.0)) + (0.041666666666666664 * (pow(l, 2.0) * pow(((double) M_PI), 4.0))))))) / F);
}
public static double code(double F, double l) {
return (Math.PI * l) + (((Math.sin((Math.PI * l)) / F) / (-1.0 - (Math.pow(l, 2.0) * ((-0.5 * Math.pow(Math.PI, 2.0)) + (0.041666666666666664 * (Math.pow(l, 2.0) * Math.pow(Math.PI, 4.0))))))) / F);
}
def code(F, l): return (math.pi * l) + (((math.sin((math.pi * l)) / F) / (-1.0 - (math.pow(l, 2.0) * ((-0.5 * math.pow(math.pi, 2.0)) + (0.041666666666666664 * (math.pow(l, 2.0) * math.pow(math.pi, 4.0))))))) / F)
function code(F, l) return Float64(Float64(pi * l) + Float64(Float64(Float64(sin(Float64(pi * l)) / F) / Float64(-1.0 - Float64((l ^ 2.0) * Float64(Float64(-0.5 * (pi ^ 2.0)) + Float64(0.041666666666666664 * Float64((l ^ 2.0) * (pi ^ 4.0))))))) / F)) end
function tmp = code(F, l) tmp = (pi * l) + (((sin((pi * l)) / F) / (-1.0 - ((l ^ 2.0) * ((-0.5 * (pi ^ 2.0)) + (0.041666666666666664 * ((l ^ 2.0) * (pi ^ 4.0))))))) / F); end
code[F_, l_] := N[(N[(Pi * l), $MachinePrecision] + N[(N[(N[(N[Sin[N[(Pi * l), $MachinePrecision]], $MachinePrecision] / F), $MachinePrecision] / N[(-1.0 - N[(N[Power[l, 2.0], $MachinePrecision] * N[(N[(-0.5 * N[Power[Pi, 2.0], $MachinePrecision]), $MachinePrecision] + N[(0.041666666666666664 * N[(N[Power[l, 2.0], $MachinePrecision] * N[Power[Pi, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\pi \cdot \ell + \frac{\frac{\frac{\sin \left(\pi \cdot \ell\right)}{F}}{-1 - {\ell}^{2} \cdot \left(-0.5 \cdot {\pi}^{2} + 0.041666666666666664 \cdot \left({\ell}^{2} \cdot {\pi}^{4}\right)\right)}}{F}
\end{array}
Initial program 74.6%
associate-*l/74.8%
*-un-lft-identity74.8%
associate-/r*81.5%
Applied egg-rr81.5%
add-cube-cbrt81.1%
pow381.0%
Applied egg-rr81.0%
Taylor expanded in l around inf 81.5%
associate-/r*81.5%
Simplified81.5%
Taylor expanded in l around 0 93.9%
Final simplification93.9%
(FPCore (F l) :precision binary64 (- (* PI l) (/ (/ (/ (sin (* PI l)) F) (fma -0.5 (pow (* PI l) 2.0) 1.0)) F)))
double code(double F, double l) {
return (((double) M_PI) * l) - (((sin((((double) M_PI) * l)) / F) / fma(-0.5, pow((((double) M_PI) * l), 2.0), 1.0)) / F);
}
function code(F, l) return Float64(Float64(pi * l) - Float64(Float64(Float64(sin(Float64(pi * l)) / F) / fma(-0.5, (Float64(pi * l) ^ 2.0), 1.0)) / F)) end
code[F_, l_] := N[(N[(Pi * l), $MachinePrecision] - N[(N[(N[(N[Sin[N[(Pi * l), $MachinePrecision]], $MachinePrecision] / F), $MachinePrecision] / N[(-0.5 * N[Power[N[(Pi * l), $MachinePrecision], 2.0], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\pi \cdot \ell - \frac{\frac{\frac{\sin \left(\pi \cdot \ell\right)}{F}}{\mathsf{fma}\left(-0.5, {\left(\pi \cdot \ell\right)}^{2}, 1\right)}}{F}
\end{array}
Initial program 74.6%
associate-*l/74.8%
*-un-lft-identity74.8%
associate-/r*81.5%
Applied egg-rr81.5%
add-cube-cbrt81.1%
pow381.0%
Applied egg-rr81.0%
Taylor expanded in l around inf 81.5%
associate-/r*81.5%
Simplified81.5%
Taylor expanded in l around 0 91.6%
+-commutative91.6%
fma-define91.6%
unpow291.6%
unpow291.6%
swap-sqr91.6%
unpow291.6%
Simplified91.6%
Final simplification91.6%
(FPCore (F l) :precision binary64 (- (* PI l) (/ (/ (tan (expm1 (log1p (* PI l)))) F) F)))
double code(double F, double l) {
return (((double) M_PI) * l) - ((tan(expm1(log1p((((double) M_PI) * l)))) / F) / F);
}
public static double code(double F, double l) {
return (Math.PI * l) - ((Math.tan(Math.expm1(Math.log1p((Math.PI * l)))) / F) / F);
}
def code(F, l): return (math.pi * l) - ((math.tan(math.expm1(math.log1p((math.pi * l)))) / F) / F)
function code(F, l) return Float64(Float64(pi * l) - Float64(Float64(tan(expm1(log1p(Float64(pi * l)))) / F) / F)) end
code[F_, l_] := N[(N[(Pi * l), $MachinePrecision] - N[(N[(N[Tan[N[(Exp[N[Log[1 + N[(Pi * l), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision] / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\pi \cdot \ell - \frac{\frac{\tan \left(\mathsf{expm1}\left(\mathsf{log1p}\left(\pi \cdot \ell\right)\right)\right)}{F}}{F}
\end{array}
Initial program 74.6%
associate-*l/74.8%
*-un-lft-identity74.8%
associate-/r*81.5%
Applied egg-rr81.5%
expm1-log1p-u69.6%
Applied egg-rr69.6%
(FPCore (F l) :precision binary64 (if (<= (* PI l) 3e-22) (- (* PI l) (/ (/ (* PI l) F) F)) (- (* PI l) (/ (tan (* PI l)) (* F F)))))
double code(double F, double l) {
double tmp;
if ((((double) M_PI) * l) <= 3e-22) {
tmp = (((double) M_PI) * l) - (((((double) M_PI) * l) / F) / F);
} 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) <= 3e-22) {
tmp = (Math.PI * l) - (((Math.PI * l) / F) / F);
} else {
tmp = (Math.PI * l) - (Math.tan((Math.PI * l)) / (F * F));
}
return tmp;
}
def code(F, l): tmp = 0 if (math.pi * l) <= 3e-22: tmp = (math.pi * l) - (((math.pi * l) / F) / F) 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) <= 3e-22) tmp = Float64(Float64(pi * l) - Float64(Float64(Float64(pi * l) / F) / F)); else tmp = Float64(Float64(pi * l) - Float64(tan(Float64(pi * l)) / Float64(F * F))); end return tmp end
function tmp_2 = code(F, l) tmp = 0.0; if ((pi * l) <= 3e-22) tmp = (pi * l) - (((pi * l) / F) / F); else tmp = (pi * l) - (tan((pi * l)) / (F * F)); end tmp_2 = tmp; end
code[F_, l_] := If[LessEqual[N[(Pi * l), $MachinePrecision], 3e-22], N[(N[(Pi * l), $MachinePrecision] - N[(N[(N[(Pi * l), $MachinePrecision] / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision], N[(N[(Pi * l), $MachinePrecision] - N[(N[Tan[N[(Pi * l), $MachinePrecision]], $MachinePrecision] / N[(F * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\pi \cdot \ell \leq 3 \cdot 10^{-22}:\\
\;\;\;\;\pi \cdot \ell - \frac{\frac{\pi \cdot \ell}{F}}{F}\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}\\
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < 2.9999999999999999e-22Initial program 78.4%
associate-*l/78.8%
*-un-lft-identity78.8%
associate-/r*88.5%
Applied egg-rr88.5%
Taylor expanded in l around 0 82.4%
if 2.9999999999999999e-22 < (*.f64 (PI.f64) l) Initial program 66.2%
*-commutative66.2%
sqr-neg66.2%
associate-*r/66.2%
sqr-neg66.2%
*-rgt-identity66.2%
Simplified66.2%
Final simplification77.3%
(FPCore (F l) :precision binary64 (- (* PI l) (/ (/ (tan (* PI l)) F) F)))
double code(double F, double l) {
return (((double) M_PI) * l) - ((tan((((double) M_PI) * l)) / F) / F);
}
public static double code(double F, double l) {
return (Math.PI * l) - ((Math.tan((Math.PI * l)) / F) / F);
}
def code(F, l): return (math.pi * l) - ((math.tan((math.pi * l)) / F) / F)
function code(F, l) return Float64(Float64(pi * l) - Float64(Float64(tan(Float64(pi * l)) / F) / F)) end
function tmp = code(F, l) tmp = (pi * l) - ((tan((pi * l)) / F) / F); end
code[F_, l_] := N[(N[(Pi * l), $MachinePrecision] - N[(N[(N[Tan[N[(Pi * l), $MachinePrecision]], $MachinePrecision] / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\pi \cdot \ell - \frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}
\end{array}
Initial program 74.6%
associate-*l/74.8%
*-un-lft-identity74.8%
associate-/r*81.5%
Applied egg-rr81.5%
(FPCore (F l) :precision binary64 (- (* PI l) (/ (/ (* PI l) F) F)))
double code(double F, double l) {
return (((double) M_PI) * l) - (((((double) M_PI) * l) / F) / F);
}
public static double code(double F, double l) {
return (Math.PI * l) - (((Math.PI * l) / F) / F);
}
def code(F, l): return (math.pi * l) - (((math.pi * l) / F) / F)
function code(F, l) return Float64(Float64(pi * l) - Float64(Float64(Float64(pi * l) / F) / F)) end
function tmp = code(F, l) tmp = (pi * l) - (((pi * l) / F) / F); end
code[F_, l_] := N[(N[(Pi * l), $MachinePrecision] - N[(N[(N[(Pi * l), $MachinePrecision] / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\pi \cdot \ell - \frac{\frac{\pi \cdot \ell}{F}}{F}
\end{array}
Initial program 74.6%
associate-*l/74.8%
*-un-lft-identity74.8%
associate-/r*81.5%
Applied egg-rr81.5%
Taylor expanded in l around 0 73.6%
Final simplification73.6%
(FPCore (F l) :precision binary64 (- (* PI l) (* (/ PI F) (/ l F))))
double code(double F, double l) {
return (((double) M_PI) * l) - ((((double) M_PI) / F) * (l / F));
}
public static double code(double F, double l) {
return (Math.PI * l) - ((Math.PI / F) * (l / F));
}
def code(F, l): return (math.pi * l) - ((math.pi / F) * (l / F))
function code(F, l) return Float64(Float64(pi * l) - Float64(Float64(pi / F) * Float64(l / F))) end
function tmp = code(F, l) tmp = (pi * l) - ((pi / F) * (l / F)); end
code[F_, l_] := N[(N[(Pi * l), $MachinePrecision] - N[(N[(Pi / F), $MachinePrecision] * N[(l / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\pi \cdot \ell - \frac{\pi}{F} \cdot \frac{\ell}{F}
\end{array}
Initial program 74.6%
*-commutative74.6%
sqr-neg74.6%
associate-*r/74.8%
sqr-neg74.8%
*-rgt-identity74.8%
Simplified74.8%
Taylor expanded in l around 0 66.9%
*-commutative66.9%
times-frac73.6%
Applied egg-rr73.6%
herbie shell --seed 2024113
(FPCore (F l)
:name "VandenBroeck and Keller, Equation (6)"
:precision binary64
(- (* PI l) (* (/ 1.0 (* F F)) (tan (* PI l)))))