
(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 12 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}
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (/ (* 0.5 (/ (/ PI a) b)) (+ a b)))
assert(a < b);
double code(double a, double b) {
return (0.5 * ((((double) M_PI) / a) / b)) / (a + b);
}
assert a < b;
public static double code(double a, double b) {
return (0.5 * ((Math.PI / a) / b)) / (a + b);
}
[a, b] = sort([a, b]) def code(a, b): return (0.5 * ((math.pi / a) / b)) / (a + b)
a, b = sort([a, b]) function code(a, b) return Float64(Float64(0.5 * Float64(Float64(pi / a) / b)) / Float64(a + b)) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = (0.5 * ((pi / a) / b)) / (a + b);
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(N[(0.5 * N[(N[(Pi / a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] / N[(a + b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{0.5 \cdot \frac{\frac{\pi}{a}}{b}}{a + b}
\end{array}
Initial program 78.5%
associate-*l*78.5%
*-rgt-identity78.5%
associate-/l*78.5%
metadata-eval78.5%
associate-*l/78.5%
*-lft-identity78.5%
sub-neg78.5%
distribute-neg-frac78.5%
metadata-eval78.5%
Simplified78.5%
*-un-lft-identity78.5%
clear-num78.4%
frac-add78.4%
associate-/r/78.5%
*-un-lft-identity78.5%
*-commutative78.5%
neg-mul-178.5%
sub-neg78.5%
flip-+99.1%
+-commutative99.1%
Applied egg-rr99.1%
*-lft-identity99.1%
associate-/r*99.6%
Simplified99.6%
*-un-lft-identity99.6%
associate-/l/99.1%
*-commutative99.1%
Applied egg-rr99.1%
*-lft-identity99.1%
associate-/r*99.6%
*-rgt-identity99.6%
associate-*r/99.6%
associate-*l/99.6%
*-lft-identity99.6%
Simplified99.6%
associate-*r/99.7%
div-inv99.8%
*-commutative99.8%
associate-*r/99.8%
associate-/r*99.8%
Applied egg-rr99.8%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -3e+98) (/ (/ PI (* b (* a 2.0))) a) (* PI (/ 0.5 (* b (* a (+ a b)))))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -3e+98) {
tmp = (((double) M_PI) / (b * (a * 2.0))) / a;
} else {
tmp = ((double) M_PI) * (0.5 / (b * (a * (a + b))));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -3e+98) {
tmp = (Math.PI / (b * (a * 2.0))) / a;
} else {
tmp = Math.PI * (0.5 / (b * (a * (a + b))));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -3e+98: tmp = (math.pi / (b * (a * 2.0))) / a else: tmp = math.pi * (0.5 / (b * (a * (a + b)))) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -3e+98) tmp = Float64(Float64(pi / Float64(b * Float64(a * 2.0))) / a); else tmp = Float64(pi * Float64(0.5 / Float64(b * Float64(a * Float64(a + b))))); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -3e+98)
tmp = (pi / (b * (a * 2.0))) / a;
else
tmp = pi * (0.5 / (b * (a * (a + b))));
end
tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[a, -3e+98], N[(N[(Pi / N[(b * N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(Pi * N[(0.5 / N[(b * N[(a * N[(a + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3 \cdot 10^{+98}:\\
\;\;\;\;\frac{\frac{\pi}{b \cdot \left(a \cdot 2\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \frac{0.5}{b \cdot \left(a \cdot \left(a + b\right)\right)}\\
\end{array}
\end{array}
if a < -3.0000000000000001e98Initial program 71.0%
*-commutative71.0%
associate-*r*71.0%
associate-*r/71.0%
associate-*r*71.0%
*-rgt-identity71.0%
sub-neg71.0%
distribute-neg-frac71.0%
metadata-eval71.0%
Simplified71.0%
associate-*l/71.0%
div-inv71.0%
metadata-eval71.0%
*-commutative71.0%
associate-*r*71.0%
*-commutative71.0%
Applied egg-rr99.6%
Taylor expanded in a around inf 99.6%
associate-/r*99.8%
div-inv99.7%
associate-/r*99.7%
Applied egg-rr99.7%
associate-*l/99.8%
associate-*r/99.8%
associate-*r/99.8%
metadata-eval99.8%
Simplified99.8%
associate-*l/99.8%
clear-num99.9%
associate-*l/99.9%
*-un-lft-identity99.9%
div-inv99.8%
clear-num100.0%
div-inv100.0%
metadata-eval100.0%
Applied egg-rr100.0%
if -3.0000000000000001e98 < a Initial program 79.8%
*-commutative79.8%
associate-*r*79.7%
associate-*r/79.7%
associate-*r*79.7%
*-rgt-identity79.7%
sub-neg79.7%
distribute-neg-frac79.7%
metadata-eval79.7%
Simplified79.7%
associate-*l/79.8%
div-inv79.8%
metadata-eval79.8%
*-commutative79.8%
associate-*r*79.8%
*-commutative79.8%
Applied egg-rr99.1%
Taylor expanded in b around 0 88.8%
+-commutative88.8%
unpow288.8%
distribute-lft-in96.1%
Simplified96.1%
Final simplification96.7%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 7e+98) (* PI (/ 0.5 (* a (* b (+ a b))))) (/ (/ PI (* b (* a 2.0))) b)))
assert(a < b);
double code(double a, double b) {
double tmp;
if (b <= 7e+98) {
tmp = ((double) M_PI) * (0.5 / (a * (b * (a + b))));
} else {
tmp = (((double) M_PI) / (b * (a * 2.0))) / b;
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (b <= 7e+98) {
tmp = Math.PI * (0.5 / (a * (b * (a + b))));
} else {
tmp = (Math.PI / (b * (a * 2.0))) / b;
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if b <= 7e+98: tmp = math.pi * (0.5 / (a * (b * (a + b)))) else: tmp = (math.pi / (b * (a * 2.0))) / b return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (b <= 7e+98) tmp = Float64(pi * Float64(0.5 / Float64(a * Float64(b * Float64(a + b))))); else tmp = Float64(Float64(pi / Float64(b * Float64(a * 2.0))) / b); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (b <= 7e+98)
tmp = pi * (0.5 / (a * (b * (a + b))));
else
tmp = (pi / (b * (a * 2.0))) / b;
end
tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[b, 7e+98], N[(Pi * N[(0.5 / N[(a * N[(b * N[(a + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Pi / N[(b * N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7 \cdot 10^{+98}:\\
\;\;\;\;\pi \cdot \frac{0.5}{a \cdot \left(b \cdot \left(a + b\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\pi}{b \cdot \left(a \cdot 2\right)}}{b}\\
\end{array}
\end{array}
if b < 7e98Initial program 82.3%
*-commutative82.3%
associate-*r*82.2%
associate-*r/82.2%
associate-*r*82.2%
*-rgt-identity82.2%
sub-neg82.2%
distribute-neg-frac82.2%
metadata-eval82.2%
Simplified82.2%
associate-*l/82.3%
div-inv82.3%
metadata-eval82.3%
*-commutative82.3%
associate-*r*82.3%
*-commutative82.3%
Applied egg-rr99.0%
Taylor expanded in a around 0 87.6%
unpow287.6%
distribute-rgt-in95.4%
Simplified95.4%
if 7e98 < b Initial program 62.5%
*-commutative62.5%
associate-*r*62.5%
associate-*r/62.5%
associate-*r*62.5%
*-rgt-identity62.5%
sub-neg62.5%
distribute-neg-frac62.5%
metadata-eval62.5%
Simplified62.5%
associate-*l/62.5%
div-inv62.5%
metadata-eval62.5%
*-commutative62.5%
associate-*r*62.5%
*-commutative62.5%
Applied egg-rr99.8%
Taylor expanded in a around 0 99.8%
associate-*l/99.7%
*-commutative99.7%
*-commutative99.7%
associate-/r*99.8%
*-commutative99.8%
associate-*l/99.7%
associate-/r*99.7%
clear-num99.7%
associate-*l/99.7%
*-un-lft-identity99.7%
div-inv99.7%
clear-num99.8%
div-inv99.8%
metadata-eval99.8%
Applied egg-rr99.8%
Final simplification96.2%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (let* ((t_0 (/ PI (* b (* a 2.0))))) (if (<= a -4e-106) (/ t_0 a) (/ t_0 b))))
assert(a < b);
double code(double a, double b) {
double t_0 = ((double) M_PI) / (b * (a * 2.0));
double tmp;
if (a <= -4e-106) {
tmp = t_0 / a;
} else {
tmp = t_0 / b;
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double t_0 = Math.PI / (b * (a * 2.0));
double tmp;
if (a <= -4e-106) {
tmp = t_0 / a;
} else {
tmp = t_0 / b;
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): t_0 = math.pi / (b * (a * 2.0)) tmp = 0 if a <= -4e-106: tmp = t_0 / a else: tmp = t_0 / b return tmp
a, b = sort([a, b]) function code(a, b) t_0 = Float64(pi / Float64(b * Float64(a * 2.0))) tmp = 0.0 if (a <= -4e-106) tmp = Float64(t_0 / a); else tmp = Float64(t_0 / b); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
t_0 = pi / (b * (a * 2.0));
tmp = 0.0;
if (a <= -4e-106)
tmp = t_0 / a;
else
tmp = t_0 / b;
end
tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function.
code[a_, b_] := Block[{t$95$0 = N[(Pi / N[(b * N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -4e-106], N[(t$95$0 / a), $MachinePrecision], N[(t$95$0 / b), $MachinePrecision]]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
t_0 := \frac{\pi}{b \cdot \left(a \cdot 2\right)}\\
\mathbf{if}\;a \leq -4 \cdot 10^{-106}:\\
\;\;\;\;\frac{t\_0}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{b}\\
\end{array}
\end{array}
if a < -3.99999999999999976e-106Initial program 84.5%
*-commutative84.5%
associate-*r*84.4%
associate-*r/84.5%
associate-*r*84.5%
*-rgt-identity84.5%
sub-neg84.5%
distribute-neg-frac84.5%
metadata-eval84.5%
Simplified84.5%
associate-*l/84.5%
div-inv84.5%
metadata-eval84.5%
*-commutative84.5%
associate-*r*84.5%
*-commutative84.5%
Applied egg-rr99.5%
Taylor expanded in a around inf 86.0%
associate-/r*85.0%
div-inv85.0%
associate-/r*84.9%
Applied egg-rr84.9%
associate-*l/85.0%
associate-*r/85.0%
associate-*r/85.0%
metadata-eval85.0%
Simplified85.0%
associate-*l/85.0%
clear-num85.1%
associate-*l/85.0%
*-un-lft-identity85.0%
div-inv85.0%
clear-num85.1%
div-inv85.1%
metadata-eval85.1%
Applied egg-rr85.1%
if -3.99999999999999976e-106 < a Initial program 76.2%
*-commutative76.2%
associate-*r*76.2%
associate-*r/76.2%
associate-*r*76.2%
*-rgt-identity76.2%
sub-neg76.2%
distribute-neg-frac76.2%
metadata-eval76.2%
Simplified76.2%
associate-*l/76.2%
div-inv76.2%
metadata-eval76.2%
*-commutative76.2%
associate-*r*76.2%
*-commutative76.2%
Applied egg-rr99.0%
Taylor expanded in a around 0 73.1%
associate-*l/73.1%
*-commutative73.1%
*-commutative73.1%
associate-/r*73.3%
*-commutative73.3%
associate-*l/73.3%
associate-/r*73.3%
clear-num73.2%
associate-*l/73.3%
*-un-lft-identity73.3%
div-inv73.3%
clear-num73.3%
div-inv73.3%
metadata-eval73.3%
Applied egg-rr73.3%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -4e-106) (/ (/ PI (* b (* a 2.0))) a) (* PI (/ 0.5 (* b (* a b))))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -4e-106) {
tmp = (((double) M_PI) / (b * (a * 2.0))) / a;
} else {
tmp = ((double) M_PI) * (0.5 / (b * (a * b)));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -4e-106) {
tmp = (Math.PI / (b * (a * 2.0))) / a;
} else {
tmp = Math.PI * (0.5 / (b * (a * b)));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -4e-106: tmp = (math.pi / (b * (a * 2.0))) / a else: tmp = math.pi * (0.5 / (b * (a * b))) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -4e-106) tmp = Float64(Float64(pi / Float64(b * Float64(a * 2.0))) / a); else tmp = Float64(pi * Float64(0.5 / Float64(b * Float64(a * b)))); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -4e-106)
tmp = (pi / (b * (a * 2.0))) / a;
else
tmp = pi * (0.5 / (b * (a * b)));
end
tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[a, -4e-106], N[(N[(Pi / N[(b * N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(Pi * N[(0.5 / N[(b * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4 \cdot 10^{-106}:\\
\;\;\;\;\frac{\frac{\pi}{b \cdot \left(a \cdot 2\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \frac{0.5}{b \cdot \left(a \cdot b\right)}\\
\end{array}
\end{array}
if a < -3.99999999999999976e-106Initial program 84.5%
*-commutative84.5%
associate-*r*84.4%
associate-*r/84.5%
associate-*r*84.5%
*-rgt-identity84.5%
sub-neg84.5%
distribute-neg-frac84.5%
metadata-eval84.5%
Simplified84.5%
associate-*l/84.5%
div-inv84.5%
metadata-eval84.5%
*-commutative84.5%
associate-*r*84.5%
*-commutative84.5%
Applied egg-rr99.5%
Taylor expanded in a around inf 86.0%
associate-/r*85.0%
div-inv85.0%
associate-/r*84.9%
Applied egg-rr84.9%
associate-*l/85.0%
associate-*r/85.0%
associate-*r/85.0%
metadata-eval85.0%
Simplified85.0%
associate-*l/85.0%
clear-num85.1%
associate-*l/85.0%
*-un-lft-identity85.0%
div-inv85.0%
clear-num85.1%
div-inv85.1%
metadata-eval85.1%
Applied egg-rr85.1%
if -3.99999999999999976e-106 < a Initial program 76.2%
*-commutative76.2%
associate-*r*76.2%
associate-*r/76.2%
associate-*r*76.2%
*-rgt-identity76.2%
sub-neg76.2%
distribute-neg-frac76.2%
metadata-eval76.2%
Simplified76.2%
associate-*l/76.2%
div-inv76.2%
metadata-eval76.2%
*-commutative76.2%
associate-*r*76.2%
*-commutative76.2%
Applied egg-rr99.0%
Taylor expanded in a around 0 73.1%
Final simplification76.4%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -4e-106) (/ (* PI (/ 0.5 a)) (* a b)) (* PI (/ 0.5 (* b (* a b))))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -4e-106) {
tmp = (((double) M_PI) * (0.5 / a)) / (a * b);
} else {
tmp = ((double) M_PI) * (0.5 / (b * (a * b)));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -4e-106) {
tmp = (Math.PI * (0.5 / a)) / (a * b);
} else {
tmp = Math.PI * (0.5 / (b * (a * b)));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -4e-106: tmp = (math.pi * (0.5 / a)) / (a * b) else: tmp = math.pi * (0.5 / (b * (a * b))) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -4e-106) tmp = Float64(Float64(pi * Float64(0.5 / a)) / Float64(a * b)); else tmp = Float64(pi * Float64(0.5 / Float64(b * Float64(a * b)))); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -4e-106)
tmp = (pi * (0.5 / a)) / (a * b);
else
tmp = pi * (0.5 / (b * (a * b)));
end
tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[a, -4e-106], N[(N[(Pi * N[(0.5 / a), $MachinePrecision]), $MachinePrecision] / N[(a * b), $MachinePrecision]), $MachinePrecision], N[(Pi * N[(0.5 / N[(b * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4 \cdot 10^{-106}:\\
\;\;\;\;\frac{\pi \cdot \frac{0.5}{a}}{a \cdot b}\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \frac{0.5}{b \cdot \left(a \cdot b\right)}\\
\end{array}
\end{array}
if a < -3.99999999999999976e-106Initial program 84.5%
*-commutative84.5%
associate-*r*84.4%
associate-*r/84.5%
associate-*r*84.5%
*-rgt-identity84.5%
sub-neg84.5%
distribute-neg-frac84.5%
metadata-eval84.5%
Simplified84.5%
associate-*l/84.5%
div-inv84.5%
metadata-eval84.5%
*-commutative84.5%
associate-*r*84.5%
*-commutative84.5%
Applied egg-rr99.5%
Taylor expanded in a around inf 86.0%
associate-/r*85.0%
div-inv85.0%
associate-/r*84.9%
Applied egg-rr84.9%
associate-*l/85.0%
associate-*r/85.0%
associate-*r/85.0%
metadata-eval85.0%
Simplified85.0%
associate-/l/85.0%
associate-*l/85.0%
Applied egg-rr85.0%
if -3.99999999999999976e-106 < a Initial program 76.2%
*-commutative76.2%
associate-*r*76.2%
associate-*r/76.2%
associate-*r*76.2%
*-rgt-identity76.2%
sub-neg76.2%
distribute-neg-frac76.2%
metadata-eval76.2%
Simplified76.2%
associate-*l/76.2%
div-inv76.2%
metadata-eval76.2%
*-commutative76.2%
associate-*r*76.2%
*-commutative76.2%
Applied egg-rr99.0%
Taylor expanded in a around 0 73.1%
Final simplification76.4%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -4e-106) (* PI (/ (/ (/ 0.5 b) a) a)) (* PI (/ 0.5 (* b (* a b))))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -4e-106) {
tmp = ((double) M_PI) * (((0.5 / b) / a) / a);
} else {
tmp = ((double) M_PI) * (0.5 / (b * (a * b)));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -4e-106) {
tmp = Math.PI * (((0.5 / b) / a) / a);
} else {
tmp = Math.PI * (0.5 / (b * (a * b)));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -4e-106: tmp = math.pi * (((0.5 / b) / a) / a) else: tmp = math.pi * (0.5 / (b * (a * b))) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -4e-106) tmp = Float64(pi * Float64(Float64(Float64(0.5 / b) / a) / a)); else tmp = Float64(pi * Float64(0.5 / Float64(b * Float64(a * b)))); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -4e-106)
tmp = pi * (((0.5 / b) / a) / a);
else
tmp = pi * (0.5 / (b * (a * b)));
end
tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[a, -4e-106], N[(Pi * N[(N[(N[(0.5 / b), $MachinePrecision] / a), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(Pi * N[(0.5 / N[(b * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4 \cdot 10^{-106}:\\
\;\;\;\;\pi \cdot \frac{\frac{\frac{0.5}{b}}{a}}{a}\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \frac{0.5}{b \cdot \left(a \cdot b\right)}\\
\end{array}
\end{array}
if a < -3.99999999999999976e-106Initial program 84.5%
*-commutative84.5%
associate-*r*84.4%
associate-*r/84.5%
associate-*r*84.5%
*-rgt-identity84.5%
sub-neg84.5%
distribute-neg-frac84.5%
metadata-eval84.5%
Simplified84.5%
associate-*l/84.5%
div-inv84.5%
metadata-eval84.5%
*-commutative84.5%
associate-*r*84.5%
*-commutative84.5%
Applied egg-rr99.5%
Taylor expanded in a around inf 86.0%
associate-/r*85.0%
div-inv85.0%
associate-/r*84.9%
Applied egg-rr84.9%
associate-*l/85.0%
associate-*r/85.0%
associate-*r/85.0%
metadata-eval85.0%
Simplified85.0%
Taylor expanded in a around 0 85.0%
associate-/l/85.1%
Simplified85.1%
if -3.99999999999999976e-106 < a Initial program 76.2%
*-commutative76.2%
associate-*r*76.2%
associate-*r/76.2%
associate-*r*76.2%
*-rgt-identity76.2%
sub-neg76.2%
distribute-neg-frac76.2%
metadata-eval76.2%
Simplified76.2%
associate-*l/76.2%
div-inv76.2%
metadata-eval76.2%
*-commutative76.2%
associate-*r*76.2%
*-commutative76.2%
Applied egg-rr99.0%
Taylor expanded in a around 0 73.1%
Final simplification76.4%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -4e-106) (* PI (/ (/ (/ 0.5 a) b) a)) (* PI (/ 0.5 (* b (* a b))))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -4e-106) {
tmp = ((double) M_PI) * (((0.5 / a) / b) / a);
} else {
tmp = ((double) M_PI) * (0.5 / (b * (a * b)));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -4e-106) {
tmp = Math.PI * (((0.5 / a) / b) / a);
} else {
tmp = Math.PI * (0.5 / (b * (a * b)));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -4e-106: tmp = math.pi * (((0.5 / a) / b) / a) else: tmp = math.pi * (0.5 / (b * (a * b))) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -4e-106) tmp = Float64(pi * Float64(Float64(Float64(0.5 / a) / b) / a)); else tmp = Float64(pi * Float64(0.5 / Float64(b * Float64(a * b)))); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -4e-106)
tmp = pi * (((0.5 / a) / b) / a);
else
tmp = pi * (0.5 / (b * (a * b)));
end
tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[a, -4e-106], N[(Pi * N[(N[(N[(0.5 / a), $MachinePrecision] / b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(Pi * N[(0.5 / N[(b * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4 \cdot 10^{-106}:\\
\;\;\;\;\pi \cdot \frac{\frac{\frac{0.5}{a}}{b}}{a}\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \frac{0.5}{b \cdot \left(a \cdot b\right)}\\
\end{array}
\end{array}
if a < -3.99999999999999976e-106Initial program 84.5%
*-commutative84.5%
associate-*r*84.4%
associate-*r/84.5%
associate-*r*84.5%
*-rgt-identity84.5%
sub-neg84.5%
distribute-neg-frac84.5%
metadata-eval84.5%
Simplified84.5%
associate-*l/84.5%
div-inv84.5%
metadata-eval84.5%
*-commutative84.5%
associate-*r*84.5%
*-commutative84.5%
Applied egg-rr99.5%
Taylor expanded in a around inf 86.0%
associate-/r*85.0%
div-inv85.0%
associate-/r*84.9%
Applied egg-rr84.9%
associate-*l/85.0%
associate-*r/85.0%
associate-*r/85.0%
metadata-eval85.0%
Simplified85.0%
if -3.99999999999999976e-106 < a Initial program 76.2%
*-commutative76.2%
associate-*r*76.2%
associate-*r/76.2%
associate-*r*76.2%
*-rgt-identity76.2%
sub-neg76.2%
distribute-neg-frac76.2%
metadata-eval76.2%
Simplified76.2%
associate-*l/76.2%
div-inv76.2%
metadata-eval76.2%
*-commutative76.2%
associate-*r*76.2%
*-commutative76.2%
Applied egg-rr99.0%
Taylor expanded in a around 0 73.1%
Final simplification76.4%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -4e-106) (* PI (/ 0.5 (* a (* a b)))) (* PI (/ 0.5 (* b (* a b))))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -4e-106) {
tmp = ((double) M_PI) * (0.5 / (a * (a * b)));
} else {
tmp = ((double) M_PI) * (0.5 / (b * (a * b)));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -4e-106) {
tmp = Math.PI * (0.5 / (a * (a * b)));
} else {
tmp = Math.PI * (0.5 / (b * (a * b)));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -4e-106: tmp = math.pi * (0.5 / (a * (a * b))) else: tmp = math.pi * (0.5 / (b * (a * b))) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -4e-106) tmp = Float64(pi * Float64(0.5 / Float64(a * Float64(a * b)))); else tmp = Float64(pi * Float64(0.5 / Float64(b * Float64(a * b)))); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -4e-106)
tmp = pi * (0.5 / (a * (a * b)));
else
tmp = pi * (0.5 / (b * (a * b)));
end
tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[a, -4e-106], N[(Pi * N[(0.5 / N[(a * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(Pi * N[(0.5 / N[(b * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4 \cdot 10^{-106}:\\
\;\;\;\;\pi \cdot \frac{0.5}{a \cdot \left(a \cdot b\right)}\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \frac{0.5}{b \cdot \left(a \cdot b\right)}\\
\end{array}
\end{array}
if a < -3.99999999999999976e-106Initial program 84.5%
*-commutative84.5%
associate-*r*84.4%
associate-*r/84.5%
associate-*r*84.5%
*-rgt-identity84.5%
sub-neg84.5%
distribute-neg-frac84.5%
metadata-eval84.5%
Simplified84.5%
associate-*l/84.5%
div-inv84.5%
metadata-eval84.5%
*-commutative84.5%
associate-*r*84.5%
*-commutative84.5%
Applied egg-rr99.5%
Taylor expanded in a around inf 86.0%
if -3.99999999999999976e-106 < a Initial program 76.2%
*-commutative76.2%
associate-*r*76.2%
associate-*r/76.2%
associate-*r*76.2%
*-rgt-identity76.2%
sub-neg76.2%
distribute-neg-frac76.2%
metadata-eval76.2%
Simplified76.2%
associate-*l/76.2%
div-inv76.2%
metadata-eval76.2%
*-commutative76.2%
associate-*r*76.2%
*-commutative76.2%
Applied egg-rr99.0%
Taylor expanded in a around 0 73.1%
Final simplification76.6%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (* (/ PI (+ a b)) (/ 0.5 (* a b))))
assert(a < b);
double code(double a, double b) {
return (((double) M_PI) / (a + b)) * (0.5 / (a * b));
}
assert a < b;
public static double code(double a, double b) {
return (Math.PI / (a + b)) * (0.5 / (a * b));
}
[a, b] = sort([a, b]) def code(a, b): return (math.pi / (a + b)) * (0.5 / (a * b))
a, b = sort([a, b]) function code(a, b) return Float64(Float64(pi / Float64(a + b)) * Float64(0.5 / Float64(a * b))) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = (pi / (a + b)) * (0.5 / (a * b));
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(N[(Pi / N[(a + b), $MachinePrecision]), $MachinePrecision] * N[(0.5 / N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\pi}{a + b} \cdot \frac{0.5}{a \cdot b}
\end{array}
Initial program 78.5%
associate-*l*78.5%
*-rgt-identity78.5%
associate-/l*78.5%
metadata-eval78.5%
associate-*l/78.5%
*-lft-identity78.5%
sub-neg78.5%
distribute-neg-frac78.5%
metadata-eval78.5%
Simplified78.5%
metadata-eval78.5%
div-inv78.5%
clear-num78.5%
clear-num78.4%
frac-times78.4%
metadata-eval78.4%
frac-add78.4%
associate-/r/78.5%
*-un-lft-identity78.5%
*-commutative78.5%
neg-mul-178.5%
sub-neg78.5%
flip-+99.1%
+-commutative99.1%
Applied egg-rr99.1%
associate-/r*99.2%
associate-/r/99.2%
metadata-eval99.2%
*-commutative99.2%
times-frac99.6%
Simplified99.6%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (* PI (/ 0.5 (* (+ a b) (* a b)))))
assert(a < b);
double code(double a, double b) {
return ((double) M_PI) * (0.5 / ((a + b) * (a * b)));
}
assert a < b;
public static double code(double a, double b) {
return Math.PI * (0.5 / ((a + b) * (a * b)));
}
[a, b] = sort([a, b]) def code(a, b): return math.pi * (0.5 / ((a + b) * (a * b)))
a, b = sort([a, b]) function code(a, b) return Float64(pi * Float64(0.5 / Float64(Float64(a + b) * Float64(a * b)))) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = pi * (0.5 / ((a + b) * (a * b)));
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(Pi * N[(0.5 / N[(N[(a + b), $MachinePrecision] * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\pi \cdot \frac{0.5}{\left(a + b\right) \cdot \left(a \cdot b\right)}
\end{array}
Initial program 78.5%
*-commutative78.5%
associate-*r*78.4%
associate-*r/78.5%
associate-*r*78.5%
*-rgt-identity78.5%
sub-neg78.5%
distribute-neg-frac78.5%
metadata-eval78.5%
Simplified78.5%
associate-*l/78.5%
div-inv78.5%
metadata-eval78.5%
*-commutative78.5%
associate-*r*78.5%
*-commutative78.5%
Applied egg-rr99.1%
Final simplification99.1%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (* PI (/ 0.5 (* a (* a b)))))
assert(a < b);
double code(double a, double b) {
return ((double) M_PI) * (0.5 / (a * (a * b)));
}
assert a < b;
public static double code(double a, double b) {
return Math.PI * (0.5 / (a * (a * b)));
}
[a, b] = sort([a, b]) def code(a, b): return math.pi * (0.5 / (a * (a * b)))
a, b = sort([a, b]) function code(a, b) return Float64(pi * Float64(0.5 / Float64(a * Float64(a * b)))) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = pi * (0.5 / (a * (a * b)));
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(Pi * N[(0.5 / N[(a * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\pi \cdot \frac{0.5}{a \cdot \left(a \cdot b\right)}
\end{array}
Initial program 78.5%
*-commutative78.5%
associate-*r*78.4%
associate-*r/78.5%
associate-*r*78.5%
*-rgt-identity78.5%
sub-neg78.5%
distribute-neg-frac78.5%
metadata-eval78.5%
Simplified78.5%
associate-*l/78.5%
div-inv78.5%
metadata-eval78.5%
*-commutative78.5%
associate-*r*78.5%
*-commutative78.5%
Applied egg-rr99.1%
Taylor expanded in a around inf 61.6%
Final simplification61.6%
herbie shell --seed 2024116
(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))))