
(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 7.2e+93) (/ (* 0.5 (/ PI a)) (* b (+ b a))) (/ (* (/ PI b) (/ 0.5 a)) (- b a))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (b <= 7.2e+93) {
tmp = (0.5 * (((double) M_PI) / a)) / (b * (b + a));
} else {
tmp = ((((double) M_PI) / b) * (0.5 / a)) / (b - a);
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (b <= 7.2e+93) {
tmp = (0.5 * (Math.PI / a)) / (b * (b + a));
} else {
tmp = ((Math.PI / b) * (0.5 / a)) / (b - a);
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if b <= 7.2e+93: tmp = (0.5 * (math.pi / a)) / (b * (b + a)) else: tmp = ((math.pi / b) * (0.5 / a)) / (b - a) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (b <= 7.2e+93) tmp = Float64(Float64(0.5 * Float64(pi / a)) / Float64(b * Float64(b + a))); else tmp = Float64(Float64(Float64(pi / b) * Float64(0.5 / a)) / Float64(b - a)); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (b <= 7.2e+93)
tmp = (0.5 * (pi / a)) / (b * (b + a));
else
tmp = ((pi / b) * (0.5 / 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[b, 7.2e+93], N[(N[(0.5 * N[(Pi / a), $MachinePrecision]), $MachinePrecision] / N[(b * N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7.2 \cdot 10^{+93}:\\
\;\;\;\;\frac{0.5 \cdot \frac{\pi}{a}}{b \cdot \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\pi}{b} \cdot \frac{0.5}{a}}{b - a}\\
\end{array}
\end{array}
if b < 7.1999999999999998e93Initial program 80.8%
*-commutative80.8%
associate-*r*80.8%
associate-*r/80.8%
associate-/l*80.8%
/-rgt-identity80.8%
associate-/l*80.8%
difference-of-squares88.9%
associate-/l*88.9%
associate-/l*99.7%
associate-*r/89.7%
sub-neg89.7%
distribute-neg-frac89.7%
metadata-eval89.7%
Simplified89.7%
Taylor expanded in a around inf 65.8%
Taylor expanded in b around 0 91.6%
associate-*r/91.6%
Simplified91.6%
clear-num91.0%
frac-times91.0%
metadata-eval91.0%
*-un-lft-identity91.0%
times-frac91.0%
metadata-eval91.0%
Applied egg-rr91.0%
associate-*r/96.8%
associate-/l*97.5%
associate-*r*97.5%
metadata-eval97.5%
+-commutative97.5%
Simplified97.5%
if 7.1999999999999998e93 < b Initial program 65.1%
associate-*r/65.1%
*-rgt-identity65.1%
associate-*l/65.2%
difference-of-squares80.8%
*-commutative80.8%
times-frac99.8%
sub-neg99.8%
distribute-neg-frac99.8%
metadata-eval99.8%
Simplified99.8%
associate-*l/99.9%
div-inv99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Taylor expanded in a around 0 99.8%
associate-*r/99.8%
*-commutative99.8%
*-commutative99.8%
times-frac99.8%
Simplified99.8%
Final simplification97.9%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 1.65e-176) (/ (* PI -0.5) (* a (* b (- a)))) (* (/ 0.5 (* b a)) (/ PI (- b a)))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (b <= 1.65e-176) {
tmp = (((double) M_PI) * -0.5) / (a * (b * -a));
} else {
tmp = (0.5 / (b * a)) * (((double) M_PI) / (b - a));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (b <= 1.65e-176) {
tmp = (Math.PI * -0.5) / (a * (b * -a));
} else {
tmp = (0.5 / (b * a)) * (Math.PI / (b - a));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if b <= 1.65e-176: tmp = (math.pi * -0.5) / (a * (b * -a)) else: tmp = (0.5 / (b * a)) * (math.pi / (b - a)) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (b <= 1.65e-176) tmp = Float64(Float64(pi * -0.5) / Float64(a * Float64(b * Float64(-a)))); else tmp = Float64(Float64(0.5 / Float64(b * a)) * Float64(pi / Float64(b - a))); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (b <= 1.65e-176)
tmp = (pi * -0.5) / (a * (b * -a));
else
tmp = (0.5 / (b * a)) * (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[b, 1.65e-176], N[(N[(Pi * -0.5), $MachinePrecision] / N[(a * N[(b * (-a)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / N[(b * a), $MachinePrecision]), $MachinePrecision] * N[(Pi / N[(b - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.65 \cdot 10^{-176}:\\
\;\;\;\;\frac{\pi \cdot -0.5}{a \cdot \left(b \cdot \left(-a\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{b \cdot a} \cdot \frac{\pi}{b - a}\\
\end{array}
\end{array}
if b < 1.65000000000000006e-176Initial program 73.9%
associate-*r/73.9%
*-rgt-identity73.9%
associate-*l/73.9%
difference-of-squares86.6%
*-commutative86.6%
times-frac99.6%
sub-neg99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in a around inf 80.1%
Taylor expanded in b around 0 73.8%
associate-*r/90.3%
Simplified73.8%
*-commutative73.8%
frac-2neg73.8%
metadata-eval73.8%
frac-times73.1%
*-un-lft-identity73.1%
*-commutative73.1%
*-commutative73.1%
Applied egg-rr73.1%
if 1.65000000000000006e-176 < b Initial program 82.6%
associate-*r/82.7%
*-rgt-identity82.7%
associate-*l/82.6%
difference-of-squares88.4%
*-commutative88.4%
times-frac99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
Simplified99.7%
associate-*l/99.7%
div-inv99.7%
metadata-eval99.7%
Applied egg-rr99.7%
Taylor expanded in a around 0 81.6%
associate-/r*81.6%
Simplified81.6%
expm1-log1p-u69.6%
expm1-udef51.5%
associate-/l*51.5%
*-commutative51.5%
associate-/l/51.5%
Applied egg-rr51.5%
expm1-def69.3%
expm1-log1p81.3%
associate-/r/81.6%
associate-*r/81.6%
*-commutative81.6%
associate-*r*81.6%
*-commutative81.6%
associate-*r/81.6%
metadata-eval81.6%
*-commutative81.6%
Simplified81.6%
Final simplification77.1%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -1e+147) (* (/ PI a) (/ 0.5 (* b a))) (/ 0.5 (* b (* (/ a PI) (+ b a))))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -1e+147) {
tmp = (((double) M_PI) / a) * (0.5 / (b * a));
} else {
tmp = 0.5 / (b * ((a / ((double) M_PI)) * (b + a)));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -1e+147) {
tmp = (Math.PI / a) * (0.5 / (b * a));
} else {
tmp = 0.5 / (b * ((a / Math.PI) * (b + a)));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -1e+147: tmp = (math.pi / a) * (0.5 / (b * a)) else: tmp = 0.5 / (b * ((a / math.pi) * (b + a))) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -1e+147) tmp = Float64(Float64(pi / a) * Float64(0.5 / Float64(b * a))); else tmp = Float64(0.5 / Float64(b * Float64(Float64(a / pi) * Float64(b + a)))); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -1e+147)
tmp = (pi / a) * (0.5 / (b * a));
else
tmp = 0.5 / (b * ((a / 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, -1e+147], N[(N[(Pi / a), $MachinePrecision] * N[(0.5 / N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 / N[(b * N[(N[(a / Pi), $MachinePrecision] * N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1 \cdot 10^{+147}:\\
\;\;\;\;\frac{\pi}{a} \cdot \frac{0.5}{b \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{b \cdot \left(\frac{a}{\pi} \cdot \left(b + a\right)\right)}\\
\end{array}
\end{array}
if a < -9.9999999999999998e146Initial program 60.6%
associate-*r/60.6%
*-rgt-identity60.6%
associate-*l/60.6%
difference-of-squares75.3%
*-commutative75.3%
times-frac99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in a around inf 99.9%
Taylor expanded in b around 0 99.9%
associate-*r/76.7%
Simplified99.9%
associate-/l*99.9%
frac-times99.8%
metadata-eval99.8%
*-commutative99.8%
Applied egg-rr99.8%
associate-*r*99.7%
associate-/l/99.8%
*-un-lft-identity99.8%
times-frac99.7%
clear-num99.8%
associate-/r*99.9%
*-commutative99.9%
Applied egg-rr99.9%
if -9.9999999999999998e146 < a Initial program 80.7%
*-commutative80.7%
associate-*r*80.7%
associate-*r/80.8%
associate-/l*80.8%
/-rgt-identity80.8%
associate-/l*80.7%
difference-of-squares89.3%
associate-/l*89.3%
associate-/l*99.7%
associate-*r/89.9%
sub-neg89.9%
distribute-neg-frac89.9%
metadata-eval89.9%
Simplified89.9%
Taylor expanded in a around inf 62.4%
Taylor expanded in b around 0 95.5%
associate-*r/95.5%
Simplified95.5%
expm1-log1p-u71.7%
expm1-udef50.4%
associate-*r/50.4%
associate-/l*50.4%
frac-times50.4%
metadata-eval50.4%
Applied egg-rr50.4%
expm1-def75.8%
expm1-log1p99.7%
associate-/r*99.7%
+-commutative99.7%
Simplified99.7%
expm1-log1p-u75.8%
expm1-udef50.4%
div-inv50.4%
associate-/l/50.4%
frac-times50.4%
metadata-eval50.4%
*-commutative50.4%
+-commutative50.4%
Applied egg-rr50.4%
expm1-def74.9%
expm1-log1p98.8%
associate-*l*95.1%
+-commutative95.1%
Simplified95.1%
Final simplification95.7%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 3.6e+131) (/ (* 0.5 (/ PI a)) (* b (+ b a))) (* (/ PI b) (/ 0.5 (* b a)))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (b <= 3.6e+131) {
tmp = (0.5 * (((double) M_PI) / a)) / (b * (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 (b <= 3.6e+131) {
tmp = (0.5 * (Math.PI / a)) / (b * (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 b <= 3.6e+131: tmp = (0.5 * (math.pi / a)) / (b * (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 (b <= 3.6e+131) tmp = Float64(Float64(0.5 * Float64(pi / a)) / Float64(b * 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 (b <= 3.6e+131)
tmp = (0.5 * (pi / a)) / (b * (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[b, 3.6e+131], N[(N[(0.5 * N[(Pi / a), $MachinePrecision]), $MachinePrecision] / N[(b * N[(b + a), $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}\;b \leq 3.6 \cdot 10^{+131}:\\
\;\;\;\;\frac{0.5 \cdot \frac{\pi}{a}}{b \cdot \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi}{b} \cdot \frac{0.5}{b \cdot a}\\
\end{array}
\end{array}
if b < 3.60000000000000031e131Initial program 81.8%
*-commutative81.8%
associate-*r*81.8%
associate-*r/81.9%
associate-/l*81.9%
/-rgt-identity81.9%
associate-/l*81.8%
difference-of-squares89.5%
associate-/l*89.5%
associate-/l*99.7%
associate-*r/90.3%
sub-neg90.3%
distribute-neg-frac90.3%
metadata-eval90.3%
Simplified90.3%
Taylor expanded in a around inf 65.0%
Taylor expanded in b around 0 92.0%
associate-*r/92.0%
Simplified92.0%
clear-num91.5%
frac-times91.5%
metadata-eval91.5%
*-un-lft-identity91.5%
times-frac91.5%
metadata-eval91.5%
Applied egg-rr91.5%
associate-*r/96.9%
associate-/l*97.7%
associate-*r*97.7%
metadata-eval97.7%
+-commutative97.7%
Simplified97.7%
if 3.60000000000000031e131 < b Initial program 52.5%
associate-*r/52.5%
*-rgt-identity52.5%
associate-*l/52.6%
difference-of-squares73.8%
*-commutative73.8%
times-frac99.8%
sub-neg99.8%
distribute-neg-frac99.8%
metadata-eval99.8%
Simplified99.8%
associate-*l/99.9%
div-inv99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Taylor expanded in a around 0 99.7%
associate-/r*99.9%
Simplified99.9%
expm1-log1p-u96.8%
expm1-udef59.1%
associate-/l*59.1%
*-commutative59.1%
associate-/l/59.1%
Applied egg-rr59.1%
expm1-def95.6%
expm1-log1p98.6%
associate-/r/99.8%
associate-*r/99.8%
*-commutative99.8%
associate-*r*99.8%
*-commutative99.8%
associate-*r/99.8%
metadata-eval99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in b around inf 99.8%
Final simplification97.9%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 1e+93) (/ (* 0.5 (/ PI a)) (* b (+ b a))) (/ (* 0.5 (/ PI (* b a))) (- b a))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (b <= 1e+93) {
tmp = (0.5 * (((double) M_PI) / a)) / (b * (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 (b <= 1e+93) {
tmp = (0.5 * (Math.PI / a)) / (b * (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 b <= 1e+93: tmp = (0.5 * (math.pi / a)) / (b * (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 (b <= 1e+93) tmp = Float64(Float64(0.5 * Float64(pi / a)) / Float64(b * Float64(b + a))); else tmp = Float64(Float64(0.5 * Float64(pi / Float64(b * a))) / Float64(b - a)); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (b <= 1e+93)
tmp = (0.5 * (pi / a)) / (b * (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[b, 1e+93], N[(N[(0.5 * N[(Pi / a), $MachinePrecision]), $MachinePrecision] / N[(b * N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(Pi / N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(b - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 10^{+93}:\\
\;\;\;\;\frac{0.5 \cdot \frac{\pi}{a}}{b \cdot \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5 \cdot \frac{\pi}{b \cdot a}}{b - a}\\
\end{array}
\end{array}
if b < 1.00000000000000004e93Initial program 80.8%
*-commutative80.8%
associate-*r*80.8%
associate-*r/80.8%
associate-/l*80.8%
/-rgt-identity80.8%
associate-/l*80.8%
difference-of-squares88.9%
associate-/l*88.9%
associate-/l*99.7%
associate-*r/89.7%
sub-neg89.7%
distribute-neg-frac89.7%
metadata-eval89.7%
Simplified89.7%
Taylor expanded in a around inf 65.8%
Taylor expanded in b around 0 91.6%
associate-*r/91.6%
Simplified91.6%
clear-num91.0%
frac-times91.0%
metadata-eval91.0%
*-un-lft-identity91.0%
times-frac91.0%
metadata-eval91.0%
Applied egg-rr91.0%
associate-*r/96.8%
associate-/l*97.5%
associate-*r*97.5%
metadata-eval97.5%
+-commutative97.5%
Simplified97.5%
if 1.00000000000000004e93 < b Initial program 65.1%
associate-*r/65.1%
*-rgt-identity65.1%
associate-*l/65.2%
difference-of-squares80.8%
*-commutative80.8%
times-frac99.8%
sub-neg99.8%
distribute-neg-frac99.8%
metadata-eval99.8%
Simplified99.8%
associate-*l/99.9%
div-inv99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Taylor expanded in a around 0 99.8%
Final simplification97.9%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -1.3e-41) (/ (* 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.3e-41) {
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.3e-41) {
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.3e-41: 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.3e-41) tmp = Float64(Float64(pi * -0.5) / Float64(a * Float64(b * Float64(-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.3e-41)
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.3e-41], N[(N[(Pi * -0.5), $MachinePrecision] / N[(a * N[(b * (-a)), $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.3 \cdot 10^{-41}:\\
\;\;\;\;\frac{\pi \cdot -0.5}{a \cdot \left(b \cdot \left(-a\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi}{b} \cdot \frac{0.5}{b \cdot a}\\
\end{array}
\end{array}
if a < -1.3e-41Initial program 80.8%
associate-*r/80.8%
*-rgt-identity80.8%
associate-*l/80.8%
difference-of-squares87.7%
*-commutative87.7%
times-frac99.6%
sub-neg99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in a around inf 92.6%
Taylor expanded in b around 0 82.8%
associate-*r/88.9%
Simplified82.8%
*-commutative82.8%
frac-2neg82.8%
metadata-eval82.8%
frac-times82.8%
*-un-lft-identity82.8%
*-commutative82.8%
*-commutative82.8%
Applied egg-rr82.8%
if -1.3e-41 < a Initial program 77.0%
associate-*r/77.0%
*-rgt-identity77.0%
associate-*l/77.0%
difference-of-squares87.3%
*-commutative87.3%
times-frac99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
Simplified99.7%
associate-*l/99.7%
div-inv99.7%
metadata-eval99.7%
Applied egg-rr99.7%
Taylor expanded in a around 0 65.6%
associate-/r*65.6%
Simplified65.6%
expm1-log1p-u53.1%
expm1-udef39.4%
associate-/l*39.4%
*-commutative39.4%
associate-/l/39.4%
Applied egg-rr39.4%
expm1-def53.1%
expm1-log1p65.6%
associate-/r/65.6%
associate-*r/65.6%
*-commutative65.6%
associate-*r*65.6%
*-commutative65.6%
associate-*r/65.6%
metadata-eval65.6%
*-commutative65.6%
Simplified65.6%
Taylor expanded in b around inf 63.2%
Final simplification68.7%
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.2e-41) (* (/ PI a) t_0) (* (/ PI b) t_0))))
assert(a < b);
double code(double a, double b) {
double t_0 = 0.5 / (b * a);
double tmp;
if (a <= -1.2e-41) {
tmp = (((double) M_PI) / a) * t_0;
} else {
tmp = (((double) M_PI) / b) * t_0;
}
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.2e-41) {
tmp = (Math.PI / a) * t_0;
} else {
tmp = (Math.PI / b) * t_0;
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): t_0 = 0.5 / (b * a) tmp = 0 if a <= -1.2e-41: tmp = (math.pi / a) * t_0 else: tmp = (math.pi / b) * t_0 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.2e-41) tmp = Float64(Float64(pi / a) * t_0); else tmp = Float64(Float64(pi / b) * t_0); 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.2e-41)
tmp = (pi / a) * t_0;
else
tmp = (pi / b) * t_0;
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.2e-41], N[(N[(Pi / a), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(Pi / b), $MachinePrecision] * t$95$0), $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.2 \cdot 10^{-41}:\\
\;\;\;\;\frac{\pi}{a} \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi}{b} \cdot t_0\\
\end{array}
\end{array}
if a < -1.20000000000000011e-41Initial program 80.8%
associate-*r/80.8%
*-rgt-identity80.8%
associate-*l/80.8%
difference-of-squares87.7%
*-commutative87.7%
times-frac99.6%
sub-neg99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in a around inf 92.6%
Taylor expanded in b around 0 82.8%
associate-*r/88.9%
Simplified82.8%
associate-/l*82.8%
frac-times82.8%
metadata-eval82.8%
*-commutative82.8%
Applied egg-rr82.8%
associate-*r*82.8%
associate-/l/82.9%
*-un-lft-identity82.9%
times-frac82.8%
clear-num82.8%
associate-/r*82.8%
*-commutative82.8%
Applied egg-rr82.8%
if -1.20000000000000011e-41 < a Initial program 77.0%
associate-*r/77.0%
*-rgt-identity77.0%
associate-*l/77.0%
difference-of-squares87.3%
*-commutative87.3%
times-frac99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
Simplified99.7%
associate-*l/99.7%
div-inv99.7%
metadata-eval99.7%
Applied egg-rr99.7%
Taylor expanded in a around 0 65.6%
associate-/r*65.6%
Simplified65.6%
expm1-log1p-u53.1%
expm1-udef39.4%
associate-/l*39.4%
*-commutative39.4%
associate-/l/39.4%
Applied egg-rr39.4%
expm1-def53.1%
expm1-log1p65.6%
associate-/r/65.6%
associate-*r/65.6%
*-commutative65.6%
associate-*r*65.6%
*-commutative65.6%
associate-*r/65.6%
metadata-eval65.6%
*-commutative65.6%
Simplified65.6%
Taylor expanded in b around inf 63.2%
Final simplification68.7%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -1e-41) (/ (/ 0.5 a) (* b (/ a PI))) (* (/ PI b) (/ 0.5 (* b a)))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -1e-41) {
tmp = (0.5 / a) / (b * (a / ((double) M_PI)));
} 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 <= -1e-41) {
tmp = (0.5 / a) / (b * (a / Math.PI));
} else {
tmp = (Math.PI / b) * (0.5 / (b * a));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -1e-41: tmp = (0.5 / a) / (b * (a / math.pi)) 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 <= -1e-41) tmp = Float64(Float64(0.5 / a) / Float64(b * Float64(a / pi))); 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 <= -1e-41)
tmp = (0.5 / a) / (b * (a / pi));
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, -1e-41], N[(N[(0.5 / a), $MachinePrecision] / N[(b * N[(a / Pi), $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 \cdot 10^{-41}:\\
\;\;\;\;\frac{\frac{0.5}{a}}{b \cdot \frac{a}{\pi}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi}{b} \cdot \frac{0.5}{b \cdot a}\\
\end{array}
\end{array}
if a < -1.00000000000000001e-41Initial program 80.8%
associate-*r/80.8%
*-rgt-identity80.8%
associate-*l/80.8%
difference-of-squares87.7%
*-commutative87.7%
times-frac99.6%
sub-neg99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in a around inf 92.6%
Taylor expanded in b around 0 82.8%
associate-*r/88.9%
Simplified82.8%
associate-/l*82.8%
associate-/r*82.8%
frac-times82.9%
Applied egg-rr82.9%
associate-*r/82.9%
metadata-eval82.9%
Simplified82.9%
if -1.00000000000000001e-41 < a Initial program 77.0%
associate-*r/77.0%
*-rgt-identity77.0%
associate-*l/77.0%
difference-of-squares87.3%
*-commutative87.3%
times-frac99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
Simplified99.7%
associate-*l/99.7%
div-inv99.7%
metadata-eval99.7%
Applied egg-rr99.7%
Taylor expanded in a around 0 65.6%
associate-/r*65.6%
Simplified65.6%
expm1-log1p-u53.1%
expm1-udef39.4%
associate-/l*39.4%
*-commutative39.4%
associate-/l/39.4%
Applied egg-rr39.4%
expm1-def53.1%
expm1-log1p65.6%
associate-/r/65.6%
associate-*r/65.6%
*-commutative65.6%
associate-*r*65.6%
*-commutative65.6%
associate-*r/65.6%
metadata-eval65.6%
*-commutative65.6%
Simplified65.6%
Taylor expanded in b around inf 63.2%
Final simplification68.8%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (/ (/ (/ 0.5 b) (/ a PI)) (+ b a)))
assert(a < b);
double code(double a, double b) {
return ((0.5 / b) / (a / ((double) M_PI))) / (b + a);
}
assert a < b;
public static double code(double a, double b) {
return ((0.5 / b) / (a / Math.PI)) / (b + a);
}
[a, b] = sort([a, b]) def code(a, b): return ((0.5 / b) / (a / math.pi)) / (b + a)
a, b = sort([a, b]) function code(a, b) return Float64(Float64(Float64(0.5 / b) / Float64(a / pi)) / Float64(b + a)) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = ((0.5 / b) / (a / pi)) / (b + a);
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(N[(N[(0.5 / b), $MachinePrecision] / N[(a / Pi), $MachinePrecision]), $MachinePrecision] / N[(b + a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\frac{\frac{0.5}{b}}{\frac{a}{\pi}}}{b + a}
\end{array}
Initial program 78.0%
*-commutative78.0%
associate-*r*78.0%
associate-*r/78.1%
associate-/l*78.1%
/-rgt-identity78.1%
associate-/l*78.0%
difference-of-squares87.4%
associate-/l*87.5%
associate-/l*99.7%
associate-*r/88.1%
sub-neg88.1%
distribute-neg-frac88.1%
metadata-eval88.1%
Simplified88.1%
Taylor expanded in a around inf 64.3%
Taylor expanded in b around 0 93.0%
associate-*r/93.0%
Simplified93.0%
expm1-log1p-u72.3%
expm1-udef53.3%
associate-*r/53.3%
associate-/l*53.3%
frac-times53.3%
metadata-eval53.3%
Applied egg-rr53.3%
expm1-def79.0%
expm1-log1p99.7%
associate-/r*99.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) (/ 0.5 (* b a))))
assert(a < b);
double code(double a, double b) {
return (((double) M_PI) / b) * (0.5 / (b * a));
}
assert a < b;
public static double code(double a, double b) {
return (Math.PI / b) * (0.5 / (b * a));
}
[a, b] = sort([a, b]) def code(a, b): return (math.pi / b) * (0.5 / (b * a))
a, b = sort([a, b]) function code(a, b) return Float64(Float64(pi / b) * Float64(0.5 / Float64(b * a))) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = (pi / b) * (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 / b), $MachinePrecision] * N[(0.5 / N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\pi}{b} \cdot \frac{0.5}{b \cdot a}
\end{array}
Initial program 78.0%
associate-*r/78.1%
*-rgt-identity78.1%
associate-*l/78.1%
difference-of-squares87.5%
*-commutative87.5%
times-frac99.6%
sub-neg99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
Simplified99.6%
associate-*l/99.7%
div-inv99.7%
metadata-eval99.7%
Applied egg-rr99.7%
Taylor expanded in a around 0 64.9%
associate-/r*65.0%
Simplified65.0%
expm1-log1p-u56.0%
expm1-udef44.3%
associate-/l*44.3%
*-commutative44.3%
associate-/l/44.3%
Applied egg-rr44.3%
expm1-def55.8%
expm1-log1p64.9%
associate-/r/65.0%
associate-*r/65.0%
*-commutative65.0%
associate-*r*65.0%
*-commutative65.0%
associate-*r/65.0%
metadata-eval65.0%
*-commutative65.0%
Simplified65.0%
Taylor expanded in b around inf 58.9%
Final simplification58.9%
herbie shell --seed 2023322
(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))))