
(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 8.5e+82) (* (/ 0.5 (* a (* b (+ a b)))) PI) (/ (/ (* PI 0.5) (* a b)) b)))
assert(a < b);
double code(double a, double b) {
double tmp;
if (b <= 8.5e+82) {
tmp = (0.5 / (a * (b * (a + b)))) * ((double) M_PI);
} else {
tmp = ((((double) M_PI) * 0.5) / (a * b)) / b;
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (b <= 8.5e+82) {
tmp = (0.5 / (a * (b * (a + b)))) * Math.PI;
} else {
tmp = ((Math.PI * 0.5) / (a * b)) / b;
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if b <= 8.5e+82: tmp = (0.5 / (a * (b * (a + b)))) * math.pi else: tmp = ((math.pi * 0.5) / (a * b)) / b return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (b <= 8.5e+82) tmp = Float64(Float64(0.5 / Float64(a * Float64(b * Float64(a + b)))) * pi); else tmp = Float64(Float64(Float64(pi * 0.5) / Float64(a * b)) / b); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (b <= 8.5e+82)
tmp = (0.5 / (a * (b * (a + b)))) * pi;
else
tmp = ((pi * 0.5) / (a * 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, 8.5e+82], N[(N[(0.5 / N[(a * N[(b * N[(a + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * Pi), $MachinePrecision], N[(N[(N[(Pi * 0.5), $MachinePrecision] / N[(a * b), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 8.5 \cdot 10^{+82}:\\
\;\;\;\;\frac{0.5}{a \cdot \left(b \cdot \left(a + b\right)\right)} \cdot \pi\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\pi \cdot 0.5}{a \cdot b}}{b}\\
\end{array}
\end{array}
if b < 8.4999999999999995e82Initial program 81.5%
Applied egg-rr0
Taylor expanded in b around 0 0
Simplified0
Applied egg-rr0
if 8.4999999999999995e82 < b Initial program 49.7%
Taylor expanded in b around inf 0
Simplified0
Applied egg-rr0
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (/ (/ (/ (- (/ PI a) (/ PI b)) 2.0) (+ b a)) (- b a)))
assert(a < b);
double code(double a, double b) {
return ((((((double) M_PI) / a) - (((double) M_PI) / b)) / 2.0) / (b + a)) / (b - a);
}
assert a < b;
public static double code(double a, double b) {
return ((((Math.PI / a) - (Math.PI / b)) / 2.0) / (b + a)) / (b - a);
}
[a, b] = sort([a, b]) def code(a, b): return ((((math.pi / a) - (math.pi / b)) / 2.0) / (b + a)) / (b - a)
a, b = sort([a, b]) function code(a, b) return Float64(Float64(Float64(Float64(Float64(pi / a) - Float64(pi / b)) / 2.0) / Float64(b + a)) / Float64(b - a)) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = ((((pi / a) - (pi / b)) / 2.0) / (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[(N[(Pi / a), $MachinePrecision] - N[(Pi / b), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] / N[(b + a), $MachinePrecision]), $MachinePrecision] / N[(b - a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\frac{\frac{\frac{\pi}{a} - \frac{\pi}{b}}{2}}{b + a}}{b - a}
\end{array}
Initial program 75.1%
Applied egg-rr0
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (* (/ (- (/ PI a) (/ PI b)) (+ b a)) (/ 0.5 (- b a))))
assert(a < b);
double code(double a, double b) {
return (((((double) M_PI) / a) - (((double) M_PI) / b)) / (b + a)) * (0.5 / (b - a));
}
assert a < b;
public static double code(double a, double b) {
return (((Math.PI / a) - (Math.PI / b)) / (b + a)) * (0.5 / (b - a));
}
[a, b] = sort([a, b]) def code(a, b): return (((math.pi / a) - (math.pi / b)) / (b + a)) * (0.5 / (b - a))
a, b = sort([a, b]) function code(a, b) return Float64(Float64(Float64(Float64(pi / a) - Float64(pi / b)) / Float64(b + a)) * Float64(0.5 / Float64(b - a))) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = (((pi / a) - (pi / b)) / (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[(N[(N[(Pi / a), $MachinePrecision] - N[(Pi / b), $MachinePrecision]), $MachinePrecision] / N[(b + a), $MachinePrecision]), $MachinePrecision] * N[(0.5 / N[(b - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\frac{\pi}{a} - \frac{\pi}{b}}{b + a} \cdot \frac{0.5}{b - a}
\end{array}
Initial program 75.1%
Applied egg-rr0
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 2.1e-22) (/ (/ 0.5 (* a b)) (/ a PI)) (/ (/ (* PI 0.5) b) (* a b))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (b <= 2.1e-22) {
tmp = (0.5 / (a * b)) / (a / ((double) M_PI));
} 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 (b <= 2.1e-22) {
tmp = (0.5 / (a * b)) / (a / Math.PI);
} else {
tmp = ((Math.PI * 0.5) / b) / (a * b);
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if b <= 2.1e-22: tmp = (0.5 / (a * b)) / (a / math.pi) else: tmp = ((math.pi * 0.5) / b) / (a * b) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (b <= 2.1e-22) tmp = Float64(Float64(0.5 / Float64(a * b)) / Float64(a / pi)); else tmp = Float64(Float64(Float64(pi * 0.5) / b) / Float64(a * b)); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (b <= 2.1e-22)
tmp = (0.5 / (a * b)) / (a / pi);
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[b, 2.1e-22], N[(N[(0.5 / N[(a * b), $MachinePrecision]), $MachinePrecision] / N[(a / Pi), $MachinePrecision]), $MachinePrecision], N[(N[(N[(Pi * 0.5), $MachinePrecision] / b), $MachinePrecision] / N[(a * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.1 \cdot 10^{-22}:\\
\;\;\;\;\frac{\frac{0.5}{a \cdot b}}{\frac{a}{\pi}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\pi \cdot 0.5}{b}}{a \cdot b}\\
\end{array}
\end{array}
if b < 2.10000000000000008e-22Initial program 78.5%
Taylor expanded in b around 0 0
Simplified0
Taylor expanded in a around inf 0
Simplified0
Applied egg-rr0
if 2.10000000000000008e-22 < b Initial program 67.6%
Taylor expanded in b around inf 0
Simplified0
Applied egg-rr0
Applied egg-rr0
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 2e-22) (/ (/ 0.5 (* a b)) (/ a PI)) (/ (/ 0.5 (/ b PI)) (* a b))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (b <= 2e-22) {
tmp = (0.5 / (a * b)) / (a / ((double) M_PI));
} else {
tmp = (0.5 / (b / ((double) M_PI))) / (a * b);
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (b <= 2e-22) {
tmp = (0.5 / (a * b)) / (a / Math.PI);
} else {
tmp = (0.5 / (b / Math.PI)) / (a * b);
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if b <= 2e-22: tmp = (0.5 / (a * b)) / (a / math.pi) else: tmp = (0.5 / (b / math.pi)) / (a * b) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (b <= 2e-22) tmp = Float64(Float64(0.5 / Float64(a * b)) / Float64(a / pi)); else tmp = Float64(Float64(0.5 / Float64(b / pi)) / Float64(a * b)); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (b <= 2e-22)
tmp = (0.5 / (a * b)) / (a / pi);
else
tmp = (0.5 / (b / pi)) / (a * b);
end
tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[b, 2e-22], N[(N[(0.5 / N[(a * b), $MachinePrecision]), $MachinePrecision] / N[(a / Pi), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / N[(b / Pi), $MachinePrecision]), $MachinePrecision] / N[(a * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2 \cdot 10^{-22}:\\
\;\;\;\;\frac{\frac{0.5}{a \cdot b}}{\frac{a}{\pi}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.5}{\frac{b}{\pi}}}{a \cdot b}\\
\end{array}
\end{array}
if b < 2.0000000000000001e-22Initial program 78.5%
Taylor expanded in b around 0 0
Simplified0
Taylor expanded in a around inf 0
Simplified0
Applied egg-rr0
if 2.0000000000000001e-22 < b Initial program 67.6%
Taylor expanded in b around inf 0
Simplified0
Applied egg-rr0
Taylor expanded in b around inf 0
Simplified0
Applied egg-rr0
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 2.5e-22) (/ (/ 0.5 (* a b)) (/ a PI)) (* (/ (/ 0.5 a) b) (/ PI b))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (b <= 2.5e-22) {
tmp = (0.5 / (a * b)) / (a / ((double) M_PI));
} else {
tmp = ((0.5 / a) / b) * (((double) M_PI) / b);
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (b <= 2.5e-22) {
tmp = (0.5 / (a * b)) / (a / Math.PI);
} else {
tmp = ((0.5 / a) / b) * (Math.PI / b);
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if b <= 2.5e-22: tmp = (0.5 / (a * b)) / (a / math.pi) else: tmp = ((0.5 / a) / b) * (math.pi / b) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (b <= 2.5e-22) tmp = Float64(Float64(0.5 / Float64(a * b)) / Float64(a / pi)); else tmp = Float64(Float64(Float64(0.5 / a) / b) * Float64(pi / b)); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (b <= 2.5e-22)
tmp = (0.5 / (a * b)) / (a / pi);
else
tmp = ((0.5 / a) / b) * (pi / b);
end
tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[b, 2.5e-22], N[(N[(0.5 / N[(a * b), $MachinePrecision]), $MachinePrecision] / N[(a / Pi), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.5 / a), $MachinePrecision] / b), $MachinePrecision] * N[(Pi / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.5 \cdot 10^{-22}:\\
\;\;\;\;\frac{\frac{0.5}{a \cdot b}}{\frac{a}{\pi}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.5}{a}}{b} \cdot \frac{\pi}{b}\\
\end{array}
\end{array}
if b < 2.49999999999999977e-22Initial program 78.5%
Taylor expanded in b around 0 0
Simplified0
Taylor expanded in a around inf 0
Simplified0
Applied egg-rr0
if 2.49999999999999977e-22 < b Initial program 67.6%
Taylor expanded in b around inf 0
Simplified0
Applied egg-rr0
Taylor expanded in b around inf 0
Simplified0
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 2.9e-22) (* (/ PI (* a b)) (/ 0.5 a)) (* (/ (/ 0.5 a) b) (/ PI b))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (b <= 2.9e-22) {
tmp = (((double) M_PI) / (a * b)) * (0.5 / a);
} else {
tmp = ((0.5 / a) / b) * (((double) M_PI) / b);
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (b <= 2.9e-22) {
tmp = (Math.PI / (a * b)) * (0.5 / a);
} else {
tmp = ((0.5 / a) / b) * (Math.PI / b);
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if b <= 2.9e-22: tmp = (math.pi / (a * b)) * (0.5 / a) else: tmp = ((0.5 / a) / b) * (math.pi / b) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (b <= 2.9e-22) tmp = Float64(Float64(pi / Float64(a * b)) * Float64(0.5 / a)); else tmp = Float64(Float64(Float64(0.5 / a) / b) * Float64(pi / b)); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (b <= 2.9e-22)
tmp = (pi / (a * b)) * (0.5 / a);
else
tmp = ((0.5 / a) / b) * (pi / b);
end
tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[b, 2.9e-22], N[(N[(Pi / N[(a * b), $MachinePrecision]), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.5 / a), $MachinePrecision] / b), $MachinePrecision] * N[(Pi / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.9 \cdot 10^{-22}:\\
\;\;\;\;\frac{\pi}{a \cdot b} \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.5}{a}}{b} \cdot \frac{\pi}{b}\\
\end{array}
\end{array}
if b < 2.9000000000000002e-22Initial program 78.5%
Taylor expanded in b around 0 0
Simplified0
Taylor expanded in a around inf 0
Simplified0
Applied egg-rr0
if 2.9000000000000002e-22 < b Initial program 67.6%
Taylor expanded in b around inf 0
Simplified0
Applied egg-rr0
Taylor expanded in b around inf 0
Simplified0
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 2.3e-22) (* (/ PI (* a b)) (/ 0.5 a)) (* PI (/ 0.5 (* b (* a b))))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (b <= 2.3e-22) {
tmp = (((double) M_PI) / (a * b)) * (0.5 / 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 (b <= 2.3e-22) {
tmp = (Math.PI / (a * b)) * (0.5 / a);
} else {
tmp = Math.PI * (0.5 / (b * (a * b)));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if b <= 2.3e-22: tmp = (math.pi / (a * b)) * (0.5 / 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 (b <= 2.3e-22) tmp = Float64(Float64(pi / Float64(a * b)) * Float64(0.5 / a)); else tmp = Float64(pi * Float64(0.5 / Float64(b * Float64(a * b)))); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (b <= 2.3e-22)
tmp = (pi / (a * b)) * (0.5 / 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[b, 2.3e-22], N[(N[(Pi / N[(a * b), $MachinePrecision]), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], N[(Pi * N[(0.5 / N[(b * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.3 \cdot 10^{-22}:\\
\;\;\;\;\frac{\pi}{a \cdot b} \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \frac{0.5}{b \cdot \left(a \cdot b\right)}\\
\end{array}
\end{array}
if b < 2.2999999999999998e-22Initial program 78.5%
Taylor expanded in b around 0 0
Simplified0
Taylor expanded in a around inf 0
Simplified0
Applied egg-rr0
if 2.2999999999999998e-22 < b Initial program 67.6%
Taylor expanded in b around inf 0
Simplified0
Applied egg-rr0
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (/ 0.5 (/ (+ a b) (/ PI (* a b)))))
assert(a < b);
double code(double a, double b) {
return 0.5 / ((a + b) / (((double) M_PI) / (a * b)));
}
assert a < b;
public static double code(double a, double b) {
return 0.5 / ((a + b) / (Math.PI / (a * b)));
}
[a, b] = sort([a, b]) def code(a, b): return 0.5 / ((a + b) / (math.pi / (a * b)))
a, b = sort([a, b]) function code(a, b) return Float64(0.5 / Float64(Float64(a + b) / Float64(pi / Float64(a * b)))) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = 0.5 / ((a + b) / (pi / (a * b)));
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(0.5 / N[(N[(a + b), $MachinePrecision] / N[(Pi / N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{0.5}{\frac{a + b}{\frac{\pi}{a \cdot b}}}
\end{array}
Initial program 75.1%
Applied egg-rr0
Taylor expanded in b around 0 0
Simplified0
Applied egg-rr0
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)))))
assert(a < b);
double code(double a, double b) {
return ((double) M_PI) * (0.5 / (b * (a * b)));
}
assert a < b;
public static double code(double a, double b) {
return Math.PI * (0.5 / (b * (a * b)));
}
[a, b] = sort([a, b]) def code(a, b): return math.pi * (0.5 / (b * (a * b)))
a, b = sort([a, b]) function code(a, b) return Float64(pi * Float64(0.5 / Float64(b * Float64(a * b)))) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = pi * (0.5 / (b * (a * b)));
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(Pi * N[(0.5 / N[(b * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\pi \cdot \frac{0.5}{b \cdot \left(a \cdot b\right)}
\end{array}
Initial program 75.1%
Taylor expanded in b around inf 0
Simplified0
Applied egg-rr0
herbie shell --seed 2024110
(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))))