
(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}
Herbie found 6 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
(let* ((t_0 (* (+ a b) 2.0)))
(if (<= a -1e+130)
(* (/ PI (- b a)) (/ (/ -1.0 b) t_0))
(if (<= a 5e+147)
(* (/ PI (* t_0 (- a))) (/ -1.0 b))
(* (/ (/ PI a) (* b a)) 0.5)))))
double code(double a, double b) {
double t_0 = (a + b) * 2.0;
double tmp;
if (a <= -1e+130) {
tmp = (((double) M_PI) / (b - a)) * ((-1.0 / b) / t_0);
} else if (a <= 5e+147) {
tmp = (((double) M_PI) / (t_0 * -a)) * (-1.0 / b);
} else {
tmp = ((((double) M_PI) / a) / (b * a)) * 0.5;
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = (a + b) * 2.0;
double tmp;
if (a <= -1e+130) {
tmp = (Math.PI / (b - a)) * ((-1.0 / b) / t_0);
} else if (a <= 5e+147) {
tmp = (Math.PI / (t_0 * -a)) * (-1.0 / b);
} else {
tmp = ((Math.PI / a) / (b * a)) * 0.5;
}
return tmp;
}
def code(a, b): t_0 = (a + b) * 2.0 tmp = 0 if a <= -1e+130: tmp = (math.pi / (b - a)) * ((-1.0 / b) / t_0) elif a <= 5e+147: tmp = (math.pi / (t_0 * -a)) * (-1.0 / b) else: tmp = ((math.pi / a) / (b * a)) * 0.5 return tmp
function code(a, b) t_0 = Float64(Float64(a + b) * 2.0) tmp = 0.0 if (a <= -1e+130) tmp = Float64(Float64(pi / Float64(b - a)) * Float64(Float64(-1.0 / b) / t_0)); elseif (a <= 5e+147) tmp = Float64(Float64(pi / Float64(t_0 * Float64(-a))) * Float64(-1.0 / b)); else tmp = Float64(Float64(Float64(pi / a) / Float64(b * a)) * 0.5); end return tmp end
function tmp_2 = code(a, b) t_0 = (a + b) * 2.0; tmp = 0.0; if (a <= -1e+130) tmp = (pi / (b - a)) * ((-1.0 / b) / t_0); elseif (a <= 5e+147) tmp = (pi / (t_0 * -a)) * (-1.0 / b); else tmp = ((pi / a) / (b * a)) * 0.5; end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[(a + b), $MachinePrecision] * 2.0), $MachinePrecision]}, If[LessEqual[a, -1e+130], N[(N[(Pi / N[(b - a), $MachinePrecision]), $MachinePrecision] * N[(N[(-1.0 / b), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 5e+147], N[(N[(Pi / N[(t$95$0 * (-a)), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / b), $MachinePrecision]), $MachinePrecision], N[(N[(N[(Pi / a), $MachinePrecision] / N[(b * a), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(a + b\right) \cdot 2\\
\mathbf{if}\;a \leq -1 \cdot 10^{+130}:\\
\;\;\;\;\frac{\pi}{b - a} \cdot \frac{\frac{-1}{b}}{t\_0}\\
\mathbf{elif}\;a \leq 5 \cdot 10^{+147}:\\
\;\;\;\;\frac{\pi}{t\_0 \cdot \left(-a\right)} \cdot \frac{-1}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\pi}{a}}{b \cdot a} \cdot 0.5\\
\end{array}
\end{array}
if a < -1.0000000000000001e130Initial program 58.1%
lift-*.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
difference-of-squaresN/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f6480.2
Applied rewrites80.2%
Taylor expanded in a around inf
lower-/.f6480.2
Applied rewrites80.2%
lift-*.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
*-rgt-identityN/A
lift-*.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
associate-*r*N/A
Applied rewrites80.2%
lift-/.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
if -1.0000000000000001e130 < a < 5.0000000000000002e147Initial program 87.4%
lift-*.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
difference-of-squaresN/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f6491.7
Applied rewrites91.7%
Taylor expanded in a around inf
lower-/.f6458.0
Applied rewrites58.0%
Taylor expanded in a around inf
mul-1-negN/A
lower-neg.f6499.6
Applied rewrites99.6%
lift-PI.f64N/A
lift-*.f64N/A
*-rgt-identityN/A
lift-PI.f6499.6
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f6499.6
Applied rewrites99.6%
if 5.0000000000000002e147 < a Initial program 50.4%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6474.5
Applied rewrites74.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6499.1
Applied rewrites99.1%
lift-PI.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* (/ (/ PI a) (* b a)) 0.5)))
(if (<= a -9.1e+167)
t_0
(if (<= a 5e+147) (* (/ PI (* (* (+ a b) 2.0) (- a))) (/ -1.0 b)) t_0))))
double code(double a, double b) {
double t_0 = ((((double) M_PI) / a) / (b * a)) * 0.5;
double tmp;
if (a <= -9.1e+167) {
tmp = t_0;
} else if (a <= 5e+147) {
tmp = (((double) M_PI) / (((a + b) * 2.0) * -a)) * (-1.0 / b);
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = ((Math.PI / a) / (b * a)) * 0.5;
double tmp;
if (a <= -9.1e+167) {
tmp = t_0;
} else if (a <= 5e+147) {
tmp = (Math.PI / (((a + b) * 2.0) * -a)) * (-1.0 / b);
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b): t_0 = ((math.pi / a) / (b * a)) * 0.5 tmp = 0 if a <= -9.1e+167: tmp = t_0 elif a <= 5e+147: tmp = (math.pi / (((a + b) * 2.0) * -a)) * (-1.0 / b) else: tmp = t_0 return tmp
function code(a, b) t_0 = Float64(Float64(Float64(pi / a) / Float64(b * a)) * 0.5) tmp = 0.0 if (a <= -9.1e+167) tmp = t_0; elseif (a <= 5e+147) tmp = Float64(Float64(pi / Float64(Float64(Float64(a + b) * 2.0) * Float64(-a))) * Float64(-1.0 / b)); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b) t_0 = ((pi / a) / (b * a)) * 0.5; tmp = 0.0; if (a <= -9.1e+167) tmp = t_0; elseif (a <= 5e+147) tmp = (pi / (((a + b) * 2.0) * -a)) * (-1.0 / b); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[(N[(Pi / a), $MachinePrecision] / N[(b * a), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[a, -9.1e+167], t$95$0, If[LessEqual[a, 5e+147], N[(N[(Pi / N[(N[(N[(a + b), $MachinePrecision] * 2.0), $MachinePrecision] * (-a)), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / b), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{\pi}{a}}{b \cdot a} \cdot 0.5\\
\mathbf{if}\;a \leq -9.1 \cdot 10^{+167}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 5 \cdot 10^{+147}:\\
\;\;\;\;\frac{\pi}{\left(\left(a + b\right) \cdot 2\right) \cdot \left(-a\right)} \cdot \frac{-1}{b}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -9.10000000000000019e167 or 5.0000000000000002e147 < a Initial program 51.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6476.8
Applied rewrites76.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6499.2
Applied rewrites99.2%
lift-PI.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
if -9.10000000000000019e167 < a < 5.0000000000000002e147Initial program 86.8%
lift-*.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
difference-of-squaresN/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f6491.3
Applied rewrites91.3%
Taylor expanded in a around inf
lower-/.f6459.1
Applied rewrites59.1%
Taylor expanded in a around inf
mul-1-negN/A
lower-neg.f6498.8
Applied rewrites98.8%
lift-PI.f64N/A
lift-*.f64N/A
*-rgt-identityN/A
lift-PI.f6498.8
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f6498.8
Applied rewrites98.8%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* (/ PI (* b (* b a))) 0.5)))
(if (<= b -2.5e-17)
t_0
(if (<= b 2.95e-5) (* (/ (/ PI a) (* b a)) 0.5) t_0))))
double code(double a, double b) {
double t_0 = (((double) M_PI) / (b * (b * a))) * 0.5;
double tmp;
if (b <= -2.5e-17) {
tmp = t_0;
} else if (b <= 2.95e-5) {
tmp = ((((double) M_PI) / a) / (b * a)) * 0.5;
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = (Math.PI / (b * (b * a))) * 0.5;
double tmp;
if (b <= -2.5e-17) {
tmp = t_0;
} else if (b <= 2.95e-5) {
tmp = ((Math.PI / a) / (b * a)) * 0.5;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b): t_0 = (math.pi / (b * (b * a))) * 0.5 tmp = 0 if b <= -2.5e-17: tmp = t_0 elif b <= 2.95e-5: tmp = ((math.pi / a) / (b * a)) * 0.5 else: tmp = t_0 return tmp
function code(a, b) t_0 = Float64(Float64(pi / Float64(b * Float64(b * a))) * 0.5) tmp = 0.0 if (b <= -2.5e-17) tmp = t_0; elseif (b <= 2.95e-5) tmp = Float64(Float64(Float64(pi / a) / Float64(b * a)) * 0.5); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b) t_0 = (pi / (b * (b * a))) * 0.5; tmp = 0.0; if (b <= -2.5e-17) tmp = t_0; elseif (b <= 2.95e-5) tmp = ((pi / a) / (b * a)) * 0.5; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[(Pi / N[(b * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[b, -2.5e-17], t$95$0, If[LessEqual[b, 2.95e-5], N[(N[(N[(Pi / a), $MachinePrecision] / N[(b * a), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\pi}{b \cdot \left(b \cdot a\right)} \cdot 0.5\\
\mathbf{if}\;b \leq -2.5 \cdot 10^{-17}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 2.95 \cdot 10^{-5}:\\
\;\;\;\;\frac{\frac{\pi}{a}}{b \cdot a} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -2.4999999999999999e-17 or 2.9499999999999999e-5 < b Initial program 76.4%
lift-*.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
difference-of-squaresN/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f6488.6
Applied rewrites88.6%
lift-PI.f64N/A
lift-*.f64N/A
*-rgt-identityN/A
lift-PI.f6488.6
lift-*.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift--.f6488.6
Applied rewrites88.6%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lower-*.f6479.5
Applied rewrites79.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6489.9
Applied rewrites89.9%
if -2.4999999999999999e-17 < b < 2.9499999999999999e-5Initial program 80.4%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6471.5
Applied rewrites71.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6483.9
Applied rewrites83.9%
lift-PI.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f6484.2
Applied rewrites84.2%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* (/ PI (* b (* b a))) 0.5)))
(if (<= b -2.5e-17)
t_0
(if (<= b 2.95e-5) (* (/ PI (* a (* a b))) 0.5) t_0))))
double code(double a, double b) {
double t_0 = (((double) M_PI) / (b * (b * a))) * 0.5;
double tmp;
if (b <= -2.5e-17) {
tmp = t_0;
} else if (b <= 2.95e-5) {
tmp = (((double) M_PI) / (a * (a * b))) * 0.5;
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = (Math.PI / (b * (b * a))) * 0.5;
double tmp;
if (b <= -2.5e-17) {
tmp = t_0;
} else if (b <= 2.95e-5) {
tmp = (Math.PI / (a * (a * b))) * 0.5;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b): t_0 = (math.pi / (b * (b * a))) * 0.5 tmp = 0 if b <= -2.5e-17: tmp = t_0 elif b <= 2.95e-5: tmp = (math.pi / (a * (a * b))) * 0.5 else: tmp = t_0 return tmp
function code(a, b) t_0 = Float64(Float64(pi / Float64(b * Float64(b * a))) * 0.5) tmp = 0.0 if (b <= -2.5e-17) tmp = t_0; elseif (b <= 2.95e-5) tmp = Float64(Float64(pi / Float64(a * Float64(a * b))) * 0.5); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b) t_0 = (pi / (b * (b * a))) * 0.5; tmp = 0.0; if (b <= -2.5e-17) tmp = t_0; elseif (b <= 2.95e-5) tmp = (pi / (a * (a * b))) * 0.5; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[(Pi / N[(b * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[b, -2.5e-17], t$95$0, If[LessEqual[b, 2.95e-5], N[(N[(Pi / N[(a * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\pi}{b \cdot \left(b \cdot a\right)} \cdot 0.5\\
\mathbf{if}\;b \leq -2.5 \cdot 10^{-17}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 2.95 \cdot 10^{-5}:\\
\;\;\;\;\frac{\pi}{a \cdot \left(a \cdot b\right)} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -2.4999999999999999e-17 or 2.9499999999999999e-5 < b Initial program 76.4%
lift-*.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
difference-of-squaresN/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f6488.6
Applied rewrites88.6%
lift-PI.f64N/A
lift-*.f64N/A
*-rgt-identityN/A
lift-PI.f6488.6
lift-*.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift--.f6488.6
Applied rewrites88.6%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lower-*.f6479.5
Applied rewrites79.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6489.9
Applied rewrites89.9%
if -2.4999999999999999e-17 < b < 2.9499999999999999e-5Initial program 80.4%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6471.5
Applied rewrites71.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6483.9
Applied rewrites83.9%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* (/ PI (* (* b b) a)) 0.5)))
(if (<= b -2.5e-17)
t_0
(if (<= b 2.95e-5) (* (/ PI (* a (* a b))) 0.5) t_0))))
double code(double a, double b) {
double t_0 = (((double) M_PI) / ((b * b) * a)) * 0.5;
double tmp;
if (b <= -2.5e-17) {
tmp = t_0;
} else if (b <= 2.95e-5) {
tmp = (((double) M_PI) / (a * (a * b))) * 0.5;
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = (Math.PI / ((b * b) * a)) * 0.5;
double tmp;
if (b <= -2.5e-17) {
tmp = t_0;
} else if (b <= 2.95e-5) {
tmp = (Math.PI / (a * (a * b))) * 0.5;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b): t_0 = (math.pi / ((b * b) * a)) * 0.5 tmp = 0 if b <= -2.5e-17: tmp = t_0 elif b <= 2.95e-5: tmp = (math.pi / (a * (a * b))) * 0.5 else: tmp = t_0 return tmp
function code(a, b) t_0 = Float64(Float64(pi / Float64(Float64(b * b) * a)) * 0.5) tmp = 0.0 if (b <= -2.5e-17) tmp = t_0; elseif (b <= 2.95e-5) tmp = Float64(Float64(pi / Float64(a * Float64(a * b))) * 0.5); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b) t_0 = (pi / ((b * b) * a)) * 0.5; tmp = 0.0; if (b <= -2.5e-17) tmp = t_0; elseif (b <= 2.95e-5) tmp = (pi / (a * (a * b))) * 0.5; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[(Pi / N[(N[(b * b), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[b, -2.5e-17], t$95$0, If[LessEqual[b, 2.95e-5], N[(N[(Pi / N[(a * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\pi}{\left(b \cdot b\right) \cdot a} \cdot 0.5\\
\mathbf{if}\;b \leq -2.5 \cdot 10^{-17}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 2.95 \cdot 10^{-5}:\\
\;\;\;\;\frac{\pi}{a \cdot \left(a \cdot b\right)} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -2.4999999999999999e-17 or 2.9499999999999999e-5 < b Initial program 76.4%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6479.5
Applied rewrites79.5%
if -2.4999999999999999e-17 < b < 2.9499999999999999e-5Initial program 80.4%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6471.5
Applied rewrites71.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6483.9
Applied rewrites83.9%
(FPCore (a b) :precision binary64 (* (/ PI (* a (* a b))) 0.5))
double code(double a, double b) {
return (((double) M_PI) / (a * (a * b))) * 0.5;
}
public static double code(double a, double b) {
return (Math.PI / (a * (a * b))) * 0.5;
}
def code(a, b): return (math.pi / (a * (a * b))) * 0.5
function code(a, b) return Float64(Float64(pi / Float64(a * Float64(a * b))) * 0.5) end
function tmp = code(a, b) tmp = (pi / (a * (a * b))) * 0.5; end
code[a_, b_] := N[(N[(Pi / N[(a * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
\\
\frac{\pi}{a \cdot \left(a \cdot b\right)} \cdot 0.5
\end{array}
Initial program 78.3%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6456.7
Applied rewrites56.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6462.7
Applied rewrites62.7%
herbie shell --seed 2025101
(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))))