
(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}
Herbie found 4 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 (<= l -6.5e+20) (* l PI) (if (<= l 0.5) (- (* PI l) (/ (* l PI) (pow F 2.0))) (* l PI))))
double code(double F, double l) {
double tmp;
if (l <= -6.5e+20) {
tmp = l * ((double) M_PI);
} else if (l <= 0.5) {
tmp = (((double) M_PI) * l) - ((l * ((double) M_PI)) / pow(F, 2.0));
} else {
tmp = l * ((double) M_PI);
}
return tmp;
}
public static double code(double F, double l) {
double tmp;
if (l <= -6.5e+20) {
tmp = l * Math.PI;
} else if (l <= 0.5) {
tmp = (Math.PI * l) - ((l * Math.PI) / Math.pow(F, 2.0));
} else {
tmp = l * Math.PI;
}
return tmp;
}
def code(F, l): tmp = 0 if l <= -6.5e+20: tmp = l * math.pi elif l <= 0.5: tmp = (math.pi * l) - ((l * math.pi) / math.pow(F, 2.0)) else: tmp = l * math.pi return tmp
function code(F, l) tmp = 0.0 if (l <= -6.5e+20) tmp = Float64(l * pi); elseif (l <= 0.5) tmp = Float64(Float64(pi * l) - Float64(Float64(l * pi) / (F ^ 2.0))); else tmp = Float64(l * pi); end return tmp end
function tmp_2 = code(F, l) tmp = 0.0; if (l <= -6.5e+20) tmp = l * pi; elseif (l <= 0.5) tmp = (pi * l) - ((l * pi) / (F ^ 2.0)); else tmp = l * pi; end tmp_2 = tmp; end
code[F_, l_] := If[LessEqual[l, -6.5e+20], N[(l * Pi), $MachinePrecision], If[LessEqual[l, 0.5], N[(N[(Pi * l), $MachinePrecision] - N[(N[(l * Pi), $MachinePrecision] / N[Power[F, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(l * Pi), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -6.5 \cdot 10^{+20}:\\
\;\;\;\;\ell \cdot \pi\\
\mathbf{elif}\;\ell \leq 0.5:\\
\;\;\;\;\pi \cdot \ell - \frac{\ell \cdot \pi}{{F}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\ell \cdot \pi\\
\end{array}
\end{array}
if l < -6.5e20 or 0.5 < l Initial program 76.0%
Taylor expanded in F around inf
Applied rewrites73.3%
if -6.5e20 < l < 0.5Initial program 76.0%
Taylor expanded in l around 0
Applied rewrites68.9%
(FPCore (F l) :precision binary64 (if (<= l -6.5e+20) (* l PI) (if (<= l 0.5) (* l (- PI (/ PI (* F F)))) (* l PI))))
double code(double F, double l) {
double tmp;
if (l <= -6.5e+20) {
tmp = l * ((double) M_PI);
} else if (l <= 0.5) {
tmp = l * (((double) M_PI) - (((double) M_PI) / (F * F)));
} else {
tmp = l * ((double) M_PI);
}
return tmp;
}
public static double code(double F, double l) {
double tmp;
if (l <= -6.5e+20) {
tmp = l * Math.PI;
} else if (l <= 0.5) {
tmp = l * (Math.PI - (Math.PI / (F * F)));
} else {
tmp = l * Math.PI;
}
return tmp;
}
def code(F, l): tmp = 0 if l <= -6.5e+20: tmp = l * math.pi elif l <= 0.5: tmp = l * (math.pi - (math.pi / (F * F))) else: tmp = l * math.pi return tmp
function code(F, l) tmp = 0.0 if (l <= -6.5e+20) tmp = Float64(l * pi); elseif (l <= 0.5) tmp = Float64(l * Float64(pi - Float64(pi / Float64(F * F)))); else tmp = Float64(l * pi); end return tmp end
function tmp_2 = code(F, l) tmp = 0.0; if (l <= -6.5e+20) tmp = l * pi; elseif (l <= 0.5) tmp = l * (pi - (pi / (F * F))); else tmp = l * pi; end tmp_2 = tmp; end
code[F_, l_] := If[LessEqual[l, -6.5e+20], N[(l * Pi), $MachinePrecision], If[LessEqual[l, 0.5], N[(l * N[(Pi - N[(Pi / N[(F * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(l * Pi), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -6.5 \cdot 10^{+20}:\\
\;\;\;\;\ell \cdot \pi\\
\mathbf{elif}\;\ell \leq 0.5:\\
\;\;\;\;\ell \cdot \left(\pi - \frac{\pi}{F \cdot F}\right)\\
\mathbf{else}:\\
\;\;\;\;\ell \cdot \pi\\
\end{array}
\end{array}
if l < -6.5e20 or 0.5 < l Initial program 76.0%
Taylor expanded in F around inf
Applied rewrites73.3%
if -6.5e20 < l < 0.5Initial program 76.0%
Taylor expanded in l around 0
Applied rewrites68.5%
Taylor expanded in F around 0
Applied rewrites44.0%
Applied rewrites68.5%
(FPCore (F l) :precision binary64 (if (<= l -7e-22) (* l PI) (if (<= l -2.05e-293) (- (/ (* l PI) (* F F))) (* l PI))))
double code(double F, double l) {
double tmp;
if (l <= -7e-22) {
tmp = l * ((double) M_PI);
} else if (l <= -2.05e-293) {
tmp = -((l * ((double) M_PI)) / (F * F));
} else {
tmp = l * ((double) M_PI);
}
return tmp;
}
public static double code(double F, double l) {
double tmp;
if (l <= -7e-22) {
tmp = l * Math.PI;
} else if (l <= -2.05e-293) {
tmp = -((l * Math.PI) / (F * F));
} else {
tmp = l * Math.PI;
}
return tmp;
}
def code(F, l): tmp = 0 if l <= -7e-22: tmp = l * math.pi elif l <= -2.05e-293: tmp = -((l * math.pi) / (F * F)) else: tmp = l * math.pi return tmp
function code(F, l) tmp = 0.0 if (l <= -7e-22) tmp = Float64(l * pi); elseif (l <= -2.05e-293) tmp = Float64(-Float64(Float64(l * pi) / Float64(F * F))); else tmp = Float64(l * pi); end return tmp end
function tmp_2 = code(F, l) tmp = 0.0; if (l <= -7e-22) tmp = l * pi; elseif (l <= -2.05e-293) tmp = -((l * pi) / (F * F)); else tmp = l * pi; end tmp_2 = tmp; end
code[F_, l_] := If[LessEqual[l, -7e-22], N[(l * Pi), $MachinePrecision], If[LessEqual[l, -2.05e-293], (-N[(N[(l * Pi), $MachinePrecision] / N[(F * F), $MachinePrecision]), $MachinePrecision]), N[(l * Pi), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -7 \cdot 10^{-22}:\\
\;\;\;\;\ell \cdot \pi\\
\mathbf{elif}\;\ell \leq -2.05 \cdot 10^{-293}:\\
\;\;\;\;-\frac{\ell \cdot \pi}{F \cdot F}\\
\mathbf{else}:\\
\;\;\;\;\ell \cdot \pi\\
\end{array}
\end{array}
if l < -7.00000000000000011e-22 or -2.04999999999999994e-293 < l Initial program 76.0%
Taylor expanded in F around inf
Applied rewrites73.3%
if -7.00000000000000011e-22 < l < -2.04999999999999994e-293Initial program 76.0%
Taylor expanded in l around 0
Applied rewrites68.5%
Taylor expanded in F around 0
Applied rewrites21.3%
Applied rewrites21.3%
(FPCore (F l) :precision binary64 (* l PI))
double code(double F, double l) {
return l * ((double) M_PI);
}
public static double code(double F, double l) {
return l * Math.PI;
}
def code(F, l): return l * math.pi
function code(F, l) return Float64(l * pi) end
function tmp = code(F, l) tmp = l * pi; end
code[F_, l_] := N[(l * Pi), $MachinePrecision]
\begin{array}{l}
\\
\ell \cdot \pi
\end{array}
Initial program 76.0%
Taylor expanded in F around inf
Applied rewrites73.3%
herbie shell --seed 2025160
(FPCore (F l)
:name "VandenBroeck and Keller, Equation (6)"
:precision binary64
(- (* PI l) (* (/ 1.0 (* F F)) (tan (* PI l)))))