
(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 9 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)) (/ 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 + b} \cdot \frac{0.5}{a \cdot b}
\end{array}
Initial program 78.3%
associate-*l*78.3%
*-rgt-identity78.3%
associate-/l*78.3%
metadata-eval78.3%
associate-*l/78.3%
*-lft-identity78.3%
sub-neg78.3%
distribute-neg-frac78.3%
metadata-eval78.3%
Simplified78.3%
metadata-eval78.3%
div-inv78.3%
*-commutative78.3%
clear-num78.1%
frac-times78.1%
*-un-lft-identity78.1%
frac-add78.1%
associate-/r/78.2%
*-un-lft-identity78.2%
*-commutative78.2%
neg-mul-178.2%
sub-neg78.2%
flip-+99.0%
+-commutative99.0%
Applied egg-rr99.0%
*-commutative99.0%
associate-/r*99.0%
Simplified99.0%
div-inv99.0%
metadata-eval99.0%
times-frac99.7%
Applied egg-rr99.7%
(FPCore (a b) :precision binary64 (if (<= a -5.3e-76) (* (/ 0.5 (* a b)) (/ PI a)) (* (/ PI (* a b)) (/ 0.5 b))))
double code(double a, double b) {
double tmp;
if (a <= -5.3e-76) {
tmp = (0.5 / (a * b)) * (((double) M_PI) / a);
} else {
tmp = (((double) M_PI) / (a * b)) * (0.5 / b);
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (a <= -5.3e-76) {
tmp = (0.5 / (a * b)) * (Math.PI / a);
} else {
tmp = (Math.PI / (a * b)) * (0.5 / b);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -5.3e-76: tmp = (0.5 / (a * b)) * (math.pi / a) else: tmp = (math.pi / (a * b)) * (0.5 / b) return tmp
function code(a, b) tmp = 0.0 if (a <= -5.3e-76) tmp = Float64(Float64(0.5 / Float64(a * b)) * Float64(pi / a)); 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 (a <= -5.3e-76) tmp = (0.5 / (a * b)) * (pi / a); else tmp = (pi / (a * b)) * (0.5 / b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -5.3e-76], N[(N[(0.5 / N[(a * b), $MachinePrecision]), $MachinePrecision] * N[(Pi / a), $MachinePrecision]), $MachinePrecision], N[(N[(Pi / N[(a * b), $MachinePrecision]), $MachinePrecision] * N[(0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5.3 \cdot 10^{-76}:\\
\;\;\;\;\frac{0.5}{a \cdot b} \cdot \frac{\pi}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi}{a \cdot b} \cdot \frac{0.5}{b}\\
\end{array}
\end{array}
if a < -5.3e-76Initial program 79.5%
associate-*l*79.5%
*-rgt-identity79.5%
associate-/l*79.5%
metadata-eval79.5%
associate-*l/79.5%
*-lft-identity79.5%
sub-neg79.5%
distribute-neg-frac79.5%
metadata-eval79.5%
Simplified79.5%
metadata-eval79.5%
div-inv79.5%
*-commutative79.5%
clear-num78.8%
frac-times79.0%
*-un-lft-identity79.0%
frac-add78.9%
associate-/r/79.0%
*-un-lft-identity79.0%
*-commutative79.0%
neg-mul-179.0%
sub-neg79.0%
flip-+99.1%
+-commutative99.1%
Applied egg-rr99.1%
*-commutative99.1%
associate-/r*99.1%
Simplified99.1%
div-inv99.1%
metadata-eval99.1%
times-frac99.7%
Applied egg-rr99.7%
Taylor expanded in a around inf 85.8%
if -5.3e-76 < a Initial program 77.8%
associate-*l*77.8%
*-rgt-identity77.8%
associate-/l*77.8%
metadata-eval77.8%
associate-*l/77.8%
*-lft-identity77.8%
sub-neg77.8%
distribute-neg-frac77.8%
metadata-eval77.8%
Simplified77.8%
metadata-eval77.8%
div-inv77.8%
*-commutative77.8%
clear-num77.8%
frac-times77.8%
*-un-lft-identity77.8%
frac-add77.7%
associate-/r/77.8%
*-un-lft-identity77.8%
*-commutative77.8%
neg-mul-177.8%
sub-neg77.8%
flip-+98.9%
+-commutative98.9%
Applied egg-rr98.9%
*-commutative98.9%
associate-/r*98.9%
Simplified98.9%
div-inv98.9%
metadata-eval98.9%
associate-*r*93.2%
times-frac94.0%
Applied egg-rr94.0%
Taylor expanded in a around 0 71.4%
Final simplification75.7%
(FPCore (a b) :precision binary64 (let* ((t_0 (/ 0.5 (* a b)))) (if (<= a -3.8e-74) (* t_0 (/ PI a)) (* t_0 (/ PI b)))))
double code(double a, double b) {
double t_0 = 0.5 / (a * b);
double tmp;
if (a <= -3.8e-74) {
tmp = t_0 * (((double) M_PI) / a);
} else {
tmp = t_0 * (((double) M_PI) / b);
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = 0.5 / (a * b);
double tmp;
if (a <= -3.8e-74) {
tmp = t_0 * (Math.PI / a);
} else {
tmp = t_0 * (Math.PI / b);
}
return tmp;
}
def code(a, b): t_0 = 0.5 / (a * b) tmp = 0 if a <= -3.8e-74: tmp = t_0 * (math.pi / a) else: tmp = t_0 * (math.pi / b) return tmp
function code(a, b) t_0 = Float64(0.5 / Float64(a * b)) tmp = 0.0 if (a <= -3.8e-74) tmp = Float64(t_0 * Float64(pi / a)); else tmp = Float64(t_0 * Float64(pi / b)); end return tmp end
function tmp_2 = code(a, b) t_0 = 0.5 / (a * b); tmp = 0.0; if (a <= -3.8e-74) tmp = t_0 * (pi / a); else tmp = t_0 * (pi / b); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(0.5 / N[(a * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -3.8e-74], N[(t$95$0 * N[(Pi / a), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(Pi / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{0.5}{a \cdot b}\\
\mathbf{if}\;a \leq -3.8 \cdot 10^{-74}:\\
\;\;\;\;t\_0 \cdot \frac{\pi}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{\pi}{b}\\
\end{array}
\end{array}
if a < -3.7999999999999996e-74Initial program 79.5%
associate-*l*79.5%
*-rgt-identity79.5%
associate-/l*79.5%
metadata-eval79.5%
associate-*l/79.5%
*-lft-identity79.5%
sub-neg79.5%
distribute-neg-frac79.5%
metadata-eval79.5%
Simplified79.5%
metadata-eval79.5%
div-inv79.5%
*-commutative79.5%
clear-num78.8%
frac-times79.0%
*-un-lft-identity79.0%
frac-add78.9%
associate-/r/79.0%
*-un-lft-identity79.0%
*-commutative79.0%
neg-mul-179.0%
sub-neg79.0%
flip-+99.1%
+-commutative99.1%
Applied egg-rr99.1%
*-commutative99.1%
associate-/r*99.1%
Simplified99.1%
div-inv99.1%
metadata-eval99.1%
times-frac99.7%
Applied egg-rr99.7%
Taylor expanded in a around inf 85.8%
if -3.7999999999999996e-74 < a Initial program 77.8%
associate-*l*77.8%
*-rgt-identity77.8%
associate-/l*77.8%
metadata-eval77.8%
associate-*l/77.8%
*-lft-identity77.8%
sub-neg77.8%
distribute-neg-frac77.8%
metadata-eval77.8%
Simplified77.8%
metadata-eval77.8%
div-inv77.8%
*-commutative77.8%
clear-num77.8%
frac-times77.8%
*-un-lft-identity77.8%
frac-add77.7%
associate-/r/77.8%
*-un-lft-identity77.8%
*-commutative77.8%
neg-mul-177.8%
sub-neg77.8%
flip-+98.9%
+-commutative98.9%
Applied egg-rr98.9%
*-commutative98.9%
associate-/r*98.9%
Simplified98.9%
div-inv98.9%
metadata-eval98.9%
times-frac99.7%
Applied egg-rr99.7%
Taylor expanded in a around 0 71.4%
Final simplification75.7%
(FPCore (a b) :precision binary64 (if (<= a -1.35e-74) (* (/ 0.5 (* a b)) (/ PI a)) (* (/ (/ PI a) b) (/ 0.5 b))))
double code(double a, double b) {
double tmp;
if (a <= -1.35e-74) {
tmp = (0.5 / (a * b)) * (((double) M_PI) / a);
} else {
tmp = ((((double) M_PI) / a) / b) * (0.5 / b);
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (a <= -1.35e-74) {
tmp = (0.5 / (a * b)) * (Math.PI / a);
} else {
tmp = ((Math.PI / a) / b) * (0.5 / b);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -1.35e-74: tmp = (0.5 / (a * b)) * (math.pi / a) else: tmp = ((math.pi / a) / b) * (0.5 / b) return tmp
function code(a, b) tmp = 0.0 if (a <= -1.35e-74) tmp = Float64(Float64(0.5 / Float64(a * b)) * Float64(pi / a)); else tmp = Float64(Float64(Float64(pi / a) / b) * Float64(0.5 / b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -1.35e-74) tmp = (0.5 / (a * b)) * (pi / a); else tmp = ((pi / a) / b) * (0.5 / b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -1.35e-74], N[(N[(0.5 / N[(a * b), $MachinePrecision]), $MachinePrecision] * N[(Pi / a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(Pi / a), $MachinePrecision] / b), $MachinePrecision] * N[(0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.35 \cdot 10^{-74}:\\
\;\;\;\;\frac{0.5}{a \cdot b} \cdot \frac{\pi}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\pi}{a}}{b} \cdot \frac{0.5}{b}\\
\end{array}
\end{array}
if a < -1.35000000000000009e-74Initial program 79.5%
associate-*l*79.5%
*-rgt-identity79.5%
associate-/l*79.5%
metadata-eval79.5%
associate-*l/79.5%
*-lft-identity79.5%
sub-neg79.5%
distribute-neg-frac79.5%
metadata-eval79.5%
Simplified79.5%
metadata-eval79.5%
div-inv79.5%
*-commutative79.5%
clear-num78.8%
frac-times79.0%
*-un-lft-identity79.0%
frac-add78.9%
associate-/r/79.0%
*-un-lft-identity79.0%
*-commutative79.0%
neg-mul-179.0%
sub-neg79.0%
flip-+99.1%
+-commutative99.1%
Applied egg-rr99.1%
*-commutative99.1%
associate-/r*99.1%
Simplified99.1%
div-inv99.1%
metadata-eval99.1%
times-frac99.7%
Applied egg-rr99.7%
Taylor expanded in a around inf 85.8%
if -1.35000000000000009e-74 < a Initial program 77.8%
associate-*l*77.8%
*-rgt-identity77.8%
associate-/l*77.8%
metadata-eval77.8%
associate-*l/77.8%
*-lft-identity77.8%
sub-neg77.8%
distribute-neg-frac77.8%
metadata-eval77.8%
Simplified77.8%
metadata-eval77.8%
div-inv77.8%
*-commutative77.8%
clear-num77.8%
frac-times77.8%
*-un-lft-identity77.8%
frac-add77.7%
associate-/r/77.8%
*-un-lft-identity77.8%
*-commutative77.8%
neg-mul-177.8%
sub-neg77.8%
flip-+98.9%
+-commutative98.9%
Applied egg-rr98.9%
*-commutative98.9%
associate-/r*98.9%
Simplified98.9%
div-inv98.9%
metadata-eval98.9%
*-commutative98.9%
associate-*l/98.9%
*-commutative98.9%
Applied egg-rr98.9%
associate-*r/98.9%
associate-/r*99.7%
associate-/l*99.6%
associate-*l/99.7%
*-commutative99.7%
associate-/r*99.6%
Simplified99.6%
Taylor expanded in a around 0 71.4%
Final simplification75.7%
(FPCore (a b) :precision binary64 (let* ((t_0 (/ (/ PI a) b))) (if (<= a -3.8e-74) (* 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 (a <= -3.8e-74) {
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 (a <= -3.8e-74) {
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 a <= -3.8e-74: tmp = t_0 * (0.5 / a) else: tmp = t_0 * (0.5 / b) return tmp
function code(a, b) t_0 = Float64(Float64(pi / a) / b) tmp = 0.0 if (a <= -3.8e-74) 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 (a <= -3.8e-74) 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[(N[(Pi / a), $MachinePrecision] / b), $MachinePrecision]}, If[LessEqual[a, -3.8e-74], 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{\frac{\pi}{a}}{b}\\
\mathbf{if}\;a \leq -3.8 \cdot 10^{-74}:\\
\;\;\;\;t\_0 \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{0.5}{b}\\
\end{array}
\end{array}
if a < -3.7999999999999996e-74Initial program 79.5%
associate-*l*79.5%
*-rgt-identity79.5%
associate-/l*79.5%
metadata-eval79.5%
associate-*l/79.5%
*-lft-identity79.5%
sub-neg79.5%
distribute-neg-frac79.5%
metadata-eval79.5%
Simplified79.5%
metadata-eval79.5%
div-inv79.5%
*-commutative79.5%
clear-num78.8%
frac-times79.0%
*-un-lft-identity79.0%
frac-add78.9%
associate-/r/79.0%
*-un-lft-identity79.0%
*-commutative79.0%
neg-mul-179.0%
sub-neg79.0%
flip-+99.1%
+-commutative99.1%
Applied egg-rr99.1%
*-commutative99.1%
associate-/r*99.1%
Simplified99.1%
div-inv99.1%
metadata-eval99.1%
*-commutative99.1%
associate-*l/99.0%
*-commutative99.0%
Applied egg-rr99.0%
associate-*r/99.1%
associate-/r*99.7%
associate-/l*99.7%
associate-*l/99.6%
*-commutative99.6%
associate-/r*99.5%
Simplified99.5%
Taylor expanded in a around inf 85.7%
if -3.7999999999999996e-74 < a Initial program 77.8%
associate-*l*77.8%
*-rgt-identity77.8%
associate-/l*77.8%
metadata-eval77.8%
associate-*l/77.8%
*-lft-identity77.8%
sub-neg77.8%
distribute-neg-frac77.8%
metadata-eval77.8%
Simplified77.8%
metadata-eval77.8%
div-inv77.8%
*-commutative77.8%
clear-num77.8%
frac-times77.8%
*-un-lft-identity77.8%
frac-add77.7%
associate-/r/77.8%
*-un-lft-identity77.8%
*-commutative77.8%
neg-mul-177.8%
sub-neg77.8%
flip-+98.9%
+-commutative98.9%
Applied egg-rr98.9%
*-commutative98.9%
associate-/r*98.9%
Simplified98.9%
div-inv98.9%
metadata-eval98.9%
*-commutative98.9%
associate-*l/98.9%
*-commutative98.9%
Applied egg-rr98.9%
associate-*r/98.9%
associate-/r*99.7%
associate-/l*99.6%
associate-*l/99.7%
*-commutative99.7%
associate-/r*99.6%
Simplified99.6%
Taylor expanded in a around 0 71.4%
Final simplification75.6%
(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 78.3%
associate-*l*78.3%
*-rgt-identity78.3%
associate-/l*78.3%
metadata-eval78.3%
associate-*l/78.3%
*-lft-identity78.3%
sub-neg78.3%
distribute-neg-frac78.3%
metadata-eval78.3%
Simplified78.3%
metadata-eval78.3%
div-inv78.3%
*-commutative78.3%
clear-num78.1%
frac-times78.1%
*-un-lft-identity78.1%
frac-add78.1%
associate-/r/78.2%
*-un-lft-identity78.2%
*-commutative78.2%
neg-mul-178.2%
sub-neg78.2%
flip-+99.0%
+-commutative99.0%
Applied egg-rr99.0%
*-commutative99.0%
associate-/r*99.0%
Simplified99.0%
div-inv99.0%
metadata-eval99.0%
*-commutative99.0%
times-frac99.7%
Applied egg-rr99.7%
(FPCore (a b) :precision binary64 (* (/ 0.5 (+ a b)) (/ (/ PI a) b)))
double code(double a, double b) {
return (0.5 / (a + b)) * ((((double) M_PI) / a) / b);
}
public static double code(double a, double b) {
return (0.5 / (a + b)) * ((Math.PI / a) / b);
}
def code(a, b): return (0.5 / (a + b)) * ((math.pi / a) / b)
function code(a, b) return Float64(Float64(0.5 / Float64(a + b)) * Float64(Float64(pi / a) / b)) end
function tmp = code(a, b) tmp = (0.5 / (a + b)) * ((pi / a) / b); end
code[a_, b_] := N[(N[(0.5 / N[(a + b), $MachinePrecision]), $MachinePrecision] * N[(N[(Pi / a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5}{a + b} \cdot \frac{\frac{\pi}{a}}{b}
\end{array}
Initial program 78.3%
associate-*l*78.3%
*-rgt-identity78.3%
associate-/l*78.3%
metadata-eval78.3%
associate-*l/78.3%
*-lft-identity78.3%
sub-neg78.3%
distribute-neg-frac78.3%
metadata-eval78.3%
Simplified78.3%
metadata-eval78.3%
div-inv78.3%
*-commutative78.3%
clear-num78.1%
frac-times78.1%
*-un-lft-identity78.1%
frac-add78.1%
associate-/r/78.2%
*-un-lft-identity78.2%
*-commutative78.2%
neg-mul-178.2%
sub-neg78.2%
flip-+99.0%
+-commutative99.0%
Applied egg-rr99.0%
*-commutative99.0%
associate-/r*99.0%
Simplified99.0%
div-inv99.0%
metadata-eval99.0%
*-commutative99.0%
associate-*l/98.9%
*-commutative98.9%
Applied egg-rr98.9%
associate-*r/99.0%
associate-/r*99.7%
associate-/l*99.6%
associate-*l/99.7%
*-commutative99.7%
associate-/r*99.6%
Simplified99.6%
(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 78.3%
*-commutative78.3%
associate-*r*78.3%
associate-*r/78.3%
associate-*r*78.3%
*-rgt-identity78.3%
sub-neg78.3%
distribute-neg-frac78.3%
metadata-eval78.3%
Simplified78.3%
*-commutative78.3%
associate-*r/78.3%
div-inv78.3%
metadata-eval78.3%
associate-*l*78.3%
*-commutative78.3%
Applied egg-rr98.9%
Final simplification98.9%
(FPCore (a b) :precision binary64 (* (/ (/ PI a) b) (/ 0.5 a)))
double code(double a, double b) {
return ((((double) M_PI) / a) / b) * (0.5 / a);
}
public static double code(double a, double b) {
return ((Math.PI / a) / b) * (0.5 / a);
}
def code(a, b): return ((math.pi / a) / b) * (0.5 / a)
function code(a, b) return Float64(Float64(Float64(pi / a) / b) * Float64(0.5 / a)) end
function tmp = code(a, b) tmp = ((pi / a) / b) * (0.5 / a); end
code[a_, b_] := N[(N[(N[(Pi / a), $MachinePrecision] / b), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\pi}{a}}{b} \cdot \frac{0.5}{a}
\end{array}
Initial program 78.3%
associate-*l*78.3%
*-rgt-identity78.3%
associate-/l*78.3%
metadata-eval78.3%
associate-*l/78.3%
*-lft-identity78.3%
sub-neg78.3%
distribute-neg-frac78.3%
metadata-eval78.3%
Simplified78.3%
metadata-eval78.3%
div-inv78.3%
*-commutative78.3%
clear-num78.1%
frac-times78.1%
*-un-lft-identity78.1%
frac-add78.1%
associate-/r/78.2%
*-un-lft-identity78.2%
*-commutative78.2%
neg-mul-178.2%
sub-neg78.2%
flip-+99.0%
+-commutative99.0%
Applied egg-rr99.0%
*-commutative99.0%
associate-/r*99.0%
Simplified99.0%
div-inv99.0%
metadata-eval99.0%
*-commutative99.0%
associate-*l/98.9%
*-commutative98.9%
Applied egg-rr98.9%
associate-*r/99.0%
associate-/r*99.7%
associate-/l*99.6%
associate-*l/99.7%
*-commutative99.7%
associate-/r*99.6%
Simplified99.6%
Taylor expanded in a around inf 61.7%
Final simplification61.7%
herbie shell --seed 2024185
(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))))