
(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 13 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 (* b 2.0)) a) (+ b a)))
assert(a < b);
double code(double a, double b) {
return ((((double) M_PI) / (b * 2.0)) / a) / (b + a);
}
assert a < b;
public static double code(double a, double b) {
return ((Math.PI / (b * 2.0)) / a) / (b + a);
}
[a, b] = sort([a, b]) def code(a, b): return ((math.pi / (b * 2.0)) / a) / (b + a)
a, b = sort([a, b]) function code(a, b) return Float64(Float64(Float64(pi / Float64(b * 2.0)) / a) / Float64(b + a)) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = ((pi / (b * 2.0)) / a) / (b + a);
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(N[(N[(Pi / N[(b * 2.0), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] / N[(b + a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\frac{\frac{\pi}{b \cdot 2}}{a}}{b + a}
\end{array}
Initial program 80.5%
Applied rewrites99.6%
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-+.f64N/A
lift-*.f64N/A
div-invN/A
associate-*r*N/A
div-invN/A
lower-/.f64N/A
Applied rewrites99.7%
lift-PI.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
associate-/r/N/A
lower-/.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f6499.7
Applied rewrites99.7%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -1.4e+152) (* PI (/ 0.5 (* a (* b a)))) (/ (* PI 0.5) (* b (* a (+ b a))))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -1.4e+152) {
tmp = ((double) M_PI) * (0.5 / (a * (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 <= -1.4e+152) {
tmp = Math.PI * (0.5 / (a * (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 <= -1.4e+152: tmp = math.pi * (0.5 / (a * (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 <= -1.4e+152) tmp = Float64(pi * Float64(0.5 / Float64(a * Float64(b * a)))); else tmp = Float64(Float64(pi * 0.5) / Float64(b * Float64(a * Float64(b + a)))); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -1.4e+152)
tmp = pi * (0.5 / (a * (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, -1.4e+152], N[(Pi * N[(0.5 / N[(a * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Pi * 0.5), $MachinePrecision] / N[(b * N[(a * N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.4 \cdot 10^{+152}:\\
\;\;\;\;\pi \cdot \frac{0.5}{a \cdot \left(b \cdot a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi \cdot 0.5}{b \cdot \left(a \cdot \left(b + a\right)\right)}\\
\end{array}
\end{array}
if a < -1.4000000000000001e152Initial program 54.6%
Taylor expanded in b around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6498.5
Applied rewrites98.5%
lift-PI.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6498.5
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6478.9
Applied rewrites78.9%
associate-*r*N/A
lift-*.f64N/A
lower-*.f6498.5
Applied rewrites98.5%
if -1.4000000000000001e152 < a Initial program 84.3%
Applied rewrites99.6%
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-+.f64N/A
lift-*.f64N/A
div-invN/A
associate-*r*N/A
div-invN/A
lower-/.f64N/A
Applied rewrites99.7%
lift-PI.f64N/A
lift-*.f64N/A
associate-/l/N/A
lift-/.f64N/A
lift-+.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
associate-/l/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
lower-*.f64N/A
distribute-rgt-inN/A
+-commutativeN/A
lift-+.f64N/A
lower-*.f6496.8
Applied rewrites96.8%
Final simplification97.0%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 9.5e+81) (/ (* PI 0.5) (* a (* b (+ b a)))) (/ (* PI 0.5) (* b (* b a)))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (b <= 9.5e+81) {
tmp = (((double) M_PI) * 0.5) / (a * (b * (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 (b <= 9.5e+81) {
tmp = (Math.PI * 0.5) / (a * (b * (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 b <= 9.5e+81: tmp = (math.pi * 0.5) / (a * (b * (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 (b <= 9.5e+81) tmp = Float64(Float64(pi * 0.5) / Float64(a * Float64(b * Float64(b + a)))); else tmp = Float64(Float64(pi * 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 (b <= 9.5e+81)
tmp = (pi * 0.5) / (a * (b * (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[b, 9.5e+81], N[(N[(Pi * 0.5), $MachinePrecision] / N[(a * N[(b * N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Pi * 0.5), $MachinePrecision] / N[(b * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 9.5 \cdot 10^{+81}:\\
\;\;\;\;\frac{\pi \cdot 0.5}{a \cdot \left(b \cdot \left(b + a\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi \cdot 0.5}{b \cdot \left(b \cdot a\right)}\\
\end{array}
\end{array}
if b < 9.50000000000000083e81Initial program 81.8%
Applied rewrites99.6%
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-+.f64N/A
lift-*.f64N/A
div-invN/A
associate-*r*N/A
div-invN/A
lower-/.f64N/A
Applied rewrites99.7%
lift-PI.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
associate-/r/N/A
lower-/.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f6499.7
Applied rewrites99.7%
lift-PI.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
associate-/r*N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
div-invN/A
metadata-evalN/A
lift-/.f64N/A
associate-*l/N/A
associate-/r*N/A
lift-*.f64N/A
lower-/.f64N/A
Applied rewrites93.7%
if 9.50000000000000083e81 < b Initial program 72.7%
lift-PI.f64N/A
lift-/.f64N/A
*-rgt-identityN/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-rgt-identityN/A
lift-/.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-subN/A
frac-timesN/A
lower-/.f64N/A
Applied rewrites88.9%
Taylor expanded in b around inf
lower-/.f64N/A
lower-PI.f64100.0
Applied rewrites100.0%
lift-PI.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
div-invN/A
metadata-evalN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l/N/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6498.9
Applied rewrites98.9%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -1e+116) (/ (* PI 0.5) (* a (* b a))) (* PI (/ 0.5 (* b (* a (+ b a)))))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -1e+116) {
tmp = (((double) M_PI) * 0.5) / (a * (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 <= -1e+116) {
tmp = (Math.PI * 0.5) / (a * (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 <= -1e+116: tmp = (math.pi * 0.5) / (a * (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 <= -1e+116) tmp = Float64(Float64(pi * 0.5) / Float64(a * Float64(b * a))); else tmp = Float64(pi * Float64(0.5 / Float64(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 <= -1e+116)
tmp = (pi * 0.5) / (a * (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, -1e+116], N[(N[(Pi * 0.5), $MachinePrecision] / N[(a * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(Pi * N[(0.5 / N[(b * N[(a * N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1 \cdot 10^{+116}:\\
\;\;\;\;\frac{\pi \cdot 0.5}{a \cdot \left(b \cdot a\right)}\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \frac{0.5}{b \cdot \left(a \cdot \left(b + a\right)\right)}\\
\end{array}
\end{array}
if a < -1.00000000000000002e116Initial program 62.5%
Taylor expanded in b around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6498.7
Applied rewrites98.7%
if -1.00000000000000002e116 < a Initial program 83.8%
Applied rewrites99.6%
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-+.f64N/A
lift-*.f64N/A
div-invN/A
associate-*r*N/A
div-invN/A
lower-/.f64N/A
Applied rewrites99.7%
lift-PI.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-+.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
associate-/l/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
lower-*.f64N/A
distribute-rgt-inN/A
+-commutativeN/A
lift-+.f64N/A
lower-*.f6496.6
Applied rewrites96.6%
Final simplification96.9%
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(pi * 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[(N[(Pi * 0.5), $MachinePrecision] / N[(b * a), $MachinePrecision]), $MachinePrecision] / N[(b + a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\frac{\pi \cdot 0.5}{b \cdot a}}{b + a}
\end{array}
Initial program 80.5%
Applied rewrites99.6%
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-+.f64N/A
lift-*.f64N/A
div-invN/A
associate-*r*N/A
div-invN/A
lower-/.f64N/A
Applied rewrites99.7%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (* (/ PI (+ b a)) (/ 0.5 (* b a))))
assert(a < b);
double code(double a, double b) {
return (((double) M_PI) / (b + a)) * (0.5 / (b * a));
}
assert a < b;
public static double code(double a, double b) {
return (Math.PI / (b + a)) * (0.5 / (b * a));
}
[a, b] = sort([a, b]) def code(a, b): return (math.pi / (b + a)) * (0.5 / (b * a))
a, b = sort([a, b]) function code(a, b) return Float64(Float64(pi / Float64(b + a)) * Float64(0.5 / Float64(b * a))) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = (pi / (b + a)) * (0.5 / (b * a));
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(N[(Pi / N[(b + a), $MachinePrecision]), $MachinePrecision] * N[(0.5 / N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\pi}{b + a} \cdot \frac{0.5}{b \cdot a}
\end{array}
Initial program 80.5%
Applied rewrites99.6%
Applied rewrites99.7%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (* (/ PI (* b a)) (/ 0.5 (+ b a))))
assert(a < b);
double code(double a, double b) {
return (((double) M_PI) / (b * a)) * (0.5 / (b + a));
}
assert a < b;
public static double code(double a, double b) {
return (Math.PI / (b * a)) * (0.5 / (b + a));
}
[a, b] = sort([a, b]) def code(a, b): return (math.pi / (b * a)) * (0.5 / (b + a))
a, b = sort([a, b]) function code(a, b) return Float64(Float64(pi / Float64(b * a)) * Float64(0.5 / Float64(b + a))) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = (pi / (b * a)) * (0.5 / (b + a));
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(N[(Pi / N[(b * a), $MachinePrecision]), $MachinePrecision] * N[(0.5 / N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\pi}{b \cdot a} \cdot \frac{0.5}{b + a}
\end{array}
Initial program 80.5%
Applied rewrites99.6%
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-+.f64N/A
lift-*.f64N/A
div-invN/A
associate-*r*N/A
div-invN/A
lower-/.f64N/A
Applied rewrites99.7%
lift-PI.f64N/A
lift-*.f64N/A
associate-/l/N/A
lift-/.f64N/A
lift-+.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
associate-*l/N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6499.6
Applied rewrites99.6%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 1.1e-95) (/ (* PI 0.5) (* a (* b a))) (/ (* PI 0.5) (* b (* b a)))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (b <= 1.1e-95) {
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 (b <= 1.1e-95) {
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 b <= 1.1e-95: 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 (b <= 1.1e-95) tmp = Float64(Float64(pi * 0.5) / Float64(a * Float64(b * a))); else tmp = Float64(Float64(pi * 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 (b <= 1.1e-95)
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[b, 1.1e-95], N[(N[(Pi * 0.5), $MachinePrecision] / N[(a * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Pi * 0.5), $MachinePrecision] / N[(b * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.1 \cdot 10^{-95}:\\
\;\;\;\;\frac{\pi \cdot 0.5}{a \cdot \left(b \cdot a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi \cdot 0.5}{b \cdot \left(b \cdot a\right)}\\
\end{array}
\end{array}
if b < 1.0999999999999999e-95Initial program 78.3%
Taylor expanded in b around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6467.8
Applied rewrites67.8%
if 1.0999999999999999e-95 < b Initial program 85.9%
lift-PI.f64N/A
lift-/.f64N/A
*-rgt-identityN/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-rgt-identityN/A
lift-/.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-subN/A
frac-timesN/A
lower-/.f64N/A
Applied rewrites94.1%
Taylor expanded in b around inf
lower-/.f64N/A
lower-PI.f6478.3
Applied rewrites78.3%
lift-PI.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
div-invN/A
metadata-evalN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l/N/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6477.8
Applied rewrites77.8%
Final simplification70.7%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 1.1e-95) (/ (* PI 0.5) (* a (* b a))) (* PI (/ 0.5 (* b (* b a))))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (b <= 1.1e-95) {
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 (b <= 1.1e-95) {
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 b <= 1.1e-95: 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 (b <= 1.1e-95) tmp = Float64(Float64(pi * 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 (b <= 1.1e-95)
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[b, 1.1e-95], N[(N[(Pi * 0.5), $MachinePrecision] / N[(a * N[(b * a), $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}\;b \leq 1.1 \cdot 10^{-95}:\\
\;\;\;\;\frac{\pi \cdot 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 b < 1.0999999999999999e-95Initial program 78.3%
Taylor expanded in b around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6467.8
Applied rewrites67.8%
if 1.0999999999999999e-95 < b Initial program 85.9%
lift-PI.f64N/A
lift-/.f64N/A
*-rgt-identityN/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-rgt-identityN/A
lift-/.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-subN/A
frac-timesN/A
lower-/.f64N/A
Applied rewrites94.1%
Taylor expanded in b around inf
lower-/.f64N/A
lower-PI.f6478.3
Applied rewrites78.3%
lift-PI.f64N/A
frac-2negN/A
lift-*.f64N/A
lift-*.f64N/A
frac-2negN/A
div-invN/A
associate-/l*N/A
div-invN/A
*-commutativeN/A
lower-*.f64N/A
div-invN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l/N/A
associate-/l/N/A
associate-/r*N/A
metadata-evalN/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6477.7
Applied rewrites77.7%
Final simplification70.6%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 1.1e-95) (* PI (/ 0.5 (* a (* b a)))) (* PI (/ 0.5 (* b (* b a))))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (b <= 1.1e-95) {
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 (b <= 1.1e-95) {
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 b <= 1.1e-95: 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 (b <= 1.1e-95) 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 (b <= 1.1e-95)
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[b, 1.1e-95], 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}\;b \leq 1.1 \cdot 10^{-95}:\\
\;\;\;\;\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 b < 1.0999999999999999e-95Initial program 78.3%
Taylor expanded in b around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6467.8
Applied rewrites67.8%
lift-PI.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6467.8
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6461.2
Applied rewrites61.2%
associate-*r*N/A
lift-*.f64N/A
lower-*.f6467.8
Applied rewrites67.8%
if 1.0999999999999999e-95 < b Initial program 85.9%
lift-PI.f64N/A
lift-/.f64N/A
*-rgt-identityN/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-rgt-identityN/A
lift-/.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-subN/A
frac-timesN/A
lower-/.f64N/A
Applied rewrites94.1%
Taylor expanded in b around inf
lower-/.f64N/A
lower-PI.f6478.3
Applied rewrites78.3%
lift-PI.f64N/A
frac-2negN/A
lift-*.f64N/A
lift-*.f64N/A
frac-2negN/A
div-invN/A
associate-/l*N/A
div-invN/A
*-commutativeN/A
lower-*.f64N/A
div-invN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l/N/A
associate-/l/N/A
associate-/r*N/A
metadata-evalN/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6477.7
Applied rewrites77.7%
Final simplification70.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(Float64(pi * 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[(N[(Pi * 0.5), $MachinePrecision] / N[(N[(b + a), $MachinePrecision] * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\pi \cdot 0.5}{\left(b + a\right) \cdot \left(b \cdot a\right)}
\end{array}
Initial program 80.5%
Applied rewrites99.6%
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-PI.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
clear-numN/A
frac-timesN/A
*-rgt-identityN/A
Applied rewrites99.2%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (* PI (/ 0.5 (* a (* b a)))))
assert(a < b);
double code(double a, double b) {
return ((double) M_PI) * (0.5 / (a * (b * a)));
}
assert a < b;
public static double code(double a, double b) {
return Math.PI * (0.5 / (a * (b * a)));
}
[a, b] = sort([a, b]) def code(a, b): return math.pi * (0.5 / (a * (b * a)))
a, b = sort([a, b]) function code(a, b) return Float64(pi * Float64(0.5 / Float64(a * Float64(b * a)))) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = pi * (0.5 / (a * (b * a)));
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(Pi * N[(0.5 / N[(a * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\pi \cdot \frac{0.5}{a \cdot \left(b \cdot a\right)}
\end{array}
Initial program 80.5%
Taylor expanded in b around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6464.0
Applied rewrites64.0%
lift-PI.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6463.9
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6459.2
Applied rewrites59.2%
associate-*r*N/A
lift-*.f64N/A
lower-*.f6463.9
Applied rewrites63.9%
Final simplification63.9%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (* PI (/ 0.5 (* b (* a a)))))
assert(a < b);
double code(double a, double b) {
return ((double) M_PI) * (0.5 / (b * (a * a)));
}
assert a < b;
public static double code(double a, double b) {
return Math.PI * (0.5 / (b * (a * a)));
}
[a, b] = sort([a, b]) def code(a, b): return math.pi * (0.5 / (b * (a * a)))
a, b = sort([a, b]) function code(a, b) return Float64(pi * Float64(0.5 / Float64(b * Float64(a * a)))) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = pi * (0.5 / (b * (a * 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[(b * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\pi \cdot \frac{0.5}{b \cdot \left(a \cdot a\right)}
\end{array}
Initial program 80.5%
Taylor expanded in b around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6464.0
Applied rewrites64.0%
lift-PI.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6463.9
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6459.2
Applied rewrites59.2%
herbie shell --seed 2024216
(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))))