
(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 (* (/ 1.0 (* 2.0 (- b a))) (* (+ (/ 1.0 a) (/ -1.0 b)) (/ PI (+ b a)))))
double code(double a, double b) {
return (1.0 / (2.0 * (b - a))) * (((1.0 / a) + (-1.0 / b)) * (((double) M_PI) / (b + a)));
}
public static double code(double a, double b) {
return (1.0 / (2.0 * (b - a))) * (((1.0 / a) + (-1.0 / b)) * (Math.PI / (b + a)));
}
def code(a, b): return (1.0 / (2.0 * (b - a))) * (((1.0 / a) + (-1.0 / b)) * (math.pi / (b + a)))
function code(a, b) return Float64(Float64(1.0 / Float64(2.0 * Float64(b - a))) * Float64(Float64(Float64(1.0 / a) + Float64(-1.0 / b)) * Float64(pi / Float64(b + a)))) end
function tmp = code(a, b) tmp = (1.0 / (2.0 * (b - a))) * (((1.0 / a) + (-1.0 / b)) * (pi / (b + a))); end
code[a_, b_] := N[(N[(1.0 / N[(2.0 * N[(b - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(1.0 / a), $MachinePrecision] + N[(-1.0 / b), $MachinePrecision]), $MachinePrecision] * N[(Pi / N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{2 \cdot \left(b - a\right)} \cdot \left(\left(\frac{1}{a} + \frac{-1}{b}\right) \cdot \frac{\pi}{b + a}\right)
\end{array}
Initial program 78.4%
*-commutative78.4%
associate-*l/78.4%
associate-*r/78.4%
associate-/l*78.4%
sub-neg78.4%
distribute-neg-frac78.4%
metadata-eval78.4%
associate-*r/78.3%
*-rgt-identity78.3%
difference-of-squares87.3%
associate-/r*87.3%
Simplified87.3%
clear-num87.2%
inv-pow87.2%
associate-/r/87.2%
Applied egg-rr87.2%
unpow-187.2%
associate-*l/87.3%
+-commutative87.3%
metadata-eval87.3%
distribute-neg-frac87.3%
sub-neg87.3%
Simplified87.3%
*-un-lft-identity87.3%
associate-/l/99.2%
inv-pow99.2%
inv-pow99.2%
Applied egg-rr99.2%
expm1-log1p-u79.0%
expm1-udef52.4%
*-un-lft-identity52.4%
inv-pow52.4%
unpow-152.4%
+-commutative52.4%
Applied egg-rr52.4%
expm1-def79.0%
expm1-log1p99.2%
associate-/r/99.6%
+-commutative99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (a b)
:precision binary64
(if (<= b 8.2e-167)
(* 0.5 (/ (/ PI a) (* b a)))
(if (<= b 4.8e+140)
(* (+ (/ 1.0 a) (/ -1.0 b)) (/ (/ PI 2.0) (- (* b b) (* a a))))
(* (/ 1.0 (* 2.0 (- b a))) (/ PI (* b a))))))
double code(double a, double b) {
double tmp;
if (b <= 8.2e-167) {
tmp = 0.5 * ((((double) M_PI) / a) / (b * a));
} else if (b <= 4.8e+140) {
tmp = ((1.0 / a) + (-1.0 / b)) * ((((double) M_PI) / 2.0) / ((b * b) - (a * a)));
} else {
tmp = (1.0 / (2.0 * (b - a))) * (((double) M_PI) / (b * a));
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (b <= 8.2e-167) {
tmp = 0.5 * ((Math.PI / a) / (b * a));
} else if (b <= 4.8e+140) {
tmp = ((1.0 / a) + (-1.0 / b)) * ((Math.PI / 2.0) / ((b * b) - (a * a)));
} else {
tmp = (1.0 / (2.0 * (b - a))) * (Math.PI / (b * a));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 8.2e-167: tmp = 0.5 * ((math.pi / a) / (b * a)) elif b <= 4.8e+140: tmp = ((1.0 / a) + (-1.0 / b)) * ((math.pi / 2.0) / ((b * b) - (a * a))) else: tmp = (1.0 / (2.0 * (b - a))) * (math.pi / (b * a)) return tmp
function code(a, b) tmp = 0.0 if (b <= 8.2e-167) tmp = Float64(0.5 * Float64(Float64(pi / a) / Float64(b * a))); elseif (b <= 4.8e+140) tmp = Float64(Float64(Float64(1.0 / a) + Float64(-1.0 / b)) * Float64(Float64(pi / 2.0) / Float64(Float64(b * b) - Float64(a * a)))); else tmp = Float64(Float64(1.0 / Float64(2.0 * Float64(b - a))) * Float64(pi / Float64(b * a))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 8.2e-167) tmp = 0.5 * ((pi / a) / (b * a)); elseif (b <= 4.8e+140) tmp = ((1.0 / a) + (-1.0 / b)) * ((pi / 2.0) / ((b * b) - (a * a))); else tmp = (1.0 / (2.0 * (b - a))) * (pi / (b * a)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 8.2e-167], N[(0.5 * N[(N[(Pi / a), $MachinePrecision] / N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.8e+140], N[(N[(N[(1.0 / a), $MachinePrecision] + N[(-1.0 / b), $MachinePrecision]), $MachinePrecision] * N[(N[(Pi / 2.0), $MachinePrecision] / N[(N[(b * b), $MachinePrecision] - N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(2.0 * N[(b - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(Pi / N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 8.2 \cdot 10^{-167}:\\
\;\;\;\;0.5 \cdot \frac{\frac{\pi}{a}}{b \cdot a}\\
\mathbf{elif}\;b \leq 4.8 \cdot 10^{+140}:\\
\;\;\;\;\left(\frac{1}{a} + \frac{-1}{b}\right) \cdot \frac{\frac{\pi}{2}}{b \cdot b - a \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 \cdot \left(b - a\right)} \cdot \frac{\pi}{b \cdot a}\\
\end{array}
\end{array}
if b < 8.20000000000000036e-167Initial program 77.5%
*-commutative77.5%
associate-*l/77.5%
associate-*r/77.5%
associate-/l*77.4%
sub-neg77.4%
distribute-neg-frac77.4%
metadata-eval77.4%
associate-*r/77.4%
*-rgt-identity77.4%
difference-of-squares85.6%
associate-/r*85.6%
Simplified85.6%
clear-num85.6%
inv-pow85.6%
associate-/r/85.6%
Applied egg-rr85.6%
unpow-185.6%
associate-*l/85.6%
+-commutative85.6%
metadata-eval85.6%
distribute-neg-frac85.6%
sub-neg85.6%
Simplified85.6%
*-un-lft-identity85.6%
associate-/l/99.3%
inv-pow99.3%
inv-pow99.3%
Applied egg-rr99.3%
Taylor expanded in b around 0 56.3%
*-commutative56.3%
unpow256.3%
associate-*r*67.3%
*-commutative67.3%
associate-/r*67.1%
*-commutative67.1%
Simplified67.1%
if 8.20000000000000036e-167 < b < 4.7999999999999999e140Initial program 99.4%
associate-*r/99.6%
*-rgt-identity99.6%
sub-neg99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
Simplified99.6%
if 4.7999999999999999e140 < b Initial program 49.3%
*-commutative49.3%
associate-*l/49.3%
associate-*r/49.3%
associate-/l*49.3%
sub-neg49.3%
distribute-neg-frac49.3%
metadata-eval49.3%
associate-*r/49.3%
*-rgt-identity49.3%
difference-of-squares76.6%
associate-/r*76.6%
Simplified76.6%
clear-num76.5%
inv-pow76.5%
associate-/r/76.6%
Applied egg-rr76.6%
unpow-176.6%
associate-*l/76.6%
+-commutative76.6%
metadata-eval76.6%
distribute-neg-frac76.6%
sub-neg76.6%
Simplified76.6%
*-un-lft-identity76.6%
associate-/l/98.7%
inv-pow98.7%
inv-pow98.7%
Applied egg-rr98.7%
expm1-log1p-u98.7%
expm1-udef74.0%
*-un-lft-identity74.0%
inv-pow74.0%
unpow-174.0%
+-commutative74.0%
Applied egg-rr74.0%
expm1-def98.7%
expm1-log1p98.7%
associate-/r/99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in a around 0 99.9%
Final simplification78.1%
(FPCore (a b)
:precision binary64
(let* ((t_0 (/ PI (+ b a))) (t_1 (* 2.0 (- b a))))
(if (<= a -4e+107)
(* 0.5 (/ (/ PI a) (* b a)))
(if (<= a -5.2e-190)
(* (+ (/ 1.0 a) (/ -1.0 b)) (/ t_0 t_1))
(* (/ 1.0 t_1) (* (/ 1.0 a) t_0))))))
double code(double a, double b) {
double t_0 = ((double) M_PI) / (b + a);
double t_1 = 2.0 * (b - a);
double tmp;
if (a <= -4e+107) {
tmp = 0.5 * ((((double) M_PI) / a) / (b * a));
} else if (a <= -5.2e-190) {
tmp = ((1.0 / a) + (-1.0 / b)) * (t_0 / t_1);
} else {
tmp = (1.0 / t_1) * ((1.0 / a) * t_0);
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = Math.PI / (b + a);
double t_1 = 2.0 * (b - a);
double tmp;
if (a <= -4e+107) {
tmp = 0.5 * ((Math.PI / a) / (b * a));
} else if (a <= -5.2e-190) {
tmp = ((1.0 / a) + (-1.0 / b)) * (t_0 / t_1);
} else {
tmp = (1.0 / t_1) * ((1.0 / a) * t_0);
}
return tmp;
}
def code(a, b): t_0 = math.pi / (b + a) t_1 = 2.0 * (b - a) tmp = 0 if a <= -4e+107: tmp = 0.5 * ((math.pi / a) / (b * a)) elif a <= -5.2e-190: tmp = ((1.0 / a) + (-1.0 / b)) * (t_0 / t_1) else: tmp = (1.0 / t_1) * ((1.0 / a) * t_0) return tmp
function code(a, b) t_0 = Float64(pi / Float64(b + a)) t_1 = Float64(2.0 * Float64(b - a)) tmp = 0.0 if (a <= -4e+107) tmp = Float64(0.5 * Float64(Float64(pi / a) / Float64(b * a))); elseif (a <= -5.2e-190) tmp = Float64(Float64(Float64(1.0 / a) + Float64(-1.0 / b)) * Float64(t_0 / t_1)); else tmp = Float64(Float64(1.0 / t_1) * Float64(Float64(1.0 / a) * t_0)); end return tmp end
function tmp_2 = code(a, b) t_0 = pi / (b + a); t_1 = 2.0 * (b - a); tmp = 0.0; if (a <= -4e+107) tmp = 0.5 * ((pi / a) / (b * a)); elseif (a <= -5.2e-190) tmp = ((1.0 / a) + (-1.0 / b)) * (t_0 / t_1); else tmp = (1.0 / t_1) * ((1.0 / a) * t_0); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(Pi / N[(b + a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 * N[(b - a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -4e+107], N[(0.5 * N[(N[(Pi / a), $MachinePrecision] / N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, -5.2e-190], N[(N[(N[(1.0 / a), $MachinePrecision] + N[(-1.0 / b), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / t$95$1), $MachinePrecision] * N[(N[(1.0 / a), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\pi}{b + a}\\
t_1 := 2 \cdot \left(b - a\right)\\
\mathbf{if}\;a \leq -4 \cdot 10^{+107}:\\
\;\;\;\;0.5 \cdot \frac{\frac{\pi}{a}}{b \cdot a}\\
\mathbf{elif}\;a \leq -5.2 \cdot 10^{-190}:\\
\;\;\;\;\left(\frac{1}{a} + \frac{-1}{b}\right) \cdot \frac{t_0}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t_1} \cdot \left(\frac{1}{a} \cdot t_0\right)\\
\end{array}
\end{array}
if a < -3.9999999999999999e107Initial program 56.4%
*-commutative56.4%
associate-*l/56.4%
associate-*r/56.4%
associate-/l*56.4%
sub-neg56.4%
distribute-neg-frac56.4%
metadata-eval56.4%
associate-*r/56.4%
*-rgt-identity56.4%
difference-of-squares68.3%
associate-/r*68.3%
Simplified68.3%
clear-num67.9%
inv-pow67.9%
associate-/r/67.9%
Applied egg-rr67.9%
unpow-167.9%
associate-*l/67.9%
+-commutative67.9%
metadata-eval67.9%
distribute-neg-frac67.9%
sub-neg67.9%
Simplified67.9%
*-un-lft-identity67.9%
associate-/l/99.2%
inv-pow99.2%
inv-pow99.2%
Applied egg-rr99.2%
Taylor expanded in b around 0 68.1%
*-commutative68.1%
unpow268.1%
associate-*r*99.4%
*-commutative99.4%
associate-/r*99.6%
*-commutative99.6%
Simplified99.6%
if -3.9999999999999999e107 < a < -5.1999999999999996e-190Initial program 91.9%
inv-pow91.9%
difference-of-squares94.9%
unpow-prod-down94.7%
inv-pow94.7%
inv-pow94.7%
Applied egg-rr94.7%
associate-*r/94.9%
*-rgt-identity94.9%
+-commutative94.9%
Simplified94.9%
frac-times94.9%
div-inv94.9%
Applied egg-rr94.9%
if -5.1999999999999996e-190 < a Initial program 78.6%
*-commutative78.6%
associate-*l/78.6%
associate-*r/78.6%
associate-/l*78.6%
sub-neg78.6%
distribute-neg-frac78.6%
metadata-eval78.6%
associate-*r/78.6%
*-rgt-identity78.6%
difference-of-squares89.4%
associate-/r*89.3%
Simplified89.3%
clear-num89.4%
inv-pow89.4%
associate-/r/89.4%
Applied egg-rr89.4%
unpow-189.4%
associate-*l/89.4%
+-commutative89.4%
metadata-eval89.4%
distribute-neg-frac89.4%
sub-neg89.4%
Simplified89.4%
*-un-lft-identity89.4%
associate-/l/99.4%
inv-pow99.4%
inv-pow99.4%
Applied egg-rr99.4%
expm1-log1p-u79.5%
expm1-udef56.9%
*-un-lft-identity56.9%
inv-pow56.9%
unpow-156.9%
+-commutative56.9%
Applied egg-rr56.9%
expm1-def79.5%
expm1-log1p99.4%
associate-/r/99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in a around 0 76.9%
Final simplification85.3%
(FPCore (a b) :precision binary64 (if (<= b 1.25e-72) (* 0.5 (/ (/ PI a) (* b a))) (* (/ 1.0 (* 2.0 (- b a))) (* (/ 1.0 a) (/ PI (+ b a))))))
double code(double a, double b) {
double tmp;
if (b <= 1.25e-72) {
tmp = 0.5 * ((((double) M_PI) / a) / (b * a));
} else {
tmp = (1.0 / (2.0 * (b - a))) * ((1.0 / a) * (((double) M_PI) / (b + a)));
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (b <= 1.25e-72) {
tmp = 0.5 * ((Math.PI / a) / (b * a));
} else {
tmp = (1.0 / (2.0 * (b - a))) * ((1.0 / a) * (Math.PI / (b + a)));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 1.25e-72: tmp = 0.5 * ((math.pi / a) / (b * a)) else: tmp = (1.0 / (2.0 * (b - a))) * ((1.0 / a) * (math.pi / (b + a))) return tmp
function code(a, b) tmp = 0.0 if (b <= 1.25e-72) tmp = Float64(0.5 * Float64(Float64(pi / a) / Float64(b * a))); else tmp = Float64(Float64(1.0 / Float64(2.0 * Float64(b - a))) * Float64(Float64(1.0 / a) * Float64(pi / Float64(b + a)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 1.25e-72) tmp = 0.5 * ((pi / a) / (b * a)); else tmp = (1.0 / (2.0 * (b - a))) * ((1.0 / a) * (pi / (b + a))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 1.25e-72], N[(0.5 * N[(N[(Pi / a), $MachinePrecision] / N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(2.0 * N[(b - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / a), $MachinePrecision] * N[(Pi / N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.25 \cdot 10^{-72}:\\
\;\;\;\;0.5 \cdot \frac{\frac{\pi}{a}}{b \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 \cdot \left(b - a\right)} \cdot \left(\frac{1}{a} \cdot \frac{\pi}{b + a}\right)\\
\end{array}
\end{array}
if b < 1.2499999999999999e-72Initial program 79.6%
*-commutative79.6%
associate-*l/79.6%
associate-*r/79.6%
associate-/l*79.5%
sub-neg79.5%
distribute-neg-frac79.5%
metadata-eval79.5%
associate-*r/79.5%
*-rgt-identity79.5%
difference-of-squares86.9%
associate-/r*86.9%
Simplified86.9%
clear-num86.9%
inv-pow86.9%
associate-/r/86.9%
Applied egg-rr86.9%
unpow-186.9%
associate-*l/87.0%
+-commutative87.0%
metadata-eval87.0%
distribute-neg-frac87.0%
sub-neg87.0%
Simplified87.0%
*-un-lft-identity87.0%
associate-/l/99.4%
inv-pow99.4%
inv-pow99.4%
Applied egg-rr99.4%
Taylor expanded in b around 0 59.4%
*-commutative59.4%
unpow259.4%
associate-*r*69.4%
*-commutative69.4%
associate-/r*69.2%
*-commutative69.2%
Simplified69.2%
if 1.2499999999999999e-72 < b Initial program 75.1%
*-commutative75.1%
associate-*l/75.1%
associate-*r/75.1%
associate-/l*75.1%
sub-neg75.1%
distribute-neg-frac75.1%
metadata-eval75.1%
associate-*r/75.1%
*-rgt-identity75.1%
difference-of-squares88.4%
associate-/r*88.3%
Simplified88.3%
clear-num88.1%
inv-pow88.1%
associate-/r/88.1%
Applied egg-rr88.1%
unpow-188.1%
associate-*l/88.2%
+-commutative88.2%
metadata-eval88.2%
distribute-neg-frac88.2%
sub-neg88.2%
Simplified88.2%
*-un-lft-identity88.2%
associate-/l/98.8%
inv-pow98.8%
inv-pow98.8%
Applied egg-rr98.8%
expm1-log1p-u85.0%
expm1-udef58.6%
*-un-lft-identity58.6%
inv-pow58.6%
unpow-158.6%
+-commutative58.6%
Applied egg-rr58.6%
expm1-def85.0%
expm1-log1p98.8%
associate-/r/99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in a around 0 94.1%
Final simplification75.8%
(FPCore (a b) :precision binary64 (if (<= b 3.4e-24) (* 0.5 (/ (/ PI a) (* b a))) (* (/ 1.0 (* 2.0 (- b a))) (/ PI (* b a)))))
double code(double a, double b) {
double tmp;
if (b <= 3.4e-24) {
tmp = 0.5 * ((((double) M_PI) / a) / (b * a));
} else {
tmp = (1.0 / (2.0 * (b - a))) * (((double) M_PI) / (b * a));
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (b <= 3.4e-24) {
tmp = 0.5 * ((Math.PI / a) / (b * a));
} else {
tmp = (1.0 / (2.0 * (b - a))) * (Math.PI / (b * a));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 3.4e-24: tmp = 0.5 * ((math.pi / a) / (b * a)) else: tmp = (1.0 / (2.0 * (b - a))) * (math.pi / (b * a)) return tmp
function code(a, b) tmp = 0.0 if (b <= 3.4e-24) tmp = Float64(0.5 * Float64(Float64(pi / a) / Float64(b * a))); else tmp = Float64(Float64(1.0 / Float64(2.0 * Float64(b - a))) * Float64(pi / Float64(b * a))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 3.4e-24) tmp = 0.5 * ((pi / a) / (b * a)); else tmp = (1.0 / (2.0 * (b - a))) * (pi / (b * a)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 3.4e-24], N[(0.5 * N[(N[(Pi / a), $MachinePrecision] / N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(2.0 * N[(b - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(Pi / N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.4 \cdot 10^{-24}:\\
\;\;\;\;0.5 \cdot \frac{\frac{\pi}{a}}{b \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 \cdot \left(b - a\right)} \cdot \frac{\pi}{b \cdot a}\\
\end{array}
\end{array}
if b < 3.39999999999999992e-24Initial program 79.9%
*-commutative79.9%
associate-*l/79.9%
associate-*r/79.9%
associate-/l*79.9%
sub-neg79.9%
distribute-neg-frac79.9%
metadata-eval79.9%
associate-*r/79.8%
*-rgt-identity79.8%
difference-of-squares87.2%
associate-/r*87.1%
Simplified87.1%
clear-num87.1%
inv-pow87.1%
associate-/r/87.1%
Applied egg-rr87.1%
unpow-187.1%
associate-*l/87.2%
+-commutative87.2%
metadata-eval87.2%
distribute-neg-frac87.2%
sub-neg87.2%
Simplified87.2%
*-un-lft-identity87.2%
associate-/l/99.4%
inv-pow99.4%
inv-pow99.4%
Applied egg-rr99.4%
Taylor expanded in b around 0 59.5%
*-commutative59.5%
unpow259.5%
associate-*r*69.3%
*-commutative69.3%
associate-/r*69.1%
*-commutative69.1%
Simplified69.1%
if 3.39999999999999992e-24 < b Initial program 74.0%
*-commutative74.0%
associate-*l/74.0%
associate-*r/74.0%
associate-/l*73.9%
sub-neg73.9%
distribute-neg-frac73.9%
metadata-eval73.9%
associate-*r/74.0%
*-rgt-identity74.0%
difference-of-squares87.8%
associate-/r*87.8%
Simplified87.8%
clear-num87.5%
inv-pow87.5%
associate-/r/87.6%
Applied egg-rr87.6%
unpow-187.6%
associate-*l/87.6%
+-commutative87.6%
metadata-eval87.6%
distribute-neg-frac87.6%
sub-neg87.6%
Simplified87.6%
*-un-lft-identity87.6%
associate-/l/98.7%
inv-pow98.7%
inv-pow98.7%
Applied egg-rr98.7%
expm1-log1p-u85.9%
expm1-udef58.3%
*-un-lft-identity58.3%
inv-pow58.3%
unpow-158.3%
+-commutative58.3%
Applied egg-rr58.3%
expm1-def85.9%
expm1-log1p98.7%
associate-/r/99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in a around 0 95.1%
Final simplification75.7%
(FPCore (a b) :precision binary64 (if (<= b 3.4e-24) (* 0.5 (/ PI (* a (* b a)))) (* 0.5 (/ PI (* b (* b a))))))
double code(double a, double b) {
double tmp;
if (b <= 3.4e-24) {
tmp = 0.5 * (((double) M_PI) / (a * (b * a)));
} else {
tmp = 0.5 * (((double) M_PI) / (b * (b * a)));
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (b <= 3.4e-24) {
tmp = 0.5 * (Math.PI / (a * (b * a)));
} else {
tmp = 0.5 * (Math.PI / (b * (b * a)));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 3.4e-24: tmp = 0.5 * (math.pi / (a * (b * a))) else: tmp = 0.5 * (math.pi / (b * (b * a))) return tmp
function code(a, b) tmp = 0.0 if (b <= 3.4e-24) tmp = Float64(0.5 * Float64(pi / Float64(a * Float64(b * a)))); else tmp = Float64(0.5 * Float64(pi / Float64(b * Float64(b * a)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 3.4e-24) tmp = 0.5 * (pi / (a * (b * a))); else tmp = 0.5 * (pi / (b * (b * a))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 3.4e-24], N[(0.5 * N[(Pi / N[(a * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(Pi / N[(b * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.4 \cdot 10^{-24}:\\
\;\;\;\;0.5 \cdot \frac{\pi}{a \cdot \left(b \cdot a\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{\pi}{b \cdot \left(b \cdot a\right)}\\
\end{array}
\end{array}
if b < 3.39999999999999992e-24Initial program 79.9%
*-commutative79.9%
associate-*l/79.9%
associate-*r/79.9%
associate-/l*79.9%
sub-neg79.9%
distribute-neg-frac79.9%
metadata-eval79.9%
associate-*r/79.8%
*-rgt-identity79.8%
difference-of-squares87.2%
associate-/r*87.1%
Simplified87.1%
clear-num87.1%
inv-pow87.1%
associate-/r/87.1%
Applied egg-rr87.1%
unpow-187.1%
associate-*l/87.2%
+-commutative87.2%
metadata-eval87.2%
distribute-neg-frac87.2%
sub-neg87.2%
Simplified87.2%
*-un-lft-identity87.2%
associate-/l/99.4%
inv-pow99.4%
inv-pow99.4%
Applied egg-rr99.4%
Taylor expanded in b around 0 59.5%
*-commutative59.5%
*-commutative59.5%
unpow259.5%
associate-*r*69.3%
Simplified69.3%
if 3.39999999999999992e-24 < b Initial program 74.0%
*-commutative74.0%
associate-*l/74.0%
associate-*r/74.0%
associate-/l*73.9%
sub-neg73.9%
distribute-neg-frac73.9%
metadata-eval73.9%
associate-*r/74.0%
*-rgt-identity74.0%
difference-of-squares87.8%
associate-/r*87.8%
Simplified87.8%
clear-num87.5%
inv-pow87.5%
associate-/r/87.6%
Applied egg-rr87.6%
unpow-187.6%
associate-*l/87.6%
+-commutative87.6%
metadata-eval87.6%
distribute-neg-frac87.6%
sub-neg87.6%
Simplified87.6%
*-un-lft-identity87.6%
associate-/l/98.7%
inv-pow98.7%
inv-pow98.7%
Applied egg-rr98.7%
Taylor expanded in b around inf 80.8%
*-commutative80.8%
unpow280.8%
associate-*l*92.0%
*-commutative92.0%
Simplified92.0%
Final simplification75.1%
(FPCore (a b) :precision binary64 (if (<= b 3.1e-24) (* 0.5 (/ (/ PI a) (* b a))) (* 0.5 (/ PI (* b (* b a))))))
double code(double a, double b) {
double tmp;
if (b <= 3.1e-24) {
tmp = 0.5 * ((((double) M_PI) / a) / (b * a));
} else {
tmp = 0.5 * (((double) M_PI) / (b * (b * a)));
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (b <= 3.1e-24) {
tmp = 0.5 * ((Math.PI / a) / (b * a));
} else {
tmp = 0.5 * (Math.PI / (b * (b * a)));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 3.1e-24: tmp = 0.5 * ((math.pi / a) / (b * a)) else: tmp = 0.5 * (math.pi / (b * (b * a))) return tmp
function code(a, b) tmp = 0.0 if (b <= 3.1e-24) tmp = Float64(0.5 * Float64(Float64(pi / a) / Float64(b * a))); else tmp = Float64(0.5 * Float64(pi / Float64(b * Float64(b * a)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 3.1e-24) tmp = 0.5 * ((pi / a) / (b * a)); else tmp = 0.5 * (pi / (b * (b * a))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 3.1e-24], N[(0.5 * N[(N[(Pi / a), $MachinePrecision] / N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(Pi / N[(b * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.1 \cdot 10^{-24}:\\
\;\;\;\;0.5 \cdot \frac{\frac{\pi}{a}}{b \cdot a}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{\pi}{b \cdot \left(b \cdot a\right)}\\
\end{array}
\end{array}
if b < 3.1e-24Initial program 79.9%
*-commutative79.9%
associate-*l/79.9%
associate-*r/79.9%
associate-/l*79.9%
sub-neg79.9%
distribute-neg-frac79.9%
metadata-eval79.9%
associate-*r/79.8%
*-rgt-identity79.8%
difference-of-squares87.2%
associate-/r*87.1%
Simplified87.1%
clear-num87.1%
inv-pow87.1%
associate-/r/87.1%
Applied egg-rr87.1%
unpow-187.1%
associate-*l/87.2%
+-commutative87.2%
metadata-eval87.2%
distribute-neg-frac87.2%
sub-neg87.2%
Simplified87.2%
*-un-lft-identity87.2%
associate-/l/99.4%
inv-pow99.4%
inv-pow99.4%
Applied egg-rr99.4%
Taylor expanded in b around 0 59.5%
*-commutative59.5%
unpow259.5%
associate-*r*69.3%
*-commutative69.3%
associate-/r*69.1%
*-commutative69.1%
Simplified69.1%
if 3.1e-24 < b Initial program 74.0%
*-commutative74.0%
associate-*l/74.0%
associate-*r/74.0%
associate-/l*73.9%
sub-neg73.9%
distribute-neg-frac73.9%
metadata-eval73.9%
associate-*r/74.0%
*-rgt-identity74.0%
difference-of-squares87.8%
associate-/r*87.8%
Simplified87.8%
clear-num87.5%
inv-pow87.5%
associate-/r/87.6%
Applied egg-rr87.6%
unpow-187.6%
associate-*l/87.6%
+-commutative87.6%
metadata-eval87.6%
distribute-neg-frac87.6%
sub-neg87.6%
Simplified87.6%
*-un-lft-identity87.6%
associate-/l/98.7%
inv-pow98.7%
inv-pow98.7%
Applied egg-rr98.7%
Taylor expanded in b around inf 80.8%
*-commutative80.8%
unpow280.8%
associate-*l*92.0%
*-commutative92.0%
Simplified92.0%
Final simplification74.9%
(FPCore (a b) :precision binary64 (if (<= b 3.5e-24) (* 0.5 (/ (/ PI a) (* b a))) (/ 0.5 (/ (* b (* b a)) PI))))
double code(double a, double b) {
double tmp;
if (b <= 3.5e-24) {
tmp = 0.5 * ((((double) M_PI) / a) / (b * a));
} else {
tmp = 0.5 / ((b * (b * a)) / ((double) M_PI));
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (b <= 3.5e-24) {
tmp = 0.5 * ((Math.PI / a) / (b * a));
} else {
tmp = 0.5 / ((b * (b * a)) / Math.PI);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 3.5e-24: tmp = 0.5 * ((math.pi / a) / (b * a)) else: tmp = 0.5 / ((b * (b * a)) / math.pi) return tmp
function code(a, b) tmp = 0.0 if (b <= 3.5e-24) tmp = Float64(0.5 * Float64(Float64(pi / a) / Float64(b * a))); else tmp = Float64(0.5 / Float64(Float64(b * Float64(b * a)) / pi)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 3.5e-24) tmp = 0.5 * ((pi / a) / (b * a)); else tmp = 0.5 / ((b * (b * a)) / pi); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 3.5e-24], N[(0.5 * N[(N[(Pi / a), $MachinePrecision] / N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 / N[(N[(b * N[(b * a), $MachinePrecision]), $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.5 \cdot 10^{-24}:\\
\;\;\;\;0.5 \cdot \frac{\frac{\pi}{a}}{b \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{\frac{b \cdot \left(b \cdot a\right)}{\pi}}\\
\end{array}
\end{array}
if b < 3.4999999999999996e-24Initial program 79.9%
*-commutative79.9%
associate-*l/79.9%
associate-*r/79.9%
associate-/l*79.9%
sub-neg79.9%
distribute-neg-frac79.9%
metadata-eval79.9%
associate-*r/79.8%
*-rgt-identity79.8%
difference-of-squares87.2%
associate-/r*87.1%
Simplified87.1%
clear-num87.1%
inv-pow87.1%
associate-/r/87.1%
Applied egg-rr87.1%
unpow-187.1%
associate-*l/87.2%
+-commutative87.2%
metadata-eval87.2%
distribute-neg-frac87.2%
sub-neg87.2%
Simplified87.2%
*-un-lft-identity87.2%
associate-/l/99.4%
inv-pow99.4%
inv-pow99.4%
Applied egg-rr99.4%
Taylor expanded in b around 0 59.5%
*-commutative59.5%
unpow259.5%
associate-*r*69.3%
*-commutative69.3%
associate-/r*69.1%
*-commutative69.1%
Simplified69.1%
if 3.4999999999999996e-24 < b Initial program 74.0%
*-commutative74.0%
associate-*l/74.0%
associate-*r/74.0%
associate-/l*73.9%
sub-neg73.9%
distribute-neg-frac73.9%
metadata-eval73.9%
associate-*r/74.0%
*-rgt-identity74.0%
difference-of-squares87.8%
associate-/r*87.8%
Simplified87.8%
clear-num87.5%
inv-pow87.5%
associate-/r/87.6%
Applied egg-rr87.6%
unpow-187.6%
associate-*l/87.6%
+-commutative87.6%
metadata-eval87.6%
distribute-neg-frac87.6%
sub-neg87.6%
Simplified87.6%
*-un-lft-identity87.6%
associate-/l/98.7%
inv-pow98.7%
inv-pow98.7%
Applied egg-rr98.7%
expm1-log1p-u85.9%
expm1-udef58.3%
*-un-lft-identity58.3%
inv-pow58.3%
unpow-158.3%
+-commutative58.3%
Applied egg-rr58.3%
expm1-def85.9%
expm1-log1p98.7%
associate-/r/99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in b around inf 80.8%
associate-*r/80.8%
associate-/l*80.8%
*-commutative80.8%
unpow280.8%
associate-*l*92.0%
*-commutative92.0%
Simplified92.0%
Final simplification74.9%
(FPCore (a b) :precision binary64 (* 0.5 (/ PI (* a (* b a)))))
double code(double a, double b) {
return 0.5 * (((double) M_PI) / (a * (b * a)));
}
public static double code(double a, double b) {
return 0.5 * (Math.PI / (a * (b * a)));
}
def code(a, b): return 0.5 * (math.pi / (a * (b * a)))
function code(a, b) return Float64(0.5 * Float64(pi / Float64(a * Float64(b * a)))) end
function tmp = code(a, b) tmp = 0.5 * (pi / (a * (b * a))); end
code[a_, b_] := N[(0.5 * N[(Pi / N[(a * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \frac{\pi}{a \cdot \left(b \cdot a\right)}
\end{array}
Initial program 78.4%
*-commutative78.4%
associate-*l/78.4%
associate-*r/78.4%
associate-/l*78.4%
sub-neg78.4%
distribute-neg-frac78.4%
metadata-eval78.4%
associate-*r/78.3%
*-rgt-identity78.3%
difference-of-squares87.3%
associate-/r*87.3%
Simplified87.3%
clear-num87.2%
inv-pow87.2%
associate-/r/87.2%
Applied egg-rr87.2%
unpow-187.2%
associate-*l/87.3%
+-commutative87.3%
metadata-eval87.3%
distribute-neg-frac87.3%
sub-neg87.3%
Simplified87.3%
*-un-lft-identity87.3%
associate-/l/99.2%
inv-pow99.2%
inv-pow99.2%
Applied egg-rr99.2%
Taylor expanded in b around 0 53.7%
*-commutative53.7%
*-commutative53.7%
unpow253.7%
associate-*r*61.0%
Simplified61.0%
Final simplification61.0%
herbie shell --seed 2023279
(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))))