
(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 6 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) 1000000000000.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) <= 1000000000000.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) <= 1000000000000.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) <= 1000000000000.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) <= 1000000000000.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) <= 1000000000000.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], 1000000000000.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 1000000000000\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 1e12 < (*.f64 (PI.f64) l) Initial program 64.7%
sqr-neg64.7%
associate-*l/64.7%
*-lft-identity64.7%
sqr-neg64.7%
Simplified64.7%
Taylor expanded in l around 0 45.4%
unpow245.4%
Simplified45.4%
Taylor expanded in F around inf 99.6%
if -2e16 < (*.f64 (PI.f64) l) < 1e12Initial program 91.3%
associate-*l/91.3%
*-un-lft-identity91.3%
associate-/r*99.1%
Applied egg-rr99.1%
Final simplification99.3%
(FPCore (F l) :precision binary64 (if (or (<= (* PI l) -500000000000.0) (not (<= (* PI l) 1e-26))) (* PI l) (* PI (- l (/ (/ l F) F)))))
double code(double F, double l) {
double tmp;
if (((((double) M_PI) * l) <= -500000000000.0) || !((((double) M_PI) * l) <= 1e-26)) {
tmp = ((double) M_PI) * l;
} else {
tmp = ((double) M_PI) * (l - ((l / F) / F));
}
return tmp;
}
public static double code(double F, double l) {
double tmp;
if (((Math.PI * l) <= -500000000000.0) || !((Math.PI * l) <= 1e-26)) {
tmp = Math.PI * l;
} else {
tmp = Math.PI * (l - ((l / F) / F));
}
return tmp;
}
def code(F, l): tmp = 0 if ((math.pi * l) <= -500000000000.0) or not ((math.pi * l) <= 1e-26): tmp = math.pi * l else: tmp = math.pi * (l - ((l / F) / F)) return tmp
function code(F, l) tmp = 0.0 if ((Float64(pi * l) <= -500000000000.0) || !(Float64(pi * l) <= 1e-26)) tmp = Float64(pi * l); else tmp = Float64(pi * Float64(l - Float64(Float64(l / F) / F))); end return tmp end
function tmp_2 = code(F, l) tmp = 0.0; if (((pi * l) <= -500000000000.0) || ~(((pi * l) <= 1e-26))) tmp = pi * l; else tmp = pi * (l - ((l / F) / F)); end tmp_2 = tmp; end
code[F_, l_] := If[Or[LessEqual[N[(Pi * l), $MachinePrecision], -500000000000.0], N[Not[LessEqual[N[(Pi * l), $MachinePrecision], 1e-26]], $MachinePrecision]], N[(Pi * l), $MachinePrecision], N[(Pi * N[(l - N[(N[(l / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\pi \cdot \ell \leq -500000000000 \lor \neg \left(\pi \cdot \ell \leq 10^{-26}\right):\\
\;\;\;\;\pi \cdot \ell\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \left(\ell - \frac{\frac{\ell}{F}}{F}\right)\\
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < -5e11 or 1e-26 < (*.f64 (PI.f64) l) Initial program 66.1%
sqr-neg66.1%
associate-*l/66.1%
*-lft-identity66.1%
sqr-neg66.1%
Simplified66.1%
Taylor expanded in l around 0 45.3%
unpow245.3%
Simplified45.3%
Taylor expanded in F around inf 96.7%
if -5e11 < (*.f64 (PI.f64) l) < 1e-26Initial program 91.3%
Taylor expanded in l around 0 90.7%
associate-/l*90.7%
associate-/r/90.7%
unpow290.7%
Simplified90.7%
*-commutative90.7%
distribute-lft-out--90.7%
associate-/r*99.0%
Applied egg-rr99.0%
Final simplification97.8%
(FPCore (F l) :precision binary64 (if (<= (* F F) 5e-155) (+ (* PI l) -1.0) (if (<= (* F F) 1e-98) (/ (- l) (/ (* F F) PI)) (* PI l))))
double code(double F, double l) {
double tmp;
if ((F * F) <= 5e-155) {
tmp = (((double) M_PI) * l) + -1.0;
} else if ((F * F) <= 1e-98) {
tmp = -l / ((F * F) / ((double) M_PI));
} else {
tmp = ((double) M_PI) * l;
}
return tmp;
}
public static double code(double F, double l) {
double tmp;
if ((F * F) <= 5e-155) {
tmp = (Math.PI * l) + -1.0;
} else if ((F * F) <= 1e-98) {
tmp = -l / ((F * F) / Math.PI);
} else {
tmp = Math.PI * l;
}
return tmp;
}
def code(F, l): tmp = 0 if (F * F) <= 5e-155: tmp = (math.pi * l) + -1.0 elif (F * F) <= 1e-98: tmp = -l / ((F * F) / math.pi) else: tmp = math.pi * l return tmp
function code(F, l) tmp = 0.0 if (Float64(F * F) <= 5e-155) tmp = Float64(Float64(pi * l) + -1.0); elseif (Float64(F * F) <= 1e-98) tmp = Float64(Float64(-l) / Float64(Float64(F * F) / pi)); else tmp = Float64(pi * l); end return tmp end
function tmp_2 = code(F, l) tmp = 0.0; if ((F * F) <= 5e-155) tmp = (pi * l) + -1.0; elseif ((F * F) <= 1e-98) tmp = -l / ((F * F) / pi); else tmp = pi * l; end tmp_2 = tmp; end
code[F_, l_] := If[LessEqual[N[(F * F), $MachinePrecision], 5e-155], N[(N[(Pi * l), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[N[(F * F), $MachinePrecision], 1e-98], N[((-l) / N[(N[(F * F), $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], N[(Pi * l), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \cdot F \leq 5 \cdot 10^{-155}:\\
\;\;\;\;\pi \cdot \ell + -1\\
\mathbf{elif}\;F \cdot F \leq 10^{-98}:\\
\;\;\;\;\frac{-\ell}{\frac{F \cdot F}{\pi}}\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell\\
\end{array}
\end{array}
if (*.f64 F F) < 4.9999999999999999e-155Initial program 43.5%
associate-/r/43.5%
inv-pow43.5%
pow-to-exp21.8%
associate-/l*26.3%
Applied egg-rr26.3%
exp-to-pow54.9%
unpow-154.9%
clear-num54.9%
associate-/l/43.5%
add-sqr-sqrt21.6%
frac-times26.6%
div-inv26.7%
associate-*l*23.6%
add-sqr-sqrt9.7%
sqrt-unprod11.1%
frac-times10.1%
add-sqr-sqrt10.1%
associate-/l/11.1%
clear-num11.1%
Applied egg-rr23.6%
*-commutative23.6%
associate-*l/23.6%
*-lft-identity23.6%
associate-/r/23.6%
*-inverses54.0%
Simplified54.0%
if 4.9999999999999999e-155 < (*.f64 F F) < 9.99999999999999939e-99Initial program 85.6%
sqr-neg85.6%
associate-*l/85.4%
*-lft-identity85.4%
sqr-neg85.4%
Simplified85.4%
Taylor expanded in l around 0 76.6%
unpow276.6%
Simplified76.6%
Taylor expanded in F around 0 76.7%
mul-1-neg76.7%
associate-/l*76.6%
unpow276.6%
Simplified76.6%
if 9.99999999999999939e-99 < (*.f64 F F) Initial program 97.7%
sqr-neg97.7%
associate-*l/97.7%
*-lft-identity97.7%
sqr-neg97.7%
Simplified97.7%
Taylor expanded in l around 0 86.8%
unpow286.8%
Simplified86.8%
Taylor expanded in F around inf 91.6%
Final simplification77.8%
(FPCore (F l) :precision binary64 (if (<= (* F F) 5e-155) (+ (* PI l) -1.0) (if (<= (* F F) 1e-98) (/ (* PI (- l)) (* F F)) (* PI l))))
double code(double F, double l) {
double tmp;
if ((F * F) <= 5e-155) {
tmp = (((double) M_PI) * l) + -1.0;
} else if ((F * F) <= 1e-98) {
tmp = (((double) M_PI) * -l) / (F * F);
} else {
tmp = ((double) M_PI) * l;
}
return tmp;
}
public static double code(double F, double l) {
double tmp;
if ((F * F) <= 5e-155) {
tmp = (Math.PI * l) + -1.0;
} else if ((F * F) <= 1e-98) {
tmp = (Math.PI * -l) / (F * F);
} else {
tmp = Math.PI * l;
}
return tmp;
}
def code(F, l): tmp = 0 if (F * F) <= 5e-155: tmp = (math.pi * l) + -1.0 elif (F * F) <= 1e-98: tmp = (math.pi * -l) / (F * F) else: tmp = math.pi * l return tmp
function code(F, l) tmp = 0.0 if (Float64(F * F) <= 5e-155) tmp = Float64(Float64(pi * l) + -1.0); elseif (Float64(F * F) <= 1e-98) tmp = Float64(Float64(pi * Float64(-l)) / Float64(F * F)); else tmp = Float64(pi * l); end return tmp end
function tmp_2 = code(F, l) tmp = 0.0; if ((F * F) <= 5e-155) tmp = (pi * l) + -1.0; elseif ((F * F) <= 1e-98) tmp = (pi * -l) / (F * F); else tmp = pi * l; end tmp_2 = tmp; end
code[F_, l_] := If[LessEqual[N[(F * F), $MachinePrecision], 5e-155], N[(N[(Pi * l), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[N[(F * F), $MachinePrecision], 1e-98], N[(N[(Pi * (-l)), $MachinePrecision] / N[(F * F), $MachinePrecision]), $MachinePrecision], N[(Pi * l), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \cdot F \leq 5 \cdot 10^{-155}:\\
\;\;\;\;\pi \cdot \ell + -1\\
\mathbf{elif}\;F \cdot F \leq 10^{-98}:\\
\;\;\;\;\frac{\pi \cdot \left(-\ell\right)}{F \cdot F}\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell\\
\end{array}
\end{array}
if (*.f64 F F) < 4.9999999999999999e-155Initial program 43.5%
associate-/r/43.5%
inv-pow43.5%
pow-to-exp21.8%
associate-/l*26.3%
Applied egg-rr26.3%
exp-to-pow54.9%
unpow-154.9%
clear-num54.9%
associate-/l/43.5%
add-sqr-sqrt21.6%
frac-times26.6%
div-inv26.7%
associate-*l*23.6%
add-sqr-sqrt9.7%
sqrt-unprod11.1%
frac-times10.1%
add-sqr-sqrt10.1%
associate-/l/11.1%
clear-num11.1%
Applied egg-rr23.6%
*-commutative23.6%
associate-*l/23.6%
*-lft-identity23.6%
associate-/r/23.6%
*-inverses54.0%
Simplified54.0%
if 4.9999999999999999e-155 < (*.f64 F F) < 9.99999999999999939e-99Initial program 85.6%
sqr-neg85.6%
associate-*l/85.4%
*-lft-identity85.4%
sqr-neg85.4%
Simplified85.4%
Taylor expanded in l around 0 76.6%
unpow276.6%
Simplified76.6%
Taylor expanded in F around 0 76.7%
associate-*r/76.7%
*-commutative76.7%
neg-mul-176.7%
distribute-rgt-neg-in76.7%
unpow276.7%
Simplified76.7%
if 9.99999999999999939e-99 < (*.f64 F F) Initial program 97.7%
sqr-neg97.7%
associate-*l/97.7%
*-lft-identity97.7%
sqr-neg97.7%
Simplified97.7%
Taylor expanded in l around 0 86.8%
unpow286.8%
Simplified86.8%
Taylor expanded in F around inf 91.6%
Final simplification77.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.2%
sqr-neg78.2%
associate-*l/78.2%
*-lft-identity78.2%
sqr-neg78.2%
Simplified78.2%
Taylor expanded in l around 0 67.1%
unpow267.1%
Simplified67.1%
Taylor expanded in F around inf 75.0%
Final simplification75.0%
(FPCore (F l) :precision binary64 -1.0)
double code(double F, double l) {
return -1.0;
}
real(8) function code(f, l)
real(8), intent (in) :: f
real(8), intent (in) :: l
code = -1.0d0
end function
public static double code(double F, double l) {
return -1.0;
}
def code(F, l): return -1.0
function code(F, l) return -1.0 end
function tmp = code(F, l) tmp = -1.0; end
code[F_, l_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 78.2%
associate-/r/78.2%
inv-pow78.2%
pow-to-exp41.4%
associate-/l*43.0%
Applied egg-rr43.0%
exp-to-pow82.2%
unpow-182.2%
clear-num82.2%
associate-/l/78.2%
add-sqr-sqrt41.7%
frac-times43.5%
div-inv43.5%
associate-*l*42.4%
add-sqr-sqrt21.6%
sqrt-unprod35.8%
frac-times35.5%
add-sqr-sqrt35.5%
associate-/l/35.8%
clear-num35.8%
Applied egg-rr25.1%
*-commutative25.1%
associate-*l/25.1%
*-lft-identity25.1%
associate-/r/25.1%
*-inverses52.1%
Simplified52.1%
Taylor expanded in l around 0 3.3%
Final simplification3.3%
herbie shell --seed 2023293
(FPCore (F l)
:name "VandenBroeck and Keller, Equation (6)"
:precision binary64
(- (* PI l) (* (/ 1.0 (* F F)) (tan (* PI l)))))