
(FPCore (a b) :precision binary64 (* (* (/ PI 2.0) (/ 1.0 (- (* b b) (* a a)))) (- (/ 1.0 a) (/ 1.0 b))))
double code(double a, double b) {
return ((((double) M_PI) / 2.0) * (1.0 / ((b * b) - (a * a)))) * ((1.0 / a) - (1.0 / b));
}
public static double code(double a, double b) {
return ((Math.PI / 2.0) * (1.0 / ((b * b) - (a * a)))) * ((1.0 / a) - (1.0 / b));
}
def code(a, b): return ((math.pi / 2.0) * (1.0 / ((b * b) - (a * a)))) * ((1.0 / a) - (1.0 / b))
function code(a, b) return Float64(Float64(Float64(pi / 2.0) * Float64(1.0 / Float64(Float64(b * b) - Float64(a * a)))) * Float64(Float64(1.0 / a) - Float64(1.0 / b))) end
function tmp = code(a, b) tmp = ((pi / 2.0) * (1.0 / ((b * b) - (a * a)))) * ((1.0 / a) - (1.0 / b)); end
code[a_, b_] := N[(N[(N[(Pi / 2.0), $MachinePrecision] * N[(1.0 / N[(N[(b * b), $MachinePrecision] - N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / a), $MachinePrecision] - N[(1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 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 a) (/ PI b)) (* 2.0 (+ a b))) (- b a)))
double code(double a, double b) {
return (((((double) M_PI) / a) - (((double) M_PI) / b)) / (2.0 * (a + b))) / (b - a);
}
public static double code(double a, double b) {
return (((Math.PI / a) - (Math.PI / b)) / (2.0 * (a + b))) / (b - a);
}
def code(a, b): return (((math.pi / a) - (math.pi / b)) / (2.0 * (a + b))) / (b - a)
function code(a, b) return Float64(Float64(Float64(Float64(pi / a) - Float64(pi / b)) / Float64(2.0 * Float64(a + b))) / Float64(b - a)) end
function tmp = code(a, b) tmp = (((pi / a) - (pi / b)) / (2.0 * (a + b))) / (b - a); end
code[a_, b_] := N[(N[(N[(N[(Pi / a), $MachinePrecision] - N[(Pi / b), $MachinePrecision]), $MachinePrecision] / N[(2.0 * N[(a + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(b - a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\frac{\pi}{a} - \frac{\pi}{b}}{2 \cdot \left(a + b\right)}}{b - a}
\end{array}
Initial program 73.3%
associate-*r/73.3%
*-rgt-identity73.3%
difference-of-squares87.4%
associate-/r*88.0%
associate-*l/99.7%
*-commutative99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
associate-/l/99.7%
Simplified99.7%
associate-*r/99.7%
*-commutative99.7%
Applied egg-rr99.7%
Taylor expanded in a around 0 99.7%
associate-*r/99.7%
associate-*l/99.7%
+-commutative99.7%
associate-*l/99.7%
associate-*r/99.7%
mul-1-neg99.7%
unsub-neg99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (a b) :precision binary64 (if (<= a -8.5e-141) (* (/ PI (* a b)) (/ -0.5 (- b a))) (* (/ 1.0 (* a b)) (* PI (/ 0.5 b)))))
double code(double a, double b) {
double tmp;
if (a <= -8.5e-141) {
tmp = (((double) M_PI) / (a * b)) * (-0.5 / (b - a));
} else {
tmp = (1.0 / (a * b)) * (((double) M_PI) * (0.5 / b));
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (a <= -8.5e-141) {
tmp = (Math.PI / (a * b)) * (-0.5 / (b - a));
} else {
tmp = (1.0 / (a * b)) * (Math.PI * (0.5 / b));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -8.5e-141: tmp = (math.pi / (a * b)) * (-0.5 / (b - a)) else: tmp = (1.0 / (a * b)) * (math.pi * (0.5 / b)) return tmp
function code(a, b) tmp = 0.0 if (a <= -8.5e-141) tmp = Float64(Float64(pi / Float64(a * b)) * Float64(-0.5 / Float64(b - a))); else tmp = Float64(Float64(1.0 / Float64(a * b)) * Float64(pi * Float64(0.5 / b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -8.5e-141) tmp = (pi / (a * b)) * (-0.5 / (b - a)); else tmp = (1.0 / (a * b)) * (pi * (0.5 / b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -8.5e-141], N[(N[(Pi / N[(a * b), $MachinePrecision]), $MachinePrecision] * N[(-0.5 / N[(b - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(a * b), $MachinePrecision]), $MachinePrecision] * N[(Pi * N[(0.5 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -8.5 \cdot 10^{-141}:\\
\;\;\;\;\frac{\pi}{a \cdot b} \cdot \frac{-0.5}{b - a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{a \cdot b} \cdot \left(\pi \cdot \frac{0.5}{b}\right)\\
\end{array}
\end{array}
if a < -8.50000000000000021e-141Initial program 82.1%
associate-*r/82.2%
*-rgt-identity82.2%
difference-of-squares92.5%
associate-/r*93.2%
associate-*l/99.6%
*-commutative99.6%
sub-neg99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
associate-/l/99.6%
Simplified99.6%
Taylor expanded in a around inf 81.2%
*-commutative81.2%
associate-/r*81.2%
Simplified81.2%
*-un-lft-identity81.2%
associate-/l*81.2%
associate-/l/81.2%
Applied egg-rr81.2%
*-lft-identity81.2%
associate-/r/81.1%
Simplified81.1%
if -8.50000000000000021e-141 < a Initial program 69.4%
associate-*r/69.4%
*-rgt-identity69.4%
difference-of-squares85.1%
associate-/r*85.7%
associate-*l/99.7%
*-commutative99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
associate-/l/99.7%
Simplified99.7%
*-un-lft-identity99.7%
associate-/l*85.2%
*-commutative85.2%
Applied egg-rr85.2%
*-lft-identity85.2%
associate-/r/99.7%
*-rgt-identity99.7%
associate-*r/99.6%
associate-/r*99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in a around 0 99.7%
Taylor expanded in a around 0 77.5%
Final simplification78.6%
(FPCore (a b) :precision binary64 (if (<= a -8.5e-141) (* (/ PI (* a b)) (/ -0.5 (- b a))) (* (/ 1.0 (* a b)) (/ (* PI 0.5) b))))
double code(double a, double b) {
double tmp;
if (a <= -8.5e-141) {
tmp = (((double) M_PI) / (a * b)) * (-0.5 / (b - a));
} else {
tmp = (1.0 / (a * b)) * ((((double) M_PI) * 0.5) / b);
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (a <= -8.5e-141) {
tmp = (Math.PI / (a * b)) * (-0.5 / (b - a));
} else {
tmp = (1.0 / (a * b)) * ((Math.PI * 0.5) / b);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -8.5e-141: tmp = (math.pi / (a * b)) * (-0.5 / (b - a)) else: tmp = (1.0 / (a * b)) * ((math.pi * 0.5) / b) return tmp
function code(a, b) tmp = 0.0 if (a <= -8.5e-141) tmp = Float64(Float64(pi / Float64(a * b)) * Float64(-0.5 / Float64(b - a))); else tmp = Float64(Float64(1.0 / Float64(a * b)) * Float64(Float64(pi * 0.5) / b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -8.5e-141) tmp = (pi / (a * b)) * (-0.5 / (b - a)); else tmp = (1.0 / (a * b)) * ((pi * 0.5) / b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -8.5e-141], N[(N[(Pi / N[(a * b), $MachinePrecision]), $MachinePrecision] * N[(-0.5 / N[(b - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(a * b), $MachinePrecision]), $MachinePrecision] * N[(N[(Pi * 0.5), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -8.5 \cdot 10^{-141}:\\
\;\;\;\;\frac{\pi}{a \cdot b} \cdot \frac{-0.5}{b - a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{a \cdot b} \cdot \frac{\pi \cdot 0.5}{b}\\
\end{array}
\end{array}
if a < -8.50000000000000021e-141Initial program 82.1%
associate-*r/82.2%
*-rgt-identity82.2%
difference-of-squares92.5%
associate-/r*93.2%
associate-*l/99.6%
*-commutative99.6%
sub-neg99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
associate-/l/99.6%
Simplified99.6%
Taylor expanded in a around inf 81.2%
*-commutative81.2%
associate-/r*81.2%
Simplified81.2%
*-un-lft-identity81.2%
associate-/l*81.2%
associate-/l/81.2%
Applied egg-rr81.2%
*-lft-identity81.2%
associate-/r/81.1%
Simplified81.1%
if -8.50000000000000021e-141 < a Initial program 69.4%
associate-*r/69.4%
*-rgt-identity69.4%
difference-of-squares85.1%
associate-/r*85.7%
associate-*l/99.7%
*-commutative99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
associate-/l/99.7%
Simplified99.7%
*-un-lft-identity99.7%
associate-/l*85.2%
*-commutative85.2%
Applied egg-rr85.2%
*-lft-identity85.2%
associate-/r/99.7%
*-rgt-identity99.7%
associate-*r/99.6%
associate-/r*99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in a around 0 99.7%
Taylor expanded in a around 0 77.6%
associate-*r/77.6%
Simplified77.6%
Final simplification78.7%
(FPCore (a b) :precision binary64 (if (<= b 2e+88) (* (/ PI a) (/ 0.5 (* b (+ a b)))) (* (/ 1.0 (* a b)) (/ (* PI 0.5) b))))
double code(double a, double b) {
double tmp;
if (b <= 2e+88) {
tmp = (((double) M_PI) / a) * (0.5 / (b * (a + b)));
} else {
tmp = (1.0 / (a * b)) * ((((double) M_PI) * 0.5) / b);
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (b <= 2e+88) {
tmp = (Math.PI / a) * (0.5 / (b * (a + b)));
} else {
tmp = (1.0 / (a * b)) * ((Math.PI * 0.5) / b);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 2e+88: tmp = (math.pi / a) * (0.5 / (b * (a + b))) else: tmp = (1.0 / (a * b)) * ((math.pi * 0.5) / b) return tmp
function code(a, b) tmp = 0.0 if (b <= 2e+88) tmp = Float64(Float64(pi / a) * Float64(0.5 / Float64(b * Float64(a + b)))); else tmp = Float64(Float64(1.0 / Float64(a * b)) * Float64(Float64(pi * 0.5) / b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 2e+88) tmp = (pi / a) * (0.5 / (b * (a + b))); else tmp = (1.0 / (a * b)) * ((pi * 0.5) / b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 2e+88], N[(N[(Pi / a), $MachinePrecision] * N[(0.5 / N[(b * N[(a + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(a * b), $MachinePrecision]), $MachinePrecision] * N[(N[(Pi * 0.5), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2 \cdot 10^{+88}:\\
\;\;\;\;\frac{\pi}{a} \cdot \frac{0.5}{b \cdot \left(a + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{a \cdot b} \cdot \frac{\pi \cdot 0.5}{b}\\
\end{array}
\end{array}
if b < 1.99999999999999992e88Initial program 75.6%
associate-*r/75.6%
*-rgt-identity75.6%
difference-of-squares88.7%
associate-/r*89.2%
associate-*l/99.7%
*-commutative99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
associate-/l/99.7%
Simplified99.7%
*-un-lft-identity99.7%
associate-/l*88.8%
*-commutative88.8%
Applied egg-rr88.8%
*-lft-identity88.8%
associate-/r/99.7%
*-rgt-identity99.7%
associate-*r/99.6%
associate-/r*99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in a around 0 99.6%
associate-*l/99.6%
*-un-lft-identity99.6%
Applied egg-rr99.6%
times-frac93.6%
associate-/l/93.4%
Simplified93.4%
if 1.99999999999999992e88 < b Initial program 63.7%
associate-*r/63.7%
*-rgt-identity63.7%
difference-of-squares81.7%
associate-/r*82.8%
associate-*l/99.6%
*-commutative99.6%
sub-neg99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
associate-/l/99.6%
Simplified99.6%
*-un-lft-identity99.6%
associate-/l*81.6%
*-commutative81.6%
Applied egg-rr81.6%
*-lft-identity81.6%
associate-/r/99.7%
*-rgt-identity99.7%
associate-*r/99.6%
associate-/r*99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in a around 0 99.8%
Taylor expanded in a around 0 99.8%
associate-*r/99.8%
Simplified99.8%
Final simplification94.6%
(FPCore (a b) :precision binary64 (if (<= b 1e+126) (* (/ PI a) (/ 0.5 (* b (+ a b)))) (/ (* 0.5 (/ PI (* a b))) (- b a))))
double code(double a, double b) {
double tmp;
if (b <= 1e+126) {
tmp = (((double) M_PI) / a) * (0.5 / (b * (a + b)));
} else {
tmp = (0.5 * (((double) M_PI) / (a * b))) / (b - a);
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (b <= 1e+126) {
tmp = (Math.PI / a) * (0.5 / (b * (a + b)));
} else {
tmp = (0.5 * (Math.PI / (a * b))) / (b - a);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 1e+126: tmp = (math.pi / a) * (0.5 / (b * (a + b))) else: tmp = (0.5 * (math.pi / (a * b))) / (b - a) return tmp
function code(a, b) tmp = 0.0 if (b <= 1e+126) tmp = Float64(Float64(pi / a) * Float64(0.5 / Float64(b * Float64(a + b)))); else tmp = Float64(Float64(0.5 * Float64(pi / Float64(a * b))) / Float64(b - a)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 1e+126) tmp = (pi / a) * (0.5 / (b * (a + b))); else tmp = (0.5 * (pi / (a * b))) / (b - a); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 1e+126], N[(N[(Pi / a), $MachinePrecision] * N[(0.5 / N[(b * N[(a + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(Pi / N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(b - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 10^{+126}:\\
\;\;\;\;\frac{\pi}{a} \cdot \frac{0.5}{b \cdot \left(a + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5 \cdot \frac{\pi}{a \cdot b}}{b - a}\\
\end{array}
\end{array}
if b < 9.99999999999999925e125Initial program 77.0%
associate-*r/77.1%
*-rgt-identity77.1%
difference-of-squares89.4%
associate-/r*89.9%
associate-*l/99.7%
*-commutative99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
associate-/l/99.7%
Simplified99.7%
*-un-lft-identity99.7%
associate-/l*89.5%
*-commutative89.5%
Applied egg-rr89.5%
*-lft-identity89.5%
associate-/r/99.7%
*-rgt-identity99.7%
associate-*r/99.6%
associate-/r*99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in a around 0 99.6%
associate-*l/99.6%
*-un-lft-identity99.6%
Applied egg-rr99.6%
times-frac93.9%
associate-/l/93.8%
Simplified93.8%
if 9.99999999999999925e125 < b Initial program 51.0%
associate-*r/51.0%
*-rgt-identity51.0%
difference-of-squares75.3%
associate-/r*76.8%
associate-*l/99.7%
*-commutative99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
associate-/l/99.7%
Simplified99.7%
Taylor expanded in a around 0 99.8%
Final simplification94.7%
(FPCore (a b) :precision binary64 (if (<= b 1.92e+93) (* (/ PI a) (/ 0.5 (* b (+ a b)))) (/ (* 0.5 (/ (/ PI a) b)) (- b a))))
double code(double a, double b) {
double tmp;
if (b <= 1.92e+93) {
tmp = (((double) M_PI) / a) * (0.5 / (b * (a + b)));
} else {
tmp = (0.5 * ((((double) M_PI) / a) / b)) / (b - a);
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (b <= 1.92e+93) {
tmp = (Math.PI / a) * (0.5 / (b * (a + b)));
} else {
tmp = (0.5 * ((Math.PI / a) / b)) / (b - a);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 1.92e+93: tmp = (math.pi / a) * (0.5 / (b * (a + b))) else: tmp = (0.5 * ((math.pi / a) / b)) / (b - a) return tmp
function code(a, b) tmp = 0.0 if (b <= 1.92e+93) tmp = Float64(Float64(pi / a) * Float64(0.5 / Float64(b * Float64(a + b)))); else tmp = Float64(Float64(0.5 * Float64(Float64(pi / a) / b)) / Float64(b - a)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 1.92e+93) tmp = (pi / a) * (0.5 / (b * (a + b))); else tmp = (0.5 * ((pi / a) / b)) / (b - a); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 1.92e+93], N[(N[(Pi / a), $MachinePrecision] * N[(0.5 / N[(b * N[(a + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(N[(Pi / a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] / N[(b - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.92 \cdot 10^{+93}:\\
\;\;\;\;\frac{\pi}{a} \cdot \frac{0.5}{b \cdot \left(a + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5 \cdot \frac{\frac{\pi}{a}}{b}}{b - a}\\
\end{array}
\end{array}
if b < 1.92000000000000004e93Initial program 75.6%
associate-*r/75.6%
*-rgt-identity75.6%
difference-of-squares88.7%
associate-/r*89.2%
associate-*l/99.7%
*-commutative99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
associate-/l/99.7%
Simplified99.7%
*-un-lft-identity99.7%
associate-/l*88.8%
*-commutative88.8%
Applied egg-rr88.8%
*-lft-identity88.8%
associate-/r/99.7%
*-rgt-identity99.7%
associate-*r/99.6%
associate-/r*99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in a around 0 99.6%
associate-*l/99.6%
*-un-lft-identity99.6%
Applied egg-rr99.6%
times-frac93.6%
associate-/l/93.4%
Simplified93.4%
if 1.92000000000000004e93 < b Initial program 63.7%
associate-*r/63.7%
*-rgt-identity63.7%
difference-of-squares81.7%
associate-/r*82.8%
associate-*l/99.6%
*-commutative99.6%
sub-neg99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
associate-/l/99.6%
Simplified99.6%
associate-*r/99.7%
*-commutative99.7%
Applied egg-rr99.7%
Taylor expanded in a around 0 99.8%
associate-*r/99.8%
associate-*l/99.8%
+-commutative99.8%
associate-*l/99.8%
associate-*r/99.8%
mul-1-neg99.8%
unsub-neg99.8%
Simplified99.8%
Taylor expanded in a around 0 99.8%
associate-/r*99.8%
Simplified99.8%
Final simplification94.7%
(FPCore (a b) :precision binary64 (let* ((t_0 (/ PI (* a b)))) (if (<= b 1.16e+120) (* t_0 (/ 0.5 a)) (* t_0 (/ -0.5 b)))))
double code(double a, double b) {
double t_0 = ((double) M_PI) / (a * b);
double tmp;
if (b <= 1.16e+120) {
tmp = t_0 * (0.5 / a);
} else {
tmp = t_0 * (-0.5 / b);
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = Math.PI / (a * b);
double tmp;
if (b <= 1.16e+120) {
tmp = t_0 * (0.5 / a);
} else {
tmp = t_0 * (-0.5 / b);
}
return tmp;
}
def code(a, b): t_0 = math.pi / (a * b) tmp = 0 if b <= 1.16e+120: tmp = t_0 * (0.5 / a) else: tmp = t_0 * (-0.5 / b) return tmp
function code(a, b) t_0 = Float64(pi / Float64(a * b)) tmp = 0.0 if (b <= 1.16e+120) tmp = Float64(t_0 * Float64(0.5 / a)); else tmp = Float64(t_0 * Float64(-0.5 / b)); end return tmp end
function tmp_2 = code(a, b) t_0 = pi / (a * b); tmp = 0.0; if (b <= 1.16e+120) tmp = t_0 * (0.5 / a); else tmp = t_0 * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(Pi / N[(a * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 1.16e+120], N[(t$95$0 * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\pi}{a \cdot b}\\
\mathbf{if}\;b \leq 1.16 \cdot 10^{+120}:\\
\;\;\;\;t\_0 \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < 1.16000000000000003e120Initial program 76.8%
associate-*r/76.9%
*-rgt-identity76.9%
difference-of-squares89.3%
associate-/r*89.8%
associate-*l/99.7%
*-commutative99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
associate-/l/99.7%
Simplified99.7%
Taylor expanded in a around inf 64.5%
*-commutative64.5%
associate-/r*64.5%
Simplified64.5%
*-un-lft-identity64.5%
associate-/l*64.3%
associate-/l/64.3%
Applied egg-rr64.3%
*-lft-identity64.3%
associate-/r/64.5%
Simplified64.5%
Taylor expanded in b around 0 62.6%
if 1.16000000000000003e120 < b Initial program 53.5%
associate-*r/53.5%
*-rgt-identity53.5%
difference-of-squares76.5%
associate-/r*78.0%
associate-*l/99.7%
*-commutative99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
associate-/l/99.7%
Simplified99.7%
Taylor expanded in a around inf 63.7%
*-commutative63.7%
associate-/r*63.7%
Simplified63.7%
*-un-lft-identity63.7%
associate-/l*63.7%
associate-/l/63.7%
Applied egg-rr63.7%
*-lft-identity63.7%
associate-/r/63.7%
Simplified63.7%
Taylor expanded in b around inf 63.7%
Final simplification62.8%
(FPCore (a b) :precision binary64 (if (<= b 1.16e+120) (* (/ PI (* a b)) (/ 0.5 a)) (/ -0.5 (* b (* a (/ b PI))))))
double code(double a, double b) {
double tmp;
if (b <= 1.16e+120) {
tmp = (((double) M_PI) / (a * b)) * (0.5 / a);
} else {
tmp = -0.5 / (b * (a * (b / ((double) M_PI))));
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (b <= 1.16e+120) {
tmp = (Math.PI / (a * b)) * (0.5 / a);
} else {
tmp = -0.5 / (b * (a * (b / Math.PI)));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 1.16e+120: tmp = (math.pi / (a * b)) * (0.5 / a) else: tmp = -0.5 / (b * (a * (b / math.pi))) return tmp
function code(a, b) tmp = 0.0 if (b <= 1.16e+120) tmp = Float64(Float64(pi / Float64(a * b)) * Float64(0.5 / a)); else tmp = Float64(-0.5 / Float64(b * Float64(a * Float64(b / pi)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 1.16e+120) tmp = (pi / (a * b)) * (0.5 / a); else tmp = -0.5 / (b * (a * (b / pi))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 1.16e+120], N[(N[(Pi / N[(a * b), $MachinePrecision]), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 / N[(b * N[(a * N[(b / Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.16 \cdot 10^{+120}:\\
\;\;\;\;\frac{\pi}{a \cdot b} \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{b \cdot \left(a \cdot \frac{b}{\pi}\right)}\\
\end{array}
\end{array}
if b < 1.16000000000000003e120Initial program 76.8%
associate-*r/76.9%
*-rgt-identity76.9%
difference-of-squares89.3%
associate-/r*89.8%
associate-*l/99.7%
*-commutative99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
associate-/l/99.7%
Simplified99.7%
Taylor expanded in a around inf 64.5%
*-commutative64.5%
associate-/r*64.5%
Simplified64.5%
*-un-lft-identity64.5%
associate-/l*64.3%
associate-/l/64.3%
Applied egg-rr64.3%
*-lft-identity64.3%
associate-/r/64.5%
Simplified64.5%
Taylor expanded in b around 0 62.6%
if 1.16000000000000003e120 < b Initial program 53.5%
associate-*r/53.5%
*-rgt-identity53.5%
difference-of-squares76.5%
associate-/r*78.0%
associate-*l/99.7%
*-commutative99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
associate-/l/99.7%
Simplified99.7%
Taylor expanded in a around inf 63.7%
*-commutative63.7%
associate-/r*63.7%
Simplified63.7%
*-un-lft-identity63.7%
associate-/l*63.7%
associate-/l/63.7%
Applied egg-rr63.7%
*-lft-identity63.7%
associate-/r/63.7%
Simplified63.7%
Taylor expanded in b around inf 63.7%
*-commutative63.7%
clear-num63.7%
associate-*r/63.7%
frac-times63.7%
metadata-eval63.7%
Applied egg-rr63.7%
Final simplification62.8%
(FPCore (a b) :precision binary64 (if (<= b 1.35e+120) (* (/ PI (* a b)) (/ 0.5 a)) (/ (/ PI a) (* b (/ b -0.5)))))
double code(double a, double b) {
double tmp;
if (b <= 1.35e+120) {
tmp = (((double) M_PI) / (a * b)) * (0.5 / a);
} else {
tmp = (((double) M_PI) / a) / (b * (b / -0.5));
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (b <= 1.35e+120) {
tmp = (Math.PI / (a * b)) * (0.5 / a);
} else {
tmp = (Math.PI / a) / (b * (b / -0.5));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 1.35e+120: tmp = (math.pi / (a * b)) * (0.5 / a) else: tmp = (math.pi / a) / (b * (b / -0.5)) return tmp
function code(a, b) tmp = 0.0 if (b <= 1.35e+120) tmp = Float64(Float64(pi / Float64(a * b)) * Float64(0.5 / a)); else tmp = Float64(Float64(pi / a) / Float64(b * Float64(b / -0.5))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 1.35e+120) tmp = (pi / (a * b)) * (0.5 / a); else tmp = (pi / a) / (b * (b / -0.5)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 1.35e+120], N[(N[(Pi / N[(a * b), $MachinePrecision]), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], N[(N[(Pi / a), $MachinePrecision] / N[(b * N[(b / -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.35 \cdot 10^{+120}:\\
\;\;\;\;\frac{\pi}{a \cdot b} \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\pi}{a}}{b \cdot \frac{b}{-0.5}}\\
\end{array}
\end{array}
if b < 1.35e120Initial program 76.8%
associate-*r/76.9%
*-rgt-identity76.9%
difference-of-squares89.3%
associate-/r*89.8%
associate-*l/99.7%
*-commutative99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
associate-/l/99.7%
Simplified99.7%
Taylor expanded in a around inf 64.5%
*-commutative64.5%
associate-/r*64.5%
Simplified64.5%
*-un-lft-identity64.5%
associate-/l*64.3%
associate-/l/64.3%
Applied egg-rr64.3%
*-lft-identity64.3%
associate-/r/64.5%
Simplified64.5%
Taylor expanded in b around 0 62.6%
if 1.35e120 < b Initial program 53.5%
associate-*r/53.5%
*-rgt-identity53.5%
difference-of-squares76.5%
associate-/r*78.0%
associate-*l/99.7%
*-commutative99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
associate-/l/99.7%
Simplified99.7%
Taylor expanded in a around inf 63.7%
*-commutative63.7%
associate-/r*63.7%
Simplified63.7%
*-un-lft-identity63.7%
associate-/l*63.7%
associate-/l/63.7%
Applied egg-rr63.7%
*-lft-identity63.7%
associate-/r/63.7%
Simplified63.7%
Taylor expanded in b around inf 63.7%
clear-num63.7%
associate-/r*63.7%
frac-times64.1%
*-un-lft-identity64.1%
Applied egg-rr64.1%
Final simplification62.8%
(FPCore (a b) :precision binary64 (* (/ 1.0 (* a b)) (* PI (/ 0.5 (+ a b)))))
double code(double a, double b) {
return (1.0 / (a * b)) * (((double) M_PI) * (0.5 / (a + b)));
}
public static double code(double a, double b) {
return (1.0 / (a * b)) * (Math.PI * (0.5 / (a + b)));
}
def code(a, b): return (1.0 / (a * b)) * (math.pi * (0.5 / (a + b)))
function code(a, b) return Float64(Float64(1.0 / Float64(a * b)) * Float64(pi * Float64(0.5 / Float64(a + b)))) end
function tmp = code(a, b) tmp = (1.0 / (a * b)) * (pi * (0.5 / (a + b))); end
code[a_, b_] := N[(N[(1.0 / N[(a * b), $MachinePrecision]), $MachinePrecision] * N[(Pi * N[(0.5 / N[(a + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{a \cdot b} \cdot \left(\pi \cdot \frac{0.5}{a + b}\right)
\end{array}
Initial program 73.3%
associate-*r/73.3%
*-rgt-identity73.3%
difference-of-squares87.4%
associate-/r*88.0%
associate-*l/99.7%
*-commutative99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
associate-/l/99.7%
Simplified99.7%
*-un-lft-identity99.7%
associate-/l*87.4%
*-commutative87.4%
Applied egg-rr87.4%
*-lft-identity87.4%
associate-/r/99.7%
*-rgt-identity99.7%
associate-*r/99.6%
associate-/r*99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in a around 0 99.7%
Final simplification99.7%
(FPCore (a b) :precision binary64 (/ (* PI (/ 0.5 (+ a b))) (* a b)))
double code(double a, double b) {
return (((double) M_PI) * (0.5 / (a + b))) / (a * b);
}
public static double code(double a, double b) {
return (Math.PI * (0.5 / (a + b))) / (a * b);
}
def code(a, b): return (math.pi * (0.5 / (a + b))) / (a * b)
function code(a, b) return Float64(Float64(pi * Float64(0.5 / Float64(a + b))) / Float64(a * b)) end
function tmp = code(a, b) tmp = (pi * (0.5 / (a + b))) / (a * b); end
code[a_, b_] := N[(N[(Pi * N[(0.5 / N[(a + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\pi \cdot \frac{0.5}{a + b}}{a \cdot b}
\end{array}
Initial program 73.3%
associate-*r/73.3%
*-rgt-identity73.3%
difference-of-squares87.4%
associate-/r*88.0%
associate-*l/99.7%
*-commutative99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
associate-/l/99.7%
Simplified99.7%
*-un-lft-identity99.7%
associate-/l*87.4%
*-commutative87.4%
Applied egg-rr87.4%
*-lft-identity87.4%
associate-/r/99.7%
*-rgt-identity99.7%
associate-*r/99.6%
associate-/r*99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in a around 0 99.7%
associate-*l/99.6%
*-un-lft-identity99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (a b) :precision binary64 (* (/ PI (* a b)) (/ -0.5 b)))
double code(double a, double b) {
return (((double) M_PI) / (a * b)) * (-0.5 / b);
}
public static double code(double a, double b) {
return (Math.PI / (a * b)) * (-0.5 / b);
}
def code(a, b): return (math.pi / (a * b)) * (-0.5 / b)
function code(a, b) return Float64(Float64(pi / Float64(a * b)) * Float64(-0.5 / b)) end
function tmp = code(a, b) tmp = (pi / (a * b)) * (-0.5 / b); end
code[a_, b_] := N[(N[(Pi / N[(a * b), $MachinePrecision]), $MachinePrecision] * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\pi}{a \cdot b} \cdot \frac{-0.5}{b}
\end{array}
Initial program 73.3%
associate-*r/73.3%
*-rgt-identity73.3%
difference-of-squares87.4%
associate-/r*88.0%
associate-*l/99.7%
*-commutative99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
associate-/l/99.7%
Simplified99.7%
Taylor expanded in a around inf 64.4%
*-commutative64.4%
associate-/r*64.3%
Simplified64.3%
*-un-lft-identity64.3%
associate-/l*64.2%
associate-/l/64.3%
Applied egg-rr64.3%
*-lft-identity64.3%
associate-/r/64.3%
Simplified64.3%
Taylor expanded in b around inf 34.8%
Final simplification34.8%
herbie shell --seed 2024030
(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))))