
(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 10 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 (/ (/ (/ (* 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(Float64(Float64(Float64(pi * 0.5) / 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[(N[(N[(N[(Pi * 0.5), $MachinePrecision] / b), $MachinePrecision] / a), $MachinePrecision] / N[(b + a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\frac{\frac{\pi \cdot 0.5}{b}}{a}}{b + a}
\end{array}
Initial program 77.2%
associate-*l*77.2%
*-rgt-identity77.2%
associate-/l*77.2%
metadata-eval77.2%
associate-*l/77.3%
*-lft-identity77.3%
sub-neg77.3%
distribute-neg-frac77.3%
metadata-eval77.3%
Simplified77.3%
metadata-eval77.3%
div-inv77.3%
*-commutative77.3%
clear-num76.7%
frac-times76.7%
*-un-lft-identity76.7%
frac-add76.7%
associate-/r/76.7%
*-un-lft-identity76.7%
*-commutative76.7%
neg-mul-176.7%
sub-neg76.7%
flip-+98.5%
+-commutative98.5%
Applied egg-rr98.5%
*-commutative98.5%
associate-/r*98.5%
Simplified98.5%
div-inv98.5%
metadata-eval98.5%
times-frac99.6%
Applied egg-rr99.6%
frac-times98.5%
metadata-eval98.5%
div-inv98.5%
associate-*r*94.5%
*-commutative94.5%
associate-/l/95.4%
associate-/r*99.7%
div-inv99.7%
metadata-eval99.7%
Applied egg-rr99.7%
Final simplification99.7%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 2e+132) (* (/ 0.5 a) (/ PI (* b (+ b a)))) (* (/ PI (* b a)) (/ 0.5 b))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (b <= 2e+132) {
tmp = (0.5 / a) * (((double) M_PI) / (b * (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 (b <= 2e+132) {
tmp = (0.5 / a) * (Math.PI / (b * (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 b <= 2e+132: tmp = (0.5 / a) * (math.pi / (b * (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 (b <= 2e+132) tmp = Float64(Float64(0.5 / a) * Float64(pi / Float64(b * 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 (b <= 2e+132)
tmp = (0.5 / a) * (pi / (b * (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[b, 2e+132], N[(N[(0.5 / a), $MachinePrecision] * N[(Pi / N[(b * 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}\;b \leq 2 \cdot 10^{+132}:\\
\;\;\;\;\frac{0.5}{a} \cdot \frac{\pi}{b \cdot \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi}{b \cdot a} \cdot \frac{0.5}{b}\\
\end{array}
\end{array}
if b < 1.99999999999999998e132Initial program 83.2%
associate-*l*83.1%
*-rgt-identity83.1%
associate-/l*83.1%
metadata-eval83.1%
associate-*l/83.2%
*-lft-identity83.2%
sub-neg83.2%
distribute-neg-frac83.2%
metadata-eval83.2%
Simplified83.2%
metadata-eval83.2%
div-inv83.2%
*-commutative83.2%
clear-num82.5%
frac-times82.5%
*-un-lft-identity82.5%
frac-add82.5%
associate-/r/82.5%
*-un-lft-identity82.5%
*-commutative82.5%
neg-mul-182.5%
sub-neg82.5%
flip-+98.5%
+-commutative98.5%
Applied egg-rr98.5%
*-commutative98.5%
associate-/r*98.5%
Simplified98.5%
associate-/r*99.6%
div-inv99.6%
metadata-eval99.6%
*-commutative99.6%
associate-/l*99.6%
times-frac95.9%
Applied egg-rr95.9%
associate-/l/95.9%
Simplified95.9%
if 1.99999999999999998e132 < b Initial program 48.7%
associate-*l*48.7%
*-rgt-identity48.7%
associate-/l*48.7%
metadata-eval48.7%
associate-*l/48.7%
*-lft-identity48.7%
sub-neg48.7%
distribute-neg-frac48.7%
metadata-eval48.7%
Simplified48.7%
metadata-eval48.7%
div-inv48.7%
*-commutative48.7%
clear-num48.7%
frac-times48.7%
*-un-lft-identity48.7%
frac-add48.8%
associate-/r/48.8%
*-un-lft-identity48.8%
*-commutative48.8%
neg-mul-148.8%
sub-neg48.8%
flip-+98.7%
+-commutative98.7%
Applied egg-rr98.7%
*-commutative98.7%
associate-/r*98.7%
Simplified98.7%
Taylor expanded in b around 0 89.6%
+-commutative89.6%
unpow289.6%
distribute-lft-in98.7%
Simplified98.7%
div-inv98.7%
metadata-eval98.7%
*-commutative98.7%
*-commutative98.7%
associate-*r*98.7%
frac-times99.7%
associate-*r/99.7%
times-frac99.7%
Applied egg-rr99.7%
Taylor expanded in a around 0 99.8%
Final simplification96.5%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -2.8e-62) (/ (/ 0.5 a) (* b (/ a PI))) (* (/ PI (* b a)) (/ 0.5 b))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -2.8e-62) {
tmp = (0.5 / a) / (b * (a / ((double) M_PI)));
} 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.8e-62) {
tmp = (0.5 / a) / (b * (a / Math.PI));
} 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.8e-62: tmp = (0.5 / a) / (b * (a / math.pi)) 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.8e-62) tmp = Float64(Float64(0.5 / a) / Float64(b * Float64(a / pi))); 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.8e-62)
tmp = (0.5 / a) / (b * (a / pi));
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.8e-62], N[(N[(0.5 / a), $MachinePrecision] / N[(b * N[(a / Pi), $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.8 \cdot 10^{-62}:\\
\;\;\;\;\frac{\frac{0.5}{a}}{b \cdot \frac{a}{\pi}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi}{b \cdot a} \cdot \frac{0.5}{b}\\
\end{array}
\end{array}
if a < -2.80000000000000002e-62Initial program 79.3%
associate-*l*79.2%
*-rgt-identity79.2%
associate-/l*79.2%
metadata-eval79.2%
associate-*l/79.3%
*-lft-identity79.3%
sub-neg79.3%
distribute-neg-frac79.3%
metadata-eval79.3%
Simplified79.3%
metadata-eval79.3%
div-inv79.3%
*-commutative79.3%
clear-num78.2%
frac-times78.3%
*-un-lft-identity78.3%
frac-add78.3%
associate-/r/78.4%
*-un-lft-identity78.4%
*-commutative78.4%
neg-mul-178.4%
sub-neg78.4%
flip-+98.0%
+-commutative98.0%
Applied egg-rr98.0%
*-commutative98.0%
associate-/r*98.0%
Simplified98.0%
div-inv98.0%
metadata-eval98.0%
times-frac99.7%
Applied egg-rr99.7%
Taylor expanded in a around inf 87.0%
clear-num87.1%
associate-/r*87.0%
frac-times87.1%
*-un-lft-identity87.1%
Applied egg-rr87.1%
if -2.80000000000000002e-62 < a Initial program 76.5%
associate-*l*76.5%
*-rgt-identity76.5%
associate-/l*76.5%
metadata-eval76.5%
associate-*l/76.5%
*-lft-identity76.5%
sub-neg76.5%
distribute-neg-frac76.5%
metadata-eval76.5%
Simplified76.5%
metadata-eval76.5%
div-inv76.5%
*-commutative76.5%
clear-num76.1%
frac-times76.1%
*-un-lft-identity76.1%
frac-add76.1%
associate-/r/76.1%
*-un-lft-identity76.1%
*-commutative76.1%
neg-mul-176.1%
sub-neg76.1%
flip-+98.7%
+-commutative98.7%
Applied egg-rr98.7%
*-commutative98.7%
associate-/r*98.7%
Simplified98.7%
Taylor expanded in b around 0 85.5%
+-commutative85.5%
unpow285.5%
distribute-lft-in96.2%
Simplified96.2%
div-inv96.2%
metadata-eval96.2%
*-commutative96.2%
*-commutative96.2%
associate-*r*98.7%
frac-times99.6%
associate-*r/99.6%
times-frac97.2%
Applied egg-rr97.2%
Taylor expanded in a around 0 75.2%
Final simplification78.5%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (let* ((t_0 (/ 0.5 (* b a)))) (if (<= a -1.65e-80) (* t_0 (/ PI a)) (* t_0 (/ PI b)))))
assert(a < b);
double code(double a, double b) {
double t_0 = 0.5 / (b * a);
double tmp;
if (a <= -1.65e-80) {
tmp = t_0 * (((double) M_PI) / a);
} else {
tmp = t_0 * (((double) M_PI) / b);
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double t_0 = 0.5 / (b * a);
double tmp;
if (a <= -1.65e-80) {
tmp = t_0 * (Math.PI / a);
} else {
tmp = t_0 * (Math.PI / b);
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): t_0 = 0.5 / (b * a) tmp = 0 if a <= -1.65e-80: tmp = t_0 * (math.pi / a) else: tmp = t_0 * (math.pi / b) return tmp
a, b = sort([a, b]) function code(a, b) t_0 = Float64(0.5 / Float64(b * a)) tmp = 0.0 if (a <= -1.65e-80) tmp = Float64(t_0 * Float64(pi / a)); else tmp = Float64(t_0 * Float64(pi / b)); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
t_0 = 0.5 / (b * a);
tmp = 0.0;
if (a <= -1.65e-80)
tmp = t_0 * (pi / a);
else
tmp = t_0 * (pi / 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[(0.5 / N[(b * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -1.65e-80], N[(t$95$0 * N[(Pi / a), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(Pi / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
t_0 := \frac{0.5}{b \cdot a}\\
\mathbf{if}\;a \leq -1.65 \cdot 10^{-80}:\\
\;\;\;\;t\_0 \cdot \frac{\pi}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{\pi}{b}\\
\end{array}
\end{array}
if a < -1.65e-80Initial program 80.2%
associate-*l*80.1%
*-rgt-identity80.1%
associate-/l*80.1%
metadata-eval80.1%
associate-*l/80.1%
*-lft-identity80.1%
sub-neg80.1%
distribute-neg-frac80.1%
metadata-eval80.1%
Simplified80.1%
metadata-eval80.1%
div-inv80.1%
*-commutative80.1%
clear-num79.1%
frac-times79.2%
*-un-lft-identity79.2%
frac-add79.2%
associate-/r/79.3%
*-un-lft-identity79.3%
*-commutative79.3%
neg-mul-179.3%
sub-neg79.3%
flip-+98.0%
+-commutative98.0%
Applied egg-rr98.0%
*-commutative98.0%
associate-/r*98.0%
Simplified98.0%
div-inv98.0%
metadata-eval98.0%
times-frac99.7%
Applied egg-rr99.7%
Taylor expanded in a around inf 87.6%
if -1.65e-80 < a Initial program 76.1%
associate-*l*76.1%
*-rgt-identity76.1%
associate-/l*76.1%
metadata-eval76.1%
associate-*l/76.2%
*-lft-identity76.2%
sub-neg76.2%
distribute-neg-frac76.2%
metadata-eval76.2%
Simplified76.2%
metadata-eval76.2%
div-inv76.2%
*-commutative76.2%
clear-num75.7%
frac-times75.7%
*-un-lft-identity75.7%
frac-add75.7%
associate-/r/75.7%
*-un-lft-identity75.7%
*-commutative75.7%
neg-mul-175.7%
sub-neg75.7%
flip-+98.7%
+-commutative98.7%
Applied egg-rr98.7%
*-commutative98.7%
associate-/r*98.7%
Simplified98.7%
div-inv98.7%
metadata-eval98.7%
times-frac99.6%
Applied egg-rr99.6%
Taylor expanded in a around 0 75.9%
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.8e-62) (* (/ 0.5 (* b a)) (/ PI a)) (* PI (/ 0.5 (* b (* b a))))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -2.8e-62) {
tmp = (0.5 / (b * a)) * (((double) M_PI) / 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.8e-62) {
tmp = (0.5 / (b * a)) * (Math.PI / 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.8e-62: tmp = (0.5 / (b * a)) * (math.pi / 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.8e-62) tmp = Float64(Float64(0.5 / Float64(b * a)) * Float64(pi / 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.8e-62)
tmp = (0.5 / (b * a)) * (pi / 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.8e-62], N[(N[(0.5 / N[(b * a), $MachinePrecision]), $MachinePrecision] * N[(Pi / a), $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.8 \cdot 10^{-62}:\\
\;\;\;\;\frac{0.5}{b \cdot a} \cdot \frac{\pi}{a}\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \frac{0.5}{b \cdot \left(b \cdot a\right)}\\
\end{array}
\end{array}
if a < -2.80000000000000002e-62Initial program 79.3%
associate-*l*79.2%
*-rgt-identity79.2%
associate-/l*79.2%
metadata-eval79.2%
associate-*l/79.3%
*-lft-identity79.3%
sub-neg79.3%
distribute-neg-frac79.3%
metadata-eval79.3%
Simplified79.3%
metadata-eval79.3%
div-inv79.3%
*-commutative79.3%
clear-num78.2%
frac-times78.3%
*-un-lft-identity78.3%
frac-add78.3%
associate-/r/78.4%
*-un-lft-identity78.4%
*-commutative78.4%
neg-mul-178.4%
sub-neg78.4%
flip-+98.0%
+-commutative98.0%
Applied egg-rr98.0%
*-commutative98.0%
associate-/r*98.0%
Simplified98.0%
div-inv98.0%
metadata-eval98.0%
times-frac99.7%
Applied egg-rr99.7%
Taylor expanded in a around inf 87.0%
if -2.80000000000000002e-62 < a Initial program 76.5%
*-commutative76.5%
associate-*r*76.4%
associate-*r/76.5%
associate-*r*76.5%
*-rgt-identity76.5%
sub-neg76.5%
distribute-neg-frac76.5%
metadata-eval76.5%
Simplified76.5%
*-commutative76.5%
associate-*r/76.5%
div-inv76.5%
metadata-eval76.5%
associate-*l*76.5%
*-commutative76.5%
Applied egg-rr98.7%
Taylor expanded in a around 0 74.6%
Final simplification78.0%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -2.8e-62) (* 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.8e-62) {
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.8e-62) {
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.8e-62: 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.8e-62) 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.8e-62)
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.8e-62], 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.8 \cdot 10^{-62}:\\
\;\;\;\;\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.80000000000000002e-62Initial 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%
*-commutative79.3%
associate-*r/79.3%
div-inv79.3%
metadata-eval79.3%
associate-*l*79.2%
*-commutative79.2%
Applied egg-rr97.8%
Taylor expanded in a around inf 85.2%
if -2.80000000000000002e-62 < a Initial program 76.5%
*-commutative76.5%
associate-*r*76.4%
associate-*r/76.5%
associate-*r*76.5%
*-rgt-identity76.5%
sub-neg76.5%
distribute-neg-frac76.5%
metadata-eval76.5%
Simplified76.5%
*-commutative76.5%
associate-*r/76.5%
div-inv76.5%
metadata-eval76.5%
associate-*l*76.5%
*-commutative76.5%
Applied egg-rr98.7%
Taylor expanded in a around 0 74.6%
Final simplification77.5%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -1.65e-80) (* PI (/ 0.5 (* a (* b a)))) (* (/ 0.5 a) (/ PI (* b b)))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -1.65e-80) {
tmp = ((double) M_PI) * (0.5 / (a * (b * a)));
} else {
tmp = (0.5 / a) * (((double) M_PI) / (b * b));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -1.65e-80) {
tmp = Math.PI * (0.5 / (a * (b * a)));
} else {
tmp = (0.5 / a) * (Math.PI / (b * b));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -1.65e-80: tmp = math.pi * (0.5 / (a * (b * a))) else: tmp = (0.5 / a) * (math.pi / (b * b)) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -1.65e-80) tmp = Float64(pi * Float64(0.5 / Float64(a * Float64(b * a)))); else tmp = Float64(Float64(0.5 / a) * Float64(pi / Float64(b * b))); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -1.65e-80)
tmp = pi * (0.5 / (a * (b * a)));
else
tmp = (0.5 / a) * (pi / (b * 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.65e-80], N[(Pi * N[(0.5 / N[(a * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / a), $MachinePrecision] * N[(Pi / N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.65 \cdot 10^{-80}:\\
\;\;\;\;\pi \cdot \frac{0.5}{a \cdot \left(b \cdot a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{a} \cdot \frac{\pi}{b \cdot b}\\
\end{array}
\end{array}
if a < -1.65e-80Initial program 80.2%
*-commutative80.2%
associate-*r*80.1%
associate-*r/80.1%
associate-*r*80.1%
*-rgt-identity80.1%
sub-neg80.1%
distribute-neg-frac80.1%
metadata-eval80.1%
Simplified80.1%
*-commutative80.1%
associate-*r/80.1%
div-inv80.1%
metadata-eval80.1%
associate-*l*80.1%
*-commutative80.1%
Applied egg-rr97.9%
Taylor expanded in a around inf 85.8%
if -1.65e-80 < a Initial program 76.1%
associate-*l*76.1%
*-rgt-identity76.1%
associate-/l*76.1%
metadata-eval76.1%
associate-*l/76.2%
*-lft-identity76.2%
sub-neg76.2%
distribute-neg-frac76.2%
metadata-eval76.2%
Simplified76.2%
metadata-eval76.2%
div-inv76.2%
*-commutative76.2%
clear-num75.7%
frac-times75.7%
*-un-lft-identity75.7%
frac-add75.7%
associate-/r/75.7%
*-un-lft-identity75.7%
*-commutative75.7%
neg-mul-175.7%
sub-neg75.7%
flip-+98.7%
+-commutative98.7%
Applied egg-rr98.7%
*-commutative98.7%
associate-/r*98.7%
Simplified98.7%
associate-/r*99.6%
div-inv99.6%
metadata-eval99.6%
*-commutative99.6%
associate-/l*99.6%
times-frac87.1%
Applied egg-rr87.1%
associate-/l/86.8%
Simplified86.8%
Taylor expanded in a around 0 63.1%
Final simplification69.6%
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 + a} \cdot \frac{0.5}{b \cdot a}
\end{array}
Initial program 77.2%
associate-*l*77.2%
*-rgt-identity77.2%
associate-/l*77.2%
metadata-eval77.2%
associate-*l/77.3%
*-lft-identity77.3%
sub-neg77.3%
distribute-neg-frac77.3%
metadata-eval77.3%
Simplified77.3%
metadata-eval77.3%
div-inv77.3%
*-commutative77.3%
clear-num76.7%
frac-times76.7%
*-un-lft-identity76.7%
frac-add76.7%
associate-/r/76.7%
*-un-lft-identity76.7%
*-commutative76.7%
neg-mul-176.7%
sub-neg76.7%
flip-+98.5%
+-commutative98.5%
Applied egg-rr98.5%
*-commutative98.5%
associate-/r*98.5%
Simplified98.5%
div-inv98.5%
metadata-eval98.5%
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 77.2%
*-commutative77.2%
associate-*r*77.2%
associate-*r/77.3%
associate-*r*77.3%
*-rgt-identity77.3%
sub-neg77.3%
distribute-neg-frac77.3%
metadata-eval77.3%
Simplified77.3%
*-commutative77.3%
associate-*r/77.3%
div-inv77.3%
metadata-eval77.3%
associate-*l*77.3%
*-commutative77.3%
Applied egg-rr98.5%
Final simplification98.5%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (* (/ 0.5 a) (/ PI (* b b))))
assert(a < b);
double code(double a, double b) {
return (0.5 / a) * (((double) M_PI) / (b * b));
}
assert a < b;
public static double code(double a, double b) {
return (0.5 / a) * (Math.PI / (b * b));
}
[a, b] = sort([a, b]) def code(a, b): return (0.5 / a) * (math.pi / (b * b))
a, b = sort([a, b]) function code(a, b) return Float64(Float64(0.5 / a) * Float64(pi / Float64(b * b))) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = (0.5 / a) * (pi / (b * b));
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(N[(0.5 / a), $MachinePrecision] * N[(Pi / N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{0.5}{a} \cdot \frac{\pi}{b \cdot b}
\end{array}
Initial program 77.2%
associate-*l*77.2%
*-rgt-identity77.2%
associate-/l*77.2%
metadata-eval77.2%
associate-*l/77.3%
*-lft-identity77.3%
sub-neg77.3%
distribute-neg-frac77.3%
metadata-eval77.3%
Simplified77.3%
metadata-eval77.3%
div-inv77.3%
*-commutative77.3%
clear-num76.7%
frac-times76.7%
*-un-lft-identity76.7%
frac-add76.7%
associate-/r/76.7%
*-un-lft-identity76.7%
*-commutative76.7%
neg-mul-176.7%
sub-neg76.7%
flip-+98.5%
+-commutative98.5%
Applied egg-rr98.5%
*-commutative98.5%
associate-/r*98.5%
Simplified98.5%
associate-/r*99.6%
div-inv99.6%
metadata-eval99.6%
*-commutative99.6%
associate-/l*99.6%
times-frac90.6%
Applied egg-rr90.6%
associate-/l/90.5%
Simplified90.5%
Taylor expanded in a around 0 59.2%
herbie shell --seed 2024130
(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))))