
(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 -9e+157) (/ (/ (* (/ PI b) 0.5) a) a) (* (/ (* PI 0.5) (* (+ a b) (- a))) (/ -1.0 b))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -9e+157) {
tmp = (((((double) M_PI) / b) * 0.5) / a) / a;
} else {
tmp = ((((double) M_PI) * 0.5) / ((a + b) * -a)) * (-1.0 / b);
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -9e+157) {
tmp = (((Math.PI / b) * 0.5) / a) / a;
} else {
tmp = ((Math.PI * 0.5) / ((a + b) * -a)) * (-1.0 / b);
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -9e+157: tmp = (((math.pi / b) * 0.5) / a) / a else: tmp = ((math.pi * 0.5) / ((a + b) * -a)) * (-1.0 / b) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -9e+157) tmp = Float64(Float64(Float64(Float64(pi / b) * 0.5) / a) / a); else tmp = Float64(Float64(Float64(pi * 0.5) / Float64(Float64(a + b) * Float64(-a))) * Float64(-1.0 / b)); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -9e+157)
tmp = (((pi / b) * 0.5) / a) / a;
else
tmp = ((pi * 0.5) / ((a + b) * -a)) * (-1.0 / 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, -9e+157], N[(N[(N[(N[(Pi / b), $MachinePrecision] * 0.5), $MachinePrecision] / a), $MachinePrecision] / a), $MachinePrecision], N[(N[(N[(Pi * 0.5), $MachinePrecision] / N[(N[(a + b), $MachinePrecision] * (-a)), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -9 \cdot 10^{+157}:\\
\;\;\;\;\frac{\frac{\frac{\pi}{b} \cdot 0.5}{a}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi \cdot 0.5}{\left(a + b\right) \cdot \left(-a\right)} \cdot \frac{-1}{b}\\
\end{array}
\end{array}
if a < -8.9999999999999997e157Initial program 78.8%
Taylor expanded in a around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
pow2N/A
lift-*.f6449.4
Applied rewrites49.4%
Taylor expanded in a around inf
lower-*.f64N/A
lift-/.f64N/A
lift-PI.f6456.6
Applied rewrites56.6%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6462.7
lift-*.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-PI.f6462.7
Applied rewrites62.7%
if -8.9999999999999997e157 < a Initial program 78.8%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
mult-flip-revN/A
lift-PI.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
difference-of-squaresN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower--.f6488.4
Applied rewrites88.4%
Taylor expanded in a around inf
lower-/.f6464.5
Applied rewrites64.5%
Taylor expanded in a around inf
lower-*.f6493.8
Applied rewrites93.8%
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6493.6
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6493.6
Applied rewrites93.6%
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)) (/ -1.0 b))))
assert(a < b);
double code(double a, double b) {
return (0.5 / (a + b)) * ((((double) M_PI) / -a) * (-1.0 / b));
}
assert a < b;
public static double code(double a, double b) {
return (0.5 / (a + b)) * ((Math.PI / -a) * (-1.0 / b));
}
[a, b] = sort([a, b]) def code(a, b): return (0.5 / (a + b)) * ((math.pi / -a) * (-1.0 / b))
a, b = sort([a, b]) function code(a, b) return Float64(Float64(0.5 / Float64(a + b)) * Float64(Float64(pi / Float64(-a)) * Float64(-1.0 / b))) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = (0.5 / (a + b)) * ((pi / -a) * (-1.0 / b));
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(N[(0.5 / N[(a + b), $MachinePrecision]), $MachinePrecision] * N[(N[(Pi / (-a)), $MachinePrecision] * N[(-1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{0.5}{a + b} \cdot \left(\frac{\pi}{-a} \cdot \frac{-1}{b}\right)
\end{array}
Initial program 78.8%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
mult-flip-revN/A
lift-PI.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
difference-of-squaresN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower--.f6488.4
Applied rewrites88.4%
Taylor expanded in a around inf
lower-/.f6464.5
Applied rewrites64.5%
Taylor expanded in a around inf
lower-*.f6493.8
Applied rewrites93.8%
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f6499.6
lift-*.f64N/A
mul-1-negN/A
lower-neg.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 -2.05e+68)
(/ (/ (* (/ PI b) 0.5) a) a)
(if (<= a -4.5e-72)
(* (* (/ 0.5 a) (/ PI (- b a))) (/ -1.0 b))
(* (* (/ 0.5 b) (/ PI (* -1.0 a))) (/ -1.0 b)))))assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -2.05e+68) {
tmp = (((((double) M_PI) / b) * 0.5) / a) / a;
} else if (a <= -4.5e-72) {
tmp = ((0.5 / a) * (((double) M_PI) / (b - a))) * (-1.0 / b);
} else {
tmp = ((0.5 / b) * (((double) M_PI) / (-1.0 * a))) * (-1.0 / b);
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -2.05e+68) {
tmp = (((Math.PI / b) * 0.5) / a) / a;
} else if (a <= -4.5e-72) {
tmp = ((0.5 / a) * (Math.PI / (b - a))) * (-1.0 / b);
} else {
tmp = ((0.5 / b) * (Math.PI / (-1.0 * a))) * (-1.0 / b);
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -2.05e+68: tmp = (((math.pi / b) * 0.5) / a) / a elif a <= -4.5e-72: tmp = ((0.5 / a) * (math.pi / (b - a))) * (-1.0 / b) else: tmp = ((0.5 / b) * (math.pi / (-1.0 * a))) * (-1.0 / b) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -2.05e+68) tmp = Float64(Float64(Float64(Float64(pi / b) * 0.5) / a) / a); elseif (a <= -4.5e-72) tmp = Float64(Float64(Float64(0.5 / a) * Float64(pi / Float64(b - a))) * Float64(-1.0 / b)); else tmp = Float64(Float64(Float64(0.5 / b) * Float64(pi / Float64(-1.0 * a))) * Float64(-1.0 / b)); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -2.05e+68)
tmp = (((pi / b) * 0.5) / a) / a;
elseif (a <= -4.5e-72)
tmp = ((0.5 / a) * (pi / (b - a))) * (-1.0 / b);
else
tmp = ((0.5 / b) * (pi / (-1.0 * a))) * (-1.0 / 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, -2.05e+68], N[(N[(N[(N[(Pi / b), $MachinePrecision] * 0.5), $MachinePrecision] / a), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[a, -4.5e-72], N[(N[(N[(0.5 / a), $MachinePrecision] * N[(Pi / N[(b - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / b), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.5 / b), $MachinePrecision] * N[(Pi / N[(-1.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.05 \cdot 10^{+68}:\\
\;\;\;\;\frac{\frac{\frac{\pi}{b} \cdot 0.5}{a}}{a}\\
\mathbf{elif}\;a \leq -4.5 \cdot 10^{-72}:\\
\;\;\;\;\left(\frac{0.5}{a} \cdot \frac{\pi}{b - a}\right) \cdot \frac{-1}{b}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{0.5}{b} \cdot \frac{\pi}{-1 \cdot a}\right) \cdot \frac{-1}{b}\\
\end{array}
\end{array}
if a < -2.05e68Initial program 78.8%
Taylor expanded in a around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
pow2N/A
lift-*.f6449.4
Applied rewrites49.4%
Taylor expanded in a around inf
lower-*.f64N/A
lift-/.f64N/A
lift-PI.f6456.6
Applied rewrites56.6%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6462.7
lift-*.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-PI.f6462.7
Applied rewrites62.7%
if -2.05e68 < a < -4.5e-72Initial program 78.8%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
mult-flip-revN/A
lift-PI.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
difference-of-squaresN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower--.f6488.4
Applied rewrites88.4%
Taylor expanded in a around inf
lower-/.f6464.5
Applied rewrites64.5%
Taylor expanded in a around inf
lower-/.f6461.4
Applied rewrites61.4%
if -4.5e-72 < a Initial program 78.8%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
mult-flip-revN/A
lift-PI.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
difference-of-squaresN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower--.f6488.4
Applied rewrites88.4%
Taylor expanded in a around inf
lower-/.f6464.5
Applied rewrites64.5%
Taylor expanded in a around inf
lower-*.f6493.8
Applied rewrites93.8%
Taylor expanded in a around 0
Applied rewrites63.1%
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (a b)
:precision binary64
(if (<= a -2.05e+68)
(/ (/ (* (/ PI b) 0.5) a) a)
(if (<= a -4.5e-72)
(* (* (/ 0.5 a) (/ PI (- b a))) (/ -1.0 b))
(* (/ 1.0 (/ (* b (* b a)) PI)) 0.5))))assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -2.05e+68) {
tmp = (((((double) M_PI) / b) * 0.5) / a) / a;
} else if (a <= -4.5e-72) {
tmp = ((0.5 / a) * (((double) M_PI) / (b - a))) * (-1.0 / b);
} else {
tmp = (1.0 / ((b * (b * a)) / ((double) M_PI))) * 0.5;
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -2.05e+68) {
tmp = (((Math.PI / b) * 0.5) / a) / a;
} else if (a <= -4.5e-72) {
tmp = ((0.5 / a) * (Math.PI / (b - a))) * (-1.0 / b);
} else {
tmp = (1.0 / ((b * (b * a)) / Math.PI)) * 0.5;
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -2.05e+68: tmp = (((math.pi / b) * 0.5) / a) / a elif a <= -4.5e-72: tmp = ((0.5 / a) * (math.pi / (b - a))) * (-1.0 / b) else: tmp = (1.0 / ((b * (b * a)) / math.pi)) * 0.5 return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -2.05e+68) tmp = Float64(Float64(Float64(Float64(pi / b) * 0.5) / a) / a); elseif (a <= -4.5e-72) tmp = Float64(Float64(Float64(0.5 / a) * Float64(pi / Float64(b - a))) * Float64(-1.0 / b)); else tmp = Float64(Float64(1.0 / Float64(Float64(b * Float64(b * a)) / pi)) * 0.5); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -2.05e+68)
tmp = (((pi / b) * 0.5) / a) / a;
elseif (a <= -4.5e-72)
tmp = ((0.5 / a) * (pi / (b - a))) * (-1.0 / b);
else
tmp = (1.0 / ((b * (b * a)) / pi)) * 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[a, -2.05e+68], N[(N[(N[(N[(Pi / b), $MachinePrecision] * 0.5), $MachinePrecision] / a), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[a, -4.5e-72], N[(N[(N[(0.5 / a), $MachinePrecision] * N[(Pi / N[(b - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / b), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[(b * N[(b * a), $MachinePrecision]), $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.05 \cdot 10^{+68}:\\
\;\;\;\;\frac{\frac{\frac{\pi}{b} \cdot 0.5}{a}}{a}\\
\mathbf{elif}\;a \leq -4.5 \cdot 10^{-72}:\\
\;\;\;\;\left(\frac{0.5}{a} \cdot \frac{\pi}{b - a}\right) \cdot \frac{-1}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{b \cdot \left(b \cdot a\right)}{\pi}} \cdot 0.5\\
\end{array}
\end{array}
if a < -2.05e68Initial program 78.8%
Taylor expanded in a around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
pow2N/A
lift-*.f6449.4
Applied rewrites49.4%
Taylor expanded in a around inf
lower-*.f64N/A
lift-/.f64N/A
lift-PI.f6456.6
Applied rewrites56.6%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6462.7
lift-*.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-PI.f6462.7
Applied rewrites62.7%
if -2.05e68 < a < -4.5e-72Initial program 78.8%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
mult-flip-revN/A
lift-PI.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
difference-of-squaresN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower--.f6488.4
Applied rewrites88.4%
Taylor expanded in a around inf
lower-/.f6464.5
Applied rewrites64.5%
Taylor expanded in a around inf
lower-/.f6461.4
Applied rewrites61.4%
if -4.5e-72 < a Initial program 78.8%
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-*.f6457.3
Applied rewrites57.3%
lift-PI.f64N/A
lift-/.f64N/A
division-flipN/A
lower-special-/N/A
lower-/.f64N/A
lower-special-/N/A
lower-/.f64N/A
lift-PI.f6457.3
Applied rewrites57.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*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 -4.5e-72) (/ (/ (* (/ PI b) 0.5) a) a) (* (/ 1.0 (/ (* b (* b a)) PI)) 0.5)))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -4.5e-72) {
tmp = (((((double) M_PI) / b) * 0.5) / a) / a;
} else {
tmp = (1.0 / ((b * (b * a)) / ((double) M_PI))) * 0.5;
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -4.5e-72) {
tmp = (((Math.PI / b) * 0.5) / a) / a;
} else {
tmp = (1.0 / ((b * (b * a)) / Math.PI)) * 0.5;
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -4.5e-72: tmp = (((math.pi / b) * 0.5) / a) / a else: tmp = (1.0 / ((b * (b * a)) / math.pi)) * 0.5 return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -4.5e-72) tmp = Float64(Float64(Float64(Float64(pi / b) * 0.5) / a) / a); else tmp = Float64(Float64(1.0 / Float64(Float64(b * Float64(b * a)) / pi)) * 0.5); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -4.5e-72)
tmp = (((pi / b) * 0.5) / a) / a;
else
tmp = (1.0 / ((b * (b * a)) / pi)) * 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[a, -4.5e-72], N[(N[(N[(N[(Pi / b), $MachinePrecision] * 0.5), $MachinePrecision] / a), $MachinePrecision] / a), $MachinePrecision], N[(N[(1.0 / N[(N[(b * N[(b * a), $MachinePrecision]), $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.5 \cdot 10^{-72}:\\
\;\;\;\;\frac{\frac{\frac{\pi}{b} \cdot 0.5}{a}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{b \cdot \left(b \cdot a\right)}{\pi}} \cdot 0.5\\
\end{array}
\end{array}
if a < -4.5e-72Initial program 78.8%
Taylor expanded in a around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
pow2N/A
lift-*.f6449.4
Applied rewrites49.4%
Taylor expanded in a around inf
lower-*.f64N/A
lift-/.f64N/A
lift-PI.f6456.6
Applied rewrites56.6%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6462.7
lift-*.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-PI.f6462.7
Applied rewrites62.7%
if -4.5e-72 < a Initial program 78.8%
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-*.f6457.3
Applied rewrites57.3%
lift-PI.f64N/A
lift-/.f64N/A
division-flipN/A
lower-special-/N/A
lower-/.f64N/A
lower-special-/N/A
lower-/.f64N/A
lift-PI.f6457.3
Applied rewrites57.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*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 -4.5e-72) (/ (/ (* (/ PI b) 0.5) a) a) (* (/ (/ PI a) (* b b)) 0.5)))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -4.5e-72) {
tmp = (((((double) M_PI) / b) * 0.5) / a) / a;
} else {
tmp = ((((double) M_PI) / a) / (b * b)) * 0.5;
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -4.5e-72) {
tmp = (((Math.PI / b) * 0.5) / a) / a;
} else {
tmp = ((Math.PI / a) / (b * b)) * 0.5;
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -4.5e-72: tmp = (((math.pi / b) * 0.5) / a) / a else: tmp = ((math.pi / a) / (b * b)) * 0.5 return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -4.5e-72) tmp = Float64(Float64(Float64(Float64(pi / b) * 0.5) / a) / a); else tmp = Float64(Float64(Float64(pi / a) / Float64(b * b)) * 0.5); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -4.5e-72)
tmp = (((pi / b) * 0.5) / a) / a;
else
tmp = ((pi / a) / (b * b)) * 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[a, -4.5e-72], N[(N[(N[(N[(Pi / b), $MachinePrecision] * 0.5), $MachinePrecision] / a), $MachinePrecision] / a), $MachinePrecision], N[(N[(N[(Pi / a), $MachinePrecision] / N[(b * b), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.5 \cdot 10^{-72}:\\
\;\;\;\;\frac{\frac{\frac{\pi}{b} \cdot 0.5}{a}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\pi}{a}}{b \cdot b} \cdot 0.5\\
\end{array}
\end{array}
if a < -4.5e-72Initial program 78.8%
Taylor expanded in a around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
pow2N/A
lift-*.f6449.4
Applied rewrites49.4%
Taylor expanded in a around inf
lower-*.f64N/A
lift-/.f64N/A
lift-PI.f6456.6
Applied rewrites56.6%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6462.7
lift-*.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-PI.f6462.7
Applied rewrites62.7%
if -4.5e-72 < a Initial program 78.8%
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-*.f6457.3
Applied rewrites57.3%
lift-PI.f64N/A
lift-/.f64N/A
division-flipN/A
lower-special-/N/A
lower-/.f64N/A
lower-special-/N/A
lower-/.f64N/A
lift-PI.f6457.3
Applied rewrites57.3%
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lower-special-/N/A
pow2N/A
*-commutativeN/A
lower-special-/N/A
division-flipN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
pow2N/A
lift-*.f6457.2
Applied rewrites57.2%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -4.5e-72) (/ (* 0.5 (/ PI b)) (* a a)) (* (/ (/ PI a) (* b b)) 0.5)))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -4.5e-72) {
tmp = (0.5 * (((double) M_PI) / b)) / (a * a);
} else {
tmp = ((((double) M_PI) / a) / (b * b)) * 0.5;
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -4.5e-72) {
tmp = (0.5 * (Math.PI / b)) / (a * a);
} else {
tmp = ((Math.PI / a) / (b * b)) * 0.5;
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -4.5e-72: tmp = (0.5 * (math.pi / b)) / (a * a) else: tmp = ((math.pi / a) / (b * b)) * 0.5 return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -4.5e-72) tmp = Float64(Float64(0.5 * Float64(pi / b)) / Float64(a * a)); else tmp = Float64(Float64(Float64(pi / a) / Float64(b * b)) * 0.5); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -4.5e-72)
tmp = (0.5 * (pi / b)) / (a * a);
else
tmp = ((pi / a) / (b * b)) * 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[a, -4.5e-72], N[(N[(0.5 * N[(Pi / b), $MachinePrecision]), $MachinePrecision] / N[(a * a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(Pi / a), $MachinePrecision] / N[(b * b), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.5 \cdot 10^{-72}:\\
\;\;\;\;\frac{0.5 \cdot \frac{\pi}{b}}{a \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\pi}{a}}{b \cdot b} \cdot 0.5\\
\end{array}
\end{array}
if a < -4.5e-72Initial program 78.8%
Taylor expanded in a around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
pow2N/A
lift-*.f6449.4
Applied rewrites49.4%
Taylor expanded in a around inf
lower-*.f64N/A
lift-/.f64N/A
lift-PI.f6456.6
Applied rewrites56.6%
if -4.5e-72 < a Initial program 78.8%
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-*.f6457.3
Applied rewrites57.3%
lift-PI.f64N/A
lift-/.f64N/A
division-flipN/A
lower-special-/N/A
lower-/.f64N/A
lower-special-/N/A
lower-/.f64N/A
lift-PI.f6457.3
Applied rewrites57.3%
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lower-special-/N/A
pow2N/A
*-commutativeN/A
lower-special-/N/A
division-flipN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
pow2N/A
lift-*.f6457.2
Applied rewrites57.2%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -4.5e-72) (* (/ PI (* (* a a) b)) 0.5) (* (/ (/ PI a) (* b b)) 0.5)))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -4.5e-72) {
tmp = (((double) M_PI) / ((a * a) * b)) * 0.5;
} else {
tmp = ((((double) M_PI) / a) / (b * b)) * 0.5;
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -4.5e-72) {
tmp = (Math.PI / ((a * a) * b)) * 0.5;
} else {
tmp = ((Math.PI / a) / (b * b)) * 0.5;
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -4.5e-72: tmp = (math.pi / ((a * a) * b)) * 0.5 else: tmp = ((math.pi / a) / (b * b)) * 0.5 return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -4.5e-72) tmp = Float64(Float64(pi / Float64(Float64(a * a) * b)) * 0.5); else tmp = Float64(Float64(Float64(pi / a) / Float64(b * b)) * 0.5); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -4.5e-72)
tmp = (pi / ((a * a) * b)) * 0.5;
else
tmp = ((pi / a) / (b * b)) * 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[a, -4.5e-72], N[(N[(Pi / N[(N[(a * a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(Pi / a), $MachinePrecision] / N[(b * b), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.5 \cdot 10^{-72}:\\
\;\;\;\;\frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\pi}{a}}{b \cdot b} \cdot 0.5\\
\end{array}
\end{array}
if a < -4.5e-72Initial program 78.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-*.f6456.7
Applied rewrites56.7%
if -4.5e-72 < a Initial program 78.8%
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-*.f6457.3
Applied rewrites57.3%
lift-PI.f64N/A
lift-/.f64N/A
division-flipN/A
lower-special-/N/A
lower-/.f64N/A
lower-special-/N/A
lower-/.f64N/A
lift-PI.f6457.3
Applied rewrites57.3%
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lower-special-/N/A
pow2N/A
*-commutativeN/A
lower-special-/N/A
division-flipN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
pow2N/A
lift-*.f6457.2
Applied rewrites57.2%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -4.5e-72) (* (/ PI (* (* a a) b)) 0.5) (* (/ PI (* (* b b) a)) 0.5)))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -4.5e-72) {
tmp = (((double) M_PI) / ((a * a) * b)) * 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 (a <= -4.5e-72) {
tmp = (Math.PI / ((a * a) * b)) * 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 a <= -4.5e-72: tmp = (math.pi / ((a * a) * b)) * 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 (a <= -4.5e-72) tmp = Float64(Float64(pi / Float64(Float64(a * a) * b)) * 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 (a <= -4.5e-72)
tmp = (pi / ((a * a) * b)) * 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[a, -4.5e-72], N[(N[(Pi / N[(N[(a * a), $MachinePrecision] * b), $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}\;a \leq -4.5 \cdot 10^{-72}:\\
\;\;\;\;\frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi}{\left(b \cdot b\right) \cdot a} \cdot 0.5\\
\end{array}
\end{array}
if a < -4.5e-72Initial program 78.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-*.f6456.7
Applied rewrites56.7%
if -4.5e-72 < a Initial program 78.8%
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-*.f6457.3
Applied rewrites57.3%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (* (/ PI (* (* a a) b)) 0.5))
assert(a < b);
double code(double a, double b) {
return (((double) M_PI) / ((a * a) * b)) * 0.5;
}
assert a < b;
public static double code(double a, double b) {
return (Math.PI / ((a * a) * b)) * 0.5;
}
[a, b] = sort([a, b]) def code(a, b): return (math.pi / ((a * a) * b)) * 0.5
a, b = sort([a, b]) function code(a, b) return Float64(Float64(pi / Float64(Float64(a * a) * b)) * 0.5) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = (pi / ((a * a) * b)) * 0.5;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(N[(Pi / N[(N[(a * a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot 0.5
\end{array}
Initial program 78.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-*.f6456.7
Applied rewrites56.7%
herbie shell --seed 2025132
(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))))