
(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) (+ a b)) (/ (+ (/ 1.0 a) (/ -1.0 b)) (- b a))))
double code(double a, double b) {
return ((0.5 * ((double) M_PI)) / (a + b)) * (((1.0 / a) + (-1.0 / b)) / (b - a));
}
public static double code(double a, double b) {
return ((0.5 * Math.PI) / (a + b)) * (((1.0 / a) + (-1.0 / b)) / (b - a));
}
def code(a, b): return ((0.5 * math.pi) / (a + b)) * (((1.0 / a) + (-1.0 / b)) / (b - a))
function code(a, b) return Float64(Float64(Float64(0.5 * pi) / Float64(a + b)) * Float64(Float64(Float64(1.0 / a) + Float64(-1.0 / b)) / Float64(b - a))) end
function tmp = code(a, b) tmp = ((0.5 * pi) / (a + b)) * (((1.0 / a) + (-1.0 / b)) / (b - a)); end
code[a_, b_] := N[(N[(N[(0.5 * Pi), $MachinePrecision] / N[(a + b), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(1.0 / a), $MachinePrecision] + N[(-1.0 / b), $MachinePrecision]), $MachinePrecision] / N[(b - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5 \cdot \pi}{a + b} \cdot \frac{\frac{1}{a} + \frac{-1}{b}}{b - a}
\end{array}
Initial program 80.5%
un-div-inv80.6%
difference-of-squares89.5%
associate-/r*89.8%
div-inv89.8%
metadata-eval89.8%
Applied egg-rr89.8%
associate-*l/99.7%
associate-/l*99.6%
Applied egg-rr99.6%
associate-/l*99.7%
associate-*r/99.7%
*-commutative99.7%
+-commutative99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (a b) :precision binary64 (if (or (<= b 3.5e-198) (and (not (<= b 7.6e-184)) (<= b 4.1e-76))) (* (/ (/ 1.0 a) b) (* 0.5 (/ PI a))) (* (/ 0.5 b) (/ PI (* a b)))))
double code(double a, double b) {
double tmp;
if ((b <= 3.5e-198) || (!(b <= 7.6e-184) && (b <= 4.1e-76))) {
tmp = ((1.0 / a) / b) * (0.5 * (((double) M_PI) / a));
} else {
tmp = (0.5 / b) * (((double) M_PI) / (a * b));
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if ((b <= 3.5e-198) || (!(b <= 7.6e-184) && (b <= 4.1e-76))) {
tmp = ((1.0 / a) / b) * (0.5 * (Math.PI / a));
} else {
tmp = (0.5 / b) * (Math.PI / (a * b));
}
return tmp;
}
def code(a, b): tmp = 0 if (b <= 3.5e-198) or (not (b <= 7.6e-184) and (b <= 4.1e-76)): tmp = ((1.0 / a) / b) * (0.5 * (math.pi / a)) else: tmp = (0.5 / b) * (math.pi / (a * b)) return tmp
function code(a, b) tmp = 0.0 if ((b <= 3.5e-198) || (!(b <= 7.6e-184) && (b <= 4.1e-76))) tmp = Float64(Float64(Float64(1.0 / a) / b) * Float64(0.5 * Float64(pi / a))); else tmp = Float64(Float64(0.5 / b) * Float64(pi / Float64(a * b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b <= 3.5e-198) || (~((b <= 7.6e-184)) && (b <= 4.1e-76))) tmp = ((1.0 / a) / b) * (0.5 * (pi / a)); else tmp = (0.5 / b) * (pi / (a * b)); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[b, 3.5e-198], And[N[Not[LessEqual[b, 7.6e-184]], $MachinePrecision], LessEqual[b, 4.1e-76]]], N[(N[(N[(1.0 / a), $MachinePrecision] / b), $MachinePrecision] * N[(0.5 * N[(Pi / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / b), $MachinePrecision] * N[(Pi / N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.5 \cdot 10^{-198} \lor \neg \left(b \leq 7.6 \cdot 10^{-184}\right) \land b \leq 4.1 \cdot 10^{-76}:\\
\;\;\;\;\frac{\frac{1}{a}}{b} \cdot \left(0.5 \cdot \frac{\pi}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{b} \cdot \frac{\pi}{a \cdot b}\\
\end{array}
\end{array}
if b < 3.50000000000000025e-198 or 7.60000000000000033e-184 < b < 4.0999999999999998e-76Initial program 80.3%
un-div-inv80.3%
difference-of-squares89.9%
associate-/r*90.3%
div-inv90.3%
metadata-eval90.3%
Applied egg-rr90.3%
associate-*l/99.7%
associate-/l*99.6%
Applied egg-rr99.6%
associate-/l*99.6%
associate-*r/99.7%
*-commutative99.7%
+-commutative99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in a around 0 99.7%
associate-/r*99.7%
Simplified99.7%
Taylor expanded in a around inf 75.5%
if 3.50000000000000025e-198 < b < 7.60000000000000033e-184 or 4.0999999999999998e-76 < b Initial program 81.1%
*-commutative81.1%
associate-*r*81.0%
associate-*r/81.0%
associate-*r*81.0%
*-rgt-identity81.0%
sub-neg81.0%
distribute-neg-frac81.0%
metadata-eval81.0%
Simplified81.0%
*-un-lft-identity81.0%
difference-of-squares88.3%
times-frac98.3%
add-sqr-sqrt0.0%
sqrt-unprod81.9%
frac-times81.9%
metadata-eval81.9%
metadata-eval81.9%
frac-times81.9%
sqrt-unprod86.4%
add-sqr-sqrt86.4%
div-inv86.4%
metadata-eval86.4%
Applied egg-rr86.4%
associate-*l/86.2%
*-lft-identity86.2%
associate-/l*87.6%
associate-*l/87.7%
+-commutative87.7%
+-commutative87.7%
*-commutative87.7%
Simplified87.7%
Taylor expanded in b around 0 87.6%
associate-*l/87.7%
*-un-lft-identity87.7%
associate-/l*87.7%
Applied egg-rr87.7%
*-commutative87.7%
times-frac87.7%
Simplified87.7%
Taylor expanded in b around inf 76.5%
Final simplification75.8%
(FPCore (a b)
:precision binary64
(let* ((t_0 (/ (/ 1.0 a) b)) (t_1 (* t_0 (* 0.5 (/ PI a)))))
(if (<= b 3.5e-198)
t_1
(if (<= b 7.6e-184)
(* (/ 0.5 b) (/ PI (* a b)))
(if (<= b 4.1e-76) t_1 (* t_0 (* 0.5 (/ PI b))))))))
double code(double a, double b) {
double t_0 = (1.0 / a) / b;
double t_1 = t_0 * (0.5 * (((double) M_PI) / a));
double tmp;
if (b <= 3.5e-198) {
tmp = t_1;
} else if (b <= 7.6e-184) {
tmp = (0.5 / b) * (((double) M_PI) / (a * b));
} else if (b <= 4.1e-76) {
tmp = t_1;
} else {
tmp = t_0 * (0.5 * (((double) M_PI) / b));
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = (1.0 / a) / b;
double t_1 = t_0 * (0.5 * (Math.PI / a));
double tmp;
if (b <= 3.5e-198) {
tmp = t_1;
} else if (b <= 7.6e-184) {
tmp = (0.5 / b) * (Math.PI / (a * b));
} else if (b <= 4.1e-76) {
tmp = t_1;
} else {
tmp = t_0 * (0.5 * (Math.PI / b));
}
return tmp;
}
def code(a, b): t_0 = (1.0 / a) / b t_1 = t_0 * (0.5 * (math.pi / a)) tmp = 0 if b <= 3.5e-198: tmp = t_1 elif b <= 7.6e-184: tmp = (0.5 / b) * (math.pi / (a * b)) elif b <= 4.1e-76: tmp = t_1 else: tmp = t_0 * (0.5 * (math.pi / b)) return tmp
function code(a, b) t_0 = Float64(Float64(1.0 / a) / b) t_1 = Float64(t_0 * Float64(0.5 * Float64(pi / a))) tmp = 0.0 if (b <= 3.5e-198) tmp = t_1; elseif (b <= 7.6e-184) tmp = Float64(Float64(0.5 / b) * Float64(pi / Float64(a * b))); elseif (b <= 4.1e-76) tmp = t_1; else tmp = Float64(t_0 * Float64(0.5 * Float64(pi / b))); end return tmp end
function tmp_2 = code(a, b) t_0 = (1.0 / a) / b; t_1 = t_0 * (0.5 * (pi / a)); tmp = 0.0; if (b <= 3.5e-198) tmp = t_1; elseif (b <= 7.6e-184) tmp = (0.5 / b) * (pi / (a * b)); elseif (b <= 4.1e-76) tmp = t_1; else tmp = t_0 * (0.5 * (pi / b)); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[(1.0 / a), $MachinePrecision] / b), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(0.5 * N[(Pi / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 3.5e-198], t$95$1, If[LessEqual[b, 7.6e-184], N[(N[(0.5 / b), $MachinePrecision] * N[(Pi / N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.1e-76], t$95$1, N[(t$95$0 * N[(0.5 * N[(Pi / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{1}{a}}{b}\\
t_1 := t\_0 \cdot \left(0.5 \cdot \frac{\pi}{a}\right)\\
\mathbf{if}\;b \leq 3.5 \cdot 10^{-198}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 7.6 \cdot 10^{-184}:\\
\;\;\;\;\frac{0.5}{b} \cdot \frac{\pi}{a \cdot b}\\
\mathbf{elif}\;b \leq 4.1 \cdot 10^{-76}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(0.5 \cdot \frac{\pi}{b}\right)\\
\end{array}
\end{array}
if b < 3.50000000000000025e-198 or 7.60000000000000033e-184 < b < 4.0999999999999998e-76Initial program 80.3%
un-div-inv80.3%
difference-of-squares89.9%
associate-/r*90.3%
div-inv90.3%
metadata-eval90.3%
Applied egg-rr90.3%
associate-*l/99.7%
associate-/l*99.6%
Applied egg-rr99.6%
associate-/l*99.6%
associate-*r/99.7%
*-commutative99.7%
+-commutative99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in a around 0 99.7%
associate-/r*99.7%
Simplified99.7%
Taylor expanded in a around inf 75.5%
if 3.50000000000000025e-198 < b < 7.60000000000000033e-184Initial program 86.2%
*-commutative86.2%
associate-*r*86.4%
associate-*r/86.7%
associate-*r*86.7%
*-rgt-identity86.7%
sub-neg86.7%
distribute-neg-frac86.7%
metadata-eval86.7%
Simplified86.7%
*-un-lft-identity86.7%
difference-of-squares86.7%
times-frac99.3%
add-sqr-sqrt0.0%
sqrt-unprod14.5%
frac-times14.5%
metadata-eval14.5%
metadata-eval14.5%
frac-times14.5%
sqrt-unprod57.9%
add-sqr-sqrt57.9%
div-inv57.9%
metadata-eval57.9%
Applied egg-rr57.9%
associate-*l/57.9%
*-lft-identity57.9%
associate-/l*57.9%
associate-*l/57.9%
+-commutative57.9%
+-commutative57.9%
*-commutative57.9%
Simplified57.9%
Taylor expanded in b around 0 57.9%
associate-*l/57.9%
*-un-lft-identity57.9%
associate-/l*57.9%
Applied egg-rr57.9%
*-commutative57.9%
times-frac58.1%
Simplified58.1%
Taylor expanded in b around inf 60.2%
if 4.0999999999999998e-76 < b Initial program 80.5%
un-div-inv80.5%
difference-of-squares88.7%
associate-/r*88.7%
div-inv88.7%
metadata-eval88.7%
Applied egg-rr88.7%
associate-*l/99.6%
associate-/l*99.7%
Applied egg-rr99.7%
associate-/l*99.8%
associate-*r/99.7%
*-commutative99.7%
+-commutative99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in a around 0 99.6%
associate-/r*99.7%
Simplified99.7%
Taylor expanded in a around 0 78.5%
Final simplification75.8%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* (/ (/ 1.0 a) b) (* 0.5 (/ PI a)))))
(if (<= b 3.5e-198)
t_0
(if (<= b 7.6e-184)
(* (/ 0.5 b) (/ PI (* a b)))
(if (<= b 5.8e-81) t_0 (* (/ 0.5 b) (/ (/ PI (- b a)) a)))))))
double code(double a, double b) {
double t_0 = ((1.0 / a) / b) * (0.5 * (((double) M_PI) / a));
double tmp;
if (b <= 3.5e-198) {
tmp = t_0;
} else if (b <= 7.6e-184) {
tmp = (0.5 / b) * (((double) M_PI) / (a * b));
} else if (b <= 5.8e-81) {
tmp = t_0;
} else {
tmp = (0.5 / b) * ((((double) M_PI) / (b - a)) / a);
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = ((1.0 / a) / b) * (0.5 * (Math.PI / a));
double tmp;
if (b <= 3.5e-198) {
tmp = t_0;
} else if (b <= 7.6e-184) {
tmp = (0.5 / b) * (Math.PI / (a * b));
} else if (b <= 5.8e-81) {
tmp = t_0;
} else {
tmp = (0.5 / b) * ((Math.PI / (b - a)) / a);
}
return tmp;
}
def code(a, b): t_0 = ((1.0 / a) / b) * (0.5 * (math.pi / a)) tmp = 0 if b <= 3.5e-198: tmp = t_0 elif b <= 7.6e-184: tmp = (0.5 / b) * (math.pi / (a * b)) elif b <= 5.8e-81: tmp = t_0 else: tmp = (0.5 / b) * ((math.pi / (b - a)) / a) return tmp
function code(a, b) t_0 = Float64(Float64(Float64(1.0 / a) / b) * Float64(0.5 * Float64(pi / a))) tmp = 0.0 if (b <= 3.5e-198) tmp = t_0; elseif (b <= 7.6e-184) tmp = Float64(Float64(0.5 / b) * Float64(pi / Float64(a * b))); elseif (b <= 5.8e-81) tmp = t_0; else tmp = Float64(Float64(0.5 / b) * Float64(Float64(pi / Float64(b - a)) / a)); end return tmp end
function tmp_2 = code(a, b) t_0 = ((1.0 / a) / b) * (0.5 * (pi / a)); tmp = 0.0; if (b <= 3.5e-198) tmp = t_0; elseif (b <= 7.6e-184) tmp = (0.5 / b) * (pi / (a * b)); elseif (b <= 5.8e-81) tmp = t_0; else tmp = (0.5 / b) * ((pi / (b - a)) / a); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[(N[(1.0 / a), $MachinePrecision] / b), $MachinePrecision] * N[(0.5 * N[(Pi / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 3.5e-198], t$95$0, If[LessEqual[b, 7.6e-184], N[(N[(0.5 / b), $MachinePrecision] * N[(Pi / N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.8e-81], t$95$0, N[(N[(0.5 / b), $MachinePrecision] * N[(N[(Pi / N[(b - a), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{1}{a}}{b} \cdot \left(0.5 \cdot \frac{\pi}{a}\right)\\
\mathbf{if}\;b \leq 3.5 \cdot 10^{-198}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 7.6 \cdot 10^{-184}:\\
\;\;\;\;\frac{0.5}{b} \cdot \frac{\pi}{a \cdot b}\\
\mathbf{elif}\;b \leq 5.8 \cdot 10^{-81}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{b} \cdot \frac{\frac{\pi}{b - a}}{a}\\
\end{array}
\end{array}
if b < 3.50000000000000025e-198 or 7.60000000000000033e-184 < b < 5.79999999999999978e-81Initial program 80.0%
un-div-inv80.0%
difference-of-squares89.8%
associate-/r*90.2%
div-inv90.2%
metadata-eval90.2%
Applied egg-rr90.2%
associate-*l/99.7%
associate-/l*99.6%
Applied egg-rr99.6%
associate-/l*99.6%
associate-*r/99.7%
*-commutative99.7%
+-commutative99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in a around 0 99.7%
associate-/r*99.7%
Simplified99.7%
Taylor expanded in a around inf 75.2%
if 3.50000000000000025e-198 < b < 7.60000000000000033e-184Initial program 86.2%
*-commutative86.2%
associate-*r*86.4%
associate-*r/86.7%
associate-*r*86.7%
*-rgt-identity86.7%
sub-neg86.7%
distribute-neg-frac86.7%
metadata-eval86.7%
Simplified86.7%
*-un-lft-identity86.7%
difference-of-squares86.7%
times-frac99.3%
add-sqr-sqrt0.0%
sqrt-unprod14.5%
frac-times14.5%
metadata-eval14.5%
metadata-eval14.5%
frac-times14.5%
sqrt-unprod57.9%
add-sqr-sqrt57.9%
div-inv57.9%
metadata-eval57.9%
Applied egg-rr57.9%
associate-*l/57.9%
*-lft-identity57.9%
associate-/l*57.9%
associate-*l/57.9%
+-commutative57.9%
+-commutative57.9%
*-commutative57.9%
Simplified57.9%
Taylor expanded in b around 0 57.9%
associate-*l/57.9%
*-un-lft-identity57.9%
associate-/l*57.9%
Applied egg-rr57.9%
*-commutative57.9%
times-frac58.1%
Simplified58.1%
Taylor expanded in b around inf 60.2%
if 5.79999999999999978e-81 < b Initial program 81.4%
*-commutative81.4%
associate-*r*81.3%
associate-*r/81.2%
associate-*r*81.2%
*-rgt-identity81.2%
sub-neg81.2%
distribute-neg-frac81.2%
metadata-eval81.2%
Simplified81.2%
*-un-lft-identity81.2%
difference-of-squares89.0%
times-frac98.3%
add-sqr-sqrt0.0%
sqrt-unprod88.6%
frac-times88.6%
metadata-eval88.6%
metadata-eval88.6%
frac-times88.6%
sqrt-unprod88.6%
add-sqr-sqrt88.6%
div-inv88.6%
metadata-eval88.6%
Applied egg-rr88.6%
associate-*l/88.5%
*-lft-identity88.5%
associate-/l*89.9%
associate-*l/90.0%
+-commutative90.0%
+-commutative90.0%
*-commutative90.0%
Simplified90.0%
Taylor expanded in b around 0 89.9%
associate-*l/90.0%
*-un-lft-identity90.0%
associate-/l*90.0%
Applied egg-rr90.0%
*-commutative90.0%
times-frac90.0%
Simplified90.0%
Final simplification78.4%
(FPCore (a b) :precision binary64 (if (<= a -3e+114) (* (/ 0.5 b) (/ (/ (- PI) a) a)) (* (/ 0.5 b) (/ PI (* a b)))))
double code(double a, double b) {
double tmp;
if (a <= -3e+114) {
tmp = (0.5 / b) * ((-((double) M_PI) / a) / a);
} else {
tmp = (0.5 / b) * (((double) M_PI) / (a * b));
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (a <= -3e+114) {
tmp = (0.5 / b) * ((-Math.PI / a) / a);
} else {
tmp = (0.5 / b) * (Math.PI / (a * b));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -3e+114: tmp = (0.5 / b) * ((-math.pi / a) / a) else: tmp = (0.5 / b) * (math.pi / (a * b)) return tmp
function code(a, b) tmp = 0.0 if (a <= -3e+114) tmp = Float64(Float64(0.5 / b) * Float64(Float64(Float64(-pi) / a) / a)); else tmp = Float64(Float64(0.5 / b) * Float64(pi / Float64(a * b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -3e+114) tmp = (0.5 / b) * ((-pi / a) / a); else tmp = (0.5 / b) * (pi / (a * b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -3e+114], N[(N[(0.5 / b), $MachinePrecision] * N[(N[((-Pi) / a), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / b), $MachinePrecision] * N[(Pi / N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3 \cdot 10^{+114}:\\
\;\;\;\;\frac{0.5}{b} \cdot \frac{\frac{-\pi}{a}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{b} \cdot \frac{\pi}{a \cdot b}\\
\end{array}
\end{array}
if a < -3e114Initial program 51.7%
*-commutative51.7%
associate-*r*51.7%
associate-*r/51.7%
associate-*r*51.7%
*-rgt-identity51.7%
sub-neg51.7%
distribute-neg-frac51.7%
metadata-eval51.7%
Simplified51.7%
*-un-lft-identity51.7%
difference-of-squares78.1%
times-frac99.8%
add-sqr-sqrt60.3%
sqrt-unprod70.5%
frac-times70.5%
metadata-eval70.5%
metadata-eval70.5%
frac-times70.5%
sqrt-unprod23.2%
add-sqr-sqrt71.3%
div-inv71.3%
metadata-eval71.3%
Applied egg-rr71.3%
associate-*l/71.3%
*-lft-identity71.3%
associate-/l*71.3%
associate-*l/71.3%
+-commutative71.3%
+-commutative71.3%
*-commutative71.3%
Simplified71.3%
Taylor expanded in b around 0 71.3%
associate-*l/71.3%
*-un-lft-identity71.3%
associate-/l*71.3%
Applied egg-rr71.3%
*-commutative71.3%
times-frac71.7%
Simplified71.7%
Taylor expanded in b around 0 71.7%
associate-*r/71.7%
mul-1-neg71.7%
Simplified71.7%
if -3e114 < a Initial program 85.5%
*-commutative85.5%
associate-*r*85.5%
associate-*r/85.5%
associate-*r*85.5%
*-rgt-identity85.5%
sub-neg85.5%
distribute-neg-frac85.5%
metadata-eval85.5%
Simplified85.5%
*-un-lft-identity85.5%
difference-of-squares91.5%
times-frac99.2%
add-sqr-sqrt55.7%
sqrt-unprod73.3%
frac-times73.2%
metadata-eval73.2%
metadata-eval73.2%
frac-times73.3%
sqrt-unprod26.9%
add-sqr-sqrt58.8%
div-inv58.8%
metadata-eval58.8%
Applied egg-rr58.8%
associate-*l/58.8%
*-lft-identity58.8%
associate-/l*59.2%
associate-*l/59.3%
+-commutative59.3%
+-commutative59.3%
*-commutative59.3%
Simplified59.3%
Taylor expanded in b around 0 59.2%
associate-*l/59.2%
*-un-lft-identity59.2%
associate-/l*59.2%
Applied egg-rr59.2%
*-commutative59.2%
times-frac59.3%
Simplified59.3%
Taylor expanded in b around inf 58.0%
Final simplification60.1%
(FPCore (a b) :precision binary64 (* (/ (* 0.5 PI) (+ a b)) (/ 1.0 (* a b))))
double code(double a, double b) {
return ((0.5 * ((double) M_PI)) / (a + b)) * (1.0 / (a * b));
}
public static double code(double a, double b) {
return ((0.5 * Math.PI) / (a + b)) * (1.0 / (a * b));
}
def code(a, b): return ((0.5 * math.pi) / (a + b)) * (1.0 / (a * b))
function code(a, b) return Float64(Float64(Float64(0.5 * pi) / Float64(a + b)) * Float64(1.0 / Float64(a * b))) end
function tmp = code(a, b) tmp = ((0.5 * pi) / (a + b)) * (1.0 / (a * b)); end
code[a_, b_] := N[(N[(N[(0.5 * Pi), $MachinePrecision] / N[(a + b), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5 \cdot \pi}{a + b} \cdot \frac{1}{a \cdot b}
\end{array}
Initial program 80.5%
un-div-inv80.6%
difference-of-squares89.5%
associate-/r*89.8%
div-inv89.8%
metadata-eval89.8%
Applied egg-rr89.8%
associate-*l/99.7%
associate-/l*99.6%
Applied egg-rr99.6%
associate-/l*99.7%
associate-*r/99.7%
*-commutative99.7%
+-commutative99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in a around 0 99.7%
Final simplification99.7%
(FPCore (a b) :precision binary64 (* (/ (* 0.5 PI) (+ a b)) (/ (/ 1.0 a) b)))
double code(double a, double b) {
return ((0.5 * ((double) M_PI)) / (a + b)) * ((1.0 / a) / b);
}
public static double code(double a, double b) {
return ((0.5 * Math.PI) / (a + b)) * ((1.0 / a) / b);
}
def code(a, b): return ((0.5 * math.pi) / (a + b)) * ((1.0 / a) / b)
function code(a, b) return Float64(Float64(Float64(0.5 * pi) / Float64(a + b)) * Float64(Float64(1.0 / a) / b)) end
function tmp = code(a, b) tmp = ((0.5 * pi) / (a + b)) * ((1.0 / a) / b); end
code[a_, b_] := N[(N[(N[(0.5 * Pi), $MachinePrecision] / N[(a + b), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5 \cdot \pi}{a + b} \cdot \frac{\frac{1}{a}}{b}
\end{array}
Initial program 80.5%
un-div-inv80.6%
difference-of-squares89.5%
associate-/r*89.8%
div-inv89.8%
metadata-eval89.8%
Applied egg-rr89.8%
associate-*l/99.7%
associate-/l*99.6%
Applied egg-rr99.6%
associate-/l*99.7%
associate-*r/99.7%
*-commutative99.7%
+-commutative99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in a around 0 99.7%
associate-/r*99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (a b) :precision binary64 (/ (* 0.5 PI) (* (+ a b) (* a b))))
double code(double a, double b) {
return (0.5 * ((double) M_PI)) / ((a + b) * (a * b));
}
public static double code(double a, double b) {
return (0.5 * Math.PI) / ((a + b) * (a * b));
}
def code(a, b): return (0.5 * math.pi) / ((a + b) * (a * b))
function code(a, b) return Float64(Float64(0.5 * pi) / Float64(Float64(a + b) * Float64(a * b))) end
function tmp = code(a, b) tmp = (0.5 * pi) / ((a + b) * (a * b)); end
code[a_, b_] := N[(N[(0.5 * Pi), $MachinePrecision] / N[(N[(a + b), $MachinePrecision] * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5 \cdot \pi}{\left(a + b\right) \cdot \left(a \cdot b\right)}
\end{array}
Initial program 80.5%
un-div-inv80.6%
difference-of-squares89.5%
associate-/r*89.8%
div-inv89.8%
metadata-eval89.8%
Applied egg-rr89.8%
associate-*l/99.7%
associate-/l*99.6%
Applied egg-rr99.6%
associate-/l*99.7%
associate-*r/99.7%
*-commutative99.7%
+-commutative99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in a around 0 99.7%
associate-/r*99.7%
Simplified99.7%
*-commutative99.7%
associate-/l/99.7%
frac-times99.2%
*-un-lft-identity99.2%
*-commutative99.2%
Applied egg-rr99.2%
Final simplification99.2%
(FPCore (a b) :precision binary64 (/ (/ (/ 0.5 b) (/ a PI)) (+ a b)))
double code(double a, double b) {
return ((0.5 / b) / (a / ((double) M_PI))) / (a + b);
}
public static double code(double a, double b) {
return ((0.5 / b) / (a / Math.PI)) / (a + b);
}
def code(a, b): return ((0.5 / b) / (a / math.pi)) / (a + b)
function code(a, b) return Float64(Float64(Float64(0.5 / b) / Float64(a / pi)) / Float64(a + b)) end
function tmp = code(a, b) tmp = ((0.5 / b) / (a / pi)) / (a + b); end
code[a_, b_] := N[(N[(N[(0.5 / b), $MachinePrecision] / N[(a / Pi), $MachinePrecision]), $MachinePrecision] / N[(a + b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\frac{0.5}{b}}{\frac{a}{\pi}}}{a + b}
\end{array}
Initial program 80.5%
un-div-inv80.6%
difference-of-squares89.5%
associate-/r*89.8%
div-inv89.8%
metadata-eval89.8%
Applied egg-rr89.8%
associate-*l/99.7%
associate-/l*99.6%
Applied egg-rr99.6%
associate-/l*99.7%
associate-*r/99.7%
*-commutative99.7%
+-commutative99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in a around 0 99.7%
associate-/r*99.7%
Simplified99.7%
associate-*l/99.6%
associate-/l/99.6%
div-inv99.7%
times-frac99.3%
clear-num99.3%
frac-times99.6%
metadata-eval99.6%
Applied egg-rr99.6%
associate-/r*99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (a b) :precision binary64 (* (/ 0.5 b) (/ PI (* a b))))
double code(double a, double b) {
return (0.5 / b) * (((double) M_PI) / (a * b));
}
public static double code(double a, double b) {
return (0.5 / b) * (Math.PI / (a * b));
}
def code(a, b): return (0.5 / b) * (math.pi / (a * b))
function code(a, b) return Float64(Float64(0.5 / b) * Float64(pi / Float64(a * b))) end
function tmp = code(a, b) tmp = (0.5 / b) * (pi / (a * b)); end
code[a_, b_] := N[(N[(0.5 / b), $MachinePrecision] * N[(Pi / N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5}{b} \cdot \frac{\pi}{a \cdot b}
\end{array}
Initial program 80.5%
*-commutative80.5%
associate-*r*80.5%
associate-*r/80.5%
associate-*r*80.5%
*-rgt-identity80.5%
sub-neg80.5%
distribute-neg-frac80.5%
metadata-eval80.5%
Simplified80.5%
*-un-lft-identity80.5%
difference-of-squares89.5%
times-frac99.3%
add-sqr-sqrt56.4%
sqrt-unprod72.9%
frac-times72.8%
metadata-eval72.8%
metadata-eval72.8%
frac-times72.9%
sqrt-unprod26.3%
add-sqr-sqrt60.7%
div-inv60.7%
metadata-eval60.7%
Applied egg-rr60.7%
associate-*l/60.6%
*-lft-identity60.6%
associate-/l*61.0%
associate-*l/61.1%
+-commutative61.1%
+-commutative61.1%
*-commutative61.1%
Simplified61.1%
Taylor expanded in b around 0 61.0%
associate-*l/61.0%
*-un-lft-identity61.0%
associate-/l*61.0%
Applied egg-rr61.0%
*-commutative61.0%
times-frac61.1%
Simplified61.1%
Taylor expanded in b around inf 56.0%
Final simplification56.0%
herbie shell --seed 2024079
(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))))