
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ 3.0 a))))) 1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * (((a * a) * (1.0d0 - a)) + ((b * b) * (3.0d0 + a))))) - 1.0d0
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + Float64(Float64(b * b) * Float64(3.0 + a))))) - 1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0; end
code[a_, b_] := N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(3.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ 3.0 a))))) 1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * (((a * a) * (1.0d0 - a)) + ((b * b) * (3.0d0 + a))))) - 1.0d0
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + Float64(Float64(b * b) * Float64(3.0 + a))))) - 1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0; end
code[a_, b_] := N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(3.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1
\end{array}
(FPCore (a b)
:precision binary64
(let* ((t_0 (* (* b b) (+ a 3.0))))
(if (<=
(+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (- 1.0 a)) t_0)))
INFINITY)
(fma 4.0 (fma a (- a (* a a)) t_0) (+ (pow (hypot a b) 4.0) -1.0))
(+ -1.0 (* (* a a) (* a (+ a -4.0)))))))
double code(double a, double b) {
double t_0 = (b * b) * (a + 3.0);
double tmp;
if ((pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + t_0))) <= ((double) INFINITY)) {
tmp = fma(4.0, fma(a, (a - (a * a)), t_0), (pow(hypot(a, b), 4.0) + -1.0));
} else {
tmp = -1.0 + ((a * a) * (a * (a + -4.0)));
}
return tmp;
}
function code(a, b) t_0 = Float64(Float64(b * b) * Float64(a + 3.0)) tmp = 0.0 if (Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + t_0))) <= Inf) tmp = fma(4.0, fma(a, Float64(a - Float64(a * a)), t_0), Float64((hypot(a, b) ^ 4.0) + -1.0)); else tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(a * Float64(a + -4.0)))); end return tmp end
code[a_, b_] := Block[{t$95$0 = N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(4.0 * N[(a * N[(a - N[(a * a), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision] + N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(a * N[(a + -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(b \cdot b\right) \cdot \left(a + 3\right)\\
\mathbf{if}\;{\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + t_0\right) \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(4, \mathsf{fma}\left(a, a - a \cdot a, t_0\right), {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot \left(a + -4\right)\right)\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) < +inf.0Initial program 99.8%
sub-neg99.8%
+-commutative99.8%
associate-+l+99.8%
fma-def99.8%
associate-*l*99.8%
fma-def99.8%
distribute-lft-out--99.8%
*-rgt-identity99.8%
+-commutative99.8%
Simplified100.0%
if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) Initial program 0.0%
sub-neg0.0%
sqr-pow0.0%
sqr-pow0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
Simplified1.4%
Taylor expanded in a around inf 36.7%
unpow336.7%
Applied egg-rr36.7%
metadata-eval36.7%
pow-prod-up36.7%
pow136.7%
pow336.7%
distribute-rgt-in90.3%
+-commutative90.3%
associate-*l*90.3%
*-commutative90.3%
Applied egg-rr90.3%
Final simplification97.4%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))))
(if (<= t_0 INFINITY) (+ t_0 -1.0) (+ -1.0 (* (* a a) (* a (+ a -4.0)))))))
double code(double a, double b) {
double t_0 = pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0 + -1.0;
} else {
tmp = -1.0 + ((a * a) * (a * (a + -4.0)));
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 + -1.0;
} else {
tmp = -1.0 + ((a * a) * (a * (a + -4.0)));
}
return tmp;
}
def code(a, b): t_0 = math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0)))) tmp = 0 if t_0 <= math.inf: tmp = t_0 + -1.0 else: tmp = -1.0 + ((a * a) * (a * (a + -4.0))) return tmp
function code(a, b) t_0 = Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + Float64(Float64(b * b) * Float64(a + 3.0))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(t_0 + -1.0); else tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(a * Float64(a + -4.0)))); end return tmp end
function tmp_2 = code(a, b) t_0 = (((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0)))); tmp = 0.0; if (t_0 <= Inf) tmp = t_0 + -1.0; else tmp = -1.0 + ((a * a) * (a * (a + -4.0))); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(t$95$0 + -1.0), $MachinePrecision], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(a * N[(a + -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\\
\mathbf{if}\;t_0 \leq \infty:\\
\;\;\;\;t_0 + -1\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot \left(a + -4\right)\right)\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) < +inf.0Initial program 99.8%
if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) Initial program 0.0%
sub-neg0.0%
sqr-pow0.0%
sqr-pow0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
Simplified1.4%
Taylor expanded in a around inf 36.7%
unpow336.7%
Applied egg-rr36.7%
metadata-eval36.7%
pow-prod-up36.7%
pow136.7%
pow336.7%
distribute-rgt-in90.3%
+-commutative90.3%
associate-*l*90.3%
*-commutative90.3%
Applied egg-rr90.3%
Final simplification97.3%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e+30) (+ -1.0 (* (+ a -4.0) (pow a 3.0))) (+ -1.0 (pow b 4.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+30) {
tmp = -1.0 + ((a + -4.0) * pow(a, 3.0));
} else {
tmp = -1.0 + pow(b, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 2d+30) then
tmp = (-1.0d0) + ((a + (-4.0d0)) * (a ** 3.0d0))
else
tmp = (-1.0d0) + (b ** 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+30) {
tmp = -1.0 + ((a + -4.0) * Math.pow(a, 3.0));
} else {
tmp = -1.0 + Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2e+30: tmp = -1.0 + ((a + -4.0) * math.pow(a, 3.0)) else: tmp = -1.0 + math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e+30) tmp = Float64(-1.0 + Float64(Float64(a + -4.0) * (a ^ 3.0))); else tmp = Float64(-1.0 + (b ^ 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2e+30) tmp = -1.0 + ((a + -4.0) * (a ^ 3.0)); else tmp = -1.0 + (b ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e+30], N[(-1.0 + N[(N[(a + -4.0), $MachinePrecision] * N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+30}:\\
\;\;\;\;-1 + \left(a + -4\right) \cdot {a}^{3}\\
\mathbf{else}:\\
\;\;\;\;-1 + {b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 2e30Initial program 83.8%
sub-neg83.8%
sqr-pow83.8%
sqr-pow83.8%
sqr-neg83.8%
distribute-rgt-in83.8%
sqr-neg83.8%
distribute-rgt-in83.8%
Simplified83.8%
Taylor expanded in a around inf 82.5%
expm1-log1p-u81.3%
expm1-udef81.2%
fma-def81.2%
Applied egg-rr81.2%
expm1-def81.3%
expm1-log1p82.5%
fma-udef82.5%
+-commutative82.5%
metadata-eval82.5%
pow-plus82.5%
*-commutative82.5%
distribute-lft-out98.5%
Simplified98.5%
if 2e30 < (*.f64 b b) Initial program 61.5%
sub-neg61.5%
sqr-pow61.5%
sqr-pow61.5%
sqr-neg61.5%
distribute-rgt-in61.5%
sqr-neg61.5%
distribute-rgt-in61.5%
Simplified62.3%
Taylor expanded in b around inf 93.9%
Final simplification96.3%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e+30) (+ -1.0 (* (+ a -4.0) (* a (* a a)))) (+ -1.0 (pow b 4.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+30) {
tmp = -1.0 + ((a + -4.0) * (a * (a * a)));
} else {
tmp = -1.0 + pow(b, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 2d+30) then
tmp = (-1.0d0) + ((a + (-4.0d0)) * (a * (a * a)))
else
tmp = (-1.0d0) + (b ** 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+30) {
tmp = -1.0 + ((a + -4.0) * (a * (a * a)));
} else {
tmp = -1.0 + Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2e+30: tmp = -1.0 + ((a + -4.0) * (a * (a * a))) else: tmp = -1.0 + math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e+30) tmp = Float64(-1.0 + Float64(Float64(a + -4.0) * Float64(a * Float64(a * a)))); else tmp = Float64(-1.0 + (b ^ 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2e+30) tmp = -1.0 + ((a + -4.0) * (a * (a * a))); else tmp = -1.0 + (b ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e+30], N[(-1.0 + N[(N[(a + -4.0), $MachinePrecision] * N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+30}:\\
\;\;\;\;-1 + \left(a + -4\right) \cdot \left(a \cdot \left(a \cdot a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + {b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 2e30Initial program 83.8%
sub-neg83.8%
sqr-pow83.8%
sqr-pow83.8%
sqr-neg83.8%
distribute-rgt-in83.8%
sqr-neg83.8%
distribute-rgt-in83.8%
Simplified83.8%
Taylor expanded in a around inf 82.5%
expm1-log1p-u81.3%
expm1-udef81.2%
fma-def81.2%
Applied egg-rr81.2%
expm1-def81.3%
expm1-log1p82.5%
fma-udef82.5%
+-commutative82.5%
metadata-eval82.5%
pow-plus82.5%
*-commutative82.5%
distribute-lft-out98.5%
Simplified98.5%
unpow382.5%
Applied egg-rr98.5%
if 2e30 < (*.f64 b b) Initial program 61.5%
sub-neg61.5%
sqr-pow61.5%
sqr-pow61.5%
sqr-neg61.5%
distribute-rgt-in61.5%
sqr-neg61.5%
distribute-rgt-in61.5%
Simplified62.3%
Taylor expanded in b around inf 93.9%
Final simplification96.2%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e+288) (+ -1.0 (* (* a a) (* a (+ a -4.0)))) (+ -1.0 (* b (* b 12.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+288) {
tmp = -1.0 + ((a * a) * (a * (a + -4.0)));
} else {
tmp = -1.0 + (b * (b * 12.0));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 2d+288) then
tmp = (-1.0d0) + ((a * a) * (a * (a + (-4.0d0))))
else
tmp = (-1.0d0) + (b * (b * 12.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+288) {
tmp = -1.0 + ((a * a) * (a * (a + -4.0)));
} else {
tmp = -1.0 + (b * (b * 12.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2e+288: tmp = -1.0 + ((a * a) * (a * (a + -4.0))) else: tmp = -1.0 + (b * (b * 12.0)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e+288) tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(a * Float64(a + -4.0)))); else tmp = Float64(-1.0 + Float64(b * Float64(b * 12.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2e+288) tmp = -1.0 + ((a * a) * (a * (a + -4.0))); else tmp = -1.0 + (b * (b * 12.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e+288], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(a * N[(a + -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(b * N[(b * 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+288}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot \left(a + -4\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + b \cdot \left(b \cdot 12\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 2e288Initial program 79.4%
sub-neg79.4%
sqr-pow79.4%
sqr-pow79.4%
sqr-neg79.4%
distribute-rgt-in79.4%
sqr-neg79.4%
distribute-rgt-in79.4%
Simplified79.4%
Taylor expanded in a around inf 65.5%
unpow365.5%
Applied egg-rr65.5%
metadata-eval65.5%
pow-prod-up65.5%
pow165.5%
pow365.4%
distribute-rgt-in80.9%
+-commutative80.9%
associate-*l*80.9%
*-commutative80.9%
Applied egg-rr80.9%
if 2e288 < (*.f64 b b) Initial program 57.3%
sub-neg57.3%
sqr-pow57.3%
sqr-pow57.3%
sqr-neg57.3%
distribute-rgt-in57.3%
sqr-neg57.3%
distribute-rgt-in57.3%
Simplified58.7%
Taylor expanded in a around 0 46.7%
+-commutative46.7%
+-commutative46.7%
associate-+l+46.7%
unpow246.7%
unpow246.7%
associate-*r*46.7%
distribute-rgt-in69.3%
metadata-eval69.3%
distribute-lft-in69.3%
*-commutative69.3%
distribute-lft-in69.3%
metadata-eval69.3%
Simplified69.3%
Taylor expanded in b around 0 65.8%
unpow265.8%
+-commutative65.8%
*-commutative65.8%
fma-udef65.8%
Simplified65.8%
fma-udef65.8%
distribute-rgt-in43.1%
*-commutative43.1%
associate-*l*52.5%
Applied egg-rr52.5%
Taylor expanded in a around 0 94.1%
unpow294.1%
*-commutative94.1%
associate-*r*94.1%
Simplified94.1%
Final simplification84.8%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e+288) (+ -1.0 (* (+ a -4.0) (* a (* a a)))) (+ -1.0 (* b (* b 12.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+288) {
tmp = -1.0 + ((a + -4.0) * (a * (a * a)));
} else {
tmp = -1.0 + (b * (b * 12.0));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 2d+288) then
tmp = (-1.0d0) + ((a + (-4.0d0)) * (a * (a * a)))
else
tmp = (-1.0d0) + (b * (b * 12.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+288) {
tmp = -1.0 + ((a + -4.0) * (a * (a * a)));
} else {
tmp = -1.0 + (b * (b * 12.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2e+288: tmp = -1.0 + ((a + -4.0) * (a * (a * a))) else: tmp = -1.0 + (b * (b * 12.0)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e+288) tmp = Float64(-1.0 + Float64(Float64(a + -4.0) * Float64(a * Float64(a * a)))); else tmp = Float64(-1.0 + Float64(b * Float64(b * 12.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2e+288) tmp = -1.0 + ((a + -4.0) * (a * (a * a))); else tmp = -1.0 + (b * (b * 12.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e+288], N[(-1.0 + N[(N[(a + -4.0), $MachinePrecision] * N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(b * N[(b * 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+288}:\\
\;\;\;\;-1 + \left(a + -4\right) \cdot \left(a \cdot \left(a \cdot a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + b \cdot \left(b \cdot 12\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 2e288Initial program 79.4%
sub-neg79.4%
sqr-pow79.4%
sqr-pow79.4%
sqr-neg79.4%
distribute-rgt-in79.4%
sqr-neg79.4%
distribute-rgt-in79.4%
Simplified79.4%
Taylor expanded in a around inf 65.5%
expm1-log1p-u64.6%
expm1-udef64.6%
fma-def64.6%
Applied egg-rr64.6%
expm1-def64.6%
expm1-log1p65.5%
fma-udef65.5%
+-commutative65.5%
metadata-eval65.5%
pow-plus65.5%
*-commutative65.5%
distribute-lft-out80.9%
Simplified80.9%
unpow365.5%
Applied egg-rr80.9%
if 2e288 < (*.f64 b b) Initial program 57.3%
sub-neg57.3%
sqr-pow57.3%
sqr-pow57.3%
sqr-neg57.3%
distribute-rgt-in57.3%
sqr-neg57.3%
distribute-rgt-in57.3%
Simplified58.7%
Taylor expanded in a around 0 46.7%
+-commutative46.7%
+-commutative46.7%
associate-+l+46.7%
unpow246.7%
unpow246.7%
associate-*r*46.7%
distribute-rgt-in69.3%
metadata-eval69.3%
distribute-lft-in69.3%
*-commutative69.3%
distribute-lft-in69.3%
metadata-eval69.3%
Simplified69.3%
Taylor expanded in b around 0 65.8%
unpow265.8%
+-commutative65.8%
*-commutative65.8%
fma-udef65.8%
Simplified65.8%
fma-udef65.8%
distribute-rgt-in43.1%
*-commutative43.1%
associate-*l*52.5%
Applied egg-rr52.5%
Taylor expanded in a around 0 94.1%
unpow294.1%
*-commutative94.1%
associate-*r*94.1%
Simplified94.1%
Final simplification84.8%
(FPCore (a b) :precision binary64 (if (<= a 9e-62) (+ -1.0 (* b (* b 12.0))) (+ -1.0 (* b (* b (* a 4.0))))))
double code(double a, double b) {
double tmp;
if (a <= 9e-62) {
tmp = -1.0 + (b * (b * 12.0));
} else {
tmp = -1.0 + (b * (b * (a * 4.0)));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= 9d-62) then
tmp = (-1.0d0) + (b * (b * 12.0d0))
else
tmp = (-1.0d0) + (b * (b * (a * 4.0d0)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= 9e-62) {
tmp = -1.0 + (b * (b * 12.0));
} else {
tmp = -1.0 + (b * (b * (a * 4.0)));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= 9e-62: tmp = -1.0 + (b * (b * 12.0)) else: tmp = -1.0 + (b * (b * (a * 4.0))) return tmp
function code(a, b) tmp = 0.0 if (a <= 9e-62) tmp = Float64(-1.0 + Float64(b * Float64(b * 12.0))); else tmp = Float64(-1.0 + Float64(b * Float64(b * Float64(a * 4.0)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= 9e-62) tmp = -1.0 + (b * (b * 12.0)); else tmp = -1.0 + (b * (b * (a * 4.0))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, 9e-62], N[(-1.0 + N[(b * N[(b * 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(b * N[(b * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 9 \cdot 10^{-62}:\\
\;\;\;\;-1 + b \cdot \left(b \cdot 12\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + b \cdot \left(b \cdot \left(a \cdot 4\right)\right)\\
\end{array}
\end{array}
if a < 9.00000000000000036e-62Initial program 82.5%
sub-neg82.5%
sqr-pow82.5%
sqr-pow82.5%
sqr-neg82.5%
distribute-rgt-in82.5%
sqr-neg82.5%
distribute-rgt-in82.5%
Simplified82.5%
Taylor expanded in a around 0 51.2%
+-commutative51.2%
+-commutative51.2%
associate-+l+51.2%
unpow251.2%
unpow251.2%
associate-*r*51.2%
distribute-rgt-in60.5%
metadata-eval60.5%
distribute-lft-in60.5%
*-commutative60.5%
distribute-lft-in60.5%
metadata-eval60.5%
Simplified60.5%
Taylor expanded in b around 0 44.3%
unpow244.3%
+-commutative44.3%
*-commutative44.3%
fma-udef44.3%
Simplified44.3%
fma-udef44.3%
distribute-rgt-in35.1%
*-commutative35.1%
associate-*l*38.9%
Applied egg-rr38.9%
Taylor expanded in a around 0 56.8%
unpow256.8%
*-commutative56.8%
associate-*r*56.8%
Simplified56.8%
if 9.00000000000000036e-62 < a Initial program 48.5%
sub-neg48.5%
sqr-pow48.5%
sqr-pow48.5%
sqr-neg48.5%
distribute-rgt-in48.5%
sqr-neg48.5%
distribute-rgt-in48.5%
Simplified49.9%
Taylor expanded in a around 0 53.5%
+-commutative53.5%
+-commutative53.5%
associate-+l+53.5%
unpow253.5%
unpow253.5%
associate-*r*53.5%
distribute-rgt-in53.5%
metadata-eval53.5%
distribute-lft-in53.5%
*-commutative53.5%
distribute-lft-in53.5%
metadata-eval53.5%
Simplified53.5%
Taylor expanded in a around inf 49.7%
*-commutative49.7%
unpow249.7%
*-commutative49.7%
associate-*r*49.7%
Simplified49.7%
Taylor expanded in b around 0 49.7%
*-commutative49.7%
unpow249.7%
*-commutative49.7%
associate-*r*49.7%
associate-*r*49.7%
*-commutative49.7%
Simplified49.7%
Final simplification54.8%
(FPCore (a b) :precision binary64 (+ -1.0 (* b (* b 12.0))))
double code(double a, double b) {
return -1.0 + (b * (b * 12.0));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (-1.0d0) + (b * (b * 12.0d0))
end function
public static double code(double a, double b) {
return -1.0 + (b * (b * 12.0));
}
def code(a, b): return -1.0 + (b * (b * 12.0))
function code(a, b) return Float64(-1.0 + Float64(b * Float64(b * 12.0))) end
function tmp = code(a, b) tmp = -1.0 + (b * (b * 12.0)); end
code[a_, b_] := N[(-1.0 + N[(b * N[(b * 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 + b \cdot \left(b \cdot 12\right)
\end{array}
Initial program 72.9%
sub-neg72.9%
sqr-pow72.9%
sqr-pow72.9%
sqr-neg72.9%
distribute-rgt-in72.9%
sqr-neg72.9%
distribute-rgt-in72.9%
Simplified73.3%
Taylor expanded in a around 0 51.9%
+-commutative51.9%
+-commutative51.9%
associate-+l+51.9%
unpow251.9%
unpow251.9%
associate-*r*51.9%
distribute-rgt-in58.5%
metadata-eval58.5%
distribute-lft-in58.5%
*-commutative58.5%
distribute-lft-in58.5%
metadata-eval58.5%
Simplified58.5%
Taylor expanded in b around 0 45.8%
unpow245.8%
+-commutative45.8%
*-commutative45.8%
fma-udef45.8%
Simplified45.8%
fma-udef45.8%
distribute-rgt-in39.2%
*-commutative39.2%
associate-*l*41.9%
Applied egg-rr41.9%
Taylor expanded in a around 0 52.4%
unpow252.4%
*-commutative52.4%
associate-*r*52.4%
Simplified52.4%
Final simplification52.4%
(FPCore (a b) :precision binary64 -1.0)
double code(double a, double b) {
return -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = -1.0d0
end function
public static double code(double a, double b) {
return -1.0;
}
def code(a, b): return -1.0
function code(a, b) return -1.0 end
function tmp = code(a, b) tmp = -1.0; end
code[a_, b_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 72.9%
sub-neg72.9%
sqr-pow72.9%
sqr-pow72.9%
sqr-neg72.9%
distribute-rgt-in72.9%
sqr-neg72.9%
distribute-rgt-in72.9%
Simplified73.3%
Taylor expanded in a around inf 68.1%
Taylor expanded in a around 0 23.9%
Final simplification23.9%
herbie shell --seed 2023272
(FPCore (a b)
:name "Bouland and Aaronson, Equation (24)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ 3.0 a))))) 1.0))