
(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 7 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}
(FPCore (a b) :precision binary64 (* (/ PI (* 2.0 (+ a b))) (/ 1.0 (* b a))))
double code(double a, double b) {
return (((double) M_PI) / (2.0 * (a + b))) * (1.0 / (b * a));
}
public static double code(double a, double b) {
return (Math.PI / (2.0 * (a + b))) * (1.0 / (b * a));
}
def code(a, b): return (math.pi / (2.0 * (a + b))) * (1.0 / (b * a))
function code(a, b) return Float64(Float64(pi / Float64(2.0 * Float64(a + b))) * Float64(1.0 / Float64(b * a))) end
function tmp = code(a, b) tmp = (pi / (2.0 * (a + b))) * (1.0 / (b * a)); end
code[a_, b_] := N[(N[(Pi / N[(2.0 * N[(a + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\pi}{2 \cdot \left(a + b\right)} \cdot \frac{1}{b \cdot a}
\end{array}
Initial program 77.7%
lift-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r/N/A
difference-of-squaresN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f6487.9
Applied rewrites87.9%
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
lift-/.f64N/A
lift-/.f64N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites99.6%
Taylor expanded in a around 0
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6499.6
Applied rewrites99.6%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
lower-/.f64N/A
lift-*.f6499.6
Applied rewrites99.6%
(FPCore (a b) :precision binary64 (if (or (<= b -1.85e+17) (not (<= b 7e-14))) (* (/ PI (* b (* b a))) 0.5) (/ (/ (* (/ PI b) 0.5) a) a)))
double code(double a, double b) {
double tmp;
if ((b <= -1.85e+17) || !(b <= 7e-14)) {
tmp = (((double) M_PI) / (b * (b * a))) * 0.5;
} else {
tmp = (((((double) M_PI) / b) * 0.5) / a) / a;
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if ((b <= -1.85e+17) || !(b <= 7e-14)) {
tmp = (Math.PI / (b * (b * a))) * 0.5;
} else {
tmp = (((Math.PI / b) * 0.5) / a) / a;
}
return tmp;
}
def code(a, b): tmp = 0 if (b <= -1.85e+17) or not (b <= 7e-14): tmp = (math.pi / (b * (b * a))) * 0.5 else: tmp = (((math.pi / b) * 0.5) / a) / a return tmp
function code(a, b) tmp = 0.0 if ((b <= -1.85e+17) || !(b <= 7e-14)) tmp = Float64(Float64(pi / Float64(b * Float64(b * a))) * 0.5); else tmp = Float64(Float64(Float64(Float64(pi / b) * 0.5) / a) / a); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b <= -1.85e+17) || ~((b <= 7e-14))) tmp = (pi / (b * (b * a))) * 0.5; else tmp = (((pi / b) * 0.5) / a) / a; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[b, -1.85e+17], N[Not[LessEqual[b, 7e-14]], $MachinePrecision]], N[(N[(Pi / N[(b * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(Pi / b), $MachinePrecision] * 0.5), $MachinePrecision] / a), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.85 \cdot 10^{+17} \lor \neg \left(b \leq 7 \cdot 10^{-14}\right):\\
\;\;\;\;\frac{\pi}{b \cdot \left(b \cdot a\right)} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{\pi}{b} \cdot 0.5}{a}}{a}\\
\end{array}
\end{array}
if b < -1.85e17 or 7.0000000000000005e-14 < b Initial program 74.9%
lift-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r/N/A
difference-of-squaresN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f6488.4
Applied rewrites88.4%
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
lift-/.f64N/A
lift-/.f64N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites99.6%
Taylor expanded in a around 0
associate-/r*N/A
+-commutativeN/A
inv-powN/A
inv-powN/A
inv-powN/A
associate-*l*N/A
frac-subN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6479.1
Applied rewrites79.1%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f6490.5
Applied rewrites90.5%
if -1.85e17 < b < 7.0000000000000005e-14Initial program 80.4%
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-*.f6462.6
Applied rewrites62.6%
lift-/.f64N/A
lift-fma.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites75.4%
Taylor expanded in a around inf
*-commutativeN/A
lift-/.f64N/A
lift-PI.f64N/A
lift-*.f6483.5
Applied rewrites83.5%
Final simplification86.9%
(FPCore (a b) :precision binary64 (if (or (<= b -1.85e+17) (not (<= b 7e-14))) (* (/ PI (* b (* b a))) 0.5) (/ (* (/ (/ PI a) b) 0.5) a)))
double code(double a, double b) {
double tmp;
if ((b <= -1.85e+17) || !(b <= 7e-14)) {
tmp = (((double) M_PI) / (b * (b * a))) * 0.5;
} else {
tmp = (((((double) M_PI) / a) / b) * 0.5) / a;
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if ((b <= -1.85e+17) || !(b <= 7e-14)) {
tmp = (Math.PI / (b * (b * a))) * 0.5;
} else {
tmp = (((Math.PI / a) / b) * 0.5) / a;
}
return tmp;
}
def code(a, b): tmp = 0 if (b <= -1.85e+17) or not (b <= 7e-14): tmp = (math.pi / (b * (b * a))) * 0.5 else: tmp = (((math.pi / a) / b) * 0.5) / a return tmp
function code(a, b) tmp = 0.0 if ((b <= -1.85e+17) || !(b <= 7e-14)) tmp = Float64(Float64(pi / Float64(b * Float64(b * a))) * 0.5); else tmp = Float64(Float64(Float64(Float64(pi / a) / b) * 0.5) / a); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b <= -1.85e+17) || ~((b <= 7e-14))) tmp = (pi / (b * (b * a))) * 0.5; else tmp = (((pi / a) / b) * 0.5) / a; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[b, -1.85e+17], N[Not[LessEqual[b, 7e-14]], $MachinePrecision]], N[(N[(Pi / N[(b * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(Pi / a), $MachinePrecision] / b), $MachinePrecision] * 0.5), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.85 \cdot 10^{+17} \lor \neg \left(b \leq 7 \cdot 10^{-14}\right):\\
\;\;\;\;\frac{\pi}{b \cdot \left(b \cdot a\right)} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{\pi}{a}}{b} \cdot 0.5}{a}\\
\end{array}
\end{array}
if b < -1.85e17 or 7.0000000000000005e-14 < b Initial program 74.9%
lift-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r/N/A
difference-of-squaresN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f6488.4
Applied rewrites88.4%
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
lift-/.f64N/A
lift-/.f64N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites99.6%
Taylor expanded in a around 0
associate-/r*N/A
+-commutativeN/A
inv-powN/A
inv-powN/A
inv-powN/A
associate-*l*N/A
frac-subN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6479.1
Applied rewrites79.1%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f6490.5
Applied rewrites90.5%
if -1.85e17 < b < 7.0000000000000005e-14Initial program 80.4%
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-*.f6462.6
Applied rewrites62.6%
lift-/.f64N/A
lift-fma.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites75.4%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-/.f64N/A
lift-PI.f6483.5
Applied rewrites83.5%
Final simplification87.0%
(FPCore (a b) :precision binary64 (if (or (<= b -1.85e+17) (not (<= b 7e-14))) (* (/ PI (* b (* b a))) 0.5) (* (/ (/ PI a) (* b a)) 0.5)))
double code(double a, double b) {
double tmp;
if ((b <= -1.85e+17) || !(b <= 7e-14)) {
tmp = (((double) M_PI) / (b * (b * a))) * 0.5;
} else {
tmp = ((((double) M_PI) / a) / (b * a)) * 0.5;
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if ((b <= -1.85e+17) || !(b <= 7e-14)) {
tmp = (Math.PI / (b * (b * a))) * 0.5;
} else {
tmp = ((Math.PI / a) / (b * a)) * 0.5;
}
return tmp;
}
def code(a, b): tmp = 0 if (b <= -1.85e+17) or not (b <= 7e-14): tmp = (math.pi / (b * (b * a))) * 0.5 else: tmp = ((math.pi / a) / (b * a)) * 0.5 return tmp
function code(a, b) tmp = 0.0 if ((b <= -1.85e+17) || !(b <= 7e-14)) tmp = Float64(Float64(pi / Float64(b * Float64(b * a))) * 0.5); else tmp = Float64(Float64(Float64(pi / a) / Float64(b * a)) * 0.5); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b <= -1.85e+17) || ~((b <= 7e-14))) tmp = (pi / (b * (b * a))) * 0.5; else tmp = ((pi / a) / (b * a)) * 0.5; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[b, -1.85e+17], N[Not[LessEqual[b, 7e-14]], $MachinePrecision]], N[(N[(Pi / N[(b * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(Pi / a), $MachinePrecision] / N[(b * a), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.85 \cdot 10^{+17} \lor \neg \left(b \leq 7 \cdot 10^{-14}\right):\\
\;\;\;\;\frac{\pi}{b \cdot \left(b \cdot a\right)} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\pi}{a}}{b \cdot a} \cdot 0.5\\
\end{array}
\end{array}
if b < -1.85e17 or 7.0000000000000005e-14 < b Initial program 74.9%
lift-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r/N/A
difference-of-squaresN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f6488.4
Applied rewrites88.4%
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
lift-/.f64N/A
lift-/.f64N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites99.6%
Taylor expanded in a around 0
associate-/r*N/A
+-commutativeN/A
inv-powN/A
inv-powN/A
inv-powN/A
associate-*l*N/A
frac-subN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6479.1
Applied rewrites79.1%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f6490.5
Applied rewrites90.5%
if -1.85e17 < b < 7.0000000000000005e-14Initial program 80.4%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6470.7
Applied rewrites70.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6483.0
Applied rewrites83.0%
lift-PI.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f6483.5
Applied rewrites83.5%
Final simplification86.9%
(FPCore (a b) :precision binary64 (if (or (<= b -1.85e+17) (not (<= b 7e-14))) (* (/ PI (* b (* b a))) 0.5) (* (/ PI (* a (* a b))) 0.5)))
double code(double a, double b) {
double tmp;
if ((b <= -1.85e+17) || !(b <= 7e-14)) {
tmp = (((double) M_PI) / (b * (b * a))) * 0.5;
} else {
tmp = (((double) M_PI) / (a * (a * b))) * 0.5;
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if ((b <= -1.85e+17) || !(b <= 7e-14)) {
tmp = (Math.PI / (b * (b * a))) * 0.5;
} else {
tmp = (Math.PI / (a * (a * b))) * 0.5;
}
return tmp;
}
def code(a, b): tmp = 0 if (b <= -1.85e+17) or not (b <= 7e-14): tmp = (math.pi / (b * (b * a))) * 0.5 else: tmp = (math.pi / (a * (a * b))) * 0.5 return tmp
function code(a, b) tmp = 0.0 if ((b <= -1.85e+17) || !(b <= 7e-14)) tmp = Float64(Float64(pi / Float64(b * Float64(b * a))) * 0.5); else tmp = Float64(Float64(pi / Float64(a * Float64(a * b))) * 0.5); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b <= -1.85e+17) || ~((b <= 7e-14))) tmp = (pi / (b * (b * a))) * 0.5; else tmp = (pi / (a * (a * b))) * 0.5; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[b, -1.85e+17], N[Not[LessEqual[b, 7e-14]], $MachinePrecision]], N[(N[(Pi / N[(b * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(Pi / N[(a * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.85 \cdot 10^{+17} \lor \neg \left(b \leq 7 \cdot 10^{-14}\right):\\
\;\;\;\;\frac{\pi}{b \cdot \left(b \cdot a\right)} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi}{a \cdot \left(a \cdot b\right)} \cdot 0.5\\
\end{array}
\end{array}
if b < -1.85e17 or 7.0000000000000005e-14 < b Initial program 74.9%
lift-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r/N/A
difference-of-squaresN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f6488.4
Applied rewrites88.4%
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
lift-/.f64N/A
lift-/.f64N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites99.6%
Taylor expanded in a around 0
associate-/r*N/A
+-commutativeN/A
inv-powN/A
inv-powN/A
inv-powN/A
associate-*l*N/A
frac-subN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6479.1
Applied rewrites79.1%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f6490.5
Applied rewrites90.5%
if -1.85e17 < b < 7.0000000000000005e-14Initial program 80.4%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6470.7
Applied rewrites70.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6483.0
Applied rewrites83.0%
Final simplification86.7%
(FPCore (a b) :precision binary64 (if (or (<= b -1.85e+17) (not (<= b 7e-14))) (* (/ PI (* (* b b) a)) 0.5) (* (/ PI (* a (* a b))) 0.5)))
double code(double a, double b) {
double tmp;
if ((b <= -1.85e+17) || !(b <= 7e-14)) {
tmp = (((double) M_PI) / ((b * b) * a)) * 0.5;
} else {
tmp = (((double) M_PI) / (a * (a * b))) * 0.5;
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if ((b <= -1.85e+17) || !(b <= 7e-14)) {
tmp = (Math.PI / ((b * b) * a)) * 0.5;
} else {
tmp = (Math.PI / (a * (a * b))) * 0.5;
}
return tmp;
}
def code(a, b): tmp = 0 if (b <= -1.85e+17) or not (b <= 7e-14): tmp = (math.pi / ((b * b) * a)) * 0.5 else: tmp = (math.pi / (a * (a * b))) * 0.5 return tmp
function code(a, b) tmp = 0.0 if ((b <= -1.85e+17) || !(b <= 7e-14)) tmp = Float64(Float64(pi / Float64(Float64(b * b) * a)) * 0.5); else tmp = Float64(Float64(pi / Float64(a * Float64(a * b))) * 0.5); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b <= -1.85e+17) || ~((b <= 7e-14))) tmp = (pi / ((b * b) * a)) * 0.5; else tmp = (pi / (a * (a * b))) * 0.5; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[b, -1.85e+17], N[Not[LessEqual[b, 7e-14]], $MachinePrecision]], N[(N[(Pi / N[(N[(b * b), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(Pi / N[(a * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.85 \cdot 10^{+17} \lor \neg \left(b \leq 7 \cdot 10^{-14}\right):\\
\;\;\;\;\frac{\pi}{\left(b \cdot b\right) \cdot a} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi}{a \cdot \left(a \cdot b\right)} \cdot 0.5\\
\end{array}
\end{array}
if b < -1.85e17 or 7.0000000000000005e-14 < b Initial program 74.9%
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-*.f6479.1
Applied rewrites79.1%
if -1.85e17 < b < 7.0000000000000005e-14Initial program 80.4%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6470.7
Applied rewrites70.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6483.0
Applied rewrites83.0%
Final simplification81.0%
(FPCore (a b) :precision binary64 (* (/ PI (* a (* a b))) 0.5))
double code(double a, double b) {
return (((double) M_PI) / (a * (a * b))) * 0.5;
}
public static double code(double a, double b) {
return (Math.PI / (a * (a * b))) * 0.5;
}
def code(a, b): return (math.pi / (a * (a * b))) * 0.5
function code(a, b) return Float64(Float64(pi / Float64(a * Float64(a * b))) * 0.5) end
function tmp = code(a, b) tmp = (pi / (a * (a * b))) * 0.5; end
code[a_, b_] := N[(N[(Pi / N[(a * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
\\
\frac{\pi}{a \cdot \left(a \cdot b\right)} \cdot 0.5
\end{array}
Initial program 77.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-*.f6457.0
Applied rewrites57.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6463.3
Applied rewrites63.3%
Final simplification63.3%
herbie shell --seed 2025086
(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))))