
(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}
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 (<= a -5e+147) (* (/ PI (* b a)) (/ 0.5 a)) (* PI (/ (/ (/ 0.5 a) (+ a b)) b))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -5e+147) {
tmp = (((double) M_PI) / (b * a)) * (0.5 / a);
} else {
tmp = ((double) M_PI) * (((0.5 / a) / (a + b)) / b);
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -5e+147) {
tmp = (Math.PI / (b * a)) * (0.5 / a);
} else {
tmp = Math.PI * (((0.5 / a) / (a + b)) / b);
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -5e+147: tmp = (math.pi / (b * a)) * (0.5 / a) else: tmp = math.pi * (((0.5 / a) / (a + b)) / b) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -5e+147) tmp = Float64(Float64(pi / Float64(b * a)) * Float64(0.5 / a)); else tmp = Float64(pi * Float64(Float64(Float64(0.5 / a) / Float64(a + b)) / b)); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -5e+147)
tmp = (pi / (b * a)) * (0.5 / a);
else
tmp = pi * (((0.5 / a) / (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[a, -5e+147], N[(N[(Pi / N[(b * a), $MachinePrecision]), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], N[(Pi * N[(N[(N[(0.5 / a), $MachinePrecision] / N[(a + b), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5 \cdot 10^{+147}:\\
\;\;\;\;\frac{\pi}{b \cdot a} \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \frac{\frac{\frac{0.5}{a}}{a + b}}{b}\\
\end{array}
\end{array}
if a < -5.0000000000000002e147Initial program 56.8%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6476.0
Applied rewrites76.0%
lift-*.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
associate-/l/N/A
associate-*r/N/A
*-commutativeN/A
pow2N/A
times-fracN/A
associate-/l/N/A
*-commutativeN/A
associate-/l/N/A
lower-*.f64N/A
associate-/l/N/A
lower-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
if -5.0000000000000002e147 < a Initial program 85.5%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-/l*N/A
*-rgt-identityN/A
difference-of-squaresN/A
associate-/r*N/A
*-lft-identityN/A
*-rgt-identityN/A
lower-/.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
*-rgt-identityN/A
lower--.f6492.1
Applied rewrites92.1%
Applied rewrites99.0%
lift-*.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
associate-*l/N/A
associate-/l*N/A
frac-2neg-revN/A
metadata-evalN/A
lower-*.f64N/A
lift-PI.f64N/A
metadata-evalN/A
frac-2neg-revN/A
lower-/.f64N/A
*-commutativeN/A
associate-*l*N/A
Applied rewrites91.4%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
count-2-revN/A
associate-/r*N/A
associate-/r*N/A
metadata-evalN/A
metadata-evalN/A
associate-*r/N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r/N/A
metadata-evalN/A
lift-/.f64N/A
lift-+.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 (<= a -1.3e+157) (* (/ PI (* b a)) (/ 0.5 a)) (/ (/ PI b) (* (+ a a) (+ a b)))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -1.3e+157) {
tmp = (((double) M_PI) / (b * a)) * (0.5 / a);
} else {
tmp = (((double) M_PI) / b) / ((a + a) * (a + b));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -1.3e+157) {
tmp = (Math.PI / (b * a)) * (0.5 / a);
} else {
tmp = (Math.PI / b) / ((a + a) * (a + b));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -1.3e+157: tmp = (math.pi / (b * a)) * (0.5 / a) else: tmp = (math.pi / b) / ((a + a) * (a + b)) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -1.3e+157) tmp = Float64(Float64(pi / Float64(b * a)) * Float64(0.5 / a)); else tmp = Float64(Float64(pi / b) / Float64(Float64(a + a) * Float64(a + b))); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -1.3e+157)
tmp = (pi / (b * a)) * (0.5 / a);
else
tmp = (pi / b) / ((a + a) * (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[a, -1.3e+157], N[(N[(Pi / N[(b * a), $MachinePrecision]), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], N[(N[(Pi / b), $MachinePrecision] / N[(N[(a + a), $MachinePrecision] * N[(a + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.3 \cdot 10^{+157}:\\
\;\;\;\;\frac{\pi}{b \cdot a} \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\pi}{b}}{\left(a + a\right) \cdot \left(a + b\right)}\\
\end{array}
\end{array}
if a < -1.30000000000000005e157Initial program 55.7%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6475.8
Applied rewrites75.8%
lift-*.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
associate-/l/N/A
associate-*r/N/A
*-commutativeN/A
pow2N/A
times-fracN/A
associate-/l/N/A
*-commutativeN/A
associate-/l/N/A
lower-*.f64N/A
associate-/l/N/A
lower-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
if -1.30000000000000005e157 < a Initial program 85.4%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-/l*N/A
*-rgt-identityN/A
difference-of-squaresN/A
associate-/r*N/A
*-lft-identityN/A
*-rgt-identityN/A
lower-/.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
*-rgt-identityN/A
lower--.f6492.2
Applied rewrites92.2%
Applied rewrites98.9%
lift-*.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
*-rgt-identityN/A
associate-*l*N/A
associate-/r*N/A
lower-/.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
count-2-revN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6499.3
Applied rewrites99.3%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -1.7e+89) (/ (* (/ PI b) (/ 0.5 a)) a) (/ PI (* (* a (+ a b)) (+ b b)))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -1.7e+89) {
tmp = ((((double) M_PI) / b) * (0.5 / a)) / a;
} else {
tmp = ((double) M_PI) / ((a * (a + b)) * (b + b));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -1.7e+89) {
tmp = ((Math.PI / b) * (0.5 / a)) / a;
} else {
tmp = Math.PI / ((a * (a + b)) * (b + b));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -1.7e+89: tmp = ((math.pi / b) * (0.5 / a)) / a else: tmp = math.pi / ((a * (a + b)) * (b + b)) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -1.7e+89) tmp = Float64(Float64(Float64(pi / b) * Float64(0.5 / a)) / a); else tmp = Float64(pi / Float64(Float64(a * Float64(a + b)) * Float64(b + b))); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -1.7e+89)
tmp = ((pi / b) * (0.5 / a)) / a;
else
tmp = pi / ((a * (a + b)) * (b + b));
end
tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[a, -1.7e+89], N[(N[(N[(Pi / b), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(Pi / N[(N[(a * N[(a + b), $MachinePrecision]), $MachinePrecision] * N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.7 \cdot 10^{+89}:\\
\;\;\;\;\frac{\frac{\pi}{b} \cdot \frac{0.5}{a}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi}{\left(a \cdot \left(a + b\right)\right) \cdot \left(b + b\right)}\\
\end{array}
\end{array}
if a < -1.7000000000000001e89Initial program 67.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6481.3
Applied rewrites81.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6498.5
Applied rewrites98.5%
lift-*.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
*-commutativeN/A
frac-timesN/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f6499.4
Applied rewrites99.4%
if -1.7000000000000001e89 < a Initial program 83.9%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-/l*N/A
*-rgt-identityN/A
difference-of-squaresN/A
associate-/r*N/A
*-lft-identityN/A
*-rgt-identityN/A
lower-/.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
*-rgt-identityN/A
lower--.f6491.3
Applied rewrites91.3%
Applied rewrites99.1%
lift-*.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
*-rgt-identityN/A
associate-*l*N/A
associate-/r*N/A
lower-/.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
count-2-revN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6499.6
Applied rewrites99.6%
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-/l/N/A
count-2-revN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
count-2-revN/A
lower-/.f64N/A
lift-PI.f64N/A
count-2-revN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-outN/A
pow2N/A
+-commutativeN/A
Applied rewrites99.1%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (* (/ PI (* (* b a) (* (+ b a) 2.0))) 1.0))
assert(a < b);
double code(double a, double b) {
return (((double) M_PI) / ((b * a) * ((b + a) * 2.0))) * 1.0;
}
assert a < b;
public static double code(double a, double b) {
return (Math.PI / ((b * a) * ((b + a) * 2.0))) * 1.0;
}
[a, b] = sort([a, b]) def code(a, b): return (math.pi / ((b * a) * ((b + a) * 2.0))) * 1.0
a, b = sort([a, b]) function code(a, b) return Float64(Float64(pi / Float64(Float64(b * a) * Float64(Float64(b + a) * 2.0))) * 1.0) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = (pi / ((b * a) * ((b + a) * 2.0))) * 1.0;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(N[(Pi / N[(N[(b * a), $MachinePrecision] * N[(N[(b + a), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\pi}{\left(b \cdot a\right) \cdot \left(\left(b + a\right) \cdot 2\right)} \cdot 1
\end{array}
Initial program 78.6%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-/l*N/A
*-rgt-identityN/A
difference-of-squaresN/A
associate-/r*N/A
*-lft-identityN/A
*-rgt-identityN/A
lower-/.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
*-rgt-identityN/A
lower--.f6488.6
Applied rewrites88.6%
Applied rewrites98.9%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 1.08e-72) (* (/ (/ PI a) (* b a)) 0.5) (/ (/ PI b) (* (+ a a) b))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (b <= 1.08e-72) {
tmp = ((((double) M_PI) / a) / (b * a)) * 0.5;
} else {
tmp = (((double) M_PI) / b) / ((a + a) * b);
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (b <= 1.08e-72) {
tmp = ((Math.PI / a) / (b * a)) * 0.5;
} else {
tmp = (Math.PI / b) / ((a + a) * b);
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if b <= 1.08e-72: tmp = ((math.pi / a) / (b * a)) * 0.5 else: tmp = (math.pi / b) / ((a + a) * b) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (b <= 1.08e-72) tmp = Float64(Float64(Float64(pi / a) / Float64(b * a)) * 0.5); else tmp = Float64(Float64(pi / b) / Float64(Float64(a + a) * b)); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (b <= 1.08e-72)
tmp = ((pi / a) / (b * a)) * 0.5;
else
tmp = (pi / b) / ((a + 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, 1.08e-72], N[(N[(N[(Pi / a), $MachinePrecision] / N[(b * a), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(Pi / b), $MachinePrecision] / N[(N[(a + a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.08 \cdot 10^{-72}:\\
\;\;\;\;\frac{\frac{\pi}{a}}{b \cdot a} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\pi}{b}}{\left(a + a\right) \cdot b}\\
\end{array}
\end{array}
if b < 1.07999999999999998e-72Initial program 78.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6479.7
Applied rewrites79.7%
lift-PI.f64N/A
lift-/.f64N/A
frac-2negN/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
frac-2negN/A
associate-/r*N/A
pow2N/A
associate-/r*N/A
associate-/l/N/A
lower-/.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f6491.5
Applied rewrites91.5%
if 1.07999999999999998e-72 < b Initial program 78.7%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-/l*N/A
*-rgt-identityN/A
difference-of-squaresN/A
associate-/r*N/A
*-lft-identityN/A
*-rgt-identityN/A
lower-/.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
*-rgt-identityN/A
lower--.f6488.6
Applied rewrites88.6%
Applied rewrites98.7%
lift-*.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
*-rgt-identityN/A
associate-*l*N/A
associate-/r*N/A
lower-/.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
count-2-revN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6499.4
Applied rewrites99.4%
Taylor expanded in a around 0
Applied rewrites89.2%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 1.08e-72) (* (/ PI a) (/ 0.5 (* b a))) (/ (/ PI b) (* (+ a a) b))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (b <= 1.08e-72) {
tmp = (((double) M_PI) / a) * (0.5 / (b * a));
} else {
tmp = (((double) M_PI) / b) / ((a + a) * b);
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (b <= 1.08e-72) {
tmp = (Math.PI / a) * (0.5 / (b * a));
} else {
tmp = (Math.PI / b) / ((a + a) * b);
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if b <= 1.08e-72: tmp = (math.pi / a) * (0.5 / (b * a)) else: tmp = (math.pi / b) / ((a + a) * b) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (b <= 1.08e-72) tmp = Float64(Float64(pi / a) * Float64(0.5 / Float64(b * a))); else tmp = Float64(Float64(pi / b) / Float64(Float64(a + a) * b)); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (b <= 1.08e-72)
tmp = (pi / a) * (0.5 / (b * a));
else
tmp = (pi / b) / ((a + 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, 1.08e-72], N[(N[(Pi / a), $MachinePrecision] * N[(0.5 / N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Pi / b), $MachinePrecision] / N[(N[(a + a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.08 \cdot 10^{-72}:\\
\;\;\;\;\frac{\pi}{a} \cdot \frac{0.5}{b \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\pi}{b}}{\left(a + a\right) \cdot b}\\
\end{array}
\end{array}
if b < 1.07999999999999998e-72Initial program 78.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6479.7
Applied rewrites79.7%
lift-*.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6491.5
Applied rewrites91.5%
if 1.07999999999999998e-72 < b Initial program 78.7%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-/l*N/A
*-rgt-identityN/A
difference-of-squaresN/A
associate-/r*N/A
*-lft-identityN/A
*-rgt-identityN/A
lower-/.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
*-rgt-identityN/A
lower--.f6488.6
Applied rewrites88.6%
Applied rewrites98.7%
lift-*.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
*-rgt-identityN/A
associate-*l*N/A
associate-/r*N/A
lower-/.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
count-2-revN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6499.4
Applied rewrites99.4%
Taylor expanded in a around 0
Applied rewrites89.2%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 1.08e-72) (* PI (/ (/ 0.5 a) (* a b))) (/ (/ PI b) (* (+ a a) b))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (b <= 1.08e-72) {
tmp = ((double) M_PI) * ((0.5 / a) / (a * b));
} else {
tmp = (((double) M_PI) / b) / ((a + a) * b);
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (b <= 1.08e-72) {
tmp = Math.PI * ((0.5 / a) / (a * b));
} else {
tmp = (Math.PI / b) / ((a + a) * b);
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if b <= 1.08e-72: tmp = math.pi * ((0.5 / a) / (a * b)) else: tmp = (math.pi / b) / ((a + a) * b) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (b <= 1.08e-72) tmp = Float64(pi * Float64(Float64(0.5 / a) / Float64(a * b))); else tmp = Float64(Float64(pi / b) / Float64(Float64(a + a) * b)); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (b <= 1.08e-72)
tmp = pi * ((0.5 / a) / (a * b));
else
tmp = (pi / b) / ((a + 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, 1.08e-72], N[(Pi * N[(N[(0.5 / a), $MachinePrecision] / N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Pi / b), $MachinePrecision] / N[(N[(a + a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.08 \cdot 10^{-72}:\\
\;\;\;\;\pi \cdot \frac{\frac{0.5}{a}}{a \cdot b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\pi}{b}}{\left(a + a\right) \cdot b}\\
\end{array}
\end{array}
if b < 1.07999999999999998e-72Initial program 78.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6479.7
Applied rewrites79.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6491.0
Applied rewrites91.0%
lift-*.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
*-commutativeN/A
frac-timesN/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-/.f64N/A
lift-/.f6491.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6491.4
Applied rewrites91.4%
if 1.07999999999999998e-72 < b Initial program 78.7%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-/l*N/A
*-rgt-identityN/A
difference-of-squaresN/A
associate-/r*N/A
*-lft-identityN/A
*-rgt-identityN/A
lower-/.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
*-rgt-identityN/A
lower--.f6488.6
Applied rewrites88.6%
Applied rewrites98.7%
lift-*.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
*-rgt-identityN/A
associate-*l*N/A
associate-/r*N/A
lower-/.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
count-2-revN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6499.4
Applied rewrites99.4%
Taylor expanded in a around 0
Applied rewrites89.2%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 1.08e-72) (* (/ PI (* a (* b a))) 0.5) (/ (/ PI b) (* (+ a a) b))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (b <= 1.08e-72) {
tmp = (((double) M_PI) / (a * (b * a))) * 0.5;
} else {
tmp = (((double) M_PI) / b) / ((a + a) * b);
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (b <= 1.08e-72) {
tmp = (Math.PI / (a * (b * a))) * 0.5;
} else {
tmp = (Math.PI / b) / ((a + a) * b);
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if b <= 1.08e-72: tmp = (math.pi / (a * (b * a))) * 0.5 else: tmp = (math.pi / b) / ((a + a) * b) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (b <= 1.08e-72) tmp = Float64(Float64(pi / Float64(a * Float64(b * a))) * 0.5); else tmp = Float64(Float64(pi / b) / Float64(Float64(a + a) * b)); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (b <= 1.08e-72)
tmp = (pi / (a * (b * a))) * 0.5;
else
tmp = (pi / b) / ((a + 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, 1.08e-72], N[(N[(Pi / N[(a * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(Pi / b), $MachinePrecision] / N[(N[(a + a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.08 \cdot 10^{-72}:\\
\;\;\;\;\frac{\pi}{a \cdot \left(b \cdot a\right)} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\pi}{b}}{\left(a + a\right) \cdot b}\\
\end{array}
\end{array}
if b < 1.07999999999999998e-72Initial program 78.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6479.7
Applied rewrites79.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6491.0
Applied rewrites91.0%
if 1.07999999999999998e-72 < b Initial program 78.7%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-/l*N/A
*-rgt-identityN/A
difference-of-squaresN/A
associate-/r*N/A
*-lft-identityN/A
*-rgt-identityN/A
lower-/.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
*-rgt-identityN/A
lower--.f6488.6
Applied rewrites88.6%
Applied rewrites98.7%
lift-*.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
*-rgt-identityN/A
associate-*l*N/A
associate-/r*N/A
lower-/.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
count-2-revN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6499.4
Applied rewrites99.4%
Taylor expanded in a around 0
Applied rewrites89.2%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 1.08e-72) (* (/ PI (* a (* b a))) 0.5) (* (/ PI (* (* b b) a)) 0.5)))
assert(a < b);
double code(double a, double b) {
double tmp;
if (b <= 1.08e-72) {
tmp = (((double) M_PI) / (a * (b * a))) * 0.5;
} else {
tmp = (((double) M_PI) / ((b * b) * a)) * 0.5;
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (b <= 1.08e-72) {
tmp = (Math.PI / (a * (b * a))) * 0.5;
} else {
tmp = (Math.PI / ((b * b) * a)) * 0.5;
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if b <= 1.08e-72: tmp = (math.pi / (a * (b * a))) * 0.5 else: tmp = (math.pi / ((b * b) * a)) * 0.5 return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (b <= 1.08e-72) tmp = Float64(Float64(pi / Float64(a * Float64(b * a))) * 0.5); else tmp = Float64(Float64(pi / Float64(Float64(b * b) * a)) * 0.5); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (b <= 1.08e-72)
tmp = (pi / (a * (b * a))) * 0.5;
else
tmp = (pi / ((b * b) * a)) * 0.5;
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.08e-72], N[(N[(Pi / N[(a * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(Pi / N[(N[(b * b), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.08 \cdot 10^{-72}:\\
\;\;\;\;\frac{\pi}{a \cdot \left(b \cdot a\right)} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi}{\left(b \cdot b\right) \cdot a} \cdot 0.5\\
\end{array}
\end{array}
if b < 1.07999999999999998e-72Initial program 78.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6479.7
Applied rewrites79.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6491.0
Applied rewrites91.0%
if 1.07999999999999998e-72 < b Initial program 78.7%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6477.7
Applied rewrites77.7%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (* (/ PI (* a (* b a))) 0.5))
assert(a < b);
double code(double a, double b) {
return (((double) M_PI) / (a * (b * a))) * 0.5;
}
assert a < b;
public static double code(double a, double b) {
return (Math.PI / (a * (b * a))) * 0.5;
}
[a, b] = sort([a, b]) def code(a, b): return (math.pi / (a * (b * a))) * 0.5
a, b = sort([a, b]) function code(a, b) return Float64(Float64(pi / Float64(a * Float64(b * a))) * 0.5) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = (pi / (a * (b * a))) * 0.5;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(N[(Pi / N[(a * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\pi}{a \cdot \left(b \cdot a\right)} \cdot 0.5
\end{array}
Initial program 78.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6457.2
Applied rewrites57.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6462.8
Applied rewrites62.8%
herbie shell --seed 2025130
(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))))