
(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 (if (<= b 5e+115) (* (/ PI a) (/ 0.5 (* b (+ b a)))) (/ (* (/ PI a) (/ 0.5 b)) b)))
assert(a < b);
double code(double a, double b) {
double tmp;
if (b <= 5e+115) {
tmp = (((double) M_PI) / a) * (0.5 / (b * (b + a)));
} else {
tmp = ((((double) M_PI) / a) * (0.5 / b)) / b;
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (b <= 5e+115) {
tmp = (Math.PI / a) * (0.5 / (b * (b + a)));
} else {
tmp = ((Math.PI / a) * (0.5 / b)) / b;
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if b <= 5e+115: tmp = (math.pi / a) * (0.5 / (b * (b + a))) else: tmp = ((math.pi / a) * (0.5 / b)) / b return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (b <= 5e+115) tmp = Float64(Float64(pi / a) * Float64(0.5 / Float64(b * Float64(b + a)))); else tmp = Float64(Float64(Float64(pi / a) * Float64(0.5 / b)) / b); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (b <= 5e+115)
tmp = (pi / a) * (0.5 / (b * (b + a)));
else
tmp = ((pi / a) * (0.5 / 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[b, 5e+115], N[(N[(Pi / a), $MachinePrecision] * N[(0.5 / N[(b * N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(Pi / a), $MachinePrecision] * N[(0.5 / b), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5 \cdot 10^{+115}:\\
\;\;\;\;\frac{\pi}{a} \cdot \frac{0.5}{b \cdot \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\pi}{a} \cdot \frac{0.5}{b}}{b}\\
\end{array}
\end{array}
if b < 5.00000000000000008e115Initial program 81.6%
div-inv81.6%
expm1-log1p-u58.2%
expm1-udef43.4%
Applied egg-rr48.5%
expm1-def74.3%
expm1-log1p99.6%
associate-*r/99.6%
associate-*r/99.6%
*-commutative99.6%
+-commutative99.6%
*-commutative99.6%
Simplified99.6%
*-commutative99.6%
+-commutative99.6%
associate-*r/99.6%
associate-*l*99.6%
Applied egg-rr99.6%
associate-*r/99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
times-frac96.6%
associate-/l/96.1%
Applied egg-rr96.1%
if 5.00000000000000008e115 < b Initial program 79.3%
div-inv79.4%
expm1-log1p-u79.4%
expm1-udef56.4%
Applied egg-rr63.9%
expm1-def99.8%
expm1-log1p99.8%
associate-*r/99.7%
associate-*r/99.7%
*-commutative99.7%
+-commutative99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in a around 0 99.7%
*-commutative99.7%
times-frac99.8%
Applied egg-rr99.8%
associate-/l/99.8%
associate-*l/99.7%
associate-/r*99.9%
associate-*l/99.9%
Applied egg-rr99.9%
Final simplification96.7%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -2.1e+139) (* (/ PI a) (/ (/ 0.5 b) a)) (* PI (/ (/ 0.5 b) (* a (+ b a))))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -2.1e+139) {
tmp = (((double) M_PI) / a) * ((0.5 / b) / a);
} else {
tmp = ((double) M_PI) * ((0.5 / b) / (a * (b + a)));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -2.1e+139) {
tmp = (Math.PI / a) * ((0.5 / b) / a);
} else {
tmp = Math.PI * ((0.5 / b) / (a * (b + a)));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -2.1e+139: tmp = (math.pi / a) * ((0.5 / b) / a) else: tmp = math.pi * ((0.5 / b) / (a * (b + a))) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -2.1e+139) tmp = Float64(Float64(pi / a) * Float64(Float64(0.5 / b) / a)); else tmp = Float64(pi * Float64(Float64(0.5 / 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 <= -2.1e+139)
tmp = (pi / a) * ((0.5 / b) / a);
else
tmp = pi * ((0.5 / 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, -2.1e+139], N[(N[(Pi / a), $MachinePrecision] * N[(N[(0.5 / b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(Pi * N[(N[(0.5 / 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 -2.1 \cdot 10^{+139}:\\
\;\;\;\;\frac{\pi}{a} \cdot \frac{\frac{0.5}{b}}{a}\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \frac{\frac{0.5}{b}}{a \cdot \left(b + a\right)}\\
\end{array}
\end{array}
if a < -2.0999999999999999e139Initial program 65.1%
div-inv65.1%
expm1-log1p-u62.4%
expm1-udef60.0%
Applied egg-rr70.6%
expm1-def97.2%
expm1-log1p99.9%
associate-*r/99.8%
associate-*r/99.7%
*-commutative99.7%
+-commutative99.7%
*-commutative99.7%
Simplified99.7%
*-commutative99.7%
+-commutative99.7%
associate-*r/99.8%
associate-*l*99.8%
Applied egg-rr99.8%
associate-*r/99.8%
metadata-eval99.8%
+-commutative99.8%
Simplified99.8%
div-inv99.8%
associate-*l*99.8%
*-commutative99.8%
associate-/r*99.8%
times-frac75.6%
div-inv75.6%
*-commutative75.6%
associate-*r/75.6%
times-frac99.9%
Applied egg-rr99.9%
Taylor expanded in b around 0 99.8%
associate-/l/99.9%
Simplified99.9%
if -2.0999999999999999e139 < a Initial program 84.0%
associate-*l*84.0%
associate-*l/84.0%
frac-sub84.0%
*-commutative84.0%
associate-*r/84.0%
*-un-lft-identity84.0%
*-rgt-identity84.0%
associate-/r/84.1%
flip-+99.6%
Applied egg-rr99.6%
associate-/l*99.0%
associate-/l/99.0%
associate-*r*96.0%
+-commutative96.0%
associate-/r/96.0%
metadata-eval96.0%
div-inv96.0%
associate-/r*96.0%
metadata-eval96.0%
+-commutative96.0%
Applied egg-rr96.0%
associate-/r*96.4%
+-commutative96.4%
Simplified96.4%
Final simplification96.9%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (/ (* PI (/ (/ 1.0 (+ b a)) (* b a))) 2.0))
assert(a < b);
double code(double a, double b) {
return (((double) M_PI) * ((1.0 / (b + a)) / (b * a))) / 2.0;
}
assert a < b;
public static double code(double a, double b) {
return (Math.PI * ((1.0 / (b + a)) / (b * a))) / 2.0;
}
[a, b] = sort([a, b]) def code(a, b): return (math.pi * ((1.0 / (b + a)) / (b * a))) / 2.0
a, b = sort([a, b]) function code(a, b) return Float64(Float64(pi * Float64(Float64(1.0 / Float64(b + a)) / Float64(b * a))) / 2.0) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = (pi * ((1.0 / (b + a)) / (b * a))) / 2.0;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(N[(Pi * N[(N[(1.0 / N[(b + a), $MachinePrecision]), $MachinePrecision] / N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\pi \cdot \frac{\frac{1}{b + a}}{b \cdot a}}{2}
\end{array}
Initial program 81.2%
associate-*l*81.2%
associate-*l/81.2%
frac-sub81.2%
*-commutative81.2%
associate-*r/81.2%
*-un-lft-identity81.2%
*-rgt-identity81.2%
associate-/r/81.3%
flip-+99.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 (if (<= a -9e-7) (* (/ PI a) (/ (/ 0.5 b) a)) (* (/ 0.5 b) (/ (/ PI b) a))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -9e-7) {
tmp = (((double) M_PI) / a) * ((0.5 / b) / a);
} else {
tmp = (0.5 / b) * ((((double) M_PI) / b) / a);
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -9e-7) {
tmp = (Math.PI / a) * ((0.5 / b) / a);
} else {
tmp = (0.5 / b) * ((Math.PI / b) / a);
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -9e-7: tmp = (math.pi / a) * ((0.5 / b) / a) else: tmp = (0.5 / b) * ((math.pi / b) / a) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -9e-7) tmp = Float64(Float64(pi / a) * Float64(Float64(0.5 / b) / a)); else tmp = Float64(Float64(0.5 / b) * Float64(Float64(pi / b) / a)); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -9e-7)
tmp = (pi / a) * ((0.5 / b) / a);
else
tmp = (0.5 / b) * ((pi / 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, -9e-7], N[(N[(Pi / a), $MachinePrecision] * N[(N[(0.5 / b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / b), $MachinePrecision] * N[(N[(Pi / b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -9 \cdot 10^{-7}:\\
\;\;\;\;\frac{\pi}{a} \cdot \frac{\frac{0.5}{b}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{b} \cdot \frac{\frac{\pi}{b}}{a}\\
\end{array}
\end{array}
if a < -8.99999999999999959e-7Initial program 81.6%
div-inv81.6%
expm1-log1p-u66.1%
expm1-udef53.2%
Applied egg-rr58.6%
expm1-def84.2%
expm1-log1p99.7%
associate-*r/99.6%
associate-*r/99.7%
*-commutative99.7%
+-commutative99.7%
*-commutative99.7%
Simplified99.7%
*-commutative99.7%
+-commutative99.7%
associate-*r/99.6%
associate-*l*99.6%
Applied egg-rr99.6%
associate-*r/99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
div-inv99.6%
associate-*l*99.6%
*-commutative99.6%
associate-/r*99.6%
times-frac87.1%
div-inv87.1%
*-commutative87.1%
associate-*r/87.1%
times-frac99.7%
Applied egg-rr99.7%
Taylor expanded in b around 0 92.0%
associate-/l/91.9%
Simplified91.9%
if -8.99999999999999959e-7 < a Initial program 81.1%
div-inv81.1%
expm1-log1p-u59.6%
expm1-udef42.3%
Applied egg-rr47.8%
expm1-def75.9%
expm1-log1p99.6%
associate-*r/99.6%
associate-*r/99.5%
*-commutative99.5%
+-commutative99.5%
*-commutative99.5%
Simplified99.5%
Taylor expanded in a around 0 70.6%
*-commutative70.6%
times-frac70.7%
Applied egg-rr70.7%
Final simplification76.7%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -4.2e-6) (/ (* PI (/ 0.5 a)) (* b a)) (* (/ 0.5 b) (/ (/ PI b) a))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -4.2e-6) {
tmp = (((double) M_PI) * (0.5 / a)) / (b * a);
} else {
tmp = (0.5 / b) * ((((double) M_PI) / b) / a);
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -4.2e-6) {
tmp = (Math.PI * (0.5 / a)) / (b * a);
} else {
tmp = (0.5 / b) * ((Math.PI / b) / a);
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -4.2e-6: tmp = (math.pi * (0.5 / a)) / (b * a) else: tmp = (0.5 / b) * ((math.pi / b) / a) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -4.2e-6) tmp = Float64(Float64(pi * Float64(0.5 / a)) / Float64(b * a)); else tmp = Float64(Float64(0.5 / b) * Float64(Float64(pi / b) / a)); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -4.2e-6)
tmp = (pi * (0.5 / a)) / (b * a);
else
tmp = (0.5 / b) * ((pi / 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, -4.2e-6], N[(N[(Pi * N[(0.5 / a), $MachinePrecision]), $MachinePrecision] / N[(b * a), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / b), $MachinePrecision] * N[(N[(Pi / b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.2 \cdot 10^{-6}:\\
\;\;\;\;\frac{\pi \cdot \frac{0.5}{a}}{b \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{b} \cdot \frac{\frac{\pi}{b}}{a}\\
\end{array}
\end{array}
if a < -4.1999999999999996e-6Initial program 81.6%
div-inv81.6%
expm1-log1p-u66.1%
expm1-udef53.2%
Applied egg-rr58.6%
expm1-def84.2%
expm1-log1p99.7%
associate-*r/99.6%
associate-*r/99.7%
*-commutative99.7%
+-commutative99.7%
*-commutative99.7%
Simplified99.7%
*-commutative99.7%
+-commutative99.7%
associate-*r/99.6%
associate-*l*99.6%
Applied egg-rr99.6%
associate-*r/99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in a around inf 91.9%
if -4.1999999999999996e-6 < a Initial program 81.1%
div-inv81.1%
expm1-log1p-u59.6%
expm1-udef42.3%
Applied egg-rr47.8%
expm1-def75.9%
expm1-log1p99.6%
associate-*r/99.6%
associate-*r/99.5%
*-commutative99.5%
+-commutative99.5%
*-commutative99.5%
Simplified99.5%
Taylor expanded in a around 0 70.6%
*-commutative70.6%
times-frac70.7%
Applied egg-rr70.7%
Final simplification76.7%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -1.25e-6) (/ (* 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 <= -1.25e-6) {
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 <= -1.25e-6) {
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 <= -1.25e-6: 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 <= -1.25e-6) tmp = Float64(Float64(pi * Float64(0.5 / a)) / Float64(b * a)); else tmp = Float64(Float64(pi * Float64(0.5 / 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 <= -1.25e-6)
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, -1.25e-6], N[(N[(Pi * N[(0.5 / a), $MachinePrecision]), $MachinePrecision] / N[(b * a), $MachinePrecision]), $MachinePrecision], N[(N[(Pi * N[(0.5 / b), $MachinePrecision]), $MachinePrecision] / N[(b * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.25 \cdot 10^{-6}:\\
\;\;\;\;\frac{\pi \cdot \frac{0.5}{a}}{b \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi \cdot \frac{0.5}{b}}{b \cdot a}\\
\end{array}
\end{array}
if a < -1.2500000000000001e-6Initial program 81.6%
div-inv81.6%
expm1-log1p-u66.1%
expm1-udef53.2%
Applied egg-rr58.6%
expm1-def84.2%
expm1-log1p99.7%
associate-*r/99.6%
associate-*r/99.7%
*-commutative99.7%
+-commutative99.7%
*-commutative99.7%
Simplified99.7%
*-commutative99.7%
+-commutative99.7%
associate-*r/99.6%
associate-*l*99.6%
Applied egg-rr99.6%
associate-*r/99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in a around inf 91.9%
if -1.2500000000000001e-6 < a Initial program 81.1%
div-inv81.1%
expm1-log1p-u59.6%
expm1-udef42.3%
Applied egg-rr47.8%
expm1-def75.9%
expm1-log1p99.6%
associate-*r/99.6%
associate-*r/99.5%
*-commutative99.5%
+-commutative99.5%
*-commutative99.5%
Simplified99.5%
*-commutative99.5%
+-commutative99.5%
associate-*r/99.6%
associate-*l*99.6%
Applied egg-rr99.6%
associate-*r/99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in a around 0 70.7%
Final simplification76.7%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -1.8e-7) (/ (* PI (/ 0.5 a)) (* b a)) (/ (/ 0.5 b) (* a (/ b PI)))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -1.8e-7) {
tmp = (((double) M_PI) * (0.5 / a)) / (b * a);
} else {
tmp = (0.5 / b) / (a * (b / ((double) M_PI)));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -1.8e-7) {
tmp = (Math.PI * (0.5 / a)) / (b * a);
} else {
tmp = (0.5 / b) / (a * (b / Math.PI));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -1.8e-7: tmp = (math.pi * (0.5 / a)) / (b * a) else: tmp = (0.5 / b) / (a * (b / math.pi)) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -1.8e-7) tmp = Float64(Float64(pi * Float64(0.5 / a)) / Float64(b * a)); else tmp = Float64(Float64(0.5 / b) / Float64(a * Float64(b / pi))); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -1.8e-7)
tmp = (pi * (0.5 / a)) / (b * a);
else
tmp = (0.5 / b) / (a * (b / pi));
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.8e-7], N[(N[(Pi * N[(0.5 / a), $MachinePrecision]), $MachinePrecision] / N[(b * a), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / b), $MachinePrecision] / N[(a * N[(b / Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.8 \cdot 10^{-7}:\\
\;\;\;\;\frac{\pi \cdot \frac{0.5}{a}}{b \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.5}{b}}{a \cdot \frac{b}{\pi}}\\
\end{array}
\end{array}
if a < -1.79999999999999997e-7Initial program 81.6%
div-inv81.6%
expm1-log1p-u66.1%
expm1-udef53.2%
Applied egg-rr58.6%
expm1-def84.2%
expm1-log1p99.7%
associate-*r/99.6%
associate-*r/99.7%
*-commutative99.7%
+-commutative99.7%
*-commutative99.7%
Simplified99.7%
*-commutative99.7%
+-commutative99.7%
associate-*r/99.6%
associate-*l*99.6%
Applied egg-rr99.6%
associate-*r/99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in a around inf 91.9%
if -1.79999999999999997e-7 < a Initial program 81.1%
div-inv81.1%
expm1-log1p-u59.6%
expm1-udef42.3%
Applied egg-rr47.8%
expm1-def75.9%
expm1-log1p99.6%
associate-*r/99.6%
associate-*r/99.5%
*-commutative99.5%
+-commutative99.5%
*-commutative99.5%
Simplified99.5%
Taylor expanded in a around 0 70.6%
*-commutative70.6%
times-frac70.7%
Applied egg-rr70.7%
clear-num70.6%
associate-*l/70.7%
*-un-lft-identity70.7%
div-inv70.7%
clear-num70.7%
Applied egg-rr70.7%
Final simplification76.7%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -9e-8) (/ (/ (* PI 0.5) a) (* b a)) (/ (/ 0.5 b) (* a (/ b PI)))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -9e-8) {
tmp = ((((double) M_PI) * 0.5) / a) / (b * a);
} else {
tmp = (0.5 / b) / (a * (b / ((double) M_PI)));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -9e-8) {
tmp = ((Math.PI * 0.5) / a) / (b * a);
} else {
tmp = (0.5 / b) / (a * (b / Math.PI));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -9e-8: tmp = ((math.pi * 0.5) / a) / (b * a) else: tmp = (0.5 / b) / (a * (b / math.pi)) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -9e-8) tmp = Float64(Float64(Float64(pi * 0.5) / a) / Float64(b * a)); else tmp = Float64(Float64(0.5 / b) / Float64(a * Float64(b / pi))); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -9e-8)
tmp = ((pi * 0.5) / a) / (b * a);
else
tmp = (0.5 / b) / (a * (b / pi));
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, -9e-8], N[(N[(N[(Pi * 0.5), $MachinePrecision] / a), $MachinePrecision] / N[(b * a), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / b), $MachinePrecision] / N[(a * N[(b / Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -9 \cdot 10^{-8}:\\
\;\;\;\;\frac{\frac{\pi \cdot 0.5}{a}}{b \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.5}{b}}{a \cdot \frac{b}{\pi}}\\
\end{array}
\end{array}
if a < -8.99999999999999986e-8Initial program 81.6%
div-inv81.6%
expm1-log1p-u66.1%
expm1-udef53.2%
Applied egg-rr58.6%
expm1-def84.2%
expm1-log1p99.7%
associate-*r/99.6%
associate-*r/99.7%
*-commutative99.7%
+-commutative99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in a around inf 92.0%
associate-*r/92.0%
*-commutative92.0%
Simplified92.0%
if -8.99999999999999986e-8 < a Initial program 81.1%
div-inv81.1%
expm1-log1p-u59.6%
expm1-udef42.3%
Applied egg-rr47.8%
expm1-def75.9%
expm1-log1p99.6%
associate-*r/99.6%
associate-*r/99.5%
*-commutative99.5%
+-commutative99.5%
*-commutative99.5%
Simplified99.5%
Taylor expanded in a around 0 70.6%
*-commutative70.6%
times-frac70.7%
Applied egg-rr70.7%
clear-num70.6%
associate-*l/70.7%
*-un-lft-identity70.7%
div-inv70.7%
clear-num70.7%
Applied egg-rr70.7%
Final simplification76.8%
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(pi * Float64(0.5 / 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[(N[(Pi * N[(0.5 / N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(b * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\pi \cdot \frac{0.5}{b + a}}{b \cdot a}
\end{array}
Initial program 81.2%
div-inv81.3%
expm1-log1p-u61.5%
expm1-udef45.4%
Applied egg-rr50.9%
expm1-def78.3%
expm1-log1p99.6%
associate-*r/99.6%
associate-*r/99.6%
*-commutative99.6%
+-commutative99.6%
*-commutative99.6%
Simplified99.6%
*-commutative99.6%
+-commutative99.6%
associate-*r/99.6%
associate-*l*99.6%
Applied egg-rr99.6%
associate-*r/99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
Final simplification99.6%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (* (/ PI a) (/ (/ 0.5 b) a)))
assert(a < b);
double code(double a, double b) {
return (((double) M_PI) / a) * ((0.5 / b) / a);
}
assert a < b;
public static double code(double a, double b) {
return (Math.PI / a) * ((0.5 / b) / a);
}
[a, b] = sort([a, b]) def code(a, b): return (math.pi / a) * ((0.5 / b) / a)
a, b = sort([a, b]) function code(a, b) return Float64(Float64(pi / a) * Float64(Float64(0.5 / b) / a)) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = (pi / 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 / a), $MachinePrecision] * N[(N[(0.5 / b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\pi}{a} \cdot \frac{\frac{0.5}{b}}{a}
\end{array}
Initial program 81.2%
div-inv81.3%
expm1-log1p-u61.5%
expm1-udef45.4%
Applied egg-rr50.9%
expm1-def78.3%
expm1-log1p99.6%
associate-*r/99.6%
associate-*r/99.6%
*-commutative99.6%
+-commutative99.6%
*-commutative99.6%
Simplified99.6%
*-commutative99.6%
+-commutative99.6%
associate-*r/99.6%
associate-*l*99.6%
Applied egg-rr99.6%
associate-*r/99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
div-inv99.6%
associate-*l*99.6%
*-commutative99.6%
associate-/r*99.5%
times-frac93.3%
div-inv93.3%
*-commutative93.3%
associate-*r/93.3%
times-frac95.4%
Applied egg-rr95.4%
Taylor expanded in b around 0 63.6%
associate-/l/63.6%
Simplified63.6%
Final simplification63.6%
herbie shell --seed 2023301
(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))))