
(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 7 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 (/ (* b a) 0.5)) (+ b a)))
double code(double a, double b) {
return (((double) M_PI) / ((b * a) / 0.5)) / (b + a);
}
public static double code(double a, double b) {
return (Math.PI / ((b * a) / 0.5)) / (b + a);
}
def code(a, b): return (math.pi / ((b * a) / 0.5)) / (b + a)
function code(a, b) return Float64(Float64(pi / Float64(Float64(b * a) / 0.5)) / Float64(b + a)) end
function tmp = code(a, b) tmp = (pi / ((b * a) / 0.5)) / (b + a); end
code[a_, b_] := N[(N[(Pi / N[(N[(b * a), $MachinePrecision] / 0.5), $MachinePrecision]), $MachinePrecision] / N[(b + a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\pi}{\frac{b \cdot a}{0.5}}}{b + a}
\end{array}
Initial program 77.3%
associate-*r/77.4%
*-rgt-identity77.4%
associate-*l/77.4%
difference-of-squares85.6%
*-commutative85.6%
times-frac99.6%
sub-neg99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
Simplified99.6%
frac-add99.6%
*-un-lft-identity99.6%
Applied egg-rr99.6%
*-commutative99.6%
neg-mul-199.6%
sub-neg99.6%
Simplified99.6%
associate-*r/99.6%
div-inv99.6%
metadata-eval99.6%
*-commutative99.6%
Applied egg-rr99.6%
Taylor expanded in b around 0 99.7%
associate-*r/99.7%
*-commutative99.7%
*-commutative99.7%
associate-/l*99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (a b) :precision binary64 (if (or (<= a -1.05e-131) (not (<= a -5e-311))) (* (/ PI a) (/ 0.5 (* b a))) (* (/ PI (* b a)) (/ -0.5 a))))
double code(double a, double b) {
double tmp;
if ((a <= -1.05e-131) || !(a <= -5e-311)) {
tmp = (((double) M_PI) / a) * (0.5 / (b * a));
} else {
tmp = (((double) M_PI) / (b * a)) * (-0.5 / a);
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if ((a <= -1.05e-131) || !(a <= -5e-311)) {
tmp = (Math.PI / a) * (0.5 / (b * a));
} else {
tmp = (Math.PI / (b * a)) * (-0.5 / a);
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -1.05e-131) or not (a <= -5e-311): tmp = (math.pi / a) * (0.5 / (b * a)) else: tmp = (math.pi / (b * a)) * (-0.5 / a) return tmp
function code(a, b) tmp = 0.0 if ((a <= -1.05e-131) || !(a <= -5e-311)) tmp = Float64(Float64(pi / a) * Float64(0.5 / Float64(b * a))); else tmp = Float64(Float64(pi / Float64(b * a)) * Float64(-0.5 / a)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -1.05e-131) || ~((a <= -5e-311))) tmp = (pi / a) * (0.5 / (b * a)); else tmp = (pi / (b * a)) * (-0.5 / a); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -1.05e-131], N[Not[LessEqual[a, -5e-311]], $MachinePrecision]], N[(N[(Pi / a), $MachinePrecision] * N[(0.5 / N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Pi / N[(b * a), $MachinePrecision]), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.05 \cdot 10^{-131} \lor \neg \left(a \leq -5 \cdot 10^{-311}\right):\\
\;\;\;\;\frac{\pi}{a} \cdot \frac{0.5}{b \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi}{b \cdot a} \cdot \frac{-0.5}{a}\\
\end{array}
\end{array}
if a < -1.04999999999999999e-131 or -5.00000000000023e-311 < a Initial program 75.5%
associate-*r/75.5%
*-rgt-identity75.5%
associate-*l/75.5%
difference-of-squares83.8%
*-commutative83.8%
times-frac99.6%
sub-neg99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in a around inf 73.9%
Taylor expanded in b around 0 66.2%
*-commutative66.2%
frac-2neg66.2%
metadata-eval66.2%
*-commutative66.2%
associate-*r/66.2%
*-commutative66.2%
metadata-eval66.2%
associate-*l*66.2%
frac-times66.3%
*-un-lft-identity66.3%
associate-*l*66.3%
metadata-eval66.3%
Applied egg-rr66.3%
*-commutative66.3%
times-frac66.2%
metadata-eval66.2%
frac-2neg66.2%
Applied egg-rr66.2%
if -1.04999999999999999e-131 < a < -5.00000000000023e-311Initial program 92.5%
associate-*r/92.5%
*-rgt-identity92.5%
associate-*l/92.8%
difference-of-squares99.9%
*-commutative99.9%
times-frac99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in a around inf 18.6%
Taylor expanded in b around 0 12.2%
*-commutative12.2%
frac-2neg12.2%
metadata-eval12.2%
*-commutative12.2%
associate-*r/12.2%
*-commutative12.2%
metadata-eval12.2%
associate-*l*12.2%
frac-times12.2%
*-un-lft-identity12.2%
associate-*l*12.2%
metadata-eval12.2%
Applied egg-rr12.2%
times-frac12.2%
add-sqr-sqrt0.5%
sqrt-unprod0.7%
sqr-neg0.7%
sqrt-unprod0.2%
add-sqr-sqrt26.8%
Applied egg-rr26.8%
Final simplification61.9%
(FPCore (a b)
:precision binary64
(if (<= a -9.8e-132)
(/ (/ (- PI) a) (* b (/ a -0.5)))
(if (<= a 9e-309)
(* (/ PI (* b a)) (/ -0.5 a))
(* (/ PI a) (/ 0.5 (* b a))))))
double code(double a, double b) {
double tmp;
if (a <= -9.8e-132) {
tmp = (-((double) M_PI) / a) / (b * (a / -0.5));
} else if (a <= 9e-309) {
tmp = (((double) M_PI) / (b * a)) * (-0.5 / a);
} else {
tmp = (((double) M_PI) / a) * (0.5 / (b * a));
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (a <= -9.8e-132) {
tmp = (-Math.PI / a) / (b * (a / -0.5));
} else if (a <= 9e-309) {
tmp = (Math.PI / (b * a)) * (-0.5 / a);
} else {
tmp = (Math.PI / a) * (0.5 / (b * a));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -9.8e-132: tmp = (-math.pi / a) / (b * (a / -0.5)) elif a <= 9e-309: tmp = (math.pi / (b * a)) * (-0.5 / a) else: tmp = (math.pi / a) * (0.5 / (b * a)) return tmp
function code(a, b) tmp = 0.0 if (a <= -9.8e-132) tmp = Float64(Float64(Float64(-pi) / a) / Float64(b * Float64(a / -0.5))); elseif (a <= 9e-309) tmp = Float64(Float64(pi / Float64(b * a)) * Float64(-0.5 / a)); else tmp = Float64(Float64(pi / a) * Float64(0.5 / Float64(b * a))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -9.8e-132) tmp = (-pi / a) / (b * (a / -0.5)); elseif (a <= 9e-309) tmp = (pi / (b * a)) * (-0.5 / a); else tmp = (pi / a) * (0.5 / (b * a)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -9.8e-132], N[(N[((-Pi) / a), $MachinePrecision] / N[(b * N[(a / -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 9e-309], N[(N[(Pi / N[(b * a), $MachinePrecision]), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], N[(N[(Pi / a), $MachinePrecision] * N[(0.5 / N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -9.8 \cdot 10^{-132}:\\
\;\;\;\;\frac{\frac{-\pi}{a}}{b \cdot \frac{a}{-0.5}}\\
\mathbf{elif}\;a \leq 9 \cdot 10^{-309}:\\
\;\;\;\;\frac{\pi}{b \cdot a} \cdot \frac{-0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi}{a} \cdot \frac{0.5}{b \cdot a}\\
\end{array}
\end{array}
if a < -9.79999999999999961e-132Initial program 73.2%
associate-*r/73.3%
*-rgt-identity73.3%
associate-*l/73.3%
difference-of-squares84.0%
*-commutative84.0%
times-frac99.5%
sub-neg99.5%
distribute-neg-frac99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in a around inf 84.1%
Taylor expanded in b around 0 75.3%
associate-*r/75.3%
*-commutative75.3%
associate-/l*75.3%
associate-/r*75.4%
frac-times75.3%
Applied egg-rr75.3%
associate-*r/75.3%
*-commutative75.3%
mul-1-neg75.3%
*-commutative75.3%
Simplified75.3%
if -9.79999999999999961e-132 < a < 9.0000000000000021e-309Initial program 92.5%
associate-*r/92.5%
*-rgt-identity92.5%
associate-*l/92.8%
difference-of-squares99.9%
*-commutative99.9%
times-frac99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in a around inf 18.6%
Taylor expanded in b around 0 12.2%
*-commutative12.2%
frac-2neg12.2%
metadata-eval12.2%
*-commutative12.2%
associate-*r/12.2%
*-commutative12.2%
metadata-eval12.2%
associate-*l*12.2%
frac-times12.2%
*-un-lft-identity12.2%
associate-*l*12.2%
metadata-eval12.2%
Applied egg-rr12.2%
times-frac12.2%
add-sqr-sqrt0.5%
sqrt-unprod0.7%
sqr-neg0.7%
sqrt-unprod0.2%
add-sqr-sqrt26.8%
Applied egg-rr26.8%
if 9.0000000000000021e-309 < a Initial program 77.0%
associate-*r/77.0%
*-rgt-identity77.0%
associate-*l/77.0%
difference-of-squares83.7%
*-commutative83.7%
times-frac99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in a around inf 67.0%
Taylor expanded in b around 0 60.0%
*-commutative60.0%
frac-2neg60.0%
metadata-eval60.0%
*-commutative60.0%
associate-*r/60.0%
*-commutative60.0%
metadata-eval60.0%
associate-*l*60.0%
frac-times60.0%
*-un-lft-identity60.0%
associate-*l*60.0%
metadata-eval60.0%
Applied egg-rr60.0%
*-commutative60.0%
times-frac60.0%
metadata-eval60.0%
frac-2neg60.0%
Applied egg-rr60.0%
Final simplification61.9%
(FPCore (a b) :precision binary64 (if (<= a -1.1e-64) (/ (/ (- PI) a) (* b (/ a -0.5))) (* (* 0.5 (/ PI b)) (/ (/ 1.0 b) a))))
double code(double a, double b) {
double tmp;
if (a <= -1.1e-64) {
tmp = (-((double) M_PI) / a) / (b * (a / -0.5));
} else {
tmp = (0.5 * (((double) M_PI) / b)) * ((1.0 / b) / a);
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (a <= -1.1e-64) {
tmp = (-Math.PI / a) / (b * (a / -0.5));
} else {
tmp = (0.5 * (Math.PI / b)) * ((1.0 / b) / a);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -1.1e-64: tmp = (-math.pi / a) / (b * (a / -0.5)) else: tmp = (0.5 * (math.pi / b)) * ((1.0 / b) / a) return tmp
function code(a, b) tmp = 0.0 if (a <= -1.1e-64) tmp = Float64(Float64(Float64(-pi) / a) / Float64(b * Float64(a / -0.5))); else tmp = Float64(Float64(0.5 * Float64(pi / b)) * Float64(Float64(1.0 / b) / a)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -1.1e-64) tmp = (-pi / a) / (b * (a / -0.5)); else tmp = (0.5 * (pi / b)) * ((1.0 / b) / a); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -1.1e-64], N[(N[((-Pi) / a), $MachinePrecision] / N[(b * N[(a / -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(Pi / b), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.1 \cdot 10^{-64}:\\
\;\;\;\;\frac{\frac{-\pi}{a}}{b \cdot \frac{a}{-0.5}}\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \frac{\pi}{b}\right) \cdot \frac{\frac{1}{b}}{a}\\
\end{array}
\end{array}
if a < -1.1e-64Initial program 70.8%
associate-*r/70.9%
*-rgt-identity70.9%
associate-*l/70.8%
difference-of-squares83.0%
*-commutative83.0%
times-frac99.6%
sub-neg99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in a around inf 90.3%
Taylor expanded in b around 0 81.3%
associate-*r/81.3%
*-commutative81.3%
associate-/l*81.3%
associate-/r*81.4%
frac-times81.4%
Applied egg-rr81.4%
associate-*r/81.4%
*-commutative81.4%
mul-1-neg81.4%
*-commutative81.4%
Simplified81.4%
if -1.1e-64 < a Initial program 80.4%
associate-*r/80.4%
*-rgt-identity80.4%
associate-*l/80.4%
difference-of-squares86.8%
*-commutative86.8%
times-frac99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
Simplified99.7%
frac-add99.6%
*-un-lft-identity99.6%
Applied egg-rr99.6%
*-commutative99.6%
neg-mul-199.6%
sub-neg99.6%
Simplified99.6%
Taylor expanded in b around inf 69.3%
*-commutative69.3%
associate-/r*69.3%
Simplified69.3%
Taylor expanded in b around inf 67.7%
Final simplification72.1%
(FPCore (a b) :precision binary64 (if (<= a -2.7e-66) (* (/ -0.5 (- b a)) (/ PI (* b a))) (* (* 0.5 (/ PI b)) (/ (/ 1.0 b) a))))
double code(double a, double b) {
double tmp;
if (a <= -2.7e-66) {
tmp = (-0.5 / (b - a)) * (((double) M_PI) / (b * a));
} else {
tmp = (0.5 * (((double) M_PI) / b)) * ((1.0 / b) / a);
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (a <= -2.7e-66) {
tmp = (-0.5 / (b - a)) * (Math.PI / (b * a));
} else {
tmp = (0.5 * (Math.PI / b)) * ((1.0 / b) / a);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -2.7e-66: tmp = (-0.5 / (b - a)) * (math.pi / (b * a)) else: tmp = (0.5 * (math.pi / b)) * ((1.0 / b) / a) return tmp
function code(a, b) tmp = 0.0 if (a <= -2.7e-66) tmp = Float64(Float64(-0.5 / Float64(b - a)) * Float64(pi / Float64(b * a))); else tmp = Float64(Float64(0.5 * Float64(pi / b)) * Float64(Float64(1.0 / b) / a)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -2.7e-66) tmp = (-0.5 / (b - a)) * (pi / (b * a)); else tmp = (0.5 * (pi / b)) * ((1.0 / b) / a); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -2.7e-66], N[(N[(-0.5 / N[(b - a), $MachinePrecision]), $MachinePrecision] * N[(Pi / N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(Pi / b), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.7 \cdot 10^{-66}:\\
\;\;\;\;\frac{-0.5}{b - a} \cdot \frac{\pi}{b \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \frac{\pi}{b}\right) \cdot \frac{\frac{1}{b}}{a}\\
\end{array}
\end{array}
if a < -2.69999999999999996e-66Initial program 70.8%
associate-*r/70.9%
*-rgt-identity70.9%
associate-*l/70.8%
difference-of-squares83.0%
*-commutative83.0%
times-frac99.6%
sub-neg99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in a around inf 90.3%
expm1-log1p-u82.2%
expm1-udef56.1%
div-inv56.1%
metadata-eval56.1%
associate-/r*56.1%
Applied egg-rr56.1%
expm1-def82.3%
expm1-log1p90.4%
associate-/l/90.3%
times-frac90.3%
associate-*l*90.3%
metadata-eval90.3%
*-commutative90.3%
times-frac90.4%
Simplified90.4%
if -2.69999999999999996e-66 < a Initial program 80.4%
associate-*r/80.4%
*-rgt-identity80.4%
associate-*l/80.4%
difference-of-squares86.8%
*-commutative86.8%
times-frac99.7%
sub-neg99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
Simplified99.7%
frac-add99.6%
*-un-lft-identity99.6%
Applied egg-rr99.6%
*-commutative99.6%
neg-mul-199.6%
sub-neg99.6%
Simplified99.6%
Taylor expanded in b around inf 69.3%
*-commutative69.3%
associate-/r*69.3%
Simplified69.3%
Taylor expanded in b around inf 67.7%
Final simplification75.0%
(FPCore (a b) :precision binary64 (/ PI (* (* a (/ b 0.5)) (+ b a))))
double code(double a, double b) {
return ((double) M_PI) / ((a * (b / 0.5)) * (b + a));
}
public static double code(double a, double b) {
return Math.PI / ((a * (b / 0.5)) * (b + a));
}
def code(a, b): return math.pi / ((a * (b / 0.5)) * (b + a))
function code(a, b) return Float64(pi / Float64(Float64(a * Float64(b / 0.5)) * Float64(b + a))) end
function tmp = code(a, b) tmp = pi / ((a * (b / 0.5)) * (b + a)); end
code[a_, b_] := N[(Pi / N[(N[(a * N[(b / 0.5), $MachinePrecision]), $MachinePrecision] * N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\pi}{\left(a \cdot \frac{b}{0.5}\right) \cdot \left(b + a\right)}
\end{array}
Initial program 77.3%
associate-*r/77.4%
*-rgt-identity77.4%
associate-*l/77.4%
difference-of-squares85.6%
*-commutative85.6%
times-frac99.6%
sub-neg99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
Simplified99.6%
frac-add99.6%
*-un-lft-identity99.6%
Applied egg-rr99.6%
*-commutative99.6%
neg-mul-199.6%
sub-neg99.6%
Simplified99.6%
associate-*r/99.6%
div-inv99.6%
metadata-eval99.6%
*-commutative99.6%
Applied egg-rr99.6%
Taylor expanded in b around 0 99.7%
associate-*r/99.7%
*-commutative99.7%
*-commutative99.7%
associate-/l*99.7%
Simplified99.7%
expm1-log1p-u79.1%
expm1-udef51.5%
associate-/l/51.5%
associate-/l*51.5%
Applied egg-rr51.5%
expm1-def78.7%
expm1-log1p99.2%
*-commutative99.2%
associate-/r/99.3%
+-commutative99.3%
Simplified99.3%
Final simplification99.3%
(FPCore (a b) :precision binary64 (* (/ PI a) (/ 0.5 (* b a))))
double code(double a, double b) {
return (((double) M_PI) / a) * (0.5 / (b * a));
}
public static double code(double a, double b) {
return (Math.PI / a) * (0.5 / (b * a));
}
def code(a, b): return (math.pi / a) * (0.5 / (b * a))
function code(a, b) return Float64(Float64(pi / a) * Float64(0.5 / Float64(b * a))) end
function tmp = code(a, b) tmp = (pi / a) * (0.5 / (b * a)); end
code[a_, b_] := N[(N[(Pi / a), $MachinePrecision] * N[(0.5 / N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\pi}{a} \cdot \frac{0.5}{b \cdot a}
\end{array}
Initial program 77.3%
associate-*r/77.4%
*-rgt-identity77.4%
associate-*l/77.4%
difference-of-squares85.6%
*-commutative85.6%
times-frac99.6%
sub-neg99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in a around inf 67.9%
Taylor expanded in b around 0 60.3%
*-commutative60.3%
frac-2neg60.3%
metadata-eval60.3%
*-commutative60.3%
associate-*r/60.3%
*-commutative60.3%
metadata-eval60.3%
associate-*l*60.3%
frac-times60.4%
*-un-lft-identity60.4%
associate-*l*60.4%
metadata-eval60.4%
Applied egg-rr60.4%
*-commutative60.4%
times-frac60.3%
metadata-eval60.3%
frac-2neg60.3%
Applied egg-rr60.3%
Final simplification60.3%
herbie shell --seed 2024010
(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))))