
(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 -8.8e+85) (* (/ PI (* a b)) (/ 0.5 a)) (/ (* 0.5 PI) (* b (* a (+ a b))))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -8.8e+85) {
tmp = (((double) M_PI) / (a * b)) * (0.5 / a);
} else {
tmp = (0.5 * ((double) M_PI)) / (b * (a * (a + b)));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -8.8e+85) {
tmp = (Math.PI / (a * b)) * (0.5 / a);
} else {
tmp = (0.5 * Math.PI) / (b * (a * (a + b)));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -8.8e+85: tmp = (math.pi / (a * b)) * (0.5 / a) else: tmp = (0.5 * math.pi) / (b * (a * (a + b))) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -8.8e+85) tmp = Float64(Float64(pi / Float64(a * b)) * Float64(0.5 / a)); else tmp = Float64(Float64(0.5 * pi) / Float64(b * Float64(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 <= -8.8e+85)
tmp = (pi / (a * b)) * (0.5 / a);
else
tmp = (0.5 * 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[a, -8.8e+85], N[(N[(Pi / N[(a * b), $MachinePrecision]), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * Pi), $MachinePrecision] / N[(b * N[(a * N[(a + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -8.8 \cdot 10^{+85}:\\
\;\;\;\;\frac{\pi}{a \cdot b} \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5 \cdot \pi}{b \cdot \left(a \cdot \left(a + b\right)\right)}\\
\end{array}
\end{array}
if a < -8.8000000000000007e85Initial program 78.8%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
lower-pow.f6456.7
Applied rewrites56.7%
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6462.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6462.3
Applied rewrites62.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6462.4
Applied rewrites62.4%
if -8.8000000000000007e85 < a Initial program 78.8%
lift-*.f64N/A
lift-/.f64N/A
mult-flip-revN/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
difference-of-squaresN/A
associate-/r*N/A
*-lft-identityN/A
/-rgt-identityN/A
mult-flipN/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f64N/A
lift-/.f64N/A
div-flipN/A
associate-/r/N/A
lower-*.f64N/A
metadata-evalN/A
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
*-rgt-identityN/A
Applied rewrites88.6%
Applied rewrites99.1%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
div-flip-revN/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-outN/A
lower-*.f64N/A
distribute-rgt-outN/A
+-commutativeN/A
lift-+.f64N/A
lower-*.f6493.5
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.5
Applied rewrites93.5%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (/ (* (/ PI (* a b)) 0.5) (+ a b)))
assert(a < b);
double code(double a, double b) {
return ((((double) M_PI) / (a * b)) * 0.5) / (a + b);
}
assert a < b;
public static double code(double a, double b) {
return ((Math.PI / (a * b)) * 0.5) / (a + b);
}
[a, b] = sort([a, b]) def code(a, b): return ((math.pi / (a * b)) * 0.5) / (a + b)
a, b = sort([a, b]) function code(a, b) return Float64(Float64(Float64(pi / Float64(a * b)) * 0.5) / Float64(a + b)) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = ((pi / (a * b)) * 0.5) / (a + b);
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(N[(N[(Pi / N[(a * b), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision] / N[(a + b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\frac{\pi}{a \cdot b} \cdot 0.5}{a + b}
\end{array}
Initial program 78.8%
lift-*.f64N/A
lift-/.f64N/A
mult-flip-revN/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
difference-of-squaresN/A
associate-/r*N/A
*-lft-identityN/A
/-rgt-identityN/A
mult-flipN/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f64N/A
lift-/.f64N/A
div-flipN/A
associate-/r/N/A
lower-*.f64N/A
metadata-evalN/A
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
*-rgt-identityN/A
Applied rewrites88.6%
Applied rewrites99.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
div-flip-revN/A
lower-/.f64N/A
div-flip-revN/A
lift-*.f64N/A
associate-/r*N/A
associate-/r/N/A
div-flipN/A
lower-*.f64N/A
lower-/.f6499.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.7
lift-+.f64N/A
+-commutativeN/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 (/ (* 0.5 PI) (* (* b a) (+ b a))))
assert(a < b);
double code(double a, double b) {
return (0.5 * ((double) M_PI)) / ((b * a) * (b + a));
}
assert a < b;
public static double code(double a, double b) {
return (0.5 * Math.PI) / ((b * a) * (b + a));
}
[a, b] = sort([a, b]) def code(a, b): return (0.5 * math.pi) / ((b * a) * (b + a))
a, b = sort([a, b]) function code(a, b) return Float64(Float64(0.5 * pi) / Float64(Float64(b * a) * Float64(b + a))) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = (0.5 * pi) / ((b * a) * (b + a));
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(N[(0.5 * Pi), $MachinePrecision] / N[(N[(b * a), $MachinePrecision] * N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{0.5 \cdot \pi}{\left(b \cdot a\right) \cdot \left(b + a\right)}
\end{array}
Initial program 78.8%
lift-*.f64N/A
lift-/.f64N/A
mult-flip-revN/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
difference-of-squaresN/A
associate-/r*N/A
*-lft-identityN/A
/-rgt-identityN/A
mult-flipN/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f64N/A
lift-/.f64N/A
div-flipN/A
associate-/r/N/A
lower-*.f64N/A
metadata-evalN/A
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
*-rgt-identityN/A
Applied rewrites88.6%
Applied rewrites99.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
div-flip-revN/A
lower-/.f64N/A
div-flip-revN/A
lift-*.f64N/A
associate-/r*N/A
associate-/r/N/A
div-flipN/A
lower-*.f64N/A
lower-/.f6499.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.7
Applied rewrites99.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f64N/A
lower-*.f6499.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.1
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.1
Applied rewrites99.1%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -7e-94) (* (/ PI (* a b)) (/ 0.5 a)) (* 0.5 (/ (/ (/ PI b) a) b))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -7e-94) {
tmp = (((double) M_PI) / (a * b)) * (0.5 / a);
} else {
tmp = 0.5 * (((((double) M_PI) / b) / a) / b);
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -7e-94) {
tmp = (Math.PI / (a * b)) * (0.5 / a);
} else {
tmp = 0.5 * (((Math.PI / b) / a) / b);
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -7e-94: tmp = (math.pi / (a * b)) * (0.5 / a) else: tmp = 0.5 * (((math.pi / b) / a) / b) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -7e-94) tmp = Float64(Float64(pi / Float64(a * b)) * Float64(0.5 / a)); else tmp = Float64(0.5 * Float64(Float64(Float64(pi / b) / a) / b)); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -7e-94)
tmp = (pi / (a * b)) * (0.5 / a);
else
tmp = 0.5 * (((pi / 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[a, -7e-94], N[(N[(Pi / N[(a * b), $MachinePrecision]), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(N[(Pi / b), $MachinePrecision] / a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -7 \cdot 10^{-94}:\\
\;\;\;\;\frac{\pi}{a \cdot b} \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{\frac{\frac{\pi}{b}}{a}}{b}\\
\end{array}
\end{array}
if a < -6.99999999999999996e-94Initial program 78.8%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
lower-pow.f6456.7
Applied rewrites56.7%
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6462.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6462.3
Applied rewrites62.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6462.4
Applied rewrites62.4%
if -6.99999999999999996e-94 < a Initial program 78.8%
lift-*.f64N/A
lift-/.f64N/A
mult-flip-revN/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
difference-of-squaresN/A
associate-/r*N/A
*-lft-identityN/A
/-rgt-identityN/A
mult-flipN/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f64N/A
lift-/.f64N/A
div-flipN/A
associate-/r/N/A
lower-*.f64N/A
metadata-evalN/A
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
*-rgt-identityN/A
Applied rewrites88.6%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
lower-pow.f6457.2
Applied rewrites57.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-pow.f64N/A
pow2N/A
associate-/r*N/A
associate-/r*N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f64N/A
lower-/.f6463.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6463.0
Applied rewrites63.0%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6463.0
Applied rewrites63.0%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -7e-94) (* (/ PI (* a b)) (/ 0.5 a)) (* (/ PI b) (/ 0.5 (* b a)))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -7e-94) {
tmp = (((double) M_PI) / (a * b)) * (0.5 / 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 <= -7e-94) {
tmp = (Math.PI / (a * b)) * (0.5 / 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 <= -7e-94: tmp = (math.pi / (a * b)) * (0.5 / 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 <= -7e-94) tmp = Float64(Float64(pi / Float64(a * b)) * Float64(0.5 / 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 <= -7e-94)
tmp = (pi / (a * b)) * (0.5 / 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, -7e-94], N[(N[(Pi / N[(a * b), $MachinePrecision]), $MachinePrecision] * N[(0.5 / a), $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 -7 \cdot 10^{-94}:\\
\;\;\;\;\frac{\pi}{a \cdot b} \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi}{b} \cdot \frac{0.5}{b \cdot a}\\
\end{array}
\end{array}
if a < -6.99999999999999996e-94Initial program 78.8%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
lower-pow.f6456.7
Applied rewrites56.7%
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6462.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6462.3
Applied rewrites62.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6462.4
Applied rewrites62.4%
if -6.99999999999999996e-94 < a Initial program 78.8%
lift-*.f64N/A
lift-/.f64N/A
mult-flip-revN/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
difference-of-squaresN/A
associate-/r*N/A
*-lft-identityN/A
/-rgt-identityN/A
mult-flipN/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f64N/A
lift-/.f64N/A
div-flipN/A
associate-/r/N/A
lower-*.f64N/A
metadata-evalN/A
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
*-rgt-identityN/A
Applied rewrites88.6%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
lower-pow.f6457.2
Applied rewrites57.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f6457.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6457.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6457.2
lift-pow.f64N/A
pow2N/A
lower-*.f6457.2
Applied rewrites57.2%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6463.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6463.0
Applied rewrites63.0%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -7e-94) (* (/ PI (* a b)) (/ 0.5 a)) (* 0.5 (/ PI (* (* a b) b)))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -7e-94) {
tmp = (((double) M_PI) / (a * b)) * (0.5 / a);
} else {
tmp = 0.5 * (((double) M_PI) / ((a * b) * b));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -7e-94) {
tmp = (Math.PI / (a * b)) * (0.5 / a);
} else {
tmp = 0.5 * (Math.PI / ((a * b) * b));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -7e-94: tmp = (math.pi / (a * b)) * (0.5 / a) else: tmp = 0.5 * (math.pi / ((a * b) * b)) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -7e-94) tmp = Float64(Float64(pi / Float64(a * b)) * Float64(0.5 / a)); else tmp = Float64(0.5 * Float64(pi / Float64(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 <= -7e-94)
tmp = (pi / (a * b)) * (0.5 / a);
else
tmp = 0.5 * (pi / ((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, -7e-94], N[(N[(Pi / N[(a * b), $MachinePrecision]), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(Pi / N[(N[(a * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -7 \cdot 10^{-94}:\\
\;\;\;\;\frac{\pi}{a \cdot b} \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{\pi}{\left(a \cdot b\right) \cdot b}\\
\end{array}
\end{array}
if a < -6.99999999999999996e-94Initial program 78.8%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
lower-pow.f6456.7
Applied rewrites56.7%
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6462.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6462.3
Applied rewrites62.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6462.4
Applied rewrites62.4%
if -6.99999999999999996e-94 < a Initial program 78.8%
lift-*.f64N/A
lift-/.f64N/A
mult-flip-revN/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
difference-of-squaresN/A
associate-/r*N/A
*-lft-identityN/A
/-rgt-identityN/A
mult-flipN/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f64N/A
lift-/.f64N/A
div-flipN/A
associate-/r/N/A
lower-*.f64N/A
metadata-evalN/A
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
*-rgt-identityN/A
Applied rewrites88.6%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
lower-pow.f6457.2
Applied rewrites57.2%
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6462.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6462.8
Applied rewrites62.8%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -7e-94) (* (/ PI a) (/ 0.5 (* a b))) (* 0.5 (/ PI (* (* a b) b)))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -7e-94) {
tmp = (((double) M_PI) / a) * (0.5 / (a * b));
} else {
tmp = 0.5 * (((double) M_PI) / ((a * b) * b));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -7e-94) {
tmp = (Math.PI / a) * (0.5 / (a * b));
} else {
tmp = 0.5 * (Math.PI / ((a * b) * b));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -7e-94: tmp = (math.pi / a) * (0.5 / (a * b)) else: tmp = 0.5 * (math.pi / ((a * b) * b)) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -7e-94) tmp = Float64(Float64(pi / a) * Float64(0.5 / Float64(a * b))); else tmp = Float64(0.5 * Float64(pi / Float64(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 <= -7e-94)
tmp = (pi / a) * (0.5 / (a * b));
else
tmp = 0.5 * (pi / ((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, -7e-94], N[(N[(Pi / a), $MachinePrecision] * N[(0.5 / N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(Pi / N[(N[(a * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -7 \cdot 10^{-94}:\\
\;\;\;\;\frac{\pi}{a} \cdot \frac{0.5}{a \cdot b}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{\pi}{\left(a \cdot b\right) \cdot b}\\
\end{array}
\end{array}
if a < -6.99999999999999996e-94Initial program 78.8%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
lower-pow.f6456.7
Applied rewrites56.7%
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6462.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6462.3
Applied rewrites62.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6462.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6462.4
Applied rewrites62.4%
if -6.99999999999999996e-94 < a Initial program 78.8%
lift-*.f64N/A
lift-/.f64N/A
mult-flip-revN/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
difference-of-squaresN/A
associate-/r*N/A
*-lft-identityN/A
/-rgt-identityN/A
mult-flipN/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f64N/A
lift-/.f64N/A
div-flipN/A
associate-/r/N/A
lower-*.f64N/A
metadata-evalN/A
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
*-rgt-identityN/A
Applied rewrites88.6%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
lower-pow.f6457.2
Applied rewrites57.2%
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6462.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6462.8
Applied rewrites62.8%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -7e-94) (* (/ 0.5 (* (* b a) a)) PI) (* 0.5 (/ PI (* (* a b) b)))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -7e-94) {
tmp = (0.5 / ((b * a) * a)) * ((double) M_PI);
} else {
tmp = 0.5 * (((double) M_PI) / ((a * b) * b));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -7e-94) {
tmp = (0.5 / ((b * a) * a)) * Math.PI;
} else {
tmp = 0.5 * (Math.PI / ((a * b) * b));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -7e-94: tmp = (0.5 / ((b * a) * a)) * math.pi else: tmp = 0.5 * (math.pi / ((a * b) * b)) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -7e-94) tmp = Float64(Float64(0.5 / Float64(Float64(b * a) * a)) * pi); else tmp = Float64(0.5 * Float64(pi / Float64(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 <= -7e-94)
tmp = (0.5 / ((b * a) * a)) * pi;
else
tmp = 0.5 * (pi / ((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, -7e-94], N[(N[(0.5 / N[(N[(b * a), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] * Pi), $MachinePrecision], N[(0.5 * N[(Pi / N[(N[(a * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -7 \cdot 10^{-94}:\\
\;\;\;\;\frac{0.5}{\left(b \cdot a\right) \cdot a} \cdot \pi\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{\pi}{\left(a \cdot b\right) \cdot b}\\
\end{array}
\end{array}
if a < -6.99999999999999996e-94Initial program 78.8%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
lower-pow.f6456.7
Applied rewrites56.7%
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6462.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6462.3
Applied rewrites62.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f6456.7
Applied rewrites56.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6462.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6462.3
Applied rewrites62.3%
if -6.99999999999999996e-94 < a Initial program 78.8%
lift-*.f64N/A
lift-/.f64N/A
mult-flip-revN/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
difference-of-squaresN/A
associate-/r*N/A
*-lft-identityN/A
/-rgt-identityN/A
mult-flipN/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f64N/A
lift-/.f64N/A
div-flipN/A
associate-/r/N/A
lower-*.f64N/A
metadata-evalN/A
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
*-rgt-identityN/A
Applied rewrites88.6%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
lower-pow.f6457.2
Applied rewrites57.2%
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6462.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6462.8
Applied rewrites62.8%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (* (/ 0.5 (* (* b a) a)) PI))
assert(a < b);
double code(double a, double b) {
return (0.5 / ((b * a) * a)) * ((double) M_PI);
}
assert a < b;
public static double code(double a, double b) {
return (0.5 / ((b * a) * a)) * Math.PI;
}
[a, b] = sort([a, b]) def code(a, b): return (0.5 / ((b * a) * a)) * math.pi
a, b = sort([a, b]) function code(a, b) return Float64(Float64(0.5 / Float64(Float64(b * a) * a)) * pi) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = (0.5 / ((b * a) * a)) * pi;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(N[(0.5 / N[(N[(b * a), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] * Pi), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{0.5}{\left(b \cdot a\right) \cdot a} \cdot \pi
\end{array}
Initial program 78.8%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
lower-pow.f6456.7
Applied rewrites56.7%
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6462.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6462.3
Applied rewrites62.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f6456.7
Applied rewrites56.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6462.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6462.3
Applied rewrites62.3%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (* 0.5 (/ PI (* (* b a) a))))
assert(a < b);
double code(double a, double b) {
return 0.5 * (((double) M_PI) / ((b * a) * a));
}
assert a < b;
public static double code(double a, double b) {
return 0.5 * (Math.PI / ((b * a) * a));
}
[a, b] = sort([a, b]) def code(a, b): return 0.5 * (math.pi / ((b * a) * a))
a, b = sort([a, b]) function code(a, b) return Float64(0.5 * Float64(pi / Float64(Float64(b * a) * a))) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = 0.5 * (pi / ((b * a) * a));
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(0.5 * N[(Pi / N[(N[(b * a), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
0.5 \cdot \frac{\pi}{\left(b \cdot a\right) \cdot a}
\end{array}
Initial program 78.8%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
lower-pow.f6456.7
Applied rewrites56.7%
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6462.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6462.3
Applied rewrites62.3%
herbie shell --seed 2025156
(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))))