
(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 9 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) (/ (/ (tan (* l (cbrt (pow PI 3.0)))) F) F)))
double code(double F, double l) {
return (((double) M_PI) * l) - ((tan((l * cbrt(pow(((double) M_PI), 3.0)))) / F) / F);
}
public static double code(double F, double l) {
return (Math.PI * l) - ((Math.tan((l * Math.cbrt(Math.pow(Math.PI, 3.0)))) / F) / F);
}
function code(F, l) return Float64(Float64(pi * l) - Float64(Float64(tan(Float64(l * cbrt((pi ^ 3.0)))) / F) / F)) end
code[F_, l_] := N[(N[(Pi * l), $MachinePrecision] - N[(N[(N[Tan[N[(l * N[Power[N[Power[Pi, 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\pi \cdot \ell - \frac{\frac{\tan \left(\ell \cdot \sqrt[3]{{\pi}^{3}}\right)}{F}}{F}
\end{array}
Initial program 77.6%
associate-*l/78.1%
*-un-lft-identity78.1%
associate-/r*84.5%
Applied egg-rr84.5%
add-cbrt-cube84.6%
pow384.6%
Applied egg-rr84.6%
Final simplification84.6%
(FPCore (F l) :precision binary64 (if (<= (/ 1.0 (* F F)) 1e+299) (- (* PI l) (/ (tan (* PI l)) (* F F))) (- (* PI l) (/ (/ PI F) (/ F l)))))
double code(double F, double l) {
double tmp;
if ((1.0 / (F * F)) <= 1e+299) {
tmp = (((double) M_PI) * l) - (tan((((double) M_PI) * l)) / (F * F));
} 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 ((1.0 / (F * F)) <= 1e+299) {
tmp = (Math.PI * l) - (Math.tan((Math.PI * l)) / (F * F));
} else {
tmp = (Math.PI * l) - ((Math.PI / F) / (F / l));
}
return tmp;
}
def code(F, l): tmp = 0 if (1.0 / (F * F)) <= 1e+299: tmp = (math.pi * l) - (math.tan((math.pi * l)) / (F * F)) else: tmp = (math.pi * l) - ((math.pi / F) / (F / l)) return tmp
function code(F, l) tmp = 0.0 if (Float64(1.0 / Float64(F * F)) <= 1e+299) tmp = Float64(Float64(pi * l) - Float64(tan(Float64(pi * l)) / Float64(F * F))); else tmp = Float64(Float64(pi * l) - Float64(Float64(pi / F) / Float64(F / l))); end return tmp end
function tmp_2 = code(F, l) tmp = 0.0; if ((1.0 / (F * F)) <= 1e+299) tmp = (pi * l) - (tan((pi * l)) / (F * F)); else tmp = (pi * l) - ((pi / F) / (F / l)); end tmp_2 = tmp; end
code[F_, l_] := If[LessEqual[N[(1.0 / N[(F * F), $MachinePrecision]), $MachinePrecision], 1e+299], N[(N[(Pi * l), $MachinePrecision] - N[(N[Tan[N[(Pi * l), $MachinePrecision]], $MachinePrecision] / N[(F * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Pi * l), $MachinePrecision] - N[(N[(Pi / F), $MachinePrecision] / N[(F / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{F \cdot F} \leq 10^{+299}:\\
\;\;\;\;\pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell - \frac{\frac{\pi}{F}}{\frac{F}{\ell}}\\
\end{array}
\end{array}
if (/.f64 1 (*.f64 F F)) < 1.0000000000000001e299Initial program 93.3%
sqr-neg93.3%
associate-*l/93.3%
*-lft-identity93.3%
sqr-neg93.3%
Simplified93.3%
if 1.0000000000000001e299 < (/.f64 1 (*.f64 F F)) Initial program 23.8%
Taylor expanded in l around 0 23.3%
associate-/l*23.2%
associate-/r/23.3%
unpow223.3%
Simplified23.3%
*-commutative23.3%
clear-num23.3%
un-div-inv23.3%
*-un-lft-identity23.3%
times-frac51.6%
/-rgt-identity51.6%
Applied egg-rr51.6%
associate-/r*51.7%
div-inv51.7%
clear-num51.7%
Applied egg-rr51.7%
clear-num51.7%
un-div-inv51.7%
Applied egg-rr51.7%
Final simplification83.9%
(FPCore (F l) :precision binary64 (+ (* PI l) (* (/ (tan (* PI l)) F) (/ -1.0 F))))
double code(double F, double l) {
return (((double) M_PI) * l) + ((tan((((double) M_PI) * l)) / F) * (-1.0 / F));
}
public static double code(double F, double l) {
return (Math.PI * l) + ((Math.tan((Math.PI * l)) / F) * (-1.0 / F));
}
def code(F, l): return (math.pi * l) + ((math.tan((math.pi * l)) / F) * (-1.0 / F))
function code(F, l) return Float64(Float64(pi * l) + Float64(Float64(tan(Float64(pi * l)) / F) * Float64(-1.0 / F))) end
function tmp = code(F, l) tmp = (pi * l) + ((tan((pi * l)) / F) * (-1.0 / F)); end
code[F_, l_] := N[(N[(Pi * l), $MachinePrecision] + N[(N[(N[Tan[N[(Pi * l), $MachinePrecision]], $MachinePrecision] / F), $MachinePrecision] * N[(-1.0 / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\pi \cdot \ell + \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \frac{-1}{F}
\end{array}
Initial program 77.6%
sqr-neg77.6%
associate-*l/78.1%
*-lft-identity78.1%
sqr-neg78.1%
Simplified78.1%
associate-/r*84.5%
div-inv84.5%
Applied egg-rr84.5%
Final simplification84.5%
(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 77.6%
associate-*l/78.1%
*-un-lft-identity78.1%
associate-/r*84.5%
Applied egg-rr84.5%
Final simplification84.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(pi * Float64(l / Float64(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[(Pi * N[(l / N[(F * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\pi \cdot \ell - \pi \cdot \frac{\ell}{F \cdot F}
\end{array}
Initial program 77.6%
Taylor expanded in l around 0 71.9%
associate-/l*71.9%
associate-/r/71.9%
unpow271.9%
Simplified71.9%
Final simplification71.9%
(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 77.6%
Taylor expanded in l around 0 71.9%
associate-/l*71.9%
associate-/r/71.9%
unpow271.9%
Simplified71.9%
*-commutative71.9%
clear-num71.9%
un-div-inv71.9%
*-un-lft-identity71.9%
times-frac78.3%
/-rgt-identity78.3%
Applied egg-rr78.3%
associate-/r*78.4%
div-inv78.3%
clear-num78.3%
Applied egg-rr78.3%
Final simplification78.3%
(FPCore (F l) :precision binary64 (- (* PI l) (/ PI (* F (/ F l)))))
double code(double F, double l) {
return (((double) M_PI) * l) - (((double) M_PI) / (F * (F / l)));
}
public static double code(double F, double l) {
return (Math.PI * l) - (Math.PI / (F * (F / l)));
}
def code(F, l): return (math.pi * l) - (math.pi / (F * (F / l)))
function code(F, l) return Float64(Float64(pi * l) - Float64(pi / Float64(F * Float64(F / l)))) end
function tmp = code(F, l) tmp = (pi * l) - (pi / (F * (F / l))); end
code[F_, l_] := N[(N[(Pi * l), $MachinePrecision] - N[(Pi / N[(F * N[(F / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\pi \cdot \ell - \frac{\pi}{F \cdot \frac{F}{\ell}}
\end{array}
Initial program 77.6%
Taylor expanded in l around 0 71.9%
associate-/l*71.9%
associate-/r/71.9%
unpow271.9%
Simplified71.9%
*-commutative71.9%
clear-num71.9%
un-div-inv71.9%
*-un-lft-identity71.9%
times-frac78.3%
/-rgt-identity78.3%
Applied egg-rr78.3%
Final simplification78.3%
(FPCore (F l) :precision binary64 (- (* PI l) (/ (* l (/ PI F)) F)))
double code(double F, double l) {
return (((double) M_PI) * l) - ((l * (((double) M_PI) / F)) / F);
}
public static double code(double F, double l) {
return (Math.PI * l) - ((l * (Math.PI / F)) / F);
}
def code(F, l): return (math.pi * l) - ((l * (math.pi / F)) / F)
function code(F, l) return Float64(Float64(pi * l) - Float64(Float64(l * Float64(pi / F)) / F)) end
function tmp = code(F, l) tmp = (pi * l) - ((l * (pi / F)) / F); end
code[F_, l_] := N[(N[(Pi * l), $MachinePrecision] - N[(N[(l * N[(Pi / F), $MachinePrecision]), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\pi \cdot \ell - \frac{\ell \cdot \frac{\pi}{F}}{F}
\end{array}
Initial program 77.6%
Taylor expanded in l around 0 71.9%
associate-/l*71.9%
associate-/r/71.9%
unpow271.9%
Simplified71.9%
*-commutative71.9%
clear-num71.9%
un-div-inv71.9%
*-un-lft-identity71.9%
times-frac78.3%
/-rgt-identity78.3%
Applied egg-rr78.3%
associate-/r*78.4%
div-inv78.3%
clear-num78.3%
Applied egg-rr78.3%
associate-*r/78.4%
Applied egg-rr78.4%
Final simplification78.4%
(FPCore (F l) :precision binary64 (- (* PI l) (/ (/ l F) (/ F PI))))
double code(double F, double l) {
return (((double) M_PI) * l) - ((l / F) / (F / ((double) M_PI)));
}
public static double code(double F, double l) {
return (Math.PI * l) - ((l / F) / (F / Math.PI));
}
def code(F, l): return (math.pi * l) - ((l / F) / (F / math.pi))
function code(F, l) return Float64(Float64(pi * l) - Float64(Float64(l / F) / Float64(F / pi))) end
function tmp = code(F, l) tmp = (pi * l) - ((l / F) / (F / pi)); end
code[F_, l_] := N[(N[(Pi * l), $MachinePrecision] - N[(N[(l / F), $MachinePrecision] / N[(F / Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\pi \cdot \ell - \frac{\frac{\ell}{F}}{\frac{F}{\pi}}
\end{array}
Initial program 77.6%
Taylor expanded in l around 0 71.9%
associate-/l*71.9%
associate-/r/71.9%
unpow271.9%
Simplified71.9%
*-commutative71.9%
clear-num71.9%
un-div-inv71.9%
*-un-lft-identity71.9%
times-frac78.3%
/-rgt-identity78.3%
Applied egg-rr78.3%
associate-/r*78.4%
div-inv78.3%
clear-num78.3%
Applied egg-rr78.3%
*-commutative78.3%
clear-num78.3%
un-div-inv78.4%
Applied egg-rr78.4%
Final simplification78.4%
herbie shell --seed 2023292
(FPCore (F l)
:name "VandenBroeck and Keller, Equation (6)"
:precision binary64
(- (* PI l) (* (/ 1.0 (* F F)) (tan (* PI l)))))