
(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}
NOTE: F should be positive before calling this function
(FPCore (F l)
:precision binary64
(let* ((t_0 (tan (* PI l))))
(if (<= F 2.25e-197)
(+ (* PI l) (/ -1.0 (/ F (* PI (/ l F)))))
(if (<= F 5e-149)
(- (* PI l) (/ (* F F) t_0))
(- (* PI l) (/ t_0 (* F F)))))))F = abs(F);
double code(double F, double l) {
double t_0 = tan((((double) M_PI) * l));
double tmp;
if (F <= 2.25e-197) {
tmp = (((double) M_PI) * l) + (-1.0 / (F / (((double) M_PI) * (l / F))));
} else if (F <= 5e-149) {
tmp = (((double) M_PI) * l) - ((F * F) / t_0);
} else {
tmp = (((double) M_PI) * l) - (t_0 / (F * F));
}
return tmp;
}
F = Math.abs(F);
public static double code(double F, double l) {
double t_0 = Math.tan((Math.PI * l));
double tmp;
if (F <= 2.25e-197) {
tmp = (Math.PI * l) + (-1.0 / (F / (Math.PI * (l / F))));
} else if (F <= 5e-149) {
tmp = (Math.PI * l) - ((F * F) / t_0);
} else {
tmp = (Math.PI * l) - (t_0 / (F * F));
}
return tmp;
}
F = abs(F) def code(F, l): t_0 = math.tan((math.pi * l)) tmp = 0 if F <= 2.25e-197: tmp = (math.pi * l) + (-1.0 / (F / (math.pi * (l / F)))) elif F <= 5e-149: tmp = (math.pi * l) - ((F * F) / t_0) else: tmp = (math.pi * l) - (t_0 / (F * F)) return tmp
F = abs(F) function code(F, l) t_0 = tan(Float64(pi * l)) tmp = 0.0 if (F <= 2.25e-197) tmp = Float64(Float64(pi * l) + Float64(-1.0 / Float64(F / Float64(pi * Float64(l / F))))); elseif (F <= 5e-149) tmp = Float64(Float64(pi * l) - Float64(Float64(F * F) / t_0)); else tmp = Float64(Float64(pi * l) - Float64(t_0 / Float64(F * F))); end return tmp end
F = abs(F) function tmp_2 = code(F, l) t_0 = tan((pi * l)); tmp = 0.0; if (F <= 2.25e-197) tmp = (pi * l) + (-1.0 / (F / (pi * (l / F)))); elseif (F <= 5e-149) tmp = (pi * l) - ((F * F) / t_0); else tmp = (pi * l) - (t_0 / (F * F)); end tmp_2 = tmp; end
NOTE: F should be positive before calling this function
code[F_, l_] := Block[{t$95$0 = N[Tan[N[(Pi * l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[F, 2.25e-197], N[(N[(Pi * l), $MachinePrecision] + N[(-1.0 / N[(F / N[(Pi * N[(l / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[F, 5e-149], N[(N[(Pi * l), $MachinePrecision] - N[(N[(F * F), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(Pi * l), $MachinePrecision] - N[(t$95$0 / N[(F * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
F = |F|\\
\\
\begin{array}{l}
t_0 := \tan \left(\pi \cdot \ell\right)\\
\mathbf{if}\;F \leq 2.25 \cdot 10^{-197}:\\
\;\;\;\;\pi \cdot \ell + \frac{-1}{\frac{F}{\pi \cdot \frac{\ell}{F}}}\\
\mathbf{elif}\;F \leq 5 \cdot 10^{-149}:\\
\;\;\;\;\pi \cdot \ell - \frac{F \cdot F}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell - \frac{t_0}{F \cdot F}\\
\end{array}
\end{array}
if F < 2.25e-197Initial program 71.7%
Taylor expanded in l around 0 67.0%
unpow267.0%
times-frac73.7%
Simplified73.7%
associate-*r/73.7%
clear-num73.7%
*-commutative73.7%
Applied egg-rr73.7%
if 2.25e-197 < F < 4.99999999999999968e-149Initial program 18.1%
inv-pow18.1%
unpow-prod-down18.1%
inv-pow18.1%
inv-pow18.1%
Applied egg-rr18.1%
un-div-inv18.1%
clear-num18.1%
Applied egg-rr18.1%
*-commutative18.1%
associate-/r/18.1%
associate-*r*32.9%
div-inv32.9%
div-inv32.9%
clear-num32.9%
unpow-132.9%
exp-to-pow9.2%
add-sqr-sqrt9.2%
sqrt-unprod9.2%
*-commutative9.2%
*-commutative9.2%
Applied egg-rr69.8%
if 4.99999999999999968e-149 < F Initial program 89.9%
associate-*l/90.0%
*-lft-identity90.0%
Simplified90.0%
Final simplification79.9%
NOTE: F should be positive before calling this function (FPCore (F l) :precision binary64 (- (* PI l) (/ (/ (tan (* l (cbrt (pow PI 3.0)))) F) F)))
F = abs(F);
double code(double F, double l) {
return (((double) M_PI) * l) - ((tan((l * cbrt(pow(((double) M_PI), 3.0)))) / F) / F);
}
F = Math.abs(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);
}
F = abs(F) function code(F, l) return Float64(Float64(pi * l) - Float64(Float64(tan(Float64(l * cbrt((pi ^ 3.0)))) / F) / F)) end
NOTE: F should be positive before calling this function 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}
F = |F|\\
\\
\pi \cdot \ell - \frac{\frac{\tan \left(\ell \cdot \sqrt[3]{{\pi}^{3}}\right)}{F}}{F}
\end{array}
Initial program 76.2%
associate-*l/76.2%
*-un-lft-identity76.2%
associate-/r*80.6%
Applied egg-rr80.6%
add-cbrt-cube80.6%
pow380.6%
Applied egg-rr80.6%
Final simplification80.6%
NOTE: F should be positive before calling this function (FPCore (F l) :precision binary64 (if (<= F 1.1e-165) (+ (* PI l) (/ -1.0 (/ F (* PI (/ l F))))) (- (* PI l) (/ (tan (* PI l)) (* F F)))))
F = abs(F);
double code(double F, double l) {
double tmp;
if (F <= 1.1e-165) {
tmp = (((double) M_PI) * l) + (-1.0 / (F / (((double) M_PI) * (l / F))));
} else {
tmp = (((double) M_PI) * l) - (tan((((double) M_PI) * l)) / (F * F));
}
return tmp;
}
F = Math.abs(F);
public static double code(double F, double l) {
double tmp;
if (F <= 1.1e-165) {
tmp = (Math.PI * l) + (-1.0 / (F / (Math.PI * (l / F))));
} else {
tmp = (Math.PI * l) - (Math.tan((Math.PI * l)) / (F * F));
}
return tmp;
}
F = abs(F) def code(F, l): tmp = 0 if F <= 1.1e-165: tmp = (math.pi * l) + (-1.0 / (F / (math.pi * (l / F)))) else: tmp = (math.pi * l) - (math.tan((math.pi * l)) / (F * F)) return tmp
F = abs(F) function code(F, l) tmp = 0.0 if (F <= 1.1e-165) tmp = Float64(Float64(pi * l) + Float64(-1.0 / Float64(F / Float64(pi * Float64(l / F))))); else tmp = Float64(Float64(pi * l) - Float64(tan(Float64(pi * l)) / Float64(F * F))); end return tmp end
F = abs(F) function tmp_2 = code(F, l) tmp = 0.0; if (F <= 1.1e-165) tmp = (pi * l) + (-1.0 / (F / (pi * (l / F)))); else tmp = (pi * l) - (tan((pi * l)) / (F * F)); end tmp_2 = tmp; end
NOTE: F should be positive before calling this function code[F_, l_] := If[LessEqual[F, 1.1e-165], N[(N[(Pi * l), $MachinePrecision] + N[(-1.0 / N[(F / N[(Pi * N[(l / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Pi * l), $MachinePrecision] - N[(N[Tan[N[(Pi * l), $MachinePrecision]], $MachinePrecision] / N[(F * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
F = |F|\\
\\
\begin{array}{l}
\mathbf{if}\;F \leq 1.1 \cdot 10^{-165}:\\
\;\;\;\;\pi \cdot \ell + \frac{-1}{\frac{F}{\pi \cdot \frac{\ell}{F}}}\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}\\
\end{array}
\end{array}
if F < 1.0999999999999999e-165Initial program 69.1%
Taylor expanded in l around 0 63.9%
unpow263.9%
times-frac71.6%
Simplified71.6%
associate-*r/71.6%
clear-num71.6%
*-commutative71.6%
Applied egg-rr71.6%
if 1.0999999999999999e-165 < F Initial program 86.0%
associate-*l/86.1%
*-lft-identity86.1%
Simplified86.1%
Final simplification77.6%
NOTE: F should be positive before calling this function (FPCore (F l) :precision binary64 (- (* PI l) (/ (/ (tan (* PI l)) F) F)))
F = abs(F);
double code(double F, double l) {
return (((double) M_PI) * l) - ((tan((((double) M_PI) * l)) / F) / F);
}
F = Math.abs(F);
public static double code(double F, double l) {
return (Math.PI * l) - ((Math.tan((Math.PI * l)) / F) / F);
}
F = abs(F) def code(F, l): return (math.pi * l) - ((math.tan((math.pi * l)) / F) / F)
F = abs(F) function code(F, l) return Float64(Float64(pi * l) - Float64(Float64(tan(Float64(pi * l)) / F) / F)) end
F = abs(F) function tmp = code(F, l) tmp = (pi * l) - ((tan((pi * l)) / F) / F); end
NOTE: F should be positive before calling this function 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}
F = |F|\\
\\
\pi \cdot \ell - \frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}
\end{array}
Initial program 76.2%
associate-*l/76.2%
*-un-lft-identity76.2%
associate-/r*80.6%
Applied egg-rr80.6%
Final simplification80.6%
NOTE: F should be positive before calling this function (FPCore (F l) :precision binary64 (- (* PI l) (* (/ l F) (/ PI F))))
F = abs(F);
double code(double F, double l) {
return (((double) M_PI) * l) - ((l / F) * (((double) M_PI) / F));
}
F = Math.abs(F);
public static double code(double F, double l) {
return (Math.PI * l) - ((l / F) * (Math.PI / F));
}
F = abs(F) def code(F, l): return (math.pi * l) - ((l / F) * (math.pi / F))
F = abs(F) function code(F, l) return Float64(Float64(pi * l) - Float64(Float64(l / F) * Float64(pi / F))) end
F = abs(F) function tmp = code(F, l) tmp = (pi * l) - ((l / F) * (pi / F)); end
NOTE: F should be positive before calling this function code[F_, l_] := N[(N[(Pi * l), $MachinePrecision] - N[(N[(l / F), $MachinePrecision] * N[(Pi / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
F = |F|\\
\\
\pi \cdot \ell - \frac{\ell}{F} \cdot \frac{\pi}{F}
\end{array}
Initial program 76.2%
Taylor expanded in l around 0 68.7%
unpow268.7%
times-frac73.1%
Simplified73.1%
Final simplification73.1%
NOTE: F should be positive before calling this function (FPCore (F l) :precision binary64 (- (* PI l) (/ (* PI (/ l F)) F)))
F = abs(F);
double code(double F, double l) {
return (((double) M_PI) * l) - ((((double) M_PI) * (l / F)) / F);
}
F = Math.abs(F);
public static double code(double F, double l) {
return (Math.PI * l) - ((Math.PI * (l / F)) / F);
}
F = abs(F) def code(F, l): return (math.pi * l) - ((math.pi * (l / F)) / F)
F = abs(F) function code(F, l) return Float64(Float64(pi * l) - Float64(Float64(pi * Float64(l / F)) / F)) end
F = abs(F) function tmp = code(F, l) tmp = (pi * l) - ((pi * (l / F)) / F); end
NOTE: F should be positive before calling this function code[F_, l_] := N[(N[(Pi * l), $MachinePrecision] - N[(N[(Pi * N[(l / F), $MachinePrecision]), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
F = |F|\\
\\
\pi \cdot \ell - \frac{\pi \cdot \frac{\ell}{F}}{F}
\end{array}
Initial program 76.2%
associate-*l/76.2%
*-un-lft-identity76.2%
associate-/r*80.6%
Applied egg-rr80.6%
Taylor expanded in l around 0 73.1%
*-commutative73.1%
associate-*r/73.1%
Simplified73.1%
Final simplification73.1%
NOTE: F should be positive before calling this function (FPCore (F l) :precision binary64 (- (* PI l) (/ (/ PI F) (/ F l))))
F = abs(F);
double code(double F, double l) {
return (((double) M_PI) * l) - ((((double) M_PI) / F) / (F / l));
}
F = Math.abs(F);
public static double code(double F, double l) {
return (Math.PI * l) - ((Math.PI / F) / (F / l));
}
F = abs(F) def code(F, l): return (math.pi * l) - ((math.pi / F) / (F / l))
F = abs(F) function code(F, l) return Float64(Float64(pi * l) - Float64(Float64(pi / F) / Float64(F / l))) end
F = abs(F) function tmp = code(F, l) tmp = (pi * l) - ((pi / F) / (F / l)); end
NOTE: F should be positive before calling this function code[F_, l_] := N[(N[(Pi * l), $MachinePrecision] - N[(N[(Pi / F), $MachinePrecision] / N[(F / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
F = |F|\\
\\
\pi \cdot \ell - \frac{\frac{\pi}{F}}{\frac{F}{\ell}}
\end{array}
Initial program 76.2%
Taylor expanded in l around 0 68.7%
unpow268.7%
times-frac73.1%
Simplified73.1%
*-commutative73.1%
clear-num73.0%
un-div-inv73.1%
Applied egg-rr73.1%
Final simplification73.1%
NOTE: F should be positive before calling this function (FPCore (F l) :precision binary64 (- (* PI l) (/ (/ (* PI l) F) F)))
F = abs(F);
double code(double F, double l) {
return (((double) M_PI) * l) - (((((double) M_PI) * l) / F) / F);
}
F = Math.abs(F);
public static double code(double F, double l) {
return (Math.PI * l) - (((Math.PI * l) / F) / F);
}
F = abs(F) def code(F, l): return (math.pi * l) - (((math.pi * l) / F) / F)
F = abs(F) function code(F, l) return Float64(Float64(pi * l) - Float64(Float64(Float64(pi * l) / F) / F)) end
F = abs(F) function tmp = code(F, l) tmp = (pi * l) - (((pi * l) / F) / F); end
NOTE: F should be positive before calling this function code[F_, l_] := N[(N[(Pi * l), $MachinePrecision] - N[(N[(N[(Pi * l), $MachinePrecision] / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
F = |F|\\
\\
\pi \cdot \ell - \frac{\frac{\pi \cdot \ell}{F}}{F}
\end{array}
Initial program 76.2%
associate-*l/76.2%
*-un-lft-identity76.2%
associate-/r*80.6%
Applied egg-rr80.6%
Taylor expanded in l around 0 73.1%
Final simplification73.1%
herbie shell --seed 2023223
(FPCore (F l)
:name "VandenBroeck and Keller, Equation (6)"
:precision binary64
(- (* PI l) (* (/ 1.0 (* F F)) (tan (* PI l)))))