
(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 10 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)) F))
(t_1 (* (pow PI 3.0) 0.3333333333333333))
(t_2
(-
(* 0.008333333333333333 (pow PI 5.0))
(fma
-0.5
(* t_1 (pow PI 2.0))
(* (pow PI 5.0) 0.041666666666666664))))
(t_3
(fma
-1.0
(/ (* (pow t_1 2.0) (* F F)) (pow PI 3.0))
(/ (* (* F F) t_2) (pow PI 2.0)))))
(if (<= F 3.5e-162)
(+ (* PI l) (* t_0 (/ -1.0 F)))
(if (<= F 2.8e-22)
(-
(* PI l)
(/
1.0
(fma
-1.0
(* (pow l 3.0) t_3)
(fma
-1.0
(*
(pow l 5.0)
(fma
-1.0
(/ t_3 (/ PI t_1))
(fma
-1.0
(/ (* t_2 (* t_1 (* F F))) (pow PI 3.0))
(/
(* F F)
(/
(pow PI 2.0)
(-
(* -0.0001984126984126984 (pow PI 7.0))
(fma
-0.5
(* (pow PI 2.0) t_2)
(fma
-0.001388888888888889
(pow PI 7.0)
(* 0.041666666666666664 (* t_1 (pow PI 4.0)))))))))))
(fma
-1.0
(/ (* t_1 (* l (* F F))) (pow PI 2.0))
(/ (* F F) (* PI l)))))))
(+ (* PI l) (/ -1.0 (/ F t_0)))))))F = abs(F);
double code(double F, double l) {
double t_0 = tan((((double) M_PI) * l)) / F;
double t_1 = pow(((double) M_PI), 3.0) * 0.3333333333333333;
double t_2 = (0.008333333333333333 * pow(((double) M_PI), 5.0)) - fma(-0.5, (t_1 * pow(((double) M_PI), 2.0)), (pow(((double) M_PI), 5.0) * 0.041666666666666664));
double t_3 = fma(-1.0, ((pow(t_1, 2.0) * (F * F)) / pow(((double) M_PI), 3.0)), (((F * F) * t_2) / pow(((double) M_PI), 2.0)));
double tmp;
if (F <= 3.5e-162) {
tmp = (((double) M_PI) * l) + (t_0 * (-1.0 / F));
} else if (F <= 2.8e-22) {
tmp = (((double) M_PI) * l) - (1.0 / fma(-1.0, (pow(l, 3.0) * t_3), fma(-1.0, (pow(l, 5.0) * fma(-1.0, (t_3 / (((double) M_PI) / t_1)), fma(-1.0, ((t_2 * (t_1 * (F * F))) / pow(((double) M_PI), 3.0)), ((F * F) / (pow(((double) M_PI), 2.0) / ((-0.0001984126984126984 * pow(((double) M_PI), 7.0)) - fma(-0.5, (pow(((double) M_PI), 2.0) * t_2), fma(-0.001388888888888889, pow(((double) M_PI), 7.0), (0.041666666666666664 * (t_1 * pow(((double) M_PI), 4.0))))))))))), fma(-1.0, ((t_1 * (l * (F * F))) / pow(((double) M_PI), 2.0)), ((F * F) / (((double) M_PI) * l))))));
} else {
tmp = (((double) M_PI) * l) + (-1.0 / (F / t_0));
}
return tmp;
}
F = abs(F) function code(F, l) t_0 = Float64(tan(Float64(pi * l)) / F) t_1 = Float64((pi ^ 3.0) * 0.3333333333333333) t_2 = Float64(Float64(0.008333333333333333 * (pi ^ 5.0)) - fma(-0.5, Float64(t_1 * (pi ^ 2.0)), Float64((pi ^ 5.0) * 0.041666666666666664))) t_3 = fma(-1.0, Float64(Float64((t_1 ^ 2.0) * Float64(F * F)) / (pi ^ 3.0)), Float64(Float64(Float64(F * F) * t_2) / (pi ^ 2.0))) tmp = 0.0 if (F <= 3.5e-162) tmp = Float64(Float64(pi * l) + Float64(t_0 * Float64(-1.0 / F))); elseif (F <= 2.8e-22) tmp = Float64(Float64(pi * l) - Float64(1.0 / fma(-1.0, Float64((l ^ 3.0) * t_3), fma(-1.0, Float64((l ^ 5.0) * fma(-1.0, Float64(t_3 / Float64(pi / t_1)), fma(-1.0, Float64(Float64(t_2 * Float64(t_1 * Float64(F * F))) / (pi ^ 3.0)), Float64(Float64(F * F) / Float64((pi ^ 2.0) / Float64(Float64(-0.0001984126984126984 * (pi ^ 7.0)) - fma(-0.5, Float64((pi ^ 2.0) * t_2), fma(-0.001388888888888889, (pi ^ 7.0), Float64(0.041666666666666664 * Float64(t_1 * (pi ^ 4.0))))))))))), fma(-1.0, Float64(Float64(t_1 * Float64(l * Float64(F * F))) / (pi ^ 2.0)), Float64(Float64(F * F) / Float64(pi * l))))))); else tmp = Float64(Float64(pi * l) + Float64(-1.0 / Float64(F / t_0))); end return tmp end
NOTE: F should be positive before calling this function
code[F_, l_] := Block[{t$95$0 = N[(N[Tan[N[(Pi * l), $MachinePrecision]], $MachinePrecision] / F), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[Pi, 3.0], $MachinePrecision] * 0.3333333333333333), $MachinePrecision]}, Block[{t$95$2 = N[(N[(0.008333333333333333 * N[Power[Pi, 5.0], $MachinePrecision]), $MachinePrecision] - N[(-0.5 * N[(t$95$1 * N[Power[Pi, 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[Power[Pi, 5.0], $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(-1.0 * N[(N[(N[Power[t$95$1, 2.0], $MachinePrecision] * N[(F * F), $MachinePrecision]), $MachinePrecision] / N[Power[Pi, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(F * F), $MachinePrecision] * t$95$2), $MachinePrecision] / N[Power[Pi, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[F, 3.5e-162], N[(N[(Pi * l), $MachinePrecision] + N[(t$95$0 * N[(-1.0 / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[F, 2.8e-22], N[(N[(Pi * l), $MachinePrecision] - N[(1.0 / N[(-1.0 * N[(N[Power[l, 3.0], $MachinePrecision] * t$95$3), $MachinePrecision] + N[(-1.0 * N[(N[Power[l, 5.0], $MachinePrecision] * N[(-1.0 * N[(t$95$3 / N[(Pi / t$95$1), $MachinePrecision]), $MachinePrecision] + N[(-1.0 * N[(N[(t$95$2 * N[(t$95$1 * N[(F * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[Pi, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(F * F), $MachinePrecision] / N[(N[Power[Pi, 2.0], $MachinePrecision] / N[(N[(-0.0001984126984126984 * N[Power[Pi, 7.0], $MachinePrecision]), $MachinePrecision] - N[(-0.5 * N[(N[Power[Pi, 2.0], $MachinePrecision] * t$95$2), $MachinePrecision] + N[(-0.001388888888888889 * N[Power[Pi, 7.0], $MachinePrecision] + N[(0.041666666666666664 * N[(t$95$1 * N[Power[Pi, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0 * N[(N[(t$95$1 * N[(l * N[(F * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[Pi, 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[(F * F), $MachinePrecision] / N[(Pi * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Pi * l), $MachinePrecision] + N[(-1.0 / N[(F / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
F = |F|\\
\\
\begin{array}{l}
t_0 := \frac{\tan \left(\pi \cdot \ell\right)}{F}\\
t_1 := {\pi}^{3} \cdot 0.3333333333333333\\
t_2 := 0.008333333333333333 \cdot {\pi}^{5} - \mathsf{fma}\left(-0.5, t_1 \cdot {\pi}^{2}, {\pi}^{5} \cdot 0.041666666666666664\right)\\
t_3 := \mathsf{fma}\left(-1, \frac{{t_1}^{2} \cdot \left(F \cdot F\right)}{{\pi}^{3}}, \frac{\left(F \cdot F\right) \cdot t_2}{{\pi}^{2}}\right)\\
\mathbf{if}\;F \leq 3.5 \cdot 10^{-162}:\\
\;\;\;\;\pi \cdot \ell + t_0 \cdot \frac{-1}{F}\\
\mathbf{elif}\;F \leq 2.8 \cdot 10^{-22}:\\
\;\;\;\;\pi \cdot \ell - \frac{1}{\mathsf{fma}\left(-1, {\ell}^{3} \cdot t_3, \mathsf{fma}\left(-1, {\ell}^{5} \cdot \mathsf{fma}\left(-1, \frac{t_3}{\frac{\pi}{t_1}}, \mathsf{fma}\left(-1, \frac{t_2 \cdot \left(t_1 \cdot \left(F \cdot F\right)\right)}{{\pi}^{3}}, \frac{F \cdot F}{\frac{{\pi}^{2}}{-0.0001984126984126984 \cdot {\pi}^{7} - \mathsf{fma}\left(-0.5, {\pi}^{2} \cdot t_2, \mathsf{fma}\left(-0.001388888888888889, {\pi}^{7}, 0.041666666666666664 \cdot \left(t_1 \cdot {\pi}^{4}\right)\right)\right)}}\right)\right), \mathsf{fma}\left(-1, \frac{t_1 \cdot \left(\ell \cdot \left(F \cdot F\right)\right)}{{\pi}^{2}}, \frac{F \cdot F}{\pi \cdot \ell}\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell + \frac{-1}{\frac{F}{t_0}}\\
\end{array}
\end{array}
if F < 3.4999999999999999e-162Initial program 67.7%
sqr-neg67.7%
associate-*l/67.7%
*-lft-identity67.7%
sqr-neg67.7%
Simplified67.7%
associate-/r*75.8%
div-inv75.8%
Applied egg-rr75.8%
if 3.4999999999999999e-162 < F < 2.79999999999999995e-22Initial program 68.1%
associate-/r/68.1%
associate-/l*68.1%
Applied egg-rr68.1%
expm1-log1p-u53.1%
Applied egg-rr53.1%
Taylor expanded in l around 0 91.4%
Simplified91.4%
if 2.79999999999999995e-22 < F Initial program 99.0%
associate-/r/99.0%
associate-/l*99.0%
Applied egg-rr99.0%
Final simplification84.5%
NOTE: F should be positive before calling this function
(FPCore (F l)
:precision binary64
(let* ((t_0 (/ (tan (* PI l)) F)) (t_1 (* (pow PI 3.0) 0.3333333333333333)))
(if (<= F 3.5e-164)
(+ (* PI l) (* t_0 (/ -1.0 F)))
(if (<= F 2.05e-22)
(+
(* PI l)
(/
-1.0
(fma
-1.0
(*
(pow l 3.0)
(fma
-1.0
(/ (* (pow t_1 2.0) (* F F)) (pow PI 3.0))
(/
(*
(* F F)
(-
(* 0.008333333333333333 (pow PI 5.0))
(fma
-0.5
(* t_1 (pow PI 2.0))
(* (pow PI 5.0) 0.041666666666666664))))
(pow PI 2.0))))
(fma
-1.0
(/ (* t_1 (* l (* F F))) (pow PI 2.0))
(/ (* F F) (* PI l))))))
(+ (* PI l) (/ -1.0 (/ F t_0)))))))F = abs(F);
double code(double F, double l) {
double t_0 = tan((((double) M_PI) * l)) / F;
double t_1 = pow(((double) M_PI), 3.0) * 0.3333333333333333;
double tmp;
if (F <= 3.5e-164) {
tmp = (((double) M_PI) * l) + (t_0 * (-1.0 / F));
} else if (F <= 2.05e-22) {
tmp = (((double) M_PI) * l) + (-1.0 / fma(-1.0, (pow(l, 3.0) * fma(-1.0, ((pow(t_1, 2.0) * (F * F)) / pow(((double) M_PI), 3.0)), (((F * F) * ((0.008333333333333333 * pow(((double) M_PI), 5.0)) - fma(-0.5, (t_1 * pow(((double) M_PI), 2.0)), (pow(((double) M_PI), 5.0) * 0.041666666666666664)))) / pow(((double) M_PI), 2.0)))), fma(-1.0, ((t_1 * (l * (F * F))) / pow(((double) M_PI), 2.0)), ((F * F) / (((double) M_PI) * l)))));
} else {
tmp = (((double) M_PI) * l) + (-1.0 / (F / t_0));
}
return tmp;
}
F = abs(F) function code(F, l) t_0 = Float64(tan(Float64(pi * l)) / F) t_1 = Float64((pi ^ 3.0) * 0.3333333333333333) tmp = 0.0 if (F <= 3.5e-164) tmp = Float64(Float64(pi * l) + Float64(t_0 * Float64(-1.0 / F))); elseif (F <= 2.05e-22) tmp = Float64(Float64(pi * l) + Float64(-1.0 / fma(-1.0, Float64((l ^ 3.0) * fma(-1.0, Float64(Float64((t_1 ^ 2.0) * Float64(F * F)) / (pi ^ 3.0)), Float64(Float64(Float64(F * F) * Float64(Float64(0.008333333333333333 * (pi ^ 5.0)) - fma(-0.5, Float64(t_1 * (pi ^ 2.0)), Float64((pi ^ 5.0) * 0.041666666666666664)))) / (pi ^ 2.0)))), fma(-1.0, Float64(Float64(t_1 * Float64(l * Float64(F * F))) / (pi ^ 2.0)), Float64(Float64(F * F) / Float64(pi * l)))))); else tmp = Float64(Float64(pi * l) + Float64(-1.0 / Float64(F / t_0))); end return tmp end
NOTE: F should be positive before calling this function
code[F_, l_] := Block[{t$95$0 = N[(N[Tan[N[(Pi * l), $MachinePrecision]], $MachinePrecision] / F), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[Pi, 3.0], $MachinePrecision] * 0.3333333333333333), $MachinePrecision]}, If[LessEqual[F, 3.5e-164], N[(N[(Pi * l), $MachinePrecision] + N[(t$95$0 * N[(-1.0 / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[F, 2.05e-22], N[(N[(Pi * l), $MachinePrecision] + N[(-1.0 / N[(-1.0 * N[(N[Power[l, 3.0], $MachinePrecision] * N[(-1.0 * N[(N[(N[Power[t$95$1, 2.0], $MachinePrecision] * N[(F * F), $MachinePrecision]), $MachinePrecision] / N[Power[Pi, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(F * F), $MachinePrecision] * N[(N[(0.008333333333333333 * N[Power[Pi, 5.0], $MachinePrecision]), $MachinePrecision] - N[(-0.5 * N[(t$95$1 * N[Power[Pi, 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[Power[Pi, 5.0], $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[Pi, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0 * N[(N[(t$95$1 * N[(l * N[(F * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[Pi, 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[(F * F), $MachinePrecision] / N[(Pi * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Pi * l), $MachinePrecision] + N[(-1.0 / N[(F / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
F = |F|\\
\\
\begin{array}{l}
t_0 := \frac{\tan \left(\pi \cdot \ell\right)}{F}\\
t_1 := {\pi}^{3} \cdot 0.3333333333333333\\
\mathbf{if}\;F \leq 3.5 \cdot 10^{-164}:\\
\;\;\;\;\pi \cdot \ell + t_0 \cdot \frac{-1}{F}\\
\mathbf{elif}\;F \leq 2.05 \cdot 10^{-22}:\\
\;\;\;\;\pi \cdot \ell + \frac{-1}{\mathsf{fma}\left(-1, {\ell}^{3} \cdot \mathsf{fma}\left(-1, \frac{{t_1}^{2} \cdot \left(F \cdot F\right)}{{\pi}^{3}}, \frac{\left(F \cdot F\right) \cdot \left(0.008333333333333333 \cdot {\pi}^{5} - \mathsf{fma}\left(-0.5, t_1 \cdot {\pi}^{2}, {\pi}^{5} \cdot 0.041666666666666664\right)\right)}{{\pi}^{2}}\right), \mathsf{fma}\left(-1, \frac{t_1 \cdot \left(\ell \cdot \left(F \cdot F\right)\right)}{{\pi}^{2}}, \frac{F \cdot F}{\pi \cdot \ell}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell + \frac{-1}{\frac{F}{t_0}}\\
\end{array}
\end{array}
if F < 3.5e-164Initial program 67.7%
sqr-neg67.7%
associate-*l/67.7%
*-lft-identity67.7%
sqr-neg67.7%
Simplified67.7%
associate-/r*75.8%
div-inv75.8%
Applied egg-rr75.8%
if 3.5e-164 < F < 2.05e-22Initial program 68.1%
associate-/r/68.1%
associate-/l*68.1%
Applied egg-rr68.1%
expm1-log1p-u53.1%
Applied egg-rr53.1%
Taylor expanded in l around 0 91.3%
Simplified91.3%
if 2.05e-22 < F Initial program 99.0%
associate-/r/99.0%
associate-/l*99.0%
Applied egg-rr99.0%
Final simplification84.5%
NOTE: F should be positive before calling this function
(FPCore (F l)
:precision binary64
(let* ((t_0 (/ (tan (* PI l)) F))
(t_1 (/ (pow PI 2.0) (* F F)))
(t_2 (/ 1.0 (* F F)))
(t_3 (* (pow PI 3.0) 0.3333333333333333)))
(if (<= t_2 1e+42)
(+ (* PI l) (/ -1.0 (/ F t_0)))
(if (<= t_2 5e+299)
(+
(* PI l)
(/
-1.0
(+
(-
(* (/ F PI) (/ F l))
(/ (* (pow PI 3.0) (* l 0.3333333333333333)) t_1))
(*
(pow l 3.0)
(+
(/ (pow t_3 2.0) (/ (pow PI 3.0) (* F F)))
(/
(-
(fma
(* -0.5 (pow PI 2.0))
t_3
(* (pow PI 5.0) 0.041666666666666664))
(* 0.008333333333333333 (pow PI 5.0)))
t_1))))))
(+ (* PI l) (* t_0 (/ -1.0 F)))))))F = abs(F);
double code(double F, double l) {
double t_0 = tan((((double) M_PI) * l)) / F;
double t_1 = pow(((double) M_PI), 2.0) / (F * F);
double t_2 = 1.0 / (F * F);
double t_3 = pow(((double) M_PI), 3.0) * 0.3333333333333333;
double tmp;
if (t_2 <= 1e+42) {
tmp = (((double) M_PI) * l) + (-1.0 / (F / t_0));
} else if (t_2 <= 5e+299) {
tmp = (((double) M_PI) * l) + (-1.0 / ((((F / ((double) M_PI)) * (F / l)) - ((pow(((double) M_PI), 3.0) * (l * 0.3333333333333333)) / t_1)) + (pow(l, 3.0) * ((pow(t_3, 2.0) / (pow(((double) M_PI), 3.0) / (F * F))) + ((fma((-0.5 * pow(((double) M_PI), 2.0)), t_3, (pow(((double) M_PI), 5.0) * 0.041666666666666664)) - (0.008333333333333333 * pow(((double) M_PI), 5.0))) / t_1)))));
} else {
tmp = (((double) M_PI) * l) + (t_0 * (-1.0 / F));
}
return tmp;
}
F = abs(F) function code(F, l) t_0 = Float64(tan(Float64(pi * l)) / F) t_1 = Float64((pi ^ 2.0) / Float64(F * F)) t_2 = Float64(1.0 / Float64(F * F)) t_3 = Float64((pi ^ 3.0) * 0.3333333333333333) tmp = 0.0 if (t_2 <= 1e+42) tmp = Float64(Float64(pi * l) + Float64(-1.0 / Float64(F / t_0))); elseif (t_2 <= 5e+299) tmp = Float64(Float64(pi * l) + Float64(-1.0 / Float64(Float64(Float64(Float64(F / pi) * Float64(F / l)) - Float64(Float64((pi ^ 3.0) * Float64(l * 0.3333333333333333)) / t_1)) + Float64((l ^ 3.0) * Float64(Float64((t_3 ^ 2.0) / Float64((pi ^ 3.0) / Float64(F * F))) + Float64(Float64(fma(Float64(-0.5 * (pi ^ 2.0)), t_3, Float64((pi ^ 5.0) * 0.041666666666666664)) - Float64(0.008333333333333333 * (pi ^ 5.0))) / t_1)))))); else tmp = Float64(Float64(pi * l) + Float64(t_0 * Float64(-1.0 / F))); end return tmp end
NOTE: F should be positive before calling this function
code[F_, l_] := Block[{t$95$0 = N[(N[Tan[N[(Pi * l), $MachinePrecision]], $MachinePrecision] / F), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[Pi, 2.0], $MachinePrecision] / N[(F * F), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 / N[(F * F), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Power[Pi, 3.0], $MachinePrecision] * 0.3333333333333333), $MachinePrecision]}, If[LessEqual[t$95$2, 1e+42], N[(N[(Pi * l), $MachinePrecision] + N[(-1.0 / N[(F / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e+299], N[(N[(Pi * l), $MachinePrecision] + N[(-1.0 / N[(N[(N[(N[(F / Pi), $MachinePrecision] * N[(F / l), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Power[Pi, 3.0], $MachinePrecision] * N[(l * 0.3333333333333333), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision] + N[(N[Power[l, 3.0], $MachinePrecision] * N[(N[(N[Power[t$95$3, 2.0], $MachinePrecision] / N[(N[Power[Pi, 3.0], $MachinePrecision] / N[(F * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(-0.5 * N[Power[Pi, 2.0], $MachinePrecision]), $MachinePrecision] * t$95$3 + N[(N[Power[Pi, 5.0], $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision] - N[(0.008333333333333333 * N[Power[Pi, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Pi * l), $MachinePrecision] + N[(t$95$0 * N[(-1.0 / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
F = |F|\\
\\
\begin{array}{l}
t_0 := \frac{\tan \left(\pi \cdot \ell\right)}{F}\\
t_1 := \frac{{\pi}^{2}}{F \cdot F}\\
t_2 := \frac{1}{F \cdot F}\\
t_3 := {\pi}^{3} \cdot 0.3333333333333333\\
\mathbf{if}\;t_2 \leq 10^{+42}:\\
\;\;\;\;\pi \cdot \ell + \frac{-1}{\frac{F}{t_0}}\\
\mathbf{elif}\;t_2 \leq 5 \cdot 10^{+299}:\\
\;\;\;\;\pi \cdot \ell + \frac{-1}{\left(\frac{F}{\pi} \cdot \frac{F}{\ell} - \frac{{\pi}^{3} \cdot \left(\ell \cdot 0.3333333333333333\right)}{t_1}\right) + {\ell}^{3} \cdot \left(\frac{{t_3}^{2}}{\frac{{\pi}^{3}}{F \cdot F}} + \frac{\mathsf{fma}\left(-0.5 \cdot {\pi}^{2}, t_3, {\pi}^{5} \cdot 0.041666666666666664\right) - 0.008333333333333333 \cdot {\pi}^{5}}{t_1}\right)}\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell + t_0 \cdot \frac{-1}{F}\\
\end{array}
\end{array}
if (/.f64 1 (*.f64 F F)) < 1.00000000000000004e42Initial program 99.2%
associate-/r/99.2%
associate-/l*99.2%
Applied egg-rr99.2%
if 1.00000000000000004e42 < (/.f64 1 (*.f64 F F)) < 5.0000000000000003e299Initial program 73.3%
associate-/r/73.3%
associate-/l*73.4%
Applied egg-rr73.4%
expm1-log1p-u56.9%
Applied egg-rr56.9%
Taylor expanded in l around 0 92.1%
Simplified92.2%
if 5.0000000000000003e299 < (/.f64 1 (*.f64 F F)) Initial program 33.8%
sqr-neg33.8%
associate-*l/33.8%
*-lft-identity33.8%
sqr-neg33.8%
Simplified33.8%
associate-/r*51.4%
div-inv51.4%
Applied egg-rr51.4%
Final simplification85.1%
NOTE: F should be positive before calling this function (FPCore (F l) :precision binary64 (if (<= F 3.5e-164) (- (* PI l) (* (/ l F) (/ PI F))) (- (* PI l) (/ (tan (* PI l)) (* F F)))))
F = abs(F);
double code(double F, double l) {
double tmp;
if (F <= 3.5e-164) {
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;
}
F = Math.abs(F);
public static double code(double F, double l) {
double tmp;
if (F <= 3.5e-164) {
tmp = (Math.PI * l) - ((l / F) * (Math.PI / 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 <= 3.5e-164: tmp = (math.pi * l) - ((l / F) * (math.pi / 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 <= 3.5e-164) 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
F = abs(F) function tmp_2 = code(F, l) tmp = 0.0; if (F <= 3.5e-164) tmp = (pi * l) - ((l / F) * (pi / 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, 3.5e-164], 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}
F = |F|\\
\\
\begin{array}{l}
\mathbf{if}\;F \leq 3.5 \cdot 10^{-164}:\\
\;\;\;\;\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 F < 3.5e-164Initial program 67.7%
Taylor expanded in l around 0 63.0%
associate-/l*63.0%
associate-/r/63.0%
unpow263.0%
Simplified63.0%
Taylor expanded in l around 0 63.0%
unpow263.0%
times-frac71.1%
Simplified71.1%
if 3.5e-164 < F Initial program 89.2%
sqr-neg89.2%
associate-*l/89.2%
*-lft-identity89.2%
sqr-neg89.2%
Simplified89.2%
Final simplification78.6%
NOTE: F should be positive before calling this function (FPCore (F l) :precision binary64 (+ (* PI l) (* (/ (tan (* PI l)) F) (/ -1.0 F))))
F = abs(F);
double code(double F, double l) {
return (((double) M_PI) * l) + ((tan((((double) M_PI) * l)) / F) * (-1.0 / F));
}
F = Math.abs(F);
public static double code(double F, double l) {
return (Math.PI * l) + ((Math.tan((Math.PI * l)) / F) * (-1.0 / F));
}
F = abs(F) def code(F, l): return (math.pi * l) + ((math.tan((math.pi * l)) / F) * (-1.0 / F))
F = abs(F) function code(F, l) return Float64(Float64(pi * l) + Float64(Float64(tan(Float64(pi * l)) / F) * Float64(-1.0 / F))) end
F = abs(F) function tmp = code(F, l) tmp = (pi * l) + ((tan((pi * l)) / F) * (-1.0 / 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] * N[(-1.0 / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
F = |F|\\
\\
\pi \cdot \ell + \frac{\tan \left(\pi \cdot \ell\right)}{F} \cdot \frac{-1}{F}
\end{array}
Initial program 76.7%
sqr-neg76.7%
associate-*l/76.7%
*-lft-identity76.7%
sqr-neg76.7%
Simplified76.7%
associate-/r*81.4%
div-inv81.4%
Applied egg-rr81.4%
Final simplification81.4%
NOTE: F should be positive before calling this function (FPCore (F l) :precision binary64 (+ (* PI l) (/ -1.0 (/ F (/ (tan (* PI l)) F)))))
F = abs(F);
double code(double F, double l) {
return (((double) M_PI) * l) + (-1.0 / (F / (tan((((double) M_PI) * l)) / F)));
}
F = Math.abs(F);
public static double code(double F, double l) {
return (Math.PI * l) + (-1.0 / (F / (Math.tan((Math.PI * l)) / F)));
}
F = abs(F) def code(F, l): return (math.pi * l) + (-1.0 / (F / (math.tan((math.pi * l)) / F)))
F = abs(F) function code(F, l) return Float64(Float64(pi * l) + Float64(-1.0 / Float64(F / Float64(tan(Float64(pi * l)) / F)))) end
F = abs(F) function tmp = code(F, l) tmp = (pi * l) + (-1.0 / (F / (tan((pi * l)) / F))); end
NOTE: F should be positive before calling this function code[F_, l_] := N[(N[(Pi * l), $MachinePrecision] + N[(-1.0 / N[(F / N[(N[Tan[N[(Pi * l), $MachinePrecision]], $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
F = |F|\\
\\
\pi \cdot \ell + \frac{-1}{\frac{F}{\frac{\tan \left(\pi \cdot \ell\right)}{F}}}
\end{array}
Initial program 76.7%
associate-/r/76.7%
associate-/l*81.4%
Applied egg-rr81.4%
Final simplification81.4%
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.7%
associate-*l/76.7%
*-un-lft-identity76.7%
associate-/r*81.4%
Applied egg-rr81.4%
Final simplification81.4%
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.7%
Taylor expanded in l around 0 69.6%
associate-/l*69.6%
associate-/r/69.6%
unpow269.6%
Simplified69.6%
Taylor expanded in l around 0 69.6%
unpow269.6%
times-frac74.4%
Simplified74.4%
Final simplification74.4%
NOTE: F should be positive before calling this function (FPCore (F l) :precision binary64 (* PI (- l (* l (pow F -2.0)))))
F = abs(F);
double code(double F, double l) {
return ((double) M_PI) * (l - (l * pow(F, -2.0)));
}
F = Math.abs(F);
public static double code(double F, double l) {
return Math.PI * (l - (l * Math.pow(F, -2.0)));
}
F = abs(F) def code(F, l): return math.pi * (l - (l * math.pow(F, -2.0)))
F = abs(F) function code(F, l) return Float64(pi * Float64(l - Float64(l * (F ^ -2.0)))) end
F = abs(F) function tmp = code(F, l) tmp = pi * (l - (l * (F ^ -2.0))); end
NOTE: F should be positive before calling this function code[F_, l_] := N[(Pi * N[(l - N[(l * N[Power[F, -2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
F = |F|\\
\\
\pi \cdot \left(\ell - \ell \cdot {F}^{-2}\right)
\end{array}
Initial program 76.7%
Taylor expanded in l around 0 69.6%
associate-/l*69.6%
associate-/r/69.6%
unpow269.6%
Simplified69.6%
add-sqr-sqrt52.0%
sqrt-unprod59.3%
pow259.3%
associate-*l/59.3%
times-frac60.1%
Applied egg-rr60.1%
unpow260.1%
rem-sqrt-square64.0%
times-frac60.8%
*-commutative60.8%
*-lft-identity60.8%
associate-*l*60.8%
associate-*l/60.8%
associate-/r*60.8%
*-lft-identity60.8%
associate-*l/60.8%
unpow-160.8%
unpow-160.8%
pow-sqr60.8%
metadata-eval60.8%
*-commutative60.8%
Simplified60.8%
Taylor expanded in l around 0 60.8%
mul-1-neg60.8%
+-commutative60.8%
sub-neg60.8%
*-commutative60.8%
unpow260.8%
associate-/l*60.8%
associate-*r/60.8%
associate-/r*64.0%
associate-/l*64.0%
*-rgt-identity64.0%
associate-*r/64.0%
associate-*l/64.0%
*-commutative64.0%
associate-*l/64.0%
*-rgt-identity64.0%
associate-*r/64.0%
associate-*l*60.8%
Simplified69.7%
Final simplification69.7%
NOTE: F should be positive before calling this function (FPCore (F l) :precision binary64 (* l (/ (/ PI F) (- F))))
F = abs(F);
double code(double F, double l) {
return l * ((((double) M_PI) / F) / -F);
}
F = Math.abs(F);
public static double code(double F, double l) {
return l * ((Math.PI / F) / -F);
}
F = abs(F) def code(F, l): return l * ((math.pi / F) / -F)
F = abs(F) function code(F, l) return Float64(l * Float64(Float64(pi / F) / Float64(-F))) end
F = abs(F) function tmp = code(F, l) tmp = l * ((pi / F) / -F); end
NOTE: F should be positive before calling this function code[F_, l_] := N[(l * N[(N[(Pi / F), $MachinePrecision] / (-F)), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
F = |F|\\
\\
\ell \cdot \frac{\frac{\pi}{F}}{-F}
\end{array}
Initial program 76.7%
Taylor expanded in l around 0 69.6%
associate-/l*69.6%
associate-/r/69.6%
unpow269.6%
Simplified69.6%
add-sqr-sqrt52.0%
sqrt-unprod59.3%
pow259.3%
associate-*l/59.3%
times-frac60.1%
Applied egg-rr60.1%
unpow260.1%
rem-sqrt-square64.0%
times-frac60.8%
*-commutative60.8%
*-lft-identity60.8%
associate-*l*60.8%
associate-*l/60.8%
associate-/r*60.8%
*-lft-identity60.8%
associate-*l/60.8%
unpow-160.8%
unpow-160.8%
pow-sqr60.8%
metadata-eval60.8%
*-commutative60.8%
Simplified60.8%
Taylor expanded in l around 0 15.2%
Simplified23.7%
Final simplification23.7%
herbie shell --seed 2023285
(FPCore (F l)
:name "VandenBroeck and Keller, Equation (6)"
:precision binary64
(- (* PI l) (* (/ 1.0 (* F F)) (tan (* PI l)))))