
(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 11 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 (/ (/ 1.0 (* b (/ (/ a 0.5) PI))) (+ b a)))
assert(a < b);
double code(double a, double b) {
return (1.0 / (b * ((a / 0.5) / ((double) M_PI)))) / (b + a);
}
assert a < b;
public static double code(double a, double b) {
return (1.0 / (b * ((a / 0.5) / Math.PI))) / (b + a);
}
[a, b] = sort([a, b]) def code(a, b): return (1.0 / (b * ((a / 0.5) / math.pi))) / (b + a)
a, b = sort([a, b]) function code(a, b) return Float64(Float64(1.0 / Float64(b * Float64(Float64(a / 0.5) / pi))) / Float64(b + a)) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = (1.0 / (b * ((a / 0.5) / pi))) / (b + a);
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(N[(1.0 / N[(b * N[(N[(a / 0.5), $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(b + a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\frac{1}{b \cdot \frac{\frac{a}{0.5}}{\pi}}}{b + a}
\end{array}
Initial program 75.0%
*-commutative75.0%
associate-*r*75.0%
associate-*r/75.0%
associate-*r*75.0%
*-rgt-identity75.0%
sub-neg75.0%
distribute-neg-frac75.0%
metadata-eval75.0%
Simplified75.0%
associate-*l/75.0%
div-inv75.0%
metadata-eval75.0%
*-commutative75.0%
associate-*r*75.0%
*-commutative75.0%
Applied egg-rr98.6%
associate-*l/98.7%
*-commutative98.7%
metadata-eval98.7%
div-inv98.7%
clear-num98.6%
div-inv98.6%
metadata-eval98.6%
Applied egg-rr98.6%
inv-pow98.6%
associate-/l*98.6%
unpow-prod-down99.6%
inv-pow99.6%
*-commutative99.6%
times-frac99.6%
Applied egg-rr99.6%
associate-*l/99.7%
*-lft-identity99.7%
unpow-199.7%
associate-*l/99.7%
*-lft-identity99.7%
times-frac99.7%
/-rgt-identity99.7%
Simplified99.7%
Final simplification99.7%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -1.3e+156) (* (/ 0.5 a) (/ PI (* b a))) (* 0.5 (/ (/ PI b) (* a (+ b a))))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -1.3e+156) {
tmp = (0.5 / a) * (((double) M_PI) / (b * a));
} else {
tmp = 0.5 * ((((double) M_PI) / b) / (a * (b + a)));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -1.3e+156) {
tmp = (0.5 / a) * (Math.PI / (b * a));
} else {
tmp = 0.5 * ((Math.PI / b) / (a * (b + a)));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -1.3e+156: tmp = (0.5 / a) * (math.pi / (b * a)) else: tmp = 0.5 * ((math.pi / b) / (a * (b + a))) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -1.3e+156) tmp = Float64(Float64(0.5 / a) * Float64(pi / Float64(b * a))); else tmp = Float64(0.5 * Float64(Float64(pi / b) / Float64(a * Float64(b + a)))); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -1.3e+156)
tmp = (0.5 / a) * (pi / (b * a));
else
tmp = 0.5 * ((pi / b) / (a * (b + a)));
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.3e+156], N[(N[(0.5 / a), $MachinePrecision] * N[(Pi / N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(Pi / b), $MachinePrecision] / N[(a * N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.3 \cdot 10^{+156}:\\
\;\;\;\;\frac{0.5}{a} \cdot \frac{\pi}{b \cdot a}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{\frac{\pi}{b}}{a \cdot \left(b + a\right)}\\
\end{array}
\end{array}
if a < -1.30000000000000009e156Initial program 46.9%
associate-*l*46.9%
*-rgt-identity46.9%
associate-/l*46.9%
metadata-eval46.9%
associate-*l/46.9%
*-lft-identity46.9%
sub-neg46.9%
distribute-neg-frac46.9%
metadata-eval46.9%
Simplified46.9%
metadata-eval46.9%
div-inv46.9%
*-commutative46.9%
clear-num46.9%
frac-times46.9%
*-un-lft-identity46.9%
frac-add46.9%
associate-/r/46.9%
*-un-lft-identity46.9%
*-commutative46.9%
neg-mul-146.9%
sub-neg46.9%
flip-+97.2%
+-commutative97.2%
Applied egg-rr97.2%
*-commutative97.2%
associate-/r*97.2%
Simplified97.2%
Taylor expanded in a around inf 97.2%
div-inv97.2%
metadata-eval97.2%
*-commutative97.2%
times-frac99.8%
*-commutative99.8%
Applied egg-rr99.8%
if -1.30000000000000009e156 < a Initial program 79.3%
*-commutative79.3%
associate-*r*79.3%
associate-*r/79.3%
associate-*r*79.3%
*-rgt-identity79.3%
sub-neg79.3%
distribute-neg-frac79.3%
metadata-eval79.3%
Simplified79.3%
associate-*l/79.3%
div-inv79.3%
metadata-eval79.3%
*-commutative79.3%
associate-*r*79.3%
*-commutative79.3%
Applied egg-rr98.8%
associate-*l/98.9%
*-commutative98.9%
metadata-eval98.9%
div-inv98.9%
clear-num98.8%
div-inv98.8%
metadata-eval98.8%
Applied egg-rr98.8%
inv-pow98.8%
associate-/l*98.8%
unpow-prod-down99.6%
inv-pow99.6%
*-commutative99.6%
times-frac99.6%
Applied egg-rr99.6%
associate-*l/99.7%
*-lft-identity99.7%
unpow-199.7%
associate-*l/99.7%
*-lft-identity99.7%
times-frac99.7%
/-rgt-identity99.7%
Simplified99.7%
*-un-lft-identity99.7%
associate-/r*99.7%
div-inv99.6%
clear-num99.7%
div-inv99.7%
clear-num99.7%
+-commutative99.7%
Applied egg-rr99.7%
*-lft-identity99.7%
associate-*l/99.6%
*-lft-identity99.6%
associate-*r/99.6%
*-commutative99.6%
associate-/l/99.7%
associate-/l/98.9%
associate-/l*98.9%
associate-/l/99.7%
associate-/r*99.6%
associate-/l/96.8%
+-commutative96.8%
Simplified96.8%
Final simplification97.2%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -2.6e-45) (* (/ 0.5 a) (/ PI (* b a))) (/ (* PI (/ 0.5 (* b a))) b)))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -2.6e-45) {
tmp = (0.5 / a) * (((double) M_PI) / (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 <= -2.6e-45) {
tmp = (0.5 / a) * (Math.PI / (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 <= -2.6e-45: tmp = (0.5 / a) * (math.pi / (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 <= -2.6e-45) tmp = Float64(Float64(0.5 / a) * Float64(pi / Float64(b * a))); else tmp = Float64(Float64(pi * Float64(0.5 / Float64(b * a))) / b); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -2.6e-45)
tmp = (0.5 / a) * (pi / (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, -2.6e-45], N[(N[(0.5 / a), $MachinePrecision] * N[(Pi / N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Pi * N[(0.5 / N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.6 \cdot 10^{-45}:\\
\;\;\;\;\frac{0.5}{a} \cdot \frac{\pi}{b \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi \cdot \frac{0.5}{b \cdot a}}{b}\\
\end{array}
\end{array}
if a < -2.59999999999999987e-45Initial program 76.3%
associate-*l*76.2%
*-rgt-identity76.2%
associate-/l*76.2%
metadata-eval76.2%
associate-*l/76.3%
*-lft-identity76.3%
sub-neg76.3%
distribute-neg-frac76.3%
metadata-eval76.3%
Simplified76.3%
metadata-eval76.3%
div-inv76.3%
*-commutative76.3%
clear-num76.3%
frac-times76.3%
*-un-lft-identity76.3%
frac-add76.3%
associate-/r/76.4%
*-un-lft-identity76.4%
*-commutative76.4%
neg-mul-176.4%
sub-neg76.4%
flip-+98.6%
+-commutative98.6%
Applied egg-rr98.6%
*-commutative98.6%
associate-/r*98.6%
Simplified98.6%
Taylor expanded in a around inf 86.3%
div-inv86.3%
metadata-eval86.3%
*-commutative86.3%
times-frac87.4%
*-commutative87.4%
Applied egg-rr87.4%
if -2.59999999999999987e-45 < a Initial program 74.4%
associate-*l*74.4%
*-rgt-identity74.4%
associate-/l*74.4%
metadata-eval74.4%
associate-*l/74.5%
*-lft-identity74.5%
sub-neg74.5%
distribute-neg-frac74.5%
metadata-eval74.5%
Simplified74.5%
metadata-eval74.5%
div-inv74.5%
*-commutative74.5%
clear-num73.9%
frac-times74.0%
*-un-lft-identity74.0%
frac-add74.0%
associate-/r/74.0%
*-un-lft-identity74.0%
*-commutative74.0%
neg-mul-174.0%
sub-neg74.0%
flip-+98.7%
+-commutative98.7%
Applied egg-rr98.7%
*-commutative98.7%
associate-/r*98.7%
Simplified98.7%
Taylor expanded in a around 0 76.0%
div-inv76.0%
metadata-eval76.0%
times-frac76.1%
Applied egg-rr76.1%
associate-*l/76.2%
*-commutative76.2%
Applied egg-rr76.2%
Final simplification79.6%
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)))) (if (<= a -2.1e-45) (* (/ 0.5 a) t_0) (* t_0 (/ 0.5 b)))))
assert(a < b);
double code(double a, double b) {
double t_0 = ((double) M_PI) / (b * a);
double tmp;
if (a <= -2.1e-45) {
tmp = (0.5 / a) * t_0;
} else {
tmp = t_0 * (0.5 / b);
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double t_0 = Math.PI / (b * a);
double tmp;
if (a <= -2.1e-45) {
tmp = (0.5 / a) * t_0;
} else {
tmp = t_0 * (0.5 / b);
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): t_0 = math.pi / (b * a) tmp = 0 if a <= -2.1e-45: tmp = (0.5 / a) * t_0 else: tmp = t_0 * (0.5 / b) return tmp
a, b = sort([a, b]) function code(a, b) t_0 = Float64(pi / Float64(b * a)) tmp = 0.0 if (a <= -2.1e-45) tmp = Float64(Float64(0.5 / a) * t_0); else tmp = Float64(t_0 * Float64(0.5 / b)); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
t_0 = pi / (b * a);
tmp = 0.0;
if (a <= -2.1e-45)
tmp = (0.5 / a) * t_0;
else
tmp = t_0 * (0.5 / 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 * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -2.1e-45], N[(N[(0.5 / a), $MachinePrecision] * t$95$0), $MachinePrecision], N[(t$95$0 * N[(0.5 / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
t_0 := \frac{\pi}{b \cdot a}\\
\mathbf{if}\;a \leq -2.1 \cdot 10^{-45}:\\
\;\;\;\;\frac{0.5}{a} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{0.5}{b}\\
\end{array}
\end{array}
if a < -2.09999999999999995e-45Initial program 76.3%
associate-*l*76.2%
*-rgt-identity76.2%
associate-/l*76.2%
metadata-eval76.2%
associate-*l/76.3%
*-lft-identity76.3%
sub-neg76.3%
distribute-neg-frac76.3%
metadata-eval76.3%
Simplified76.3%
metadata-eval76.3%
div-inv76.3%
*-commutative76.3%
clear-num76.3%
frac-times76.3%
*-un-lft-identity76.3%
frac-add76.3%
associate-/r/76.4%
*-un-lft-identity76.4%
*-commutative76.4%
neg-mul-176.4%
sub-neg76.4%
flip-+98.6%
+-commutative98.6%
Applied egg-rr98.6%
*-commutative98.6%
associate-/r*98.6%
Simplified98.6%
Taylor expanded in a around inf 86.3%
div-inv86.3%
metadata-eval86.3%
*-commutative86.3%
times-frac87.4%
*-commutative87.4%
Applied egg-rr87.4%
if -2.09999999999999995e-45 < a Initial program 74.4%
associate-*l*74.4%
*-rgt-identity74.4%
associate-/l*74.4%
metadata-eval74.4%
associate-*l/74.5%
*-lft-identity74.5%
sub-neg74.5%
distribute-neg-frac74.5%
metadata-eval74.5%
Simplified74.5%
metadata-eval74.5%
div-inv74.5%
*-commutative74.5%
clear-num73.9%
frac-times74.0%
*-un-lft-identity74.0%
frac-add74.0%
associate-/r/74.0%
*-un-lft-identity74.0%
*-commutative74.0%
neg-mul-174.0%
sub-neg74.0%
flip-+98.7%
+-commutative98.7%
Applied egg-rr98.7%
*-commutative98.7%
associate-/r*98.7%
Simplified98.7%
Taylor expanded in a around 0 76.0%
div-inv76.0%
metadata-eval76.0%
*-commutative76.0%
times-frac76.2%
Applied egg-rr76.2%
Final simplification79.6%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -2.3e-45) (* PI (/ 0.5 (* a (* b a)))) (* (/ PI (* b a)) (/ 0.5 b))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -2.3e-45) {
tmp = ((double) M_PI) * (0.5 / (a * (b * a)));
} else {
tmp = (((double) M_PI) / (b * a)) * (0.5 / b);
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -2.3e-45) {
tmp = Math.PI * (0.5 / (a * (b * a)));
} else {
tmp = (Math.PI / (b * a)) * (0.5 / b);
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -2.3e-45: tmp = math.pi * (0.5 / (a * (b * a))) else: tmp = (math.pi / (b * a)) * (0.5 / b) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -2.3e-45) tmp = Float64(pi * Float64(0.5 / Float64(a * Float64(b * a)))); else tmp = Float64(Float64(pi / Float64(b * a)) * Float64(0.5 / b)); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -2.3e-45)
tmp = pi * (0.5 / (a * (b * a)));
else
tmp = (pi / (b * a)) * (0.5 / 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, -2.3e-45], N[(Pi * N[(0.5 / N[(a * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Pi / N[(b * a), $MachinePrecision]), $MachinePrecision] * N[(0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.3 \cdot 10^{-45}:\\
\;\;\;\;\pi \cdot \frac{0.5}{a \cdot \left(b \cdot a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi}{b \cdot a} \cdot \frac{0.5}{b}\\
\end{array}
\end{array}
if a < -2.29999999999999992e-45Initial program 76.3%
*-commutative76.3%
associate-*r*76.3%
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.3%
div-inv76.3%
metadata-eval76.3%
*-commutative76.3%
associate-*r*76.3%
*-commutative76.3%
Applied egg-rr98.5%
Taylor expanded in a around inf 86.3%
if -2.29999999999999992e-45 < a Initial program 74.4%
associate-*l*74.4%
*-rgt-identity74.4%
associate-/l*74.4%
metadata-eval74.4%
associate-*l/74.5%
*-lft-identity74.5%
sub-neg74.5%
distribute-neg-frac74.5%
metadata-eval74.5%
Simplified74.5%
metadata-eval74.5%
div-inv74.5%
*-commutative74.5%
clear-num73.9%
frac-times74.0%
*-un-lft-identity74.0%
frac-add74.0%
associate-/r/74.0%
*-un-lft-identity74.0%
*-commutative74.0%
neg-mul-174.0%
sub-neg74.0%
flip-+98.7%
+-commutative98.7%
Applied egg-rr98.7%
*-commutative98.7%
associate-/r*98.7%
Simplified98.7%
Taylor expanded in a around 0 76.0%
div-inv76.0%
metadata-eval76.0%
*-commutative76.0%
times-frac76.2%
Applied egg-rr76.2%
Final simplification79.2%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -1.08e-45) (* PI (/ 0.5 (* a (* b a)))) (* (/ PI b) (/ 0.5 (* b a)))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -1.08e-45) {
tmp = ((double) M_PI) * (0.5 / (a * (b * a)));
} else {
tmp = (((double) M_PI) / b) * (0.5 / (b * a));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -1.08e-45) {
tmp = Math.PI * (0.5 / (a * (b * a)));
} else {
tmp = (Math.PI / b) * (0.5 / (b * a));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -1.08e-45: tmp = math.pi * (0.5 / (a * (b * a))) else: tmp = (math.pi / b) * (0.5 / (b * a)) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -1.08e-45) tmp = Float64(pi * Float64(0.5 / Float64(a * Float64(b * a)))); else tmp = Float64(Float64(pi / b) * Float64(0.5 / Float64(b * a))); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -1.08e-45)
tmp = pi * (0.5 / (a * (b * a)));
else
tmp = (pi / b) * (0.5 / (b * a));
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.08e-45], N[(Pi * N[(0.5 / N[(a * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Pi / b), $MachinePrecision] * N[(0.5 / N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.08 \cdot 10^{-45}:\\
\;\;\;\;\pi \cdot \frac{0.5}{a \cdot \left(b \cdot a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi}{b} \cdot \frac{0.5}{b \cdot a}\\
\end{array}
\end{array}
if a < -1.08e-45Initial program 76.3%
*-commutative76.3%
associate-*r*76.3%
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.3%
div-inv76.3%
metadata-eval76.3%
*-commutative76.3%
associate-*r*76.3%
*-commutative76.3%
Applied egg-rr98.5%
Taylor expanded in a around inf 86.3%
if -1.08e-45 < a Initial program 74.4%
associate-*l*74.4%
*-rgt-identity74.4%
associate-/l*74.4%
metadata-eval74.4%
associate-*l/74.5%
*-lft-identity74.5%
sub-neg74.5%
distribute-neg-frac74.5%
metadata-eval74.5%
Simplified74.5%
metadata-eval74.5%
div-inv74.5%
*-commutative74.5%
clear-num73.9%
frac-times74.0%
*-un-lft-identity74.0%
frac-add74.0%
associate-/r/74.0%
*-un-lft-identity74.0%
*-commutative74.0%
neg-mul-174.0%
sub-neg74.0%
flip-+98.7%
+-commutative98.7%
Applied egg-rr98.7%
*-commutative98.7%
associate-/r*98.7%
Simplified98.7%
Taylor expanded in a around 0 76.0%
div-inv76.0%
metadata-eval76.0%
times-frac76.1%
Applied egg-rr76.1%
Final simplification79.2%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -2.35e-45) (* PI (/ 0.5 (* a (* b a)))) (* PI (/ 0.5 (* b (* b a))))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -2.35e-45) {
tmp = ((double) M_PI) * (0.5 / (a * (b * a)));
} else {
tmp = ((double) M_PI) * (0.5 / (b * (b * a)));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -2.35e-45) {
tmp = Math.PI * (0.5 / (a * (b * a)));
} else {
tmp = Math.PI * (0.5 / (b * (b * a)));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -2.35e-45: tmp = math.pi * (0.5 / (a * (b * a))) else: tmp = math.pi * (0.5 / (b * (b * a))) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -2.35e-45) tmp = Float64(pi * Float64(0.5 / Float64(a * Float64(b * a)))); else tmp = Float64(pi * Float64(0.5 / Float64(b * Float64(b * a)))); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -2.35e-45)
tmp = pi * (0.5 / (a * (b * a)));
else
tmp = pi * (0.5 / (b * (b * a)));
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, -2.35e-45], N[(Pi * N[(0.5 / N[(a * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(Pi * N[(0.5 / N[(b * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.35 \cdot 10^{-45}:\\
\;\;\;\;\pi \cdot \frac{0.5}{a \cdot \left(b \cdot a\right)}\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \frac{0.5}{b \cdot \left(b \cdot a\right)}\\
\end{array}
\end{array}
if a < -2.3499999999999999e-45Initial program 76.3%
*-commutative76.3%
associate-*r*76.3%
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.3%
div-inv76.3%
metadata-eval76.3%
*-commutative76.3%
associate-*r*76.3%
*-commutative76.3%
Applied egg-rr98.5%
Taylor expanded in a around inf 86.3%
if -2.3499999999999999e-45 < a Initial program 74.4%
*-commutative74.4%
associate-*r*74.5%
associate-*r/74.5%
associate-*r*74.5%
*-rgt-identity74.5%
sub-neg74.5%
distribute-neg-frac74.5%
metadata-eval74.5%
Simplified74.5%
associate-*l/74.5%
div-inv74.5%
metadata-eval74.5%
*-commutative74.5%
associate-*r*74.5%
*-commutative74.5%
Applied egg-rr98.7%
Taylor expanded in a around 0 76.0%
Final simplification79.1%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (/ (* (/ PI b) (/ 0.5 a)) (+ b a)))
assert(a < b);
double code(double a, double b) {
return ((((double) M_PI) / b) * (0.5 / a)) / (b + a);
}
assert a < b;
public static double code(double a, double b) {
return ((Math.PI / b) * (0.5 / a)) / (b + a);
}
[a, b] = sort([a, b]) def code(a, b): return ((math.pi / b) * (0.5 / a)) / (b + a)
a, b = sort([a, b]) function code(a, b) return Float64(Float64(Float64(pi / b) * Float64(0.5 / a)) / Float64(b + a)) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = ((pi / b) * (0.5 / a)) / (b + a);
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(N[(N[(Pi / b), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision] / N[(b + a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\frac{\pi}{b} \cdot \frac{0.5}{a}}{b + a}
\end{array}
Initial program 75.0%
*-commutative75.0%
associate-*r*75.0%
associate-*r/75.0%
associate-*r*75.0%
*-rgt-identity75.0%
sub-neg75.0%
distribute-neg-frac75.0%
metadata-eval75.0%
Simplified75.0%
associate-*l/75.0%
div-inv75.0%
metadata-eval75.0%
*-commutative75.0%
associate-*r*75.0%
*-commutative75.0%
Applied egg-rr98.6%
associate-*l/98.7%
*-commutative98.7%
metadata-eval98.7%
div-inv98.7%
clear-num98.6%
div-inv98.6%
metadata-eval98.6%
Applied egg-rr98.6%
inv-pow98.6%
associate-/l*98.6%
unpow-prod-down99.6%
inv-pow99.6%
*-commutative99.6%
times-frac99.6%
Applied egg-rr99.6%
associate-*l/99.7%
*-lft-identity99.7%
unpow-199.7%
associate-*l/99.7%
*-lft-identity99.7%
times-frac99.7%
/-rgt-identity99.7%
Simplified99.7%
*-un-lft-identity99.7%
associate-/r*99.6%
div-inv99.6%
clear-num99.7%
div-inv99.7%
clear-num99.7%
+-commutative99.7%
Applied egg-rr99.7%
*-lft-identity99.7%
associate-*r*99.7%
*-commutative99.7%
associate-*r/99.7%
*-rgt-identity99.7%
+-commutative99.7%
Simplified99.7%
Final simplification99.7%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (* (/ PI (* b a)) (/ 0.5 (+ b a))))
assert(a < b);
double code(double a, double b) {
return (((double) M_PI) / (b * a)) * (0.5 / (b + a));
}
assert a < b;
public static double code(double a, double b) {
return (Math.PI / (b * a)) * (0.5 / (b + a));
}
[a, b] = sort([a, b]) def code(a, b): return (math.pi / (b * a)) * (0.5 / (b + a))
a, b = sort([a, b]) function code(a, b) return Float64(Float64(pi / Float64(b * a)) * Float64(0.5 / Float64(b + a))) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = (pi / (b * a)) * (0.5 / (b + a));
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(N[(Pi / N[(b * a), $MachinePrecision]), $MachinePrecision] * N[(0.5 / N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\pi}{b \cdot a} \cdot \frac{0.5}{b + a}
\end{array}
Initial program 75.0%
*-commutative75.0%
associate-*r*75.0%
associate-*r/75.0%
associate-*r*75.0%
*-rgt-identity75.0%
sub-neg75.0%
distribute-neg-frac75.0%
metadata-eval75.0%
Simplified75.0%
associate-*l/75.0%
div-inv75.0%
metadata-eval75.0%
*-commutative75.0%
associate-*r*75.0%
*-commutative75.0%
Applied egg-rr98.6%
associate-*l/98.7%
*-commutative98.7%
metadata-eval98.7%
div-inv98.7%
associate-/r*99.6%
div-inv99.6%
metadata-eval99.6%
Applied egg-rr99.6%
associate-/l/98.7%
times-frac99.6%
Applied egg-rr99.6%
Final simplification99.6%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (* PI (/ 0.5 (* (+ b a) (* b a)))))
assert(a < b);
double code(double a, double b) {
return ((double) M_PI) * (0.5 / ((b + a) * (b * a)));
}
assert a < b;
public static double code(double a, double b) {
return Math.PI * (0.5 / ((b + a) * (b * a)));
}
[a, b] = sort([a, b]) def code(a, b): return math.pi * (0.5 / ((b + a) * (b * a)))
a, b = sort([a, b]) function code(a, b) return Float64(pi * Float64(0.5 / Float64(Float64(b + a) * Float64(b * a)))) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = pi * (0.5 / ((b + a) * (b * a)));
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[(b + a), $MachinePrecision] * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\pi \cdot \frac{0.5}{\left(b + a\right) \cdot \left(b \cdot a\right)}
\end{array}
Initial program 75.0%
*-commutative75.0%
associate-*r*75.0%
associate-*r/75.0%
associate-*r*75.0%
*-rgt-identity75.0%
sub-neg75.0%
distribute-neg-frac75.0%
metadata-eval75.0%
Simplified75.0%
associate-*l/75.0%
div-inv75.0%
metadata-eval75.0%
*-commutative75.0%
associate-*r*75.0%
*-commutative75.0%
Applied egg-rr98.6%
Final simplification98.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)))))
assert(a < b);
double code(double a, double b) {
return ((double) M_PI) * (0.5 / (a * (b * a)));
}
assert a < b;
public static double code(double a, double b) {
return Math.PI * (0.5 / (a * (b * a)));
}
[a, b] = sort([a, b]) def code(a, b): return math.pi * (0.5 / (a * (b * a)))
a, b = sort([a, b]) function code(a, b) return Float64(pi * Float64(0.5 / Float64(a * Float64(b * a)))) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = pi * (0.5 / (a * (b * a)));
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[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\pi \cdot \frac{0.5}{a \cdot \left(b \cdot a\right)}
\end{array}
Initial program 75.0%
*-commutative75.0%
associate-*r*75.0%
associate-*r/75.0%
associate-*r*75.0%
*-rgt-identity75.0%
sub-neg75.0%
distribute-neg-frac75.0%
metadata-eval75.0%
Simplified75.0%
associate-*l/75.0%
div-inv75.0%
metadata-eval75.0%
*-commutative75.0%
associate-*r*75.0%
*-commutative75.0%
Applied egg-rr98.6%
Taylor expanded in a around inf 60.2%
Final simplification60.2%
herbie shell --seed 2024155
(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))))