
(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 7 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 80.9%
*-commutative80.9%
associate-*r*80.9%
associate-*r/80.9%
associate-*r*80.9%
*-rgt-identity80.9%
sub-neg80.9%
distribute-neg-frac80.9%
metadata-eval80.9%
Simplified80.9%
*-un-lft-identity80.9%
difference-of-squares88.3%
times-frac99.5%
Applied egg-rr61.5%
associate-*l/61.6%
*-lft-identity61.6%
associate-*r*61.6%
distribute-rgt-out61.6%
associate-*l/61.6%
*-lft-identity61.6%
*-commutative61.6%
associate-*r/61.6%
associate-*l/61.6%
*-lft-identity61.6%
*-commutative61.6%
associate-*r/61.6%
fma-define61.6%
associate-*r/61.6%
+-commutative61.6%
Simplified61.6%
Taylor expanded in a around 0 99.6%
associate-*r/99.6%
Applied egg-rr99.6%
associate-/r*99.6%
associate-*r/99.6%
associate-*r/99.6%
Simplified99.6%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 2.85e+147) (/ (* 0.5 PI) (* a (* b (+ a b)))) (/ (* 0.5 (/ PI b)) (* a b))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (b <= 2.85e+147) {
tmp = (0.5 * ((double) M_PI)) / (a * (b * (a + b)));
} else {
tmp = (0.5 * (((double) M_PI) / b)) / (a * b);
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (b <= 2.85e+147) {
tmp = (0.5 * Math.PI) / (a * (b * (a + b)));
} else {
tmp = (0.5 * (Math.PI / b)) / (a * b);
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if b <= 2.85e+147: tmp = (0.5 * math.pi) / (a * (b * (a + b))) else: tmp = (0.5 * (math.pi / b)) / (a * b) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (b <= 2.85e+147) tmp = Float64(Float64(0.5 * pi) / Float64(a * Float64(b * Float64(a + b)))); else tmp = Float64(Float64(0.5 * Float64(pi / b)) / Float64(a * b)); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (b <= 2.85e+147)
tmp = (0.5 * pi) / (a * (b * (a + b)));
else
tmp = (0.5 * (pi / 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[b, 2.85e+147], N[(N[(0.5 * Pi), $MachinePrecision] / N[(a * N[(b * N[(a + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(Pi / b), $MachinePrecision]), $MachinePrecision] / N[(a * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.85 \cdot 10^{+147}:\\
\;\;\;\;\frac{0.5 \cdot \pi}{a \cdot \left(b \cdot \left(a + b\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5 \cdot \frac{\pi}{b}}{a \cdot b}\\
\end{array}
\end{array}
if b < 2.84999999999999996e147Initial program 82.6%
*-commutative82.6%
associate-*r*82.6%
associate-*r/82.6%
associate-*r*82.6%
*-rgt-identity82.6%
sub-neg82.6%
distribute-neg-frac82.6%
metadata-eval82.6%
Simplified82.6%
*-commutative82.6%
difference-of-squares89.4%
times-frac99.6%
div-inv99.6%
metadata-eval99.6%
add-sqr-sqrt55.9%
sqrt-unprod69.2%
frac-times69.2%
metadata-eval69.2%
metadata-eval69.2%
frac-times69.2%
sqrt-unprod23.2%
add-sqr-sqrt58.5%
Applied egg-rr58.5%
*-commutative58.5%
+-commutative58.5%
associate-/l*58.5%
+-commutative58.5%
Simplified58.5%
Taylor expanded in b around inf 99.6%
*-un-lft-identity99.6%
associate-/r*99.5%
Applied egg-rr99.5%
associate-*r/99.5%
associate-*l/99.4%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
associate-/l/99.6%
associate-*r/99.6%
*-commutative99.6%
frac-times99.1%
*-un-lft-identity99.1%
associate-*l*94.4%
Applied egg-rr94.4%
if 2.84999999999999996e147 < b Initial program 59.4%
*-commutative59.4%
associate-*r*59.4%
associate-*r/59.4%
associate-*r*59.4%
*-rgt-identity59.4%
sub-neg59.4%
distribute-neg-frac59.4%
metadata-eval59.4%
Simplified59.4%
*-commutative59.4%
difference-of-squares75.2%
times-frac99.8%
div-inv99.8%
metadata-eval99.8%
add-sqr-sqrt0.0%
sqrt-unprod99.8%
frac-times99.8%
metadata-eval99.8%
metadata-eval99.8%
frac-times99.8%
sqrt-unprod99.8%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
*-commutative99.8%
+-commutative99.8%
associate-/l*99.7%
+-commutative99.7%
Simplified99.7%
Taylor expanded in b around inf 99.5%
Taylor expanded in a around 0 99.5%
*-commutative99.5%
div-inv99.8%
associate-*r/99.8%
*-commutative99.8%
*-un-lft-identity99.8%
times-frac99.8%
metadata-eval99.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 -7.5e-94) (/ (* 0.5 (/ PI a)) (* a b)) (/ (* 0.5 (/ PI b)) (* a b))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -7.5e-94) {
tmp = (0.5 * (((double) M_PI) / a)) / (a * b);
} else {
tmp = (0.5 * (((double) M_PI) / b)) / (a * b);
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -7.5e-94) {
tmp = (0.5 * (Math.PI / a)) / (a * b);
} else {
tmp = (0.5 * (Math.PI / b)) / (a * b);
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -7.5e-94: tmp = (0.5 * (math.pi / a)) / (a * b) else: tmp = (0.5 * (math.pi / b)) / (a * b) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -7.5e-94) tmp = Float64(Float64(0.5 * Float64(pi / a)) / Float64(a * b)); else tmp = Float64(Float64(0.5 * Float64(pi / 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 <= -7.5e-94)
tmp = (0.5 * (pi / a)) / (a * b);
else
tmp = (0.5 * (pi / 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, -7.5e-94], N[(N[(0.5 * N[(Pi / a), $MachinePrecision]), $MachinePrecision] / N[(a * b), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(Pi / b), $MachinePrecision]), $MachinePrecision] / N[(a * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -7.5 \cdot 10^{-94}:\\
\;\;\;\;\frac{0.5 \cdot \frac{\pi}{a}}{a \cdot b}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5 \cdot \frac{\pi}{b}}{a \cdot b}\\
\end{array}
\end{array}
if a < -7.5000000000000003e-94Initial program 86.9%
*-commutative86.9%
associate-*r*86.9%
associate-*r/86.9%
associate-*r*86.9%
*-rgt-identity86.9%
sub-neg86.9%
distribute-neg-frac86.9%
metadata-eval86.9%
Simplified86.9%
*-commutative86.9%
difference-of-squares96.0%
times-frac99.6%
div-inv99.6%
metadata-eval99.6%
add-sqr-sqrt47.9%
sqrt-unprod58.3%
frac-times58.3%
metadata-eval58.3%
metadata-eval58.3%
frac-times58.3%
sqrt-unprod19.1%
add-sqr-sqrt46.8%
Applied egg-rr46.8%
*-commutative46.8%
+-commutative46.8%
associate-/l*46.8%
+-commutative46.8%
Simplified46.8%
Taylor expanded in b around inf 99.6%
associate-*l/99.6%
*-un-lft-identity99.6%
associate-*r/99.6%
*-commutative99.6%
Applied egg-rr99.6%
Taylor expanded in a around inf 83.9%
if -7.5000000000000003e-94 < a Initial program 78.3%
*-commutative78.3%
associate-*r*78.3%
associate-*r/78.3%
associate-*r*78.3%
*-rgt-identity78.3%
sub-neg78.3%
distribute-neg-frac78.3%
metadata-eval78.3%
Simplified78.3%
*-commutative78.3%
difference-of-squares85.0%
times-frac99.6%
div-inv99.6%
metadata-eval99.6%
add-sqr-sqrt53.4%
sqrt-unprod77.2%
frac-times77.2%
metadata-eval77.2%
metadata-eval77.2%
frac-times77.2%
sqrt-unprod33.1%
add-sqr-sqrt67.9%
Applied egg-rr67.9%
*-commutative67.9%
+-commutative67.9%
associate-/l*67.9%
+-commutative67.9%
Simplified67.9%
Taylor expanded in b around inf 99.5%
Taylor expanded in a around 0 67.9%
*-commutative67.9%
div-inv67.9%
associate-*r/68.0%
*-commutative68.0%
*-un-lft-identity68.0%
times-frac68.0%
metadata-eval68.0%
Applied egg-rr68.0%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -1.35e-94) (/ (* 0.5 (/ PI a)) (* a b)) (/ (* 0.5 PI) (* b (* a b)))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -1.35e-94) {
tmp = (0.5 * (((double) M_PI) / a)) / (a * b);
} else {
tmp = (0.5 * ((double) M_PI)) / (b * (a * b));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -1.35e-94) {
tmp = (0.5 * (Math.PI / a)) / (a * b);
} else {
tmp = (0.5 * Math.PI) / (b * (a * b));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -1.35e-94: tmp = (0.5 * (math.pi / a)) / (a * b) else: tmp = (0.5 * math.pi) / (b * (a * b)) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -1.35e-94) tmp = Float64(Float64(0.5 * Float64(pi / a)) / Float64(a * b)); else tmp = Float64(Float64(0.5 * pi) / 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 <= -1.35e-94)
tmp = (0.5 * (pi / a)) / (a * b);
else
tmp = (0.5 * pi) / (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, -1.35e-94], N[(N[(0.5 * N[(Pi / a), $MachinePrecision]), $MachinePrecision] / N[(a * b), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * Pi), $MachinePrecision] / N[(b * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.35 \cdot 10^{-94}:\\
\;\;\;\;\frac{0.5 \cdot \frac{\pi}{a}}{a \cdot b}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5 \cdot \pi}{b \cdot \left(a \cdot b\right)}\\
\end{array}
\end{array}
if a < -1.3500000000000001e-94Initial program 86.9%
*-commutative86.9%
associate-*r*86.9%
associate-*r/86.9%
associate-*r*86.9%
*-rgt-identity86.9%
sub-neg86.9%
distribute-neg-frac86.9%
metadata-eval86.9%
Simplified86.9%
*-commutative86.9%
difference-of-squares96.0%
times-frac99.6%
div-inv99.6%
metadata-eval99.6%
add-sqr-sqrt47.9%
sqrt-unprod58.3%
frac-times58.3%
metadata-eval58.3%
metadata-eval58.3%
frac-times58.3%
sqrt-unprod19.1%
add-sqr-sqrt46.8%
Applied egg-rr46.8%
*-commutative46.8%
+-commutative46.8%
associate-/l*46.8%
+-commutative46.8%
Simplified46.8%
Taylor expanded in b around inf 99.6%
associate-*l/99.6%
*-un-lft-identity99.6%
associate-*r/99.6%
*-commutative99.6%
Applied egg-rr99.6%
Taylor expanded in a around inf 83.9%
if -1.3500000000000001e-94 < a Initial program 78.3%
*-commutative78.3%
associate-*r*78.3%
associate-*r/78.3%
associate-*r*78.3%
*-rgt-identity78.3%
sub-neg78.3%
distribute-neg-frac78.3%
metadata-eval78.3%
Simplified78.3%
*-commutative78.3%
difference-of-squares85.0%
times-frac99.6%
div-inv99.6%
metadata-eval99.6%
add-sqr-sqrt53.4%
sqrt-unprod77.2%
frac-times77.2%
metadata-eval77.2%
metadata-eval77.2%
frac-times77.2%
sqrt-unprod33.1%
add-sqr-sqrt67.9%
Applied egg-rr67.9%
*-commutative67.9%
+-commutative67.9%
associate-/l*67.9%
+-commutative67.9%
Simplified67.9%
Taylor expanded in b around inf 99.5%
Taylor expanded in a around 0 67.9%
associate-*r/68.0%
*-commutative68.0%
frac-times68.0%
*-un-lft-identity68.0%
Applied egg-rr68.0%
Final simplification72.8%
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(pi / Float64(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[(Pi / N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a + b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{0.5 \cdot \frac{\pi}{a \cdot b}}{a + b}
\end{array}
Initial program 80.9%
*-commutative80.9%
associate-*r*80.9%
associate-*r/80.9%
associate-*r*80.9%
*-rgt-identity80.9%
sub-neg80.9%
distribute-neg-frac80.9%
metadata-eval80.9%
Simplified80.9%
*-un-lft-identity80.9%
difference-of-squares88.3%
times-frac99.5%
Applied egg-rr61.5%
associate-*l/61.6%
*-lft-identity61.6%
associate-*r*61.6%
distribute-rgt-out61.6%
associate-*l/61.6%
*-lft-identity61.6%
*-commutative61.6%
associate-*r/61.6%
associate-*l/61.6%
*-lft-identity61.6%
*-commutative61.6%
associate-*r/61.6%
fma-define61.6%
associate-*r/61.6%
+-commutative61.6%
Simplified61.6%
Taylor expanded in a around 0 99.6%
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 * pi) / Float64(Float64(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 * Pi), $MachinePrecision] / N[(N[(a + b), $MachinePrecision] * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{0.5 \cdot \pi}{\left(a + b\right) \cdot \left(a \cdot b\right)}
\end{array}
Initial program 80.9%
*-commutative80.9%
associate-*r*80.9%
associate-*r/80.9%
associate-*r*80.9%
*-rgt-identity80.9%
sub-neg80.9%
distribute-neg-frac80.9%
metadata-eval80.9%
Simplified80.9%
*-commutative80.9%
difference-of-squares88.3%
times-frac99.6%
div-inv99.6%
metadata-eval99.6%
add-sqr-sqrt51.7%
sqrt-unprod71.5%
frac-times71.5%
metadata-eval71.5%
metadata-eval71.5%
frac-times71.5%
sqrt-unprod28.9%
add-sqr-sqrt61.6%
Applied egg-rr61.6%
*-commutative61.6%
+-commutative61.6%
associate-/l*61.5%
+-commutative61.5%
Simplified61.5%
Taylor expanded in b around inf 99.6%
associate-*r/99.6%
+-commutative99.6%
frac-times99.2%
*-un-lft-identity99.2%
*-commutative99.2%
+-commutative99.2%
Applied egg-rr99.2%
Final simplification99.2%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (/ (* 0.5 PI) (* b (* a b))))
assert(a < b);
double code(double a, double b) {
return (0.5 * ((double) M_PI)) / (b * (a * b));
}
assert a < b;
public static double code(double a, double b) {
return (0.5 * Math.PI) / (b * (a * b));
}
[a, b] = sort([a, b]) def code(a, b): return (0.5 * math.pi) / (b * (a * b))
a, b = sort([a, b]) function code(a, b) return Float64(Float64(0.5 * pi) / Float64(b * Float64(a * b))) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = (0.5 * pi) / (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 * Pi), $MachinePrecision] / N[(b * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{0.5 \cdot \pi}{b \cdot \left(a \cdot b\right)}
\end{array}
Initial program 80.9%
*-commutative80.9%
associate-*r*80.9%
associate-*r/80.9%
associate-*r*80.9%
*-rgt-identity80.9%
sub-neg80.9%
distribute-neg-frac80.9%
metadata-eval80.9%
Simplified80.9%
*-commutative80.9%
difference-of-squares88.3%
times-frac99.6%
div-inv99.6%
metadata-eval99.6%
add-sqr-sqrt51.7%
sqrt-unprod71.5%
frac-times71.5%
metadata-eval71.5%
metadata-eval71.5%
frac-times71.5%
sqrt-unprod28.9%
add-sqr-sqrt61.6%
Applied egg-rr61.6%
*-commutative61.6%
+-commutative61.6%
associate-/l*61.5%
+-commutative61.5%
Simplified61.5%
Taylor expanded in b around inf 99.6%
Taylor expanded in a around 0 59.5%
associate-*r/59.6%
*-commutative59.6%
frac-times59.3%
*-un-lft-identity59.3%
Applied egg-rr59.3%
Final simplification59.3%
herbie shell --seed 2024129
(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))))