
(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
(let* ((t_0 (tan (* PI l))) (t_1 (- (* PI l) (/ (* F F) t_0))))
(if (<= (* PI l) -2e+22)
t_1
(if (<= (* PI l) 7.5e+194)
(- (* PI l) (/ (/ t_0 F) F))
(if (<= (* PI l) 2e+226)
t_1
(- (* PI l) (/ (tan (expm1 (log1p (* PI l)))) (* F F))))))))
double code(double F, double l) {
double t_0 = tan((((double) M_PI) * l));
double t_1 = (((double) M_PI) * l) - ((F * F) / t_0);
double tmp;
if ((((double) M_PI) * l) <= -2e+22) {
tmp = t_1;
} else if ((((double) M_PI) * l) <= 7.5e+194) {
tmp = (((double) M_PI) * l) - ((t_0 / F) / F);
} else if ((((double) M_PI) * l) <= 2e+226) {
tmp = t_1;
} else {
tmp = (((double) M_PI) * l) - (tan(expm1(log1p((((double) M_PI) * l)))) / (F * F));
}
return tmp;
}
public static double code(double F, double l) {
double t_0 = Math.tan((Math.PI * l));
double t_1 = (Math.PI * l) - ((F * F) / t_0);
double tmp;
if ((Math.PI * l) <= -2e+22) {
tmp = t_1;
} else if ((Math.PI * l) <= 7.5e+194) {
tmp = (Math.PI * l) - ((t_0 / F) / F);
} else if ((Math.PI * l) <= 2e+226) {
tmp = t_1;
} else {
tmp = (Math.PI * l) - (Math.tan(Math.expm1(Math.log1p((Math.PI * l)))) / (F * F));
}
return tmp;
}
def code(F, l): t_0 = math.tan((math.pi * l)) t_1 = (math.pi * l) - ((F * F) / t_0) tmp = 0 if (math.pi * l) <= -2e+22: tmp = t_1 elif (math.pi * l) <= 7.5e+194: tmp = (math.pi * l) - ((t_0 / F) / F) elif (math.pi * l) <= 2e+226: tmp = t_1 else: tmp = (math.pi * l) - (math.tan(math.expm1(math.log1p((math.pi * l)))) / (F * F)) return tmp
function code(F, l) t_0 = tan(Float64(pi * l)) t_1 = Float64(Float64(pi * l) - Float64(Float64(F * F) / t_0)) tmp = 0.0 if (Float64(pi * l) <= -2e+22) tmp = t_1; elseif (Float64(pi * l) <= 7.5e+194) tmp = Float64(Float64(pi * l) - Float64(Float64(t_0 / F) / F)); elseif (Float64(pi * l) <= 2e+226) tmp = t_1; else tmp = Float64(Float64(pi * l) - Float64(tan(expm1(log1p(Float64(pi * l)))) / Float64(F * F))); end return tmp end
code[F_, l_] := Block[{t$95$0 = N[Tan[N[(Pi * l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(Pi * l), $MachinePrecision] - N[(N[(F * F), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(Pi * l), $MachinePrecision], -2e+22], t$95$1, If[LessEqual[N[(Pi * l), $MachinePrecision], 7.5e+194], N[(N[(Pi * l), $MachinePrecision] - N[(N[(t$95$0 / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(Pi * l), $MachinePrecision], 2e+226], t$95$1, N[(N[(Pi * l), $MachinePrecision] - N[(N[Tan[N[(Exp[N[Log[1 + N[(Pi * l), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision] / N[(F * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan \left(\pi \cdot \ell\right)\\
t_1 := \pi \cdot \ell - \frac{F \cdot F}{t_0}\\
\mathbf{if}\;\pi \cdot \ell \leq -2 \cdot 10^{+22}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\pi \cdot \ell \leq 7.5 \cdot 10^{+194}:\\
\;\;\;\;\pi \cdot \ell - \frac{\frac{t_0}{F}}{F}\\
\mathbf{elif}\;\pi \cdot \ell \leq 2 \cdot 10^{+226}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell - \frac{\tan \left(\mathsf{expm1}\left(\mathsf{log1p}\left(\pi \cdot \ell\right)\right)\right)}{F \cdot F}\\
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < -2e22 or 7.5000000000000002e194 < (*.f64 (PI.f64) l) < 1.99999999999999992e226Initial program 49.2%
inv-pow49.2%
unpow-prod-down49.2%
pow-prod-up49.2%
add-sqr-sqrt14.8%
pow214.8%
pow-pow14.8%
metadata-eval14.8%
metadata-eval14.8%
Applied egg-rr14.8%
*-commutative14.8%
sqrt-pow249.2%
sqr-pow49.2%
metadata-eval49.2%
metadata-eval49.2%
inv-pow49.2%
metadata-eval49.2%
metadata-eval49.2%
inv-pow49.2%
associate-*r*49.2%
div-inv49.2%
div-inv49.2%
clear-num49.2%
unpow-149.2%
exp-to-pow25.3%
add-sqr-sqrt10.9%
sqrt-unprod16.3%
Applied egg-rr76.9%
if -2e22 < (*.f64 (PI.f64) l) < 7.5000000000000002e194Initial program 87.0%
associate-*l/87.7%
*-un-lft-identity87.7%
associate-/r*94.1%
Applied egg-rr94.1%
if 1.99999999999999992e226 < (*.f64 (PI.f64) l) Initial program 75.8%
associate-*l/75.8%
*-lft-identity75.8%
Simplified75.8%
expm1-log1p-u76.8%
Applied egg-rr76.8%
Final simplification88.4%
(FPCore (F l)
:precision binary64
(let* ((t_0 (tan (* PI l))) (t_1 (- (* PI l) (/ (* F F) t_0))))
(if (<= (* PI l) -2e+22)
t_1
(if (<= (* PI l) 7.5e+194)
(- (* PI l) (/ (/ t_0 F) F))
(if (<= (* PI l) 2e+226)
t_1
(- (* PI l) (* t_0 (exp (* (log F) -2.0)))))))))
double code(double F, double l) {
double t_0 = tan((((double) M_PI) * l));
double t_1 = (((double) M_PI) * l) - ((F * F) / t_0);
double tmp;
if ((((double) M_PI) * l) <= -2e+22) {
tmp = t_1;
} else if ((((double) M_PI) * l) <= 7.5e+194) {
tmp = (((double) M_PI) * l) - ((t_0 / F) / F);
} else if ((((double) M_PI) * l) <= 2e+226) {
tmp = t_1;
} else {
tmp = (((double) M_PI) * l) - (t_0 * exp((log(F) * -2.0)));
}
return tmp;
}
public static double code(double F, double l) {
double t_0 = Math.tan((Math.PI * l));
double t_1 = (Math.PI * l) - ((F * F) / t_0);
double tmp;
if ((Math.PI * l) <= -2e+22) {
tmp = t_1;
} else if ((Math.PI * l) <= 7.5e+194) {
tmp = (Math.PI * l) - ((t_0 / F) / F);
} else if ((Math.PI * l) <= 2e+226) {
tmp = t_1;
} else {
tmp = (Math.PI * l) - (t_0 * Math.exp((Math.log(F) * -2.0)));
}
return tmp;
}
def code(F, l): t_0 = math.tan((math.pi * l)) t_1 = (math.pi * l) - ((F * F) / t_0) tmp = 0 if (math.pi * l) <= -2e+22: tmp = t_1 elif (math.pi * l) <= 7.5e+194: tmp = (math.pi * l) - ((t_0 / F) / F) elif (math.pi * l) <= 2e+226: tmp = t_1 else: tmp = (math.pi * l) - (t_0 * math.exp((math.log(F) * -2.0))) return tmp
function code(F, l) t_0 = tan(Float64(pi * l)) t_1 = Float64(Float64(pi * l) - Float64(Float64(F * F) / t_0)) tmp = 0.0 if (Float64(pi * l) <= -2e+22) tmp = t_1; elseif (Float64(pi * l) <= 7.5e+194) tmp = Float64(Float64(pi * l) - Float64(Float64(t_0 / F) / F)); elseif (Float64(pi * l) <= 2e+226) tmp = t_1; else tmp = Float64(Float64(pi * l) - Float64(t_0 * exp(Float64(log(F) * -2.0)))); end return tmp end
function tmp_2 = code(F, l) t_0 = tan((pi * l)); t_1 = (pi * l) - ((F * F) / t_0); tmp = 0.0; if ((pi * l) <= -2e+22) tmp = t_1; elseif ((pi * l) <= 7.5e+194) tmp = (pi * l) - ((t_0 / F) / F); elseif ((pi * l) <= 2e+226) tmp = t_1; else tmp = (pi * l) - (t_0 * exp((log(F) * -2.0))); end tmp_2 = tmp; end
code[F_, l_] := Block[{t$95$0 = N[Tan[N[(Pi * l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(Pi * l), $MachinePrecision] - N[(N[(F * F), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(Pi * l), $MachinePrecision], -2e+22], t$95$1, If[LessEqual[N[(Pi * l), $MachinePrecision], 7.5e+194], N[(N[(Pi * l), $MachinePrecision] - N[(N[(t$95$0 / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(Pi * l), $MachinePrecision], 2e+226], t$95$1, N[(N[(Pi * l), $MachinePrecision] - N[(t$95$0 * N[Exp[N[(N[Log[F], $MachinePrecision] * -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan \left(\pi \cdot \ell\right)\\
t_1 := \pi \cdot \ell - \frac{F \cdot F}{t_0}\\
\mathbf{if}\;\pi \cdot \ell \leq -2 \cdot 10^{+22}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\pi \cdot \ell \leq 7.5 \cdot 10^{+194}:\\
\;\;\;\;\pi \cdot \ell - \frac{\frac{t_0}{F}}{F}\\
\mathbf{elif}\;\pi \cdot \ell \leq 2 \cdot 10^{+226}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell - t_0 \cdot e^{\log F \cdot -2}\\
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < -2e22 or 7.5000000000000002e194 < (*.f64 (PI.f64) l) < 1.99999999999999992e226Initial program 49.2%
inv-pow49.2%
unpow-prod-down49.2%
pow-prod-up49.2%
add-sqr-sqrt14.8%
pow214.8%
pow-pow14.8%
metadata-eval14.8%
metadata-eval14.8%
Applied egg-rr14.8%
*-commutative14.8%
sqrt-pow249.2%
sqr-pow49.2%
metadata-eval49.2%
metadata-eval49.2%
inv-pow49.2%
metadata-eval49.2%
metadata-eval49.2%
inv-pow49.2%
associate-*r*49.2%
div-inv49.2%
div-inv49.2%
clear-num49.2%
unpow-149.2%
exp-to-pow25.3%
add-sqr-sqrt10.9%
sqrt-unprod16.3%
Applied egg-rr76.9%
if -2e22 < (*.f64 (PI.f64) l) < 7.5000000000000002e194Initial program 87.0%
associate-*l/87.7%
*-un-lft-identity87.7%
associate-/r*94.1%
Applied egg-rr94.1%
if 1.99999999999999992e226 < (*.f64 (PI.f64) l) Initial program 75.8%
inv-pow75.8%
unpow-prod-down75.8%
pow-prod-up75.8%
pow-to-exp32.1%
metadata-eval32.1%
Applied egg-rr32.1%
Final simplification85.6%
(FPCore (F l)
:precision binary64
(let* ((t_0 (tan (* PI l))) (t_1 (- (* PI l) (/ (* F F) t_0))))
(if (<= (* PI l) -2e+22)
t_1
(if (<= (* PI l) 5e-88)
(- (* PI l) (* (/ l F) (/ PI F)))
(if (or (<= (* PI l) 7.5e+194) (not (<= (* PI l) 2e+226)))
(- (* PI l) (/ t_0 (* F F)))
t_1)))))
double code(double F, double l) {
double t_0 = tan((((double) M_PI) * l));
double t_1 = (((double) M_PI) * l) - ((F * F) / t_0);
double tmp;
if ((((double) M_PI) * l) <= -2e+22) {
tmp = t_1;
} else if ((((double) M_PI) * l) <= 5e-88) {
tmp = (((double) M_PI) * l) - ((l / F) * (((double) M_PI) / F));
} else if (((((double) M_PI) * l) <= 7.5e+194) || !((((double) M_PI) * l) <= 2e+226)) {
tmp = (((double) M_PI) * l) - (t_0 / (F * F));
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double F, double l) {
double t_0 = Math.tan((Math.PI * l));
double t_1 = (Math.PI * l) - ((F * F) / t_0);
double tmp;
if ((Math.PI * l) <= -2e+22) {
tmp = t_1;
} else if ((Math.PI * l) <= 5e-88) {
tmp = (Math.PI * l) - ((l / F) * (Math.PI / F));
} else if (((Math.PI * l) <= 7.5e+194) || !((Math.PI * l) <= 2e+226)) {
tmp = (Math.PI * l) - (t_0 / (F * F));
} else {
tmp = t_1;
}
return tmp;
}
def code(F, l): t_0 = math.tan((math.pi * l)) t_1 = (math.pi * l) - ((F * F) / t_0) tmp = 0 if (math.pi * l) <= -2e+22: tmp = t_1 elif (math.pi * l) <= 5e-88: tmp = (math.pi * l) - ((l / F) * (math.pi / F)) elif ((math.pi * l) <= 7.5e+194) or not ((math.pi * l) <= 2e+226): tmp = (math.pi * l) - (t_0 / (F * F)) else: tmp = t_1 return tmp
function code(F, l) t_0 = tan(Float64(pi * l)) t_1 = Float64(Float64(pi * l) - Float64(Float64(F * F) / t_0)) tmp = 0.0 if (Float64(pi * l) <= -2e+22) tmp = t_1; elseif (Float64(pi * l) <= 5e-88) tmp = Float64(Float64(pi * l) - Float64(Float64(l / F) * Float64(pi / F))); elseif ((Float64(pi * l) <= 7.5e+194) || !(Float64(pi * l) <= 2e+226)) tmp = Float64(Float64(pi * l) - Float64(t_0 / Float64(F * F))); else tmp = t_1; end return tmp end
function tmp_2 = code(F, l) t_0 = tan((pi * l)); t_1 = (pi * l) - ((F * F) / t_0); tmp = 0.0; if ((pi * l) <= -2e+22) tmp = t_1; elseif ((pi * l) <= 5e-88) tmp = (pi * l) - ((l / F) * (pi / F)); elseif (((pi * l) <= 7.5e+194) || ~(((pi * l) <= 2e+226))) tmp = (pi * l) - (t_0 / (F * F)); else tmp = t_1; end tmp_2 = tmp; end
code[F_, l_] := Block[{t$95$0 = N[Tan[N[(Pi * l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(Pi * l), $MachinePrecision] - N[(N[(F * F), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(Pi * l), $MachinePrecision], -2e+22], t$95$1, If[LessEqual[N[(Pi * l), $MachinePrecision], 5e-88], N[(N[(Pi * l), $MachinePrecision] - N[(N[(l / F), $MachinePrecision] * N[(Pi / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[N[(Pi * l), $MachinePrecision], 7.5e+194], N[Not[LessEqual[N[(Pi * l), $MachinePrecision], 2e+226]], $MachinePrecision]], N[(N[(Pi * l), $MachinePrecision] - N[(t$95$0 / N[(F * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan \left(\pi \cdot \ell\right)\\
t_1 := \pi \cdot \ell - \frac{F \cdot F}{t_0}\\
\mathbf{if}\;\pi \cdot \ell \leq -2 \cdot 10^{+22}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\pi \cdot \ell \leq 5 \cdot 10^{-88}:\\
\;\;\;\;\pi \cdot \ell - \frac{\ell}{F} \cdot \frac{\pi}{F}\\
\mathbf{elif}\;\pi \cdot \ell \leq 7.5 \cdot 10^{+194} \lor \neg \left(\pi \cdot \ell \leq 2 \cdot 10^{+226}\right):\\
\;\;\;\;\pi \cdot \ell - \frac{t_0}{F \cdot F}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < -2e22 or 7.5000000000000002e194 < (*.f64 (PI.f64) l) < 1.99999999999999992e226Initial program 49.2%
inv-pow49.2%
unpow-prod-down49.2%
pow-prod-up49.2%
add-sqr-sqrt14.8%
pow214.8%
pow-pow14.8%
metadata-eval14.8%
metadata-eval14.8%
Applied egg-rr14.8%
*-commutative14.8%
sqrt-pow249.2%
sqr-pow49.2%
metadata-eval49.2%
metadata-eval49.2%
inv-pow49.2%
metadata-eval49.2%
metadata-eval49.2%
inv-pow49.2%
associate-*r*49.2%
div-inv49.2%
div-inv49.2%
clear-num49.2%
unpow-149.2%
exp-to-pow25.3%
add-sqr-sqrt10.9%
sqrt-unprod16.3%
Applied egg-rr76.9%
if -2e22 < (*.f64 (PI.f64) l) < 5.00000000000000009e-88Initial program 88.6%
Taylor expanded in l around 0 89.7%
unpow289.7%
times-frac99.6%
Simplified99.6%
if 5.00000000000000009e-88 < (*.f64 (PI.f64) l) < 7.5000000000000002e194 or 1.99999999999999992e226 < (*.f64 (PI.f64) l) Initial program 82.1%
associate-*l/82.1%
*-lft-identity82.1%
Simplified82.1%
Final simplification88.3%
(FPCore (F l)
:precision binary64
(let* ((t_0 (tan (* PI l))) (t_1 (- (* PI l) (/ (* F F) t_0))))
(if (<= (* PI l) -2e+22)
t_1
(if (<= (* PI l) 7.5e+194)
(- (* PI l) (/ (/ t_0 F) F))
(if (<= (* PI l) 2e+226) t_1 (- (* PI l) (/ t_0 (* F F))))))))
double code(double F, double l) {
double t_0 = tan((((double) M_PI) * l));
double t_1 = (((double) M_PI) * l) - ((F * F) / t_0);
double tmp;
if ((((double) M_PI) * l) <= -2e+22) {
tmp = t_1;
} else if ((((double) M_PI) * l) <= 7.5e+194) {
tmp = (((double) M_PI) * l) - ((t_0 / F) / F);
} else if ((((double) M_PI) * l) <= 2e+226) {
tmp = t_1;
} else {
tmp = (((double) M_PI) * l) - (t_0 / (F * F));
}
return tmp;
}
public static double code(double F, double l) {
double t_0 = Math.tan((Math.PI * l));
double t_1 = (Math.PI * l) - ((F * F) / t_0);
double tmp;
if ((Math.PI * l) <= -2e+22) {
tmp = t_1;
} else if ((Math.PI * l) <= 7.5e+194) {
tmp = (Math.PI * l) - ((t_0 / F) / F);
} else if ((Math.PI * l) <= 2e+226) {
tmp = t_1;
} else {
tmp = (Math.PI * l) - (t_0 / (F * F));
}
return tmp;
}
def code(F, l): t_0 = math.tan((math.pi * l)) t_1 = (math.pi * l) - ((F * F) / t_0) tmp = 0 if (math.pi * l) <= -2e+22: tmp = t_1 elif (math.pi * l) <= 7.5e+194: tmp = (math.pi * l) - ((t_0 / F) / F) elif (math.pi * l) <= 2e+226: tmp = t_1 else: tmp = (math.pi * l) - (t_0 / (F * F)) return tmp
function code(F, l) t_0 = tan(Float64(pi * l)) t_1 = Float64(Float64(pi * l) - Float64(Float64(F * F) / t_0)) tmp = 0.0 if (Float64(pi * l) <= -2e+22) tmp = t_1; elseif (Float64(pi * l) <= 7.5e+194) tmp = Float64(Float64(pi * l) - Float64(Float64(t_0 / F) / F)); elseif (Float64(pi * l) <= 2e+226) tmp = t_1; else tmp = Float64(Float64(pi * l) - Float64(t_0 / Float64(F * F))); end return tmp end
function tmp_2 = code(F, l) t_0 = tan((pi * l)); t_1 = (pi * l) - ((F * F) / t_0); tmp = 0.0; if ((pi * l) <= -2e+22) tmp = t_1; elseif ((pi * l) <= 7.5e+194) tmp = (pi * l) - ((t_0 / F) / F); elseif ((pi * l) <= 2e+226) tmp = t_1; else tmp = (pi * l) - (t_0 / (F * F)); end tmp_2 = tmp; end
code[F_, l_] := Block[{t$95$0 = N[Tan[N[(Pi * l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(Pi * l), $MachinePrecision] - N[(N[(F * F), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(Pi * l), $MachinePrecision], -2e+22], t$95$1, If[LessEqual[N[(Pi * l), $MachinePrecision], 7.5e+194], N[(N[(Pi * l), $MachinePrecision] - N[(N[(t$95$0 / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(Pi * l), $MachinePrecision], 2e+226], t$95$1, N[(N[(Pi * l), $MachinePrecision] - N[(t$95$0 / N[(F * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan \left(\pi \cdot \ell\right)\\
t_1 := \pi \cdot \ell - \frac{F \cdot F}{t_0}\\
\mathbf{if}\;\pi \cdot \ell \leq -2 \cdot 10^{+22}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\pi \cdot \ell \leq 7.5 \cdot 10^{+194}:\\
\;\;\;\;\pi \cdot \ell - \frac{\frac{t_0}{F}}{F}\\
\mathbf{elif}\;\pi \cdot \ell \leq 2 \cdot 10^{+226}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell - \frac{t_0}{F \cdot F}\\
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < -2e22 or 7.5000000000000002e194 < (*.f64 (PI.f64) l) < 1.99999999999999992e226Initial program 49.2%
inv-pow49.2%
unpow-prod-down49.2%
pow-prod-up49.2%
add-sqr-sqrt14.8%
pow214.8%
pow-pow14.8%
metadata-eval14.8%
metadata-eval14.8%
Applied egg-rr14.8%
*-commutative14.8%
sqrt-pow249.2%
sqr-pow49.2%
metadata-eval49.2%
metadata-eval49.2%
inv-pow49.2%
metadata-eval49.2%
metadata-eval49.2%
inv-pow49.2%
associate-*r*49.2%
div-inv49.2%
div-inv49.2%
clear-num49.2%
unpow-149.2%
exp-to-pow25.3%
add-sqr-sqrt10.9%
sqrt-unprod16.3%
Applied egg-rr76.9%
if -2e22 < (*.f64 (PI.f64) l) < 7.5000000000000002e194Initial program 87.0%
associate-*l/87.7%
*-un-lft-identity87.7%
associate-/r*94.1%
Applied egg-rr94.1%
if 1.99999999999999992e226 < (*.f64 (PI.f64) l) Initial program 75.8%
associate-*l/75.8%
*-lft-identity75.8%
Simplified75.8%
Final simplification88.3%
(FPCore (F l) :precision binary64 (if (<= (* F F) 2e-320) (- (* PI l) (* (/ l F) (/ PI F))) (- (* PI l) (/ (tan (* PI l)) (* F F)))))
double code(double F, double l) {
double tmp;
if ((F * F) <= 2e-320) {
tmp = (((double) M_PI) * l) - ((l / F) * (((double) M_PI) / 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 ((F * F) <= 2e-320) {
tmp = (Math.PI * l) - ((l / F) * (Math.PI / F));
} else {
tmp = (Math.PI * l) - (Math.tan((Math.PI * l)) / (F * F));
}
return tmp;
}
def code(F, l): tmp = 0 if (F * F) <= 2e-320: tmp = (math.pi * l) - ((l / F) * (math.pi / F)) else: tmp = (math.pi * l) - (math.tan((math.pi * l)) / (F * F)) return tmp
function code(F, l) tmp = 0.0 if (Float64(F * F) <= 2e-320) tmp = Float64(Float64(pi * l) - Float64(Float64(l / F) * Float64(pi / 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 ((F * F) <= 2e-320) tmp = (pi * l) - ((l / F) * (pi / F)); else tmp = (pi * l) - (tan((pi * l)) / (F * F)); end tmp_2 = tmp; end
code[F_, l_] := If[LessEqual[N[(F * F), $MachinePrecision], 2e-320], N[(N[(Pi * l), $MachinePrecision] - N[(N[(l / F), $MachinePrecision] * N[(Pi / F), $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}
\\
\begin{array}{l}
\mathbf{if}\;F \cdot F \leq 2 \cdot 10^{-320}:\\
\;\;\;\;\pi \cdot \ell - \frac{\ell}{F} \cdot \frac{\pi}{F}\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell - \frac{\tan \left(\pi \cdot \ell\right)}{F \cdot F}\\
\end{array}
\end{array}
if (*.f64 F F) < 1.99998e-320Initial program 32.4%
Taylor expanded in l around 0 30.0%
unpow230.0%
times-frac49.2%
Simplified49.2%
if 1.99998e-320 < (*.f64 F F) Initial program 88.6%
associate-*l/89.0%
*-lft-identity89.0%
Simplified89.0%
Final simplification80.2%
(FPCore (F l) :precision binary64 (- (* PI l) (* (/ l F) (/ PI F))))
double code(double F, double l) {
return (((double) M_PI) * l) - ((l / F) * (((double) M_PI) / F));
}
public static double code(double F, double l) {
return (Math.PI * l) - ((l / F) * (Math.PI / F));
}
def code(F, l): return (math.pi * l) - ((l / F) * (math.pi / F))
function code(F, l) return Float64(Float64(pi * l) - Float64(Float64(l / F) * Float64(pi / F))) end
function tmp = code(F, l) tmp = (pi * l) - ((l / F) * (pi / F)); end
code[F_, l_] := N[(N[(Pi * l), $MachinePrecision] - N[(N[(l / F), $MachinePrecision] * N[(Pi / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\pi \cdot \ell - \frac{\ell}{F} \cdot \frac{\pi}{F}
\end{array}
Initial program 76.1%
Taylor expanded in l around 0 68.6%
unpow268.6%
times-frac72.9%
Simplified72.9%
Final simplification72.9%
herbie shell --seed 2023240
(FPCore (F l)
:name "VandenBroeck and Keller, Equation (6)"
:precision binary64
(- (* PI l) (* (/ 1.0 (* F F)) (tan (* PI l)))))