
(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 8 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 b)) (* 2.0 (+ a b))))
double code(double a, double b) {
return (((double) M_PI) / (a * b)) / (2.0 * (a + b));
}
public static double code(double a, double b) {
return (Math.PI / (a * b)) / (2.0 * (a + b));
}
def code(a, b): return (math.pi / (a * b)) / (2.0 * (a + b))
function code(a, b) return Float64(Float64(pi / Float64(a * b)) / Float64(2.0 * Float64(a + b))) end
function tmp = code(a, b) tmp = (pi / (a * b)) / (2.0 * (a + b)); end
code[a_, b_] := N[(N[(Pi / N[(a * b), $MachinePrecision]), $MachinePrecision] / N[(2.0 * N[(a + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\pi}{a \cdot b}}{2 \cdot \left(a + b\right)}
\end{array}
Initial program 79.2%
associate-*l*79.2%
associate-*l/79.2%
*-lft-identity79.2%
difference-of-squares87.0%
associate-/l/99.6%
sub-neg99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in a around 0 99.6%
associate-*r/99.6%
associate-/l/99.6%
associate-*r/99.6%
expm1-log1p-u78.1%
expm1-udef53.0%
Applied egg-rr53.0%
expm1-def77.5%
expm1-log1p99.0%
*-rgt-identity99.0%
*-commutative99.0%
times-frac99.0%
*-commutative99.0%
associate-/r*99.6%
associate-/l/99.6%
times-frac99.6%
associate-*r/99.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in b around 0 99.7%
Final simplification99.7%
(FPCore (a b) :precision binary64 (if (or (<= b 1.7e-306) (not (<= b 4.3e-203))) (/ PI (* 2.0 (* b (* a b)))) (* (/ PI (* a b)) (/ -0.5 b))))
double code(double a, double b) {
double tmp;
if ((b <= 1.7e-306) || !(b <= 4.3e-203)) {
tmp = ((double) M_PI) / (2.0 * (b * (a * b)));
} else {
tmp = (((double) M_PI) / (a * b)) * (-0.5 / b);
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if ((b <= 1.7e-306) || !(b <= 4.3e-203)) {
tmp = Math.PI / (2.0 * (b * (a * b)));
} else {
tmp = (Math.PI / (a * b)) * (-0.5 / b);
}
return tmp;
}
def code(a, b): tmp = 0 if (b <= 1.7e-306) or not (b <= 4.3e-203): tmp = math.pi / (2.0 * (b * (a * b))) else: tmp = (math.pi / (a * b)) * (-0.5 / b) return tmp
function code(a, b) tmp = 0.0 if ((b <= 1.7e-306) || !(b <= 4.3e-203)) tmp = Float64(pi / Float64(2.0 * Float64(b * Float64(a * b)))); else tmp = Float64(Float64(pi / Float64(a * b)) * Float64(-0.5 / b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b <= 1.7e-306) || ~((b <= 4.3e-203))) tmp = pi / (2.0 * (b * (a * b))); else tmp = (pi / (a * b)) * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[b, 1.7e-306], N[Not[LessEqual[b, 4.3e-203]], $MachinePrecision]], N[(Pi / N[(2.0 * N[(b * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Pi / N[(a * b), $MachinePrecision]), $MachinePrecision] * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.7 \cdot 10^{-306} \lor \neg \left(b \leq 4.3 \cdot 10^{-203}\right):\\
\;\;\;\;\frac{\pi}{2 \cdot \left(b \cdot \left(a \cdot b\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi}{a \cdot b} \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < 1.6999999999999999e-306 or 4.30000000000000027e-203 < b Initial program 80.5%
associate-*l*80.5%
associate-*l/80.5%
*-lft-identity80.5%
difference-of-squares88.4%
associate-/l/99.6%
sub-neg99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in a around 0 99.7%
div-inv99.7%
metadata-eval99.7%
*-commutative99.7%
*-commutative99.7%
associate-/l/99.1%
*-commutative99.1%
metadata-eval99.1%
div-inv99.1%
frac-times99.1%
*-un-lft-identity99.1%
+-commutative99.1%
Applied egg-rr99.1%
expm1-log1p-u66.1%
expm1-udef35.6%
+-commutative35.6%
*-commutative35.6%
Applied egg-rr35.6%
expm1-def66.1%
expm1-log1p99.1%
*-commutative99.1%
associate-*l*95.4%
+-commutative95.4%
Simplified95.4%
Taylor expanded in a around 0 64.5%
if 1.6999999999999999e-306 < b < 4.30000000000000027e-203Initial program 69.0%
associate-*l*69.0%
associate-*l/69.0%
*-lft-identity69.0%
difference-of-squares75.9%
associate-/l/99.2%
sub-neg99.2%
distribute-neg-frac99.2%
metadata-eval99.2%
Simplified99.2%
Taylor expanded in a around 0 99.5%
div-inv99.5%
metadata-eval99.5%
*-commutative99.5%
*-commutative99.5%
associate-/l/99.2%
associate-/l/75.9%
*-commutative75.9%
metadata-eval75.9%
div-inv75.9%
frac-2neg75.9%
frac-times76.0%
+-commutative76.0%
metadata-eval76.0%
Applied egg-rr76.0%
*-commutative76.0%
associate-/r*76.0%
associate-*l/76.0%
*-lft-identity76.0%
*-commutative76.0%
Simplified76.0%
Taylor expanded in a around 0 15.9%
expm1-log1p-u12.3%
expm1-udef12.3%
div-inv12.3%
times-frac12.3%
add-sqr-sqrt0.0%
sqrt-unprod17.8%
sqr-neg17.8%
sqrt-unprod17.8%
add-sqr-sqrt17.8%
metadata-eval17.8%
Applied egg-rr17.8%
expm1-def17.8%
expm1-log1p18.4%
associate-/l/18.4%
Simplified18.4%
Final simplification59.3%
(FPCore (a b)
:precision binary64
(if (<= b -6e-309)
(/ PI (* 2.0 (* b (* a b))))
(if (<= b 5.2e-203)
(* (/ PI (* a b)) (/ -0.5 b))
(/ (/ PI b) (* a (* b 2.0))))))
double code(double a, double b) {
double tmp;
if (b <= -6e-309) {
tmp = ((double) M_PI) / (2.0 * (b * (a * b)));
} else if (b <= 5.2e-203) {
tmp = (((double) M_PI) / (a * b)) * (-0.5 / b);
} else {
tmp = (((double) M_PI) / b) / (a * (b * 2.0));
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (b <= -6e-309) {
tmp = Math.PI / (2.0 * (b * (a * b)));
} else if (b <= 5.2e-203) {
tmp = (Math.PI / (a * b)) * (-0.5 / b);
} else {
tmp = (Math.PI / b) / (a * (b * 2.0));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -6e-309: tmp = math.pi / (2.0 * (b * (a * b))) elif b <= 5.2e-203: tmp = (math.pi / (a * b)) * (-0.5 / b) else: tmp = (math.pi / b) / (a * (b * 2.0)) return tmp
function code(a, b) tmp = 0.0 if (b <= -6e-309) tmp = Float64(pi / Float64(2.0 * Float64(b * Float64(a * b)))); elseif (b <= 5.2e-203) tmp = Float64(Float64(pi / Float64(a * b)) * Float64(-0.5 / b)); else tmp = Float64(Float64(pi / b) / Float64(a * Float64(b * 2.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -6e-309) tmp = pi / (2.0 * (b * (a * b))); elseif (b <= 5.2e-203) tmp = (pi / (a * b)) * (-0.5 / b); else tmp = (pi / b) / (a * (b * 2.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -6e-309], N[(Pi / N[(2.0 * N[(b * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.2e-203], N[(N[(Pi / N[(a * b), $MachinePrecision]), $MachinePrecision] * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision], N[(N[(Pi / b), $MachinePrecision] / N[(a * N[(b * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6 \cdot 10^{-309}:\\
\;\;\;\;\frac{\pi}{2 \cdot \left(b \cdot \left(a \cdot b\right)\right)}\\
\mathbf{elif}\;b \leq 5.2 \cdot 10^{-203}:\\
\;\;\;\;\frac{\pi}{a \cdot b} \cdot \frac{-0.5}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\pi}{b}}{a \cdot \left(b \cdot 2\right)}\\
\end{array}
\end{array}
if b < -6.000000000000001e-309Initial program 79.5%
associate-*l*79.5%
associate-*l/79.5%
*-lft-identity79.5%
difference-of-squares88.5%
associate-/l/99.6%
sub-neg99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in a around 0 99.7%
div-inv99.7%
metadata-eval99.7%
*-commutative99.7%
*-commutative99.7%
associate-/l/99.7%
*-commutative99.7%
metadata-eval99.7%
div-inv99.7%
frac-times99.7%
*-un-lft-identity99.7%
+-commutative99.7%
Applied egg-rr99.7%
expm1-log1p-u52.6%
expm1-udef17.8%
+-commutative17.8%
*-commutative17.8%
Applied egg-rr17.8%
expm1-def52.6%
expm1-log1p99.7%
*-commutative99.7%
associate-*l*95.9%
+-commutative95.9%
Simplified95.9%
Taylor expanded in a around 0 60.6%
if -6.000000000000001e-309 < b < 5.19999999999999951e-203Initial program 69.0%
associate-*l*69.0%
associate-*l/69.0%
*-lft-identity69.0%
difference-of-squares75.9%
associate-/l/99.2%
sub-neg99.2%
distribute-neg-frac99.2%
metadata-eval99.2%
Simplified99.2%
Taylor expanded in a around 0 99.5%
div-inv99.5%
metadata-eval99.5%
*-commutative99.5%
*-commutative99.5%
associate-/l/99.2%
associate-/l/75.9%
*-commutative75.9%
metadata-eval75.9%
div-inv75.9%
frac-2neg75.9%
frac-times76.0%
+-commutative76.0%
metadata-eval76.0%
Applied egg-rr76.0%
*-commutative76.0%
associate-/r*76.0%
associate-*l/76.0%
*-lft-identity76.0%
*-commutative76.0%
Simplified76.0%
Taylor expanded in a around 0 15.9%
expm1-log1p-u12.3%
expm1-udef12.3%
div-inv12.3%
times-frac12.3%
add-sqr-sqrt0.0%
sqrt-unprod17.8%
sqr-neg17.8%
sqrt-unprod17.8%
add-sqr-sqrt17.8%
metadata-eval17.8%
Applied egg-rr17.8%
expm1-def17.8%
expm1-log1p18.4%
associate-/l/18.4%
Simplified18.4%
if 5.19999999999999951e-203 < b Initial program 81.6%
associate-*l*81.7%
associate-*l/81.7%
*-lft-identity81.7%
difference-of-squares88.4%
associate-/l/99.6%
sub-neg99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in a around 0 99.6%
div-inv99.5%
associate-/l/99.6%
+-commutative99.6%
Applied egg-rr99.6%
*-commutative99.6%
*-commutative99.6%
frac-times96.0%
*-un-lft-identity96.0%
times-frac96.0%
associate-*l/96.0%
*-un-lft-identity96.0%
associate-*l*96.0%
+-commutative96.0%
Applied egg-rr96.0%
Taylor expanded in b around inf 70.2%
associate-*r*70.2%
*-commutative70.2%
associate-*l*70.2%
*-commutative70.2%
Simplified70.2%
Final simplification59.7%
(FPCore (a b) :precision binary64 (if (<= a -2.7e-44) (* (/ (/ 1.0 b) (* a 2.0)) (/ PI a)) (/ (/ PI b) (* a (* b 2.0)))))
double code(double a, double b) {
double tmp;
if (a <= -2.7e-44) {
tmp = ((1.0 / b) / (a * 2.0)) * (((double) M_PI) / a);
} else {
tmp = (((double) M_PI) / b) / (a * (b * 2.0));
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (a <= -2.7e-44) {
tmp = ((1.0 / b) / (a * 2.0)) * (Math.PI / a);
} else {
tmp = (Math.PI / b) / (a * (b * 2.0));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -2.7e-44: tmp = ((1.0 / b) / (a * 2.0)) * (math.pi / a) else: tmp = (math.pi / b) / (a * (b * 2.0)) return tmp
function code(a, b) tmp = 0.0 if (a <= -2.7e-44) tmp = Float64(Float64(Float64(1.0 / b) / Float64(a * 2.0)) * Float64(pi / a)); else tmp = Float64(Float64(pi / b) / Float64(a * Float64(b * 2.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -2.7e-44) tmp = ((1.0 / b) / (a * 2.0)) * (pi / a); else tmp = (pi / b) / (a * (b * 2.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -2.7e-44], N[(N[(N[(1.0 / b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision] * N[(Pi / a), $MachinePrecision]), $MachinePrecision], N[(N[(Pi / b), $MachinePrecision] / N[(a * N[(b * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.7 \cdot 10^{-44}:\\
\;\;\;\;\frac{\frac{1}{b}}{a \cdot 2} \cdot \frac{\pi}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\pi}{b}}{a \cdot \left(b \cdot 2\right)}\\
\end{array}
\end{array}
if a < -2.6999999999999999e-44Initial program 80.2%
associate-*l*80.3%
associate-*l/80.2%
*-lft-identity80.2%
difference-of-squares91.9%
associate-/l/99.5%
sub-neg99.5%
distribute-neg-frac99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in a around 0 99.6%
div-inv99.6%
metadata-eval99.6%
*-commutative99.6%
*-commutative99.6%
associate-/l/99.5%
*-commutative99.5%
metadata-eval99.5%
div-inv99.5%
frac-times99.7%
*-un-lft-identity99.7%
+-commutative99.7%
Applied egg-rr99.7%
associate-/r*99.7%
*-un-lft-identity99.7%
*-commutative99.7%
times-frac99.7%
associate-/l/99.6%
times-frac91.9%
*-commutative91.9%
associate-/r*91.9%
associate-*l*91.9%
*-commutative91.9%
times-frac99.6%
+-commutative99.6%
Applied egg-rr99.6%
Taylor expanded in b around 0 90.2%
if -2.6999999999999999e-44 < a Initial program 78.9%
associate-*l*78.8%
associate-*l/78.9%
*-lft-identity78.9%
difference-of-squares85.5%
associate-/l/99.6%
sub-neg99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in a around 0 99.6%
div-inv99.6%
associate-/l/99.5%
+-commutative99.5%
Applied egg-rr99.5%
*-commutative99.5%
*-commutative99.5%
frac-times94.3%
*-un-lft-identity94.3%
times-frac94.2%
associate-*l/94.3%
*-un-lft-identity94.3%
associate-*l*94.3%
+-commutative94.3%
Applied egg-rr94.3%
Taylor expanded in b around inf 65.0%
associate-*r*65.5%
*-commutative65.5%
associate-*l*65.0%
*-commutative65.0%
Simplified65.0%
Final simplification70.9%
(FPCore (a b) :precision binary64 (if (<= b 1.95e+114) (/ PI (* 2.0 (* a (* b (+ a b))))) (* (/ PI b) (/ (/ 1.0 b) (* a 2.0)))))
double code(double a, double b) {
double tmp;
if (b <= 1.95e+114) {
tmp = ((double) M_PI) / (2.0 * (a * (b * (a + b))));
} else {
tmp = (((double) M_PI) / b) * ((1.0 / b) / (a * 2.0));
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (b <= 1.95e+114) {
tmp = Math.PI / (2.0 * (a * (b * (a + b))));
} else {
tmp = (Math.PI / b) * ((1.0 / b) / (a * 2.0));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 1.95e+114: tmp = math.pi / (2.0 * (a * (b * (a + b)))) else: tmp = (math.pi / b) * ((1.0 / b) / (a * 2.0)) return tmp
function code(a, b) tmp = 0.0 if (b <= 1.95e+114) tmp = Float64(pi / Float64(2.0 * Float64(a * Float64(b * Float64(a + b))))); else tmp = Float64(Float64(pi / b) * Float64(Float64(1.0 / b) / Float64(a * 2.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 1.95e+114) tmp = pi / (2.0 * (a * (b * (a + b)))); else tmp = (pi / b) * ((1.0 / b) / (a * 2.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 1.95e+114], N[(Pi / N[(2.0 * N[(a * N[(b * N[(a + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Pi / b), $MachinePrecision] * N[(N[(1.0 / b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.95 \cdot 10^{+114}:\\
\;\;\;\;\frac{\pi}{2 \cdot \left(a \cdot \left(b \cdot \left(a + b\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi}{b} \cdot \frac{\frac{1}{b}}{a \cdot 2}\\
\end{array}
\end{array}
if b < 1.95e114Initial program 82.4%
associate-*l*82.4%
associate-*l/82.4%
*-lft-identity82.4%
difference-of-squares88.4%
associate-/l/99.5%
sub-neg99.5%
distribute-neg-frac99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in a around 0 99.6%
div-inv99.6%
metadata-eval99.6%
*-commutative99.6%
*-commutative99.6%
associate-/l/99.4%
*-commutative99.4%
metadata-eval99.4%
div-inv99.4%
frac-times99.5%
*-un-lft-identity99.5%
+-commutative99.5%
Applied egg-rr99.5%
expm1-log1p-u70.4%
expm1-udef34.7%
+-commutative34.7%
*-commutative34.7%
Applied egg-rr34.7%
expm1-def70.4%
expm1-log1p99.5%
associate-*r*95.3%
*-commutative95.3%
*-commutative95.3%
+-commutative95.3%
Simplified95.3%
if 1.95e114 < b Initial program 60.6%
associate-*l*60.5%
associate-*l/60.6%
*-lft-identity60.6%
difference-of-squares79.0%
associate-/l/99.8%
sub-neg99.8%
distribute-neg-frac99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in a around 0 99.6%
div-inv99.6%
metadata-eval99.6%
*-commutative99.6%
*-commutative99.6%
associate-/l/96.4%
*-commutative96.4%
metadata-eval96.4%
div-inv96.4%
frac-times96.4%
*-un-lft-identity96.4%
+-commutative96.4%
Applied egg-rr96.4%
associate-/r*96.4%
*-un-lft-identity96.4%
*-commutative96.4%
times-frac99.7%
associate-/l/99.8%
times-frac99.7%
*-commutative99.7%
associate-/r*99.7%
associate-*l*99.7%
*-commutative99.7%
times-frac99.8%
+-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in b around inf 99.8%
Final simplification96.0%
(FPCore (a b) :precision binary64 (/ PI (* 2.0 (* (* a b) (+ a b)))))
double code(double a, double b) {
return ((double) M_PI) / (2.0 * ((a * b) * (a + b)));
}
public static double code(double a, double b) {
return Math.PI / (2.0 * ((a * b) * (a + b)));
}
def code(a, b): return math.pi / (2.0 * ((a * b) * (a + b)))
function code(a, b) return Float64(pi / Float64(2.0 * Float64(Float64(a * b) * Float64(a + b)))) end
function tmp = code(a, b) tmp = pi / (2.0 * ((a * b) * (a + b))); end
code[a_, b_] := N[(Pi / N[(2.0 * N[(N[(a * b), $MachinePrecision] * N[(a + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\pi}{2 \cdot \left(\left(a \cdot b\right) \cdot \left(a + b\right)\right)}
\end{array}
Initial program 79.2%
associate-*l*79.2%
associate-*l/79.2%
*-lft-identity79.2%
difference-of-squares87.0%
associate-/l/99.6%
sub-neg99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in a around 0 99.6%
div-inv99.6%
metadata-eval99.6%
*-commutative99.6%
*-commutative99.6%
associate-/l/99.0%
*-commutative99.0%
metadata-eval99.0%
div-inv99.0%
frac-times99.0%
*-un-lft-identity99.0%
+-commutative99.0%
Applied egg-rr99.0%
Final simplification99.0%
(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 79.2%
associate-*l*79.2%
associate-*l/79.2%
*-lft-identity79.2%
difference-of-squares87.0%
associate-/l/99.6%
sub-neg99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in a around 0 99.6%
div-inv99.6%
metadata-eval99.6%
*-commutative99.6%
*-commutative99.6%
associate-/l/99.6%
associate-/l/93.7%
*-commutative93.7%
metadata-eval93.7%
div-inv93.7%
frac-2neg93.7%
frac-times93.7%
+-commutative93.7%
metadata-eval93.7%
Applied egg-rr93.7%
*-commutative93.7%
associate-/r*93.7%
associate-*l/93.7%
*-lft-identity93.7%
*-commutative93.7%
Simplified93.7%
Taylor expanded in a around 0 59.3%
expm1-log1p-u45.7%
expm1-udef41.4%
div-inv41.4%
times-frac41.4%
add-sqr-sqrt0.0%
sqrt-unprod31.5%
sqr-neg31.5%
sqrt-unprod31.5%
add-sqr-sqrt31.5%
metadata-eval31.5%
Applied egg-rr31.5%
expm1-def23.8%
expm1-log1p27.3%
associate-/l/27.3%
Simplified27.3%
Final simplification27.3%
(FPCore (a b) :precision binary64 (* (/ (/ PI b) b) (/ -0.5 a)))
double code(double a, double b) {
return ((((double) M_PI) / b) / b) * (-0.5 / a);
}
public static double code(double a, double b) {
return ((Math.PI / b) / b) * (-0.5 / a);
}
def code(a, b): return ((math.pi / b) / b) * (-0.5 / a)
function code(a, b) return Float64(Float64(Float64(pi / b) / b) * Float64(-0.5 / a)) end
function tmp = code(a, b) tmp = ((pi / b) / b) * (-0.5 / a); end
code[a_, b_] := N[(N[(N[(Pi / b), $MachinePrecision] / b), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\pi}{b}}{b} \cdot \frac{-0.5}{a}
\end{array}
Initial program 79.2%
associate-*l*79.2%
associate-*l/79.2%
*-lft-identity79.2%
difference-of-squares87.0%
associate-/l/99.6%
sub-neg99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in a around 0 99.6%
div-inv99.6%
metadata-eval99.6%
*-commutative99.6%
*-commutative99.6%
associate-/l/99.6%
associate-/l/93.7%
*-commutative93.7%
metadata-eval93.7%
div-inv93.7%
frac-2neg93.7%
frac-times93.7%
+-commutative93.7%
metadata-eval93.7%
Applied egg-rr93.7%
*-commutative93.7%
associate-/r*93.7%
associate-*l/93.7%
*-lft-identity93.7%
*-commutative93.7%
Simplified93.7%
Taylor expanded in a around 0 59.3%
div-inv59.3%
*-commutative59.3%
times-frac53.5%
add-sqr-sqrt0.0%
sqrt-unprod27.4%
sqr-neg27.4%
sqrt-unprod27.4%
add-sqr-sqrt27.4%
metadata-eval27.4%
Applied egg-rr27.4%
Final simplification27.4%
herbie shell --seed 2024021
(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))))