
(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 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}
(FPCore (a b) :precision binary64 (* (* 0.5 PI) (/ (/ 1.0 (+ a b)) (* a b))))
double code(double a, double b) {
return (0.5 * ((double) M_PI)) * ((1.0 / (a + b)) / (a * b));
}
public static double code(double a, double b) {
return (0.5 * Math.PI) * ((1.0 / (a + b)) / (a * b));
}
def code(a, b): return (0.5 * math.pi) * ((1.0 / (a + b)) / (a * b))
function code(a, b) return Float64(Float64(0.5 * pi) * Float64(Float64(1.0 / Float64(a + b)) / Float64(a * b))) end
function tmp = code(a, b) tmp = (0.5 * pi) * ((1.0 / (a + b)) / (a * b)); end
code[a_, b_] := N[(N[(0.5 * Pi), $MachinePrecision] * N[(N[(1.0 / N[(a + b), $MachinePrecision]), $MachinePrecision] / N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \pi\right) \cdot \frac{\frac{1}{a + b}}{a \cdot b}
\end{array}
Initial program 82.2%
associate-*l*82.1%
*-rgt-identity82.1%
associate-/l*82.1%
metadata-eval82.1%
associate-*l/82.2%
*-lft-identity82.2%
sub-neg82.2%
distribute-neg-frac82.2%
metadata-eval82.2%
Simplified82.2%
metadata-eval82.2%
div-inv82.2%
*-commutative82.2%
clear-num82.1%
frac-times82.2%
*-un-lft-identity82.2%
frac-add82.2%
associate-/r/82.2%
*-un-lft-identity82.2%
*-commutative82.2%
neg-mul-182.2%
sub-neg82.2%
flip-+99.3%
+-commutative99.3%
Applied egg-rr99.3%
*-commutative99.3%
associate-/r*99.3%
Simplified99.3%
associate-/r*99.6%
div-inv99.6%
metadata-eval99.6%
*-commutative99.6%
div-inv99.7%
*-commutative99.7%
metadata-eval99.7%
div-inv99.7%
*-un-lft-identity99.7%
times-frac99.7%
div-inv99.7%
metadata-eval99.7%
*-commutative99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (a b) :precision binary64 (let* ((t_0 (/ PI (+ a b)))) (if (<= b 4.3e-40) (* (/ 0.5 a) (/ t_0 b)) (* (/ 0.5 b) (/ t_0 a)))))
double code(double a, double b) {
double t_0 = ((double) M_PI) / (a + b);
double tmp;
if (b <= 4.3e-40) {
tmp = (0.5 / a) * (t_0 / b);
} else {
tmp = (0.5 / b) * (t_0 / a);
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = Math.PI / (a + b);
double tmp;
if (b <= 4.3e-40) {
tmp = (0.5 / a) * (t_0 / b);
} else {
tmp = (0.5 / b) * (t_0 / a);
}
return tmp;
}
def code(a, b): t_0 = math.pi / (a + b) tmp = 0 if b <= 4.3e-40: tmp = (0.5 / a) * (t_0 / b) else: tmp = (0.5 / b) * (t_0 / a) return tmp
function code(a, b) t_0 = Float64(pi / Float64(a + b)) tmp = 0.0 if (b <= 4.3e-40) tmp = Float64(Float64(0.5 / a) * Float64(t_0 / b)); else tmp = Float64(Float64(0.5 / b) * Float64(t_0 / a)); end return tmp end
function tmp_2 = code(a, b) t_0 = pi / (a + b); tmp = 0.0; if (b <= 4.3e-40) tmp = (0.5 / a) * (t_0 / b); else tmp = (0.5 / b) * (t_0 / a); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(Pi / N[(a + b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 4.3e-40], N[(N[(0.5 / a), $MachinePrecision] * N[(t$95$0 / b), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / b), $MachinePrecision] * N[(t$95$0 / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\pi}{a + b}\\
\mathbf{if}\;b \leq 4.3 \cdot 10^{-40}:\\
\;\;\;\;\frac{0.5}{a} \cdot \frac{t\_0}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{b} \cdot \frac{t\_0}{a}\\
\end{array}
\end{array}
if b < 4.3000000000000003e-40Initial program 80.7%
associate-*l*80.8%
*-rgt-identity80.8%
associate-/l*80.8%
metadata-eval80.8%
associate-*l/80.8%
*-lft-identity80.8%
sub-neg80.8%
distribute-neg-frac80.8%
metadata-eval80.8%
Simplified80.8%
metadata-eval80.8%
div-inv80.8%
*-commutative80.8%
clear-num80.8%
frac-times80.8%
*-un-lft-identity80.8%
frac-add80.8%
associate-/r/80.8%
*-un-lft-identity80.8%
*-commutative80.8%
neg-mul-180.8%
sub-neg80.8%
flip-+99.2%
+-commutative99.2%
Applied egg-rr99.2%
*-commutative99.2%
associate-/r*99.2%
Simplified99.2%
associate-/r*99.6%
div-inv99.6%
metadata-eval99.6%
*-commutative99.6%
associate-/l*99.6%
times-frac96.8%
Applied egg-rr96.8%
if 4.3000000000000003e-40 < b Initial program 85.3%
associate-*l*85.1%
*-rgt-identity85.1%
associate-/l*85.1%
metadata-eval85.1%
associate-*l/85.2%
*-lft-identity85.2%
sub-neg85.2%
distribute-neg-frac85.2%
metadata-eval85.2%
Simplified85.2%
metadata-eval85.2%
div-inv85.2%
*-commutative85.2%
clear-num85.1%
frac-times85.2%
*-un-lft-identity85.2%
frac-add85.2%
associate-/r/85.1%
*-un-lft-identity85.1%
*-commutative85.1%
neg-mul-185.1%
sub-neg85.1%
flip-+99.6%
+-commutative99.6%
Applied egg-rr99.6%
*-commutative99.6%
associate-/r*99.6%
Simplified99.6%
associate-/r*99.6%
div-inv99.6%
metadata-eval99.6%
*-commutative99.6%
associate-/l*99.6%
*-commutative99.6%
times-frac99.7%
Applied egg-rr99.7%
(FPCore (a b) :precision binary64 (if (<= b 1.2e+97) (* (/ 0.5 a) (/ (/ PI (+ a b)) b)) (* (/ 0.5 b) (/ (/ PI a) b))))
double code(double a, double b) {
double tmp;
if (b <= 1.2e+97) {
tmp = (0.5 / a) * ((((double) M_PI) / (a + b)) / b);
} else {
tmp = (0.5 / b) * ((((double) M_PI) / a) / b);
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (b <= 1.2e+97) {
tmp = (0.5 / a) * ((Math.PI / (a + b)) / b);
} else {
tmp = (0.5 / b) * ((Math.PI / a) / b);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 1.2e+97: tmp = (0.5 / a) * ((math.pi / (a + b)) / b) else: tmp = (0.5 / b) * ((math.pi / a) / b) return tmp
function code(a, b) tmp = 0.0 if (b <= 1.2e+97) tmp = Float64(Float64(0.5 / a) * Float64(Float64(pi / Float64(a + b)) / b)); else tmp = Float64(Float64(0.5 / b) * Float64(Float64(pi / a) / b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 1.2e+97) tmp = (0.5 / a) * ((pi / (a + b)) / b); else tmp = (0.5 / b) * ((pi / a) / b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 1.2e+97], N[(N[(0.5 / a), $MachinePrecision] * N[(N[(Pi / N[(a + b), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / b), $MachinePrecision] * N[(N[(Pi / a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.2 \cdot 10^{+97}:\\
\;\;\;\;\frac{0.5}{a} \cdot \frac{\frac{\pi}{a + b}}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{b} \cdot \frac{\frac{\pi}{a}}{b}\\
\end{array}
\end{array}
if b < 1.2e97Initial program 83.7%
associate-*l*83.7%
*-rgt-identity83.7%
associate-/l*83.7%
metadata-eval83.7%
associate-*l/83.7%
*-lft-identity83.7%
sub-neg83.7%
distribute-neg-frac83.7%
metadata-eval83.7%
Simplified83.7%
metadata-eval83.7%
div-inv83.7%
*-commutative83.7%
clear-num83.7%
frac-times83.7%
*-un-lft-identity83.7%
frac-add83.7%
associate-/r/83.7%
*-un-lft-identity83.7%
*-commutative83.7%
neg-mul-183.7%
sub-neg83.7%
flip-+99.2%
+-commutative99.2%
Applied egg-rr99.2%
*-commutative99.2%
associate-/r*99.2%
Simplified99.2%
associate-/r*99.6%
div-inv99.6%
metadata-eval99.6%
*-commutative99.6%
associate-/l*99.6%
times-frac97.2%
Applied egg-rr97.2%
if 1.2e97 < b Initial program 75.3%
associate-*l*75.2%
*-rgt-identity75.2%
associate-/l*75.2%
metadata-eval75.2%
associate-*l/75.2%
*-lft-identity75.2%
sub-neg75.2%
distribute-neg-frac75.2%
metadata-eval75.2%
Simplified75.2%
metadata-eval75.2%
div-inv75.2%
*-commutative75.2%
clear-num75.2%
frac-times75.3%
*-un-lft-identity75.3%
frac-add75.3%
associate-/r/75.2%
*-un-lft-identity75.2%
*-commutative75.2%
neg-mul-175.2%
sub-neg75.2%
flip-+99.7%
+-commutative99.7%
Applied egg-rr99.7%
*-commutative99.7%
associate-/r*99.7%
Simplified99.7%
Taylor expanded in a around 0 99.7%
div-inv99.7%
metadata-eval99.7%
*-commutative99.7%
times-frac99.8%
associate-/r*99.8%
Applied egg-rr99.8%
Final simplification97.7%
(FPCore (a b) :precision binary64 (if (<= a -9e-73) (/ (/ 0.5 a) (* b (/ a PI))) (* (/ 0.5 b) (/ (/ PI a) b))))
double code(double a, double b) {
double tmp;
if (a <= -9e-73) {
tmp = (0.5 / a) / (b * (a / ((double) M_PI)));
} else {
tmp = (0.5 / b) * ((((double) M_PI) / a) / b);
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (a <= -9e-73) {
tmp = (0.5 / a) / (b * (a / Math.PI));
} else {
tmp = (0.5 / b) * ((Math.PI / a) / b);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -9e-73: tmp = (0.5 / a) / (b * (a / math.pi)) else: tmp = (0.5 / b) * ((math.pi / a) / b) return tmp
function code(a, b) tmp = 0.0 if (a <= -9e-73) tmp = Float64(Float64(0.5 / a) / Float64(b * Float64(a / pi))); else tmp = Float64(Float64(0.5 / b) * Float64(Float64(pi / a) / b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -9e-73) tmp = (0.5 / a) / (b * (a / pi)); else tmp = (0.5 / b) * ((pi / a) / b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -9e-73], N[(N[(0.5 / a), $MachinePrecision] / N[(b * N[(a / Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / b), $MachinePrecision] * N[(N[(Pi / a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -9 \cdot 10^{-73}:\\
\;\;\;\;\frac{\frac{0.5}{a}}{b \cdot \frac{a}{\pi}}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{b} \cdot \frac{\frac{\pi}{a}}{b}\\
\end{array}
\end{array}
if a < -9e-73Initial program 81.6%
associate-*l*81.7%
*-rgt-identity81.7%
associate-/l*81.7%
metadata-eval81.7%
associate-*l/81.8%
*-lft-identity81.8%
sub-neg81.8%
distribute-neg-frac81.8%
metadata-eval81.8%
Simplified81.8%
metadata-eval81.8%
div-inv81.8%
*-commutative81.8%
clear-num81.7%
frac-times81.7%
*-un-lft-identity81.7%
frac-add81.7%
associate-/r/81.7%
*-un-lft-identity81.7%
*-commutative81.7%
neg-mul-181.7%
sub-neg81.7%
flip-+98.3%
+-commutative98.3%
Applied egg-rr98.3%
*-commutative98.3%
associate-/r*98.3%
Simplified98.3%
associate-/r*99.5%
div-inv99.5%
metadata-eval99.5%
*-commutative99.5%
associate-/l*99.5%
times-frac99.6%
Applied egg-rr99.6%
Taylor expanded in a around inf 85.9%
associate-/r*85.8%
Simplified85.8%
clear-num85.8%
un-div-inv85.9%
div-inv85.8%
clear-num85.9%
Applied egg-rr85.9%
if -9e-73 < a Initial program 82.4%
associate-*l*82.3%
*-rgt-identity82.3%
associate-/l*82.3%
metadata-eval82.3%
associate-*l/82.4%
*-lft-identity82.4%
sub-neg82.4%
distribute-neg-frac82.4%
metadata-eval82.4%
Simplified82.4%
metadata-eval82.4%
div-inv82.4%
*-commutative82.4%
clear-num82.3%
frac-times82.4%
*-un-lft-identity82.4%
frac-add82.4%
associate-/r/82.4%
*-un-lft-identity82.4%
*-commutative82.4%
neg-mul-182.4%
sub-neg82.4%
flip-+99.7%
+-commutative99.7%
Applied egg-rr99.7%
*-commutative99.7%
associate-/r*99.7%
Simplified99.7%
Taylor expanded in a around 0 73.2%
div-inv73.2%
metadata-eval73.2%
*-commutative73.2%
times-frac73.0%
associate-/r*73.0%
Applied egg-rr73.0%
Final simplification76.8%
(FPCore (a b) :precision binary64 (let* ((t_0 (/ (/ PI a) b))) (if (<= a -7e-73) (* (/ 0.5 a) t_0) (* (/ 0.5 b) t_0))))
double code(double a, double b) {
double t_0 = (((double) M_PI) / a) / b;
double tmp;
if (a <= -7e-73) {
tmp = (0.5 / a) * t_0;
} else {
tmp = (0.5 / b) * t_0;
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = (Math.PI / a) / b;
double tmp;
if (a <= -7e-73) {
tmp = (0.5 / a) * t_0;
} else {
tmp = (0.5 / b) * t_0;
}
return tmp;
}
def code(a, b): t_0 = (math.pi / a) / b tmp = 0 if a <= -7e-73: tmp = (0.5 / a) * t_0 else: tmp = (0.5 / b) * t_0 return tmp
function code(a, b) t_0 = Float64(Float64(pi / a) / b) tmp = 0.0 if (a <= -7e-73) tmp = Float64(Float64(0.5 / a) * t_0); else tmp = Float64(Float64(0.5 / b) * t_0); end return tmp end
function tmp_2 = code(a, b) t_0 = (pi / a) / b; tmp = 0.0; if (a <= -7e-73) tmp = (0.5 / a) * t_0; else tmp = (0.5 / b) * t_0; end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[(Pi / a), $MachinePrecision] / b), $MachinePrecision]}, If[LessEqual[a, -7e-73], N[(N[(0.5 / a), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(0.5 / b), $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{\pi}{a}}{b}\\
\mathbf{if}\;a \leq -7 \cdot 10^{-73}:\\
\;\;\;\;\frac{0.5}{a} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{b} \cdot t\_0\\
\end{array}
\end{array}
if a < -6.9999999999999995e-73Initial program 81.6%
associate-*l*81.7%
*-rgt-identity81.7%
associate-/l*81.7%
metadata-eval81.7%
associate-*l/81.8%
*-lft-identity81.8%
sub-neg81.8%
distribute-neg-frac81.8%
metadata-eval81.8%
Simplified81.8%
metadata-eval81.8%
div-inv81.8%
*-commutative81.8%
clear-num81.7%
frac-times81.7%
*-un-lft-identity81.7%
frac-add81.7%
associate-/r/81.7%
*-un-lft-identity81.7%
*-commutative81.7%
neg-mul-181.7%
sub-neg81.7%
flip-+98.3%
+-commutative98.3%
Applied egg-rr98.3%
*-commutative98.3%
associate-/r*98.3%
Simplified98.3%
associate-/r*99.5%
div-inv99.5%
metadata-eval99.5%
*-commutative99.5%
associate-/l*99.5%
times-frac99.6%
Applied egg-rr99.6%
Taylor expanded in a around inf 85.9%
associate-/r*85.8%
Simplified85.8%
if -6.9999999999999995e-73 < a Initial program 82.4%
associate-*l*82.3%
*-rgt-identity82.3%
associate-/l*82.3%
metadata-eval82.3%
associate-*l/82.4%
*-lft-identity82.4%
sub-neg82.4%
distribute-neg-frac82.4%
metadata-eval82.4%
Simplified82.4%
metadata-eval82.4%
div-inv82.4%
*-commutative82.4%
clear-num82.3%
frac-times82.4%
*-un-lft-identity82.4%
frac-add82.4%
associate-/r/82.4%
*-un-lft-identity82.4%
*-commutative82.4%
neg-mul-182.4%
sub-neg82.4%
flip-+99.7%
+-commutative99.7%
Applied egg-rr99.7%
*-commutative99.7%
associate-/r*99.7%
Simplified99.7%
Taylor expanded in a around 0 73.2%
div-inv73.2%
metadata-eval73.2%
*-commutative73.2%
times-frac73.0%
associate-/r*73.0%
Applied egg-rr73.0%
Final simplification76.8%
(FPCore (a b) :precision binary64 (if (<= a -9e-73) (* (/ 0.5 a) (/ (/ PI a) b)) (* PI (/ 0.5 (* b (* a b))))))
double code(double a, double b) {
double tmp;
if (a <= -9e-73) {
tmp = (0.5 / a) * ((((double) M_PI) / a) / b);
} else {
tmp = ((double) M_PI) * (0.5 / (b * (a * b)));
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (a <= -9e-73) {
tmp = (0.5 / a) * ((Math.PI / a) / b);
} else {
tmp = Math.PI * (0.5 / (b * (a * b)));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -9e-73: tmp = (0.5 / a) * ((math.pi / a) / b) else: tmp = math.pi * (0.5 / (b * (a * b))) return tmp
function code(a, b) tmp = 0.0 if (a <= -9e-73) tmp = Float64(Float64(0.5 / a) * Float64(Float64(pi / a) / b)); else tmp = Float64(pi * Float64(0.5 / Float64(b * Float64(a * b)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -9e-73) tmp = (0.5 / a) * ((pi / a) / b); else tmp = pi * (0.5 / (b * (a * b))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -9e-73], N[(N[(0.5 / a), $MachinePrecision] * N[(N[(Pi / a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], N[(Pi * N[(0.5 / N[(b * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -9 \cdot 10^{-73}:\\
\;\;\;\;\frac{0.5}{a} \cdot \frac{\frac{\pi}{a}}{b}\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \frac{0.5}{b \cdot \left(a \cdot b\right)}\\
\end{array}
\end{array}
if a < -9e-73Initial program 81.6%
associate-*l*81.7%
*-rgt-identity81.7%
associate-/l*81.7%
metadata-eval81.7%
associate-*l/81.8%
*-lft-identity81.8%
sub-neg81.8%
distribute-neg-frac81.8%
metadata-eval81.8%
Simplified81.8%
metadata-eval81.8%
div-inv81.8%
*-commutative81.8%
clear-num81.7%
frac-times81.7%
*-un-lft-identity81.7%
frac-add81.7%
associate-/r/81.7%
*-un-lft-identity81.7%
*-commutative81.7%
neg-mul-181.7%
sub-neg81.7%
flip-+98.3%
+-commutative98.3%
Applied egg-rr98.3%
*-commutative98.3%
associate-/r*98.3%
Simplified98.3%
associate-/r*99.5%
div-inv99.5%
metadata-eval99.5%
*-commutative99.5%
associate-/l*99.5%
times-frac99.6%
Applied egg-rr99.6%
Taylor expanded in a around inf 85.9%
associate-/r*85.8%
Simplified85.8%
if -9e-73 < a Initial program 82.4%
*-commutative82.4%
associate-*r*82.3%
associate-*r/82.4%
associate-*r*82.4%
*-rgt-identity82.4%
sub-neg82.4%
distribute-neg-frac82.4%
metadata-eval82.4%
Simplified82.4%
*-commutative82.4%
associate-*r/82.4%
div-inv82.4%
metadata-eval82.4%
associate-*l*82.4%
*-commutative82.4%
Applied egg-rr99.7%
Taylor expanded in a around 0 73.2%
Final simplification76.9%
(FPCore (a b) :precision binary64 (if (<= a -9e-73) (* (/ 0.5 a) (/ (/ PI a) b)) (* (/ 0.5 a) (/ (/ PI b) b))))
double code(double a, double b) {
double tmp;
if (a <= -9e-73) {
tmp = (0.5 / a) * ((((double) M_PI) / a) / b);
} else {
tmp = (0.5 / a) * ((((double) M_PI) / b) / b);
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (a <= -9e-73) {
tmp = (0.5 / a) * ((Math.PI / a) / b);
} else {
tmp = (0.5 / a) * ((Math.PI / b) / b);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -9e-73: tmp = (0.5 / a) * ((math.pi / a) / b) else: tmp = (0.5 / a) * ((math.pi / b) / b) return tmp
function code(a, b) tmp = 0.0 if (a <= -9e-73) tmp = Float64(Float64(0.5 / a) * Float64(Float64(pi / a) / b)); else tmp = Float64(Float64(0.5 / a) * Float64(Float64(pi / b) / b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -9e-73) tmp = (0.5 / a) * ((pi / a) / b); else tmp = (0.5 / a) * ((pi / b) / b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -9e-73], N[(N[(0.5 / a), $MachinePrecision] * N[(N[(Pi / a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / a), $MachinePrecision] * N[(N[(Pi / b), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -9 \cdot 10^{-73}:\\
\;\;\;\;\frac{0.5}{a} \cdot \frac{\frac{\pi}{a}}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{a} \cdot \frac{\frac{\pi}{b}}{b}\\
\end{array}
\end{array}
if a < -9e-73Initial program 81.6%
associate-*l*81.7%
*-rgt-identity81.7%
associate-/l*81.7%
metadata-eval81.7%
associate-*l/81.8%
*-lft-identity81.8%
sub-neg81.8%
distribute-neg-frac81.8%
metadata-eval81.8%
Simplified81.8%
metadata-eval81.8%
div-inv81.8%
*-commutative81.8%
clear-num81.7%
frac-times81.7%
*-un-lft-identity81.7%
frac-add81.7%
associate-/r/81.7%
*-un-lft-identity81.7%
*-commutative81.7%
neg-mul-181.7%
sub-neg81.7%
flip-+98.3%
+-commutative98.3%
Applied egg-rr98.3%
*-commutative98.3%
associate-/r*98.3%
Simplified98.3%
associate-/r*99.5%
div-inv99.5%
metadata-eval99.5%
*-commutative99.5%
associate-/l*99.5%
times-frac99.6%
Applied egg-rr99.6%
Taylor expanded in a around inf 85.9%
associate-/r*85.8%
Simplified85.8%
if -9e-73 < a Initial program 82.4%
associate-*l*82.3%
*-rgt-identity82.3%
associate-/l*82.3%
metadata-eval82.3%
associate-*l/82.4%
*-lft-identity82.4%
sub-neg82.4%
distribute-neg-frac82.4%
metadata-eval82.4%
Simplified82.4%
metadata-eval82.4%
div-inv82.4%
*-commutative82.4%
clear-num82.3%
frac-times82.4%
*-un-lft-identity82.4%
frac-add82.4%
associate-/r/82.4%
*-un-lft-identity82.4%
*-commutative82.4%
neg-mul-182.4%
sub-neg82.4%
flip-+99.7%
+-commutative99.7%
Applied egg-rr99.7%
*-commutative99.7%
associate-/r*99.7%
Simplified99.7%
associate-/r*99.6%
div-inv99.6%
metadata-eval99.6%
*-commutative99.6%
associate-/l*99.6%
times-frac93.2%
Applied egg-rr93.2%
Taylor expanded in a around 0 66.4%
(FPCore (a b) :precision binary64 (* (/ PI (* a b)) (/ 0.5 (+ a b))))
double code(double a, double b) {
return (((double) M_PI) / (a * b)) * (0.5 / (a + b));
}
public static double code(double a, double b) {
return (Math.PI / (a * b)) * (0.5 / (a + b));
}
def code(a, b): return (math.pi / (a * b)) * (0.5 / (a + b))
function code(a, b) return Float64(Float64(pi / Float64(a * b)) * Float64(0.5 / Float64(a + b))) end
function tmp = code(a, b) tmp = (pi / (a * b)) * (0.5 / (a + b)); end
code[a_, b_] := N[(N[(Pi / N[(a * b), $MachinePrecision]), $MachinePrecision] * N[(0.5 / N[(a + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\pi}{a \cdot b} \cdot \frac{0.5}{a + b}
\end{array}
Initial program 82.2%
associate-*l*82.1%
*-rgt-identity82.1%
associate-/l*82.1%
metadata-eval82.1%
associate-*l/82.2%
*-lft-identity82.2%
sub-neg82.2%
distribute-neg-frac82.2%
metadata-eval82.2%
Simplified82.2%
metadata-eval82.2%
div-inv82.2%
*-commutative82.2%
clear-num82.1%
frac-times82.2%
*-un-lft-identity82.2%
frac-add82.2%
associate-/r/82.2%
*-un-lft-identity82.2%
*-commutative82.2%
neg-mul-182.2%
sub-neg82.2%
flip-+99.3%
+-commutative99.3%
Applied egg-rr99.3%
*-commutative99.3%
associate-/r*99.3%
Simplified99.3%
div-inv99.3%
metadata-eval99.3%
*-commutative99.3%
times-frac99.7%
Applied egg-rr99.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(pi * Float64(0.5 / Float64(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[(Pi * N[(0.5 / N[(N[(a + b), $MachinePrecision] * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\pi \cdot \frac{0.5}{\left(a + b\right) \cdot \left(a \cdot b\right)}
\end{array}
Initial program 82.2%
*-commutative82.2%
associate-*r*82.2%
associate-*r/82.2%
associate-*r*82.2%
*-rgt-identity82.2%
sub-neg82.2%
distribute-neg-frac82.2%
metadata-eval82.2%
Simplified82.2%
*-commutative82.2%
associate-*r/82.2%
div-inv82.2%
metadata-eval82.2%
associate-*l*82.2%
*-commutative82.2%
Applied egg-rr99.3%
Final simplification99.3%
(FPCore (a b) :precision binary64 (* (/ 0.5 a) (/ (/ PI a) b)))
double code(double a, double b) {
return (0.5 / a) * ((((double) M_PI) / a) / b);
}
public static double code(double a, double b) {
return (0.5 / a) * ((Math.PI / a) / b);
}
def code(a, b): return (0.5 / a) * ((math.pi / a) / b)
function code(a, b) return Float64(Float64(0.5 / a) * Float64(Float64(pi / a) / b)) end
function tmp = code(a, b) tmp = (0.5 / a) * ((pi / a) / b); end
code[a_, b_] := N[(N[(0.5 / a), $MachinePrecision] * N[(N[(Pi / a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5}{a} \cdot \frac{\frac{\pi}{a}}{b}
\end{array}
Initial program 82.2%
associate-*l*82.1%
*-rgt-identity82.1%
associate-/l*82.1%
metadata-eval82.1%
associate-*l/82.2%
*-lft-identity82.2%
sub-neg82.2%
distribute-neg-frac82.2%
metadata-eval82.2%
Simplified82.2%
metadata-eval82.2%
div-inv82.2%
*-commutative82.2%
clear-num82.1%
frac-times82.2%
*-un-lft-identity82.2%
frac-add82.2%
associate-/r/82.2%
*-un-lft-identity82.2%
*-commutative82.2%
neg-mul-182.2%
sub-neg82.2%
flip-+99.3%
+-commutative99.3%
Applied egg-rr99.3%
*-commutative99.3%
associate-/r*99.3%
Simplified99.3%
associate-/r*99.6%
div-inv99.6%
metadata-eval99.6%
*-commutative99.6%
associate-/l*99.6%
times-frac95.0%
Applied egg-rr95.0%
Taylor expanded in a around inf 61.9%
associate-/r*61.9%
Simplified61.9%
herbie shell --seed 2024182
(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))))