
(FPCore (a b) :precision binary64 (* (* (/ PI 2.0) (/ 1.0 (- (* b b) (* a a)))) (- (/ 1.0 a) (/ 1.0 b))))
double code(double a, double b) {
return ((((double) M_PI) / 2.0) * (1.0 / ((b * b) - (a * a)))) * ((1.0 / a) - (1.0 / b));
}
public static double code(double a, double b) {
return ((Math.PI / 2.0) * (1.0 / ((b * b) - (a * a)))) * ((1.0 / a) - (1.0 / b));
}
def code(a, b): return ((math.pi / 2.0) * (1.0 / ((b * b) - (a * a)))) * ((1.0 / a) - (1.0 / b))
function code(a, b) return Float64(Float64(Float64(pi / 2.0) * Float64(1.0 / Float64(Float64(b * b) - Float64(a * a)))) * Float64(Float64(1.0 / a) - Float64(1.0 / b))) end
function tmp = code(a, b) tmp = ((pi / 2.0) * (1.0 / ((b * b) - (a * a)))) * ((1.0 / a) - (1.0 / b)); end
code[a_, b_] := N[(N[(N[(Pi / 2.0), $MachinePrecision] * N[(1.0 / N[(N[(b * b), $MachinePrecision] - N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / a), $MachinePrecision] - N[(1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b) :precision binary64 (* (* (/ PI 2.0) (/ 1.0 (- (* b b) (* a a)))) (- (/ 1.0 a) (/ 1.0 b))))
double code(double a, double b) {
return ((((double) M_PI) / 2.0) * (1.0 / ((b * b) - (a * a)))) * ((1.0 / a) - (1.0 / b));
}
public static double code(double a, double b) {
return ((Math.PI / 2.0) * (1.0 / ((b * b) - (a * a)))) * ((1.0 / a) - (1.0 / b));
}
def code(a, b): return ((math.pi / 2.0) * (1.0 / ((b * b) - (a * a)))) * ((1.0 / a) - (1.0 / b))
function code(a, b) return Float64(Float64(Float64(pi / 2.0) * Float64(1.0 / Float64(Float64(b * b) - Float64(a * a)))) * Float64(Float64(1.0 / a) - Float64(1.0 / b))) end
function tmp = code(a, b) tmp = ((pi / 2.0) * (1.0 / ((b * b) - (a * a)))) * ((1.0 / a) - (1.0 / b)); end
code[a_, b_] := N[(N[(N[(Pi / 2.0), $MachinePrecision] * N[(1.0 / N[(N[(b * b), $MachinePrecision] - N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / a), $MachinePrecision] - N[(1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right)
\end{array}
(FPCore (a b) :precision binary64 (/ (/ PI (+ b a)) (* (* b a) 2.0)))
double code(double a, double b) {
return (((double) M_PI) / (b + a)) / ((b * a) * 2.0);
}
public static double code(double a, double b) {
return (Math.PI / (b + a)) / ((b * a) * 2.0);
}
def code(a, b): return (math.pi / (b + a)) / ((b * a) * 2.0)
function code(a, b) return Float64(Float64(pi / Float64(b + a)) / Float64(Float64(b * a) * 2.0)) end
function tmp = code(a, b) tmp = (pi / (b + a)) / ((b * a) * 2.0); end
code[a_, b_] := N[(N[(Pi / N[(b + a), $MachinePrecision]), $MachinePrecision] / N[(N[(b * a), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\pi}{b + a}}{\left(b \cdot a\right) \cdot 2}
\end{array}
Initial program 75.9%
add-sqr-sqrt51.7%
sqrt-unprod47.8%
pow147.8%
pow147.8%
pow-sqr47.8%
Applied egg-rr53.5%
associate-*r/53.5%
associate-*l*53.5%
+-commutative53.5%
*-commutative53.5%
Simplified53.5%
sqrt-pow199.6%
*-commutative99.6%
metadata-eval99.6%
pow199.6%
associate-*r*99.6%
metadata-eval99.6%
div-inv99.6%
*-commutative99.6%
associate-*l/99.6%
frac-times99.6%
*-commutative99.6%
un-div-inv99.7%
+-commutative99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (a b) :precision binary64 (if (<= a -9e+106) (/ (/ (* PI (/ 0.5 a)) b) a) (/ PI (* b (* a (* (+ b a) 2.0))))))
double code(double a, double b) {
double tmp;
if (a <= -9e+106) {
tmp = ((((double) M_PI) * (0.5 / a)) / b) / a;
} else {
tmp = ((double) M_PI) / (b * (a * ((b + a) * 2.0)));
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (a <= -9e+106) {
tmp = ((Math.PI * (0.5 / a)) / b) / a;
} else {
tmp = Math.PI / (b * (a * ((b + a) * 2.0)));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -9e+106: tmp = ((math.pi * (0.5 / a)) / b) / a else: tmp = math.pi / (b * (a * ((b + a) * 2.0))) return tmp
function code(a, b) tmp = 0.0 if (a <= -9e+106) tmp = Float64(Float64(Float64(pi * Float64(0.5 / a)) / b) / a); else tmp = Float64(pi / Float64(b * Float64(a * Float64(Float64(b + a) * 2.0)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -9e+106) tmp = ((pi * (0.5 / a)) / b) / a; else tmp = pi / (b * (a * ((b + a) * 2.0))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -9e+106], N[(N[(N[(Pi * N[(0.5 / a), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision] / a), $MachinePrecision], N[(Pi / N[(b * N[(a * N[(N[(b + a), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -9 \cdot 10^{+106}:\\
\;\;\;\;\frac{\frac{\pi \cdot \frac{0.5}{a}}{b}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi}{b \cdot \left(a \cdot \left(\left(b + a\right) \cdot 2\right)\right)}\\
\end{array}
\end{array}
if a < -8.9999999999999994e106Initial program 59.8%
add-sqr-sqrt57.1%
sqrt-unprod55.3%
pow155.3%
pow155.3%
pow-sqr55.3%
Applied egg-rr73.4%
associate-*r/73.4%
associate-*l*73.4%
+-commutative73.4%
*-commutative73.4%
Simplified73.4%
sqrt-pow199.6%
*-commutative99.6%
metadata-eval99.6%
pow199.6%
associate-/r*99.7%
un-div-inv99.7%
+-commutative99.7%
Applied egg-rr99.7%
Taylor expanded in b around 0 99.7%
if -8.9999999999999994e106 < a Initial program 78.7%
associate-*l*78.6%
associate-*l/78.6%
frac-sub78.6%
*-commutative78.6%
associate-*r/78.5%
*-commutative78.5%
*-un-lft-identity78.5%
*-un-lft-identity78.5%
associate-/r/78.6%
flip-+99.5%
Applied egg-rr99.5%
associate-/l*98.9%
associate-/l/99.0%
associate-/r/99.0%
metadata-eval99.0%
*-commutative99.0%
associate-*l*99.0%
*-commutative99.0%
associate-*l*94.8%
+-commutative94.8%
Simplified94.8%
Final simplification95.5%
(FPCore (a b) :precision binary64 (if (<= b 9.5e-81) (/ (* 0.5 (/ (/ PI b) a)) a) (* PI (/ (/ 0.5 (* b a)) b))))
double code(double a, double b) {
double tmp;
if (b <= 9.5e-81) {
tmp = (0.5 * ((((double) M_PI) / b) / a)) / a;
} else {
tmp = ((double) M_PI) * ((0.5 / (b * a)) / b);
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (b <= 9.5e-81) {
tmp = (0.5 * ((Math.PI / b) / a)) / a;
} else {
tmp = Math.PI * ((0.5 / (b * a)) / b);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 9.5e-81: tmp = (0.5 * ((math.pi / b) / a)) / a else: tmp = math.pi * ((0.5 / (b * a)) / b) return tmp
function code(a, b) tmp = 0.0 if (b <= 9.5e-81) tmp = Float64(Float64(0.5 * Float64(Float64(pi / b) / a)) / a); else tmp = Float64(pi * Float64(Float64(0.5 / Float64(b * a)) / b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 9.5e-81) tmp = (0.5 * ((pi / b) / a)) / a; else tmp = pi * ((0.5 / (b * a)) / b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 9.5e-81], N[(N[(0.5 * N[(N[(Pi / b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(Pi * N[(N[(0.5 / N[(b * a), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 9.5 \cdot 10^{-81}:\\
\;\;\;\;\frac{0.5 \cdot \frac{\frac{\pi}{b}}{a}}{a}\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \frac{\frac{0.5}{b \cdot a}}{b}\\
\end{array}
\end{array}
if b < 9.49999999999999917e-81Initial program 74.9%
add-sqr-sqrt46.9%
sqrt-unprod44.9%
pow144.9%
pow144.9%
pow-sqr44.9%
Applied egg-rr50.3%
associate-*r/50.4%
associate-*l*50.4%
+-commutative50.4%
*-commutative50.4%
Simplified50.4%
sqrt-pow199.6%
*-commutative99.6%
metadata-eval99.6%
pow199.6%
associate-/r*94.5%
un-div-inv94.5%
+-commutative94.5%
Applied egg-rr94.5%
Taylor expanded in b around 0 73.7%
associate-/l/73.7%
Simplified73.7%
if 9.49999999999999917e-81 < b Initial program 78.0%
associate-*l*77.9%
associate-*l/77.9%
frac-sub77.9%
*-commutative77.9%
associate-*r/77.8%
*-commutative77.8%
*-un-lft-identity77.8%
*-un-lft-identity77.8%
associate-/r/77.9%
flip-+99.6%
Applied egg-rr99.6%
associate-/l*97.0%
associate-/l/96.9%
associate-/r/97.0%
metadata-eval97.0%
*-commutative97.0%
associate-*l*97.0%
*-commutative97.0%
associate-*l*95.9%
+-commutative95.9%
Simplified95.9%
Taylor expanded in a around 0 84.4%
associate-*r*84.4%
*-commutative84.4%
*-commutative84.4%
Simplified84.4%
div-inv84.4%
*-commutative84.4%
*-commutative84.4%
associate-/r*84.7%
associate-*r*84.7%
*-commutative84.7%
associate-/r*84.7%
metadata-eval84.7%
Applied egg-rr84.7%
Final simplification77.0%
(FPCore (a b) :precision binary64 (let* ((t_0 (* 0.5 (/ (/ PI b) a)))) (if (<= a -1.8e-66) (/ t_0 a) (/ t_0 b))))
double code(double a, double b) {
double t_0 = 0.5 * ((((double) M_PI) / b) / a);
double tmp;
if (a <= -1.8e-66) {
tmp = t_0 / a;
} else {
tmp = t_0 / b;
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = 0.5 * ((Math.PI / b) / a);
double tmp;
if (a <= -1.8e-66) {
tmp = t_0 / a;
} else {
tmp = t_0 / b;
}
return tmp;
}
def code(a, b): t_0 = 0.5 * ((math.pi / b) / a) tmp = 0 if a <= -1.8e-66: tmp = t_0 / a else: tmp = t_0 / b return tmp
function code(a, b) t_0 = Float64(0.5 * Float64(Float64(pi / b) / a)) tmp = 0.0 if (a <= -1.8e-66) tmp = Float64(t_0 / a); else tmp = Float64(t_0 / b); end return tmp end
function tmp_2 = code(a, b) t_0 = 0.5 * ((pi / b) / a); tmp = 0.0; if (a <= -1.8e-66) tmp = t_0 / a; else tmp = t_0 / b; end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(0.5 * N[(N[(Pi / b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -1.8e-66], N[(t$95$0 / a), $MachinePrecision], N[(t$95$0 / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \frac{\frac{\pi}{b}}{a}\\
\mathbf{if}\;a \leq -1.8 \cdot 10^{-66}:\\
\;\;\;\;\frac{t_0}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{b}\\
\end{array}
\end{array}
if a < -1.80000000000000006e-66Initial program 77.2%
add-sqr-sqrt51.0%
sqrt-unprod46.8%
pow146.8%
pow146.8%
pow-sqr46.8%
Applied egg-rr56.3%
associate-*r/56.3%
associate-*l*56.3%
+-commutative56.3%
*-commutative56.3%
Simplified56.3%
sqrt-pow199.6%
*-commutative99.6%
metadata-eval99.6%
pow199.6%
associate-/r*99.1%
un-div-inv99.1%
+-commutative99.1%
Applied egg-rr99.1%
Taylor expanded in b around 0 84.1%
associate-/l/84.0%
Simplified84.0%
if -1.80000000000000006e-66 < a Initial program 75.4%
associate-*l*75.3%
associate-*l/75.3%
frac-sub75.3%
*-commutative75.3%
associate-*r/75.2%
*-commutative75.2%
*-un-lft-identity75.2%
*-un-lft-identity75.2%
associate-/r/75.2%
flip-+99.5%
Applied egg-rr99.5%
associate-/l*98.8%
associate-/l/98.9%
associate-/r/99.0%
metadata-eval99.0%
*-commutative99.0%
associate-*l*99.0%
*-commutative99.0%
associate-*l*93.9%
+-commutative93.9%
Simplified93.9%
Taylor expanded in a around 0 67.7%
associate-*r*67.7%
*-commutative67.7%
*-commutative67.7%
Simplified67.7%
*-un-lft-identity67.7%
times-frac67.9%
associate-*r*67.9%
*-commutative67.9%
associate-*l*67.9%
Applied egg-rr67.9%
associate-*l/67.9%
associate-*r*67.9%
*-commutative67.9%
associate-/l/67.9%
metadata-eval67.9%
associate-/l*67.9%
/-rgt-identity67.9%
*-commutative67.9%
associate-*r/67.9%
*-commutative67.9%
*-lft-identity67.9%
associate-/l/67.9%
Simplified67.9%
Final simplification72.5%
(FPCore (a b) :precision binary64 (if (<= a -8.2e-64) (/ (/ 0.5 a) (/ (* b a) PI)) (/ (* 0.5 (/ (/ PI b) a)) b)))
double code(double a, double b) {
double tmp;
if (a <= -8.2e-64) {
tmp = (0.5 / a) / ((b * a) / ((double) M_PI));
} else {
tmp = (0.5 * ((((double) M_PI) / b) / a)) / b;
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (a <= -8.2e-64) {
tmp = (0.5 / a) / ((b * a) / Math.PI);
} else {
tmp = (0.5 * ((Math.PI / b) / a)) / b;
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -8.2e-64: tmp = (0.5 / a) / ((b * a) / math.pi) else: tmp = (0.5 * ((math.pi / b) / a)) / b return tmp
function code(a, b) tmp = 0.0 if (a <= -8.2e-64) tmp = Float64(Float64(0.5 / a) / Float64(Float64(b * a) / pi)); else tmp = Float64(Float64(0.5 * Float64(Float64(pi / b) / a)) / b); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -8.2e-64) tmp = (0.5 / a) / ((b * a) / pi); else tmp = (0.5 * ((pi / b) / a)) / b; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -8.2e-64], N[(N[(0.5 / a), $MachinePrecision] / N[(N[(b * a), $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(N[(Pi / b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -8.2 \cdot 10^{-64}:\\
\;\;\;\;\frac{\frac{0.5}{a}}{\frac{b \cdot a}{\pi}}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5 \cdot \frac{\frac{\pi}{b}}{a}}{b}\\
\end{array}
\end{array}
if a < -8.2000000000000001e-64Initial program 78.2%
add-sqr-sqrt51.6%
sqrt-unprod47.3%
pow147.3%
pow147.3%
pow-sqr47.3%
Applied egg-rr57.0%
associate-*r/57.0%
associate-*l*57.0%
+-commutative57.0%
*-commutative57.0%
Simplified57.0%
sqrt-pow199.6%
*-commutative99.6%
metadata-eval99.6%
pow199.6%
*-commutative99.6%
associate-/l*99.7%
un-div-inv99.7%
+-commutative99.7%
Applied egg-rr99.7%
Taylor expanded in b around 0 85.2%
if -8.2000000000000001e-64 < a Initial program 75.0%
associate-*l*74.9%
associate-*l/74.9%
frac-sub74.9%
*-commutative74.9%
associate-*r/74.8%
*-commutative74.8%
*-un-lft-identity74.8%
*-un-lft-identity74.8%
associate-/r/74.9%
flip-+99.5%
Applied egg-rr99.5%
associate-/l*98.8%
associate-/l/98.9%
associate-/r/99.0%
metadata-eval99.0%
*-commutative99.0%
associate-*l*99.0%
*-commutative99.0%
associate-*l*94.0%
+-commutative94.0%
Simplified94.0%
Taylor expanded in a around 0 67.9%
associate-*r*67.9%
*-commutative67.9%
*-commutative67.9%
Simplified67.9%
*-un-lft-identity67.9%
times-frac68.0%
associate-*r*68.0%
*-commutative68.0%
associate-*l*68.0%
Applied egg-rr68.0%
associate-*l/68.1%
associate-*r*68.1%
*-commutative68.1%
associate-/l/68.1%
metadata-eval68.1%
associate-/l*68.1%
/-rgt-identity68.1%
*-commutative68.1%
associate-*r/68.1%
*-commutative68.1%
*-lft-identity68.1%
associate-/l/68.1%
Simplified68.1%
Final simplification72.8%
(FPCore (a b) :precision binary64 (if (<= b 7.7e-81) (/ (* 0.5 (/ (/ PI b) a)) a) (/ (/ (* PI 0.5) b) (* b a))))
double code(double a, double b) {
double tmp;
if (b <= 7.7e-81) {
tmp = (0.5 * ((((double) M_PI) / b) / a)) / a;
} else {
tmp = ((((double) M_PI) * 0.5) / b) / (b * a);
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (b <= 7.7e-81) {
tmp = (0.5 * ((Math.PI / b) / a)) / a;
} else {
tmp = ((Math.PI * 0.5) / b) / (b * a);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 7.7e-81: tmp = (0.5 * ((math.pi / b) / a)) / a else: tmp = ((math.pi * 0.5) / b) / (b * a) return tmp
function code(a, b) tmp = 0.0 if (b <= 7.7e-81) tmp = Float64(Float64(0.5 * Float64(Float64(pi / b) / a)) / a); else tmp = Float64(Float64(Float64(pi * 0.5) / b) / Float64(b * a)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 7.7e-81) tmp = (0.5 * ((pi / b) / a)) / a; else tmp = ((pi * 0.5) / b) / (b * a); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 7.7e-81], N[(N[(0.5 * N[(N[(Pi / b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(N[(Pi * 0.5), $MachinePrecision] / b), $MachinePrecision] / N[(b * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7.7 \cdot 10^{-81}:\\
\;\;\;\;\frac{0.5 \cdot \frac{\frac{\pi}{b}}{a}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\pi \cdot 0.5}{b}}{b \cdot a}\\
\end{array}
\end{array}
if b < 7.7000000000000002e-81Initial program 74.9%
add-sqr-sqrt46.9%
sqrt-unprod44.9%
pow144.9%
pow144.9%
pow-sqr44.9%
Applied egg-rr50.3%
associate-*r/50.4%
associate-*l*50.4%
+-commutative50.4%
*-commutative50.4%
Simplified50.4%
sqrt-pow199.6%
*-commutative99.6%
metadata-eval99.6%
pow199.6%
associate-/r*94.5%
un-div-inv94.5%
+-commutative94.5%
Applied egg-rr94.5%
Taylor expanded in b around 0 73.7%
associate-/l/73.7%
Simplified73.7%
if 7.7000000000000002e-81 < b Initial program 78.0%
associate-*l*77.9%
associate-*l/77.9%
frac-sub77.9%
*-commutative77.9%
associate-*r/77.8%
*-commutative77.8%
*-un-lft-identity77.8%
*-un-lft-identity77.8%
associate-/r/77.9%
flip-+99.6%
Applied egg-rr99.6%
associate-/l*97.0%
associate-/l/96.9%
associate-/r/97.0%
metadata-eval97.0%
*-commutative97.0%
associate-*l*97.0%
*-commutative97.0%
associate-*l*95.9%
+-commutative95.9%
Simplified95.9%
Taylor expanded in a around 0 84.4%
associate-*r*84.4%
*-commutative84.4%
*-commutative84.4%
Simplified84.4%
div-inv84.4%
*-commutative84.4%
*-commutative84.4%
associate-/r*84.7%
associate-*r*84.7%
*-commutative84.7%
associate-/r*84.7%
metadata-eval84.7%
Applied egg-rr84.7%
associate-*l/84.7%
associate-*l/84.7%
associate-*r/84.7%
associate-/r*84.8%
associate-*r/84.8%
associate-/l/84.8%
associate-*r/84.8%
Applied egg-rr84.8%
Final simplification77.1%
(FPCore (a b) :precision binary64 (if (<= b 2.9e-82) (/ (/ (* PI (/ 0.5 a)) b) a) (/ (/ (* PI 0.5) b) (* b a))))
double code(double a, double b) {
double tmp;
if (b <= 2.9e-82) {
tmp = ((((double) M_PI) * (0.5 / a)) / b) / a;
} else {
tmp = ((((double) M_PI) * 0.5) / b) / (b * a);
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (b <= 2.9e-82) {
tmp = ((Math.PI * (0.5 / a)) / b) / a;
} else {
tmp = ((Math.PI * 0.5) / b) / (b * a);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 2.9e-82: tmp = ((math.pi * (0.5 / a)) / b) / a else: tmp = ((math.pi * 0.5) / b) / (b * a) return tmp
function code(a, b) tmp = 0.0 if (b <= 2.9e-82) tmp = Float64(Float64(Float64(pi * Float64(0.5 / a)) / b) / a); else tmp = Float64(Float64(Float64(pi * 0.5) / b) / Float64(b * a)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 2.9e-82) tmp = ((pi * (0.5 / a)) / b) / a; else tmp = ((pi * 0.5) / b) / (b * a); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 2.9e-82], N[(N[(N[(Pi * N[(0.5 / a), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision] / a), $MachinePrecision], N[(N[(N[(Pi * 0.5), $MachinePrecision] / b), $MachinePrecision] / N[(b * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.9 \cdot 10^{-82}:\\
\;\;\;\;\frac{\frac{\pi \cdot \frac{0.5}{a}}{b}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\pi \cdot 0.5}{b}}{b \cdot a}\\
\end{array}
\end{array}
if b < 2.89999999999999977e-82Initial program 74.9%
add-sqr-sqrt46.9%
sqrt-unprod44.9%
pow144.9%
pow144.9%
pow-sqr44.9%
Applied egg-rr50.3%
associate-*r/50.4%
associate-*l*50.4%
+-commutative50.4%
*-commutative50.4%
Simplified50.4%
sqrt-pow199.6%
*-commutative99.6%
metadata-eval99.6%
pow199.6%
associate-/r*94.5%
un-div-inv94.5%
+-commutative94.5%
Applied egg-rr94.5%
Taylor expanded in b around 0 73.6%
if 2.89999999999999977e-82 < b Initial program 78.0%
associate-*l*77.9%
associate-*l/77.9%
frac-sub77.9%
*-commutative77.9%
associate-*r/77.8%
*-commutative77.8%
*-un-lft-identity77.8%
*-un-lft-identity77.8%
associate-/r/77.9%
flip-+99.6%
Applied egg-rr99.6%
associate-/l*97.0%
associate-/l/96.9%
associate-/r/97.0%
metadata-eval97.0%
*-commutative97.0%
associate-*l*97.0%
*-commutative97.0%
associate-*l*95.9%
+-commutative95.9%
Simplified95.9%
Taylor expanded in a around 0 84.4%
associate-*r*84.4%
*-commutative84.4%
*-commutative84.4%
Simplified84.4%
div-inv84.4%
*-commutative84.4%
*-commutative84.4%
associate-/r*84.7%
associate-*r*84.7%
*-commutative84.7%
associate-/r*84.7%
metadata-eval84.7%
Applied egg-rr84.7%
associate-*l/84.7%
associate-*l/84.7%
associate-*r/84.7%
associate-/r*84.8%
associate-*r/84.8%
associate-/l/84.8%
associate-*r/84.8%
Applied egg-rr84.8%
Final simplification77.0%
(FPCore (a b) :precision binary64 (/ (/ 0.5 (+ b a)) (/ (* b a) PI)))
double code(double a, double b) {
return (0.5 / (b + a)) / ((b * a) / ((double) M_PI));
}
public static double code(double a, double b) {
return (0.5 / (b + a)) / ((b * a) / Math.PI);
}
def code(a, b): return (0.5 / (b + a)) / ((b * a) / math.pi)
function code(a, b) return Float64(Float64(0.5 / Float64(b + a)) / Float64(Float64(b * a) / pi)) end
function tmp = code(a, b) tmp = (0.5 / (b + a)) / ((b * a) / pi); end
code[a_, b_] := N[(N[(0.5 / N[(b + a), $MachinePrecision]), $MachinePrecision] / N[(N[(b * a), $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{0.5}{b + a}}{\frac{b \cdot a}{\pi}}
\end{array}
Initial program 75.9%
add-sqr-sqrt51.7%
sqrt-unprod47.8%
pow147.8%
pow147.8%
pow-sqr47.8%
Applied egg-rr53.5%
associate-*r/53.5%
associate-*l*53.5%
+-commutative53.5%
*-commutative53.5%
Simplified53.5%
sqrt-pow199.6%
*-commutative99.6%
metadata-eval99.6%
pow199.6%
*-commutative99.6%
associate-/l*99.6%
un-div-inv99.6%
+-commutative99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (a b) :precision binary64 (* PI (/ (/ 0.5 (* b a)) b)))
double code(double a, double b) {
return ((double) M_PI) * ((0.5 / (b * a)) / b);
}
public static double code(double a, double b) {
return Math.PI * ((0.5 / (b * a)) / b);
}
def code(a, b): return math.pi * ((0.5 / (b * a)) / b)
function code(a, b) return Float64(pi * Float64(Float64(0.5 / Float64(b * a)) / b)) end
function tmp = code(a, b) tmp = pi * ((0.5 / (b * a)) / b); end
code[a_, b_] := N[(Pi * N[(N[(0.5 / N[(b * a), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\pi \cdot \frac{\frac{0.5}{b \cdot a}}{b}
\end{array}
Initial program 75.9%
associate-*l*75.8%
associate-*l/75.8%
frac-sub75.8%
*-commutative75.8%
associate-*r/75.7%
*-commutative75.7%
*-un-lft-identity75.7%
*-un-lft-identity75.7%
associate-/r/75.8%
flip-+99.6%
Applied egg-rr99.6%
associate-/l*98.7%
associate-/l/98.8%
associate-/r/98.9%
metadata-eval98.9%
*-commutative98.9%
associate-*l*98.9%
*-commutative98.9%
associate-*l*91.2%
+-commutative91.2%
Simplified91.2%
Taylor expanded in a around 0 60.5%
associate-*r*60.5%
*-commutative60.5%
*-commutative60.5%
Simplified60.5%
div-inv60.4%
*-commutative60.4%
*-commutative60.4%
associate-/r*60.6%
associate-*r*60.6%
*-commutative60.6%
associate-/r*60.6%
metadata-eval60.6%
Applied egg-rr60.6%
Final simplification60.6%
herbie shell --seed 2023305
(FPCore (a b)
:name "NMSE Section 6.1 mentioned, B"
:precision binary64
(* (* (/ PI 2.0) (/ 1.0 (- (* b b) (* a a)))) (- (/ 1.0 a) (/ 1.0 b))))