
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 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) * (1.0 - (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) * (1.0d0 - (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) * (1.0 - (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) * (1.0 - (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(1.0 - 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) * (1.0 - (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[(1.0 - N[(3.0 * a), $MachinePrecision]), $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(1 - 3 \cdot a\right)\right)\right) - 1
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 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) (- 1.0 (* 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) * (1.0 - (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) * (1.0d0 - (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) * (1.0 - (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) * (1.0 - (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(1.0 - 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) * (1.0 - (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[(1.0 - N[(3.0 * a), $MachinePrecision]), $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(1 - 3 \cdot a\right)\right)\right) - 1
\end{array}
(FPCore (a b)
:precision binary64
(if (<=
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* b b) (- 1.0 (* a 3.0))) (* (* a a) (+ a 1.0)))))
1e+305)
(+
(fma
4.0
(fma a (fma a a a) (* b (* b (fma a -3.0 1.0))))
(pow (hypot a b) 4.0))
-1.0)
(+ (cbrt (pow (pow (hypot a b) 2.0) 6.0)) (+ (* (* b b) 4.0) -1.0))))
double code(double a, double b) {
double tmp;
if ((pow(((a * a) + (b * b)), 2.0) + (4.0 * (((b * b) * (1.0 - (a * 3.0))) + ((a * a) * (a + 1.0))))) <= 1e+305) {
tmp = fma(4.0, fma(a, fma(a, a, a), (b * (b * fma(a, -3.0, 1.0)))), pow(hypot(a, b), 4.0)) + -1.0;
} else {
tmp = cbrt(pow(pow(hypot(a, b), 2.0), 6.0)) + (((b * b) * 4.0) + -1.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(b * b) * Float64(1.0 - Float64(a * 3.0))) + Float64(Float64(a * a) * Float64(a + 1.0))))) <= 1e+305) tmp = Float64(fma(4.0, fma(a, fma(a, a, a), Float64(b * Float64(b * fma(a, -3.0, 1.0)))), (hypot(a, b) ^ 4.0)) + -1.0); else tmp = Float64(cbrt(((hypot(a, b) ^ 2.0) ^ 6.0)) + Float64(Float64(Float64(b * b) * 4.0) + -1.0)); end return tmp end
code[a_, b_] := If[LessEqual[N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * N[(a + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+305], N[(N[(4.0 * N[(a * N[(a * a + a), $MachinePrecision] + N[(b * N[(b * N[(a * -3.0 + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[N[Power[N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 2.0], $MachinePrecision], 6.0], $MachinePrecision], 1/3], $MachinePrecision] + N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right) + \left(a \cdot a\right) \cdot \left(a + 1\right)\right) \leq 10^{+305}:\\
\;\;\;\;\mathsf{fma}\left(4, \mathsf{fma}\left(a, \mathsf{fma}\left(a, a, a\right), b \cdot \left(b \cdot \mathsf{fma}\left(a, -3, 1\right)\right)\right), {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{\left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{2}\right)}^{6}} + \left(\left(b \cdot b\right) \cdot 4 + -1\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 1 (*.f64 3 a)))))) < 9.9999999999999994e304Initial program 99.6%
sub-neg99.6%
Simplified100.0%
if 9.9999999999999994e304 < (+.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 1 (*.f64 3 a)))))) Initial program 57.7%
associate--l+57.7%
fma-def57.7%
Simplified60.3%
fma-def60.3%
add-cbrt-cube60.3%
pow360.3%
pow-pow60.3%
add-sqr-sqrt60.3%
hypot-udef60.3%
hypot-udef60.3%
pow260.3%
metadata-eval60.3%
Applied egg-rr60.3%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* b b) (- 1.0 (* a 3.0))) (* (* a a) (+ a 1.0)))))))
(if (<= t_0 1e+305)
(+ t_0 -1.0)
(+ (cbrt (pow (pow (hypot a b) 2.0) 6.0)) (+ (* (* b b) 4.0) -1.0)))))
double code(double a, double b) {
double t_0 = pow(((a * a) + (b * b)), 2.0) + (4.0 * (((b * b) * (1.0 - (a * 3.0))) + ((a * a) * (a + 1.0))));
double tmp;
if (t_0 <= 1e+305) {
tmp = t_0 + -1.0;
} else {
tmp = cbrt(pow(pow(hypot(a, b), 2.0), 6.0)) + (((b * b) * 4.0) + -1.0);
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((b * b) * (1.0 - (a * 3.0))) + ((a * a) * (a + 1.0))));
double tmp;
if (t_0 <= 1e+305) {
tmp = t_0 + -1.0;
} else {
tmp = Math.cbrt(Math.pow(Math.pow(Math.hypot(a, b), 2.0), 6.0)) + (((b * b) * 4.0) + -1.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(b * b) * Float64(1.0 - Float64(a * 3.0))) + Float64(Float64(a * a) * Float64(a + 1.0))))) tmp = 0.0 if (t_0 <= 1e+305) tmp = Float64(t_0 + -1.0); else tmp = Float64(cbrt(((hypot(a, b) ^ 2.0) ^ 6.0)) + Float64(Float64(Float64(b * b) * 4.0) + -1.0)); end return 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[(b * b), $MachinePrecision] * N[(1.0 - N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * N[(a + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e+305], N[(t$95$0 + -1.0), $MachinePrecision], N[(N[Power[N[Power[N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 2.0], $MachinePrecision], 6.0], $MachinePrecision], 1/3], $MachinePrecision] + N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right) + \left(a \cdot a\right) \cdot \left(a + 1\right)\right)\\
\mathbf{if}\;t_0 \leq 10^{+305}:\\
\;\;\;\;t_0 + -1\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{\left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{2}\right)}^{6}} + \left(\left(b \cdot b\right) \cdot 4 + -1\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 1 (*.f64 3 a)))))) < 9.9999999999999994e304Initial program 99.6%
if 9.9999999999999994e304 < (+.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 1 (*.f64 3 a)))))) Initial program 57.7%
associate--l+57.7%
fma-def57.7%
Simplified60.3%
fma-def60.3%
add-cbrt-cube60.3%
pow360.3%
pow-pow60.3%
add-sqr-sqrt60.3%
hypot-udef60.3%
hypot-udef60.3%
pow260.3%
metadata-eval60.3%
Applied egg-rr60.3%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* b b) (- 1.0 (* a 3.0))) (* (* a a) (+ a 1.0)))))))
(if (<= t_0 INFINITY)
(+ t_0 -1.0)
(+ (pow a 4.0) (+ (* 2.0 (* (* a b) (* a b))) -1.0)))))
double code(double a, double b) {
double t_0 = pow(((a * a) + (b * b)), 2.0) + (4.0 * (((b * b) * (1.0 - (a * 3.0))) + ((a * a) * (a + 1.0))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0 + -1.0;
} else {
tmp = pow(a, 4.0) + ((2.0 * ((a * b) * (a * b))) + -1.0);
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((b * b) * (1.0 - (a * 3.0))) + ((a * a) * (a + 1.0))));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 + -1.0;
} else {
tmp = Math.pow(a, 4.0) + ((2.0 * ((a * b) * (a * b))) + -1.0);
}
return tmp;
}
def code(a, b): t_0 = math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((b * b) * (1.0 - (a * 3.0))) + ((a * a) * (a + 1.0)))) tmp = 0 if t_0 <= math.inf: tmp = t_0 + -1.0 else: tmp = math.pow(a, 4.0) + ((2.0 * ((a * b) * (a * b))) + -1.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(b * b) * Float64(1.0 - Float64(a * 3.0))) + Float64(Float64(a * a) * Float64(a + 1.0))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(t_0 + -1.0); else tmp = Float64((a ^ 4.0) + Float64(Float64(2.0 * Float64(Float64(a * b) * Float64(a * b))) + -1.0)); end return tmp end
function tmp_2 = code(a, b) t_0 = (((a * a) + (b * b)) ^ 2.0) + (4.0 * (((b * b) * (1.0 - (a * 3.0))) + ((a * a) * (a + 1.0)))); tmp = 0.0; if (t_0 <= Inf) tmp = t_0 + -1.0; else tmp = (a ^ 4.0) + ((2.0 * ((a * b) * (a * b))) + -1.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[(b * b), $MachinePrecision] * N[(1.0 - N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * N[(a + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(t$95$0 + -1.0), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] + N[(N[(2.0 * N[(N[(a * b), $MachinePrecision] * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right) + \left(a \cdot a\right) \cdot \left(a + 1\right)\right)\\
\mathbf{if}\;t_0 \leq \infty:\\
\;\;\;\;t_0 + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} + \left(2 \cdot \left(\left(a \cdot b\right) \cdot \left(a \cdot b\right)\right) + -1\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 1 (*.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 1 (*.f64 3 a)))))) Initial program 0.0%
associate--l+0.0%
fma-def0.0%
Simplified6.1%
fma-def6.1%
add-cbrt-cube6.1%
pow36.1%
pow-pow6.1%
add-sqr-sqrt6.1%
hypot-udef6.1%
hypot-udef6.1%
pow26.1%
metadata-eval6.1%
Applied egg-rr6.1%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in b around 0 84.8%
associate--l+84.8%
*-commutative84.8%
unpow284.8%
unpow284.8%
Simplified84.8%
Taylor expanded in a around inf 84.8%
unpow284.8%
unpow284.8%
unswap-sqr100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (a b) :precision binary64 (if (or (<= a -11000000.0) (not (<= a 210.0))) (+ (pow a 4.0) (+ (* 2.0 (* (* a b) (* a b))) -1.0)) (+ (+ (* (* b b) 4.0) -1.0) (pow b 4.0))))
double code(double a, double b) {
double tmp;
if ((a <= -11000000.0) || !(a <= 210.0)) {
tmp = pow(a, 4.0) + ((2.0 * ((a * b) * (a * b))) + -1.0);
} else {
tmp = (((b * b) * 4.0) + -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 ((a <= (-11000000.0d0)) .or. (.not. (a <= 210.0d0))) then
tmp = (a ** 4.0d0) + ((2.0d0 * ((a * b) * (a * b))) + (-1.0d0))
else
tmp = (((b * b) * 4.0d0) + (-1.0d0)) + (b ** 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -11000000.0) || !(a <= 210.0)) {
tmp = Math.pow(a, 4.0) + ((2.0 * ((a * b) * (a * b))) + -1.0);
} else {
tmp = (((b * b) * 4.0) + -1.0) + Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -11000000.0) or not (a <= 210.0): tmp = math.pow(a, 4.0) + ((2.0 * ((a * b) * (a * b))) + -1.0) else: tmp = (((b * b) * 4.0) + -1.0) + math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if ((a <= -11000000.0) || !(a <= 210.0)) tmp = Float64((a ^ 4.0) + Float64(Float64(2.0 * Float64(Float64(a * b) * Float64(a * b))) + -1.0)); else tmp = Float64(Float64(Float64(Float64(b * b) * 4.0) + -1.0) + (b ^ 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -11000000.0) || ~((a <= 210.0))) tmp = (a ^ 4.0) + ((2.0 * ((a * b) * (a * b))) + -1.0); else tmp = (((b * b) * 4.0) + -1.0) + (b ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -11000000.0], N[Not[LessEqual[a, 210.0]], $MachinePrecision]], N[(N[Power[a, 4.0], $MachinePrecision] + N[(N[(2.0 * N[(N[(a * b), $MachinePrecision] * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + -1.0), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -11000000 \lor \neg \left(a \leq 210\right):\\
\;\;\;\;{a}^{4} + \left(2 \cdot \left(\left(a \cdot b\right) \cdot \left(a \cdot b\right)\right) + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(b \cdot b\right) \cdot 4 + -1\right) + {b}^{4}\\
\end{array}
\end{array}
if a < -1.1e7 or 210 < a Initial program 51.3%
associate--l+51.3%
fma-def51.3%
Simplified54.3%
fma-def54.3%
add-cbrt-cube41.4%
pow341.3%
pow-pow41.3%
add-sqr-sqrt41.3%
hypot-udef41.3%
hypot-udef41.3%
pow241.3%
metadata-eval41.3%
Applied egg-rr41.3%
Taylor expanded in a around 0 85.8%
unpow285.8%
Simplified85.8%
Taylor expanded in b around 0 80.7%
associate--l+80.7%
*-commutative80.7%
unpow280.7%
unpow280.7%
Simplified80.7%
Taylor expanded in a around inf 80.7%
unpow280.7%
unpow280.7%
unswap-sqr96.8%
Simplified96.8%
if -1.1e7 < a < 210Initial program 99.9%
associate--l+99.9%
fma-def99.9%
Simplified99.9%
fma-def99.9%
add-cbrt-cube90.5%
pow390.6%
pow-pow90.6%
add-sqr-sqrt90.6%
hypot-udef90.6%
hypot-udef90.6%
pow290.6%
metadata-eval90.6%
Applied egg-rr90.6%
Taylor expanded in a around 0 90.2%
unpow290.2%
Simplified90.2%
Taylor expanded in a around 0 99.6%
Final simplification98.1%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+65) (+ (pow a 4.0) (+ (* (* a a) 4.0) -1.0)) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+65) {
tmp = pow(a, 4.0) + (((a * a) * 4.0) + -1.0);
} else {
tmp = 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) <= 5d+65) then
tmp = (a ** 4.0d0) + (((a * a) * 4.0d0) + (-1.0d0))
else
tmp = b ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+65) {
tmp = Math.pow(a, 4.0) + (((a * a) * 4.0) + -1.0);
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e+65: tmp = math.pow(a, 4.0) + (((a * a) * 4.0) + -1.0) else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e+65) tmp = Float64((a ^ 4.0) + Float64(Float64(Float64(a * a) * 4.0) + -1.0)); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5e+65) tmp = (a ^ 4.0) + (((a * a) * 4.0) + -1.0); else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e+65], N[(N[Power[a, 4.0], $MachinePrecision] + N[(N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{+65}:\\
\;\;\;\;{a}^{4} + \left(\left(a \cdot a\right) \cdot 4 + -1\right)\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 4.99999999999999973e65Initial program 82.1%
associate--l+82.1%
fma-def82.1%
Simplified82.1%
Taylor expanded in b around 0 80.1%
associate--l+80.1%
associate-*r*80.1%
unpow280.1%
Simplified80.1%
Taylor expanded in a around 0 95.1%
unpow295.1%
Simplified95.1%
if 4.99999999999999973e65 < (*.f64 b b) Initial program 64.3%
associate--l+64.3%
fma-def64.3%
Simplified67.7%
Taylor expanded in b around inf 96.0%
Final simplification95.5%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+65) (+ (pow a 4.0) (+ (* (* a a) 4.0) -1.0)) (+ (+ (* (* b b) 4.0) -1.0) (pow b 4.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+65) {
tmp = pow(a, 4.0) + (((a * a) * 4.0) + -1.0);
} else {
tmp = (((b * b) * 4.0) + -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) <= 5d+65) then
tmp = (a ** 4.0d0) + (((a * a) * 4.0d0) + (-1.0d0))
else
tmp = (((b * b) * 4.0d0) + (-1.0d0)) + (b ** 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+65) {
tmp = Math.pow(a, 4.0) + (((a * a) * 4.0) + -1.0);
} else {
tmp = (((b * b) * 4.0) + -1.0) + Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e+65: tmp = math.pow(a, 4.0) + (((a * a) * 4.0) + -1.0) else: tmp = (((b * b) * 4.0) + -1.0) + math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e+65) tmp = Float64((a ^ 4.0) + Float64(Float64(Float64(a * a) * 4.0) + -1.0)); else tmp = Float64(Float64(Float64(Float64(b * b) * 4.0) + -1.0) + (b ^ 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5e+65) tmp = (a ^ 4.0) + (((a * a) * 4.0) + -1.0); else tmp = (((b * b) * 4.0) + -1.0) + (b ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e+65], N[(N[Power[a, 4.0], $MachinePrecision] + N[(N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + -1.0), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{+65}:\\
\;\;\;\;{a}^{4} + \left(\left(a \cdot a\right) \cdot 4 + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(b \cdot b\right) \cdot 4 + -1\right) + {b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 4.99999999999999973e65Initial program 82.1%
associate--l+82.1%
fma-def82.1%
Simplified82.1%
Taylor expanded in b around 0 80.1%
associate--l+80.1%
associate-*r*80.1%
unpow280.1%
Simplified80.1%
Taylor expanded in a around 0 95.1%
unpow295.1%
Simplified95.1%
if 4.99999999999999973e65 < (*.f64 b b) Initial program 64.3%
associate--l+64.3%
fma-def64.3%
Simplified67.7%
fma-def67.7%
add-cbrt-cube56.4%
pow356.4%
pow-pow56.4%
add-sqr-sqrt56.4%
hypot-udef56.4%
hypot-udef56.4%
pow256.4%
metadata-eval56.4%
Applied egg-rr56.4%
Taylor expanded in a around 0 88.6%
unpow288.6%
Simplified88.6%
Taylor expanded in a around 0 96.0%
Final simplification95.5%
(FPCore (a b) :precision binary64 (if (<= a -4.1e+39) (pow a 4.0) (if (<= a 7.6e+30) (+ (* (* b b) (fma b b 4.0)) -1.0) (pow a 4.0))))
double code(double a, double b) {
double tmp;
if (a <= -4.1e+39) {
tmp = pow(a, 4.0);
} else if (a <= 7.6e+30) {
tmp = ((b * b) * fma(b, b, 4.0)) + -1.0;
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (a <= -4.1e+39) tmp = a ^ 4.0; elseif (a <= 7.6e+30) tmp = Float64(Float64(Float64(b * b) * fma(b, b, 4.0)) + -1.0); else tmp = a ^ 4.0; end return tmp end
code[a_, b_] := If[LessEqual[a, -4.1e+39], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 7.6e+30], N[(N[(N[(b * b), $MachinePrecision] * N[(b * b + 4.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.1 \cdot 10^{+39}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 7.6 \cdot 10^{+30}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \mathsf{fma}\left(b, b, 4\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -4.10000000000000004e39 or 7.6000000000000003e30 < a Initial program 46.9%
associate--l+46.9%
fma-def46.9%
Simplified50.3%
Taylor expanded in a around inf 94.5%
if -4.10000000000000004e39 < a < 7.6000000000000003e30Initial program 97.7%
associate--l+97.7%
fma-def97.7%
Simplified97.7%
fma-def97.7%
add-cbrt-cube88.8%
pow388.8%
pow-pow88.8%
add-sqr-sqrt88.8%
hypot-udef88.8%
hypot-udef88.8%
pow288.8%
metadata-eval88.8%
Applied egg-rr88.8%
Taylor expanded in a around 0 89.6%
unpow289.6%
Simplified89.6%
Taylor expanded in a around 0 95.4%
associate-+r-95.4%
metadata-eval95.4%
pow-sqr95.3%
pow295.3%
pow295.3%
distribute-rgt-out95.3%
fma-def95.3%
Applied egg-rr95.3%
Final simplification94.9%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e-16) (+ (* (* a a) 4.0) -1.0) (if (<= (* b b) 5e+65) (pow a 4.0) (pow b 4.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e-16) {
tmp = ((a * a) * 4.0) + -1.0;
} else if ((b * b) <= 5e+65) {
tmp = pow(a, 4.0);
} else {
tmp = 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) <= 5d-16) then
tmp = ((a * a) * 4.0d0) + (-1.0d0)
else if ((b * b) <= 5d+65) then
tmp = a ** 4.0d0
else
tmp = b ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 5e-16) {
tmp = ((a * a) * 4.0) + -1.0;
} else if ((b * b) <= 5e+65) {
tmp = Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e-16: tmp = ((a * a) * 4.0) + -1.0 elif (b * b) <= 5e+65: tmp = math.pow(a, 4.0) else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e-16) tmp = Float64(Float64(Float64(a * a) * 4.0) + -1.0); elseif (Float64(b * b) <= 5e+65) tmp = a ^ 4.0; else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5e-16) tmp = ((a * a) * 4.0) + -1.0; elseif ((b * b) <= 5e+65) tmp = a ^ 4.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e-16], N[(N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[N[(b * b), $MachinePrecision], 5e+65], N[Power[a, 4.0], $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{-16}:\\
\;\;\;\;\left(a \cdot a\right) \cdot 4 + -1\\
\mathbf{elif}\;b \cdot b \leq 5 \cdot 10^{+65}:\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 5.0000000000000004e-16Initial program 82.4%
associate--l+82.4%
fma-def82.4%
Simplified82.4%
Taylor expanded in b around 0 82.5%
associate--l+82.5%
associate-*r*82.5%
unpow282.5%
Simplified82.5%
Taylor expanded in a around 0 64.4%
sub-neg64.4%
distribute-lft-out64.4%
unpow264.4%
metadata-eval64.4%
Simplified64.4%
Taylor expanded in a around 0 76.1%
unpow276.1%
Simplified76.1%
if 5.0000000000000004e-16 < (*.f64 b b) < 4.99999999999999973e65Initial program 79.4%
associate--l+79.4%
fma-def79.4%
Simplified79.4%
Taylor expanded in a around inf 66.8%
if 4.99999999999999973e65 < (*.f64 b b) Initial program 64.3%
associate--l+64.3%
fma-def64.3%
Simplified67.7%
Taylor expanded in b around inf 96.0%
Final simplification84.5%
(FPCore (a b) :precision binary64 (if (or (<= a -2.4) (not (<= a 3.6e-11))) (pow a 4.0) (+ (* 4.0 (* (* a a) (+ a 1.0))) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -2.4) || !(a <= 3.6e-11)) {
tmp = pow(a, 4.0);
} else {
tmp = (4.0 * ((a * a) * (a + 1.0))) + -1.0;
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a <= (-2.4d0)) .or. (.not. (a <= 3.6d-11))) then
tmp = a ** 4.0d0
else
tmp = (4.0d0 * ((a * a) * (a + 1.0d0))) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -2.4) || !(a <= 3.6e-11)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = (4.0 * ((a * a) * (a + 1.0))) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -2.4) or not (a <= 3.6e-11): tmp = math.pow(a, 4.0) else: tmp = (4.0 * ((a * a) * (a + 1.0))) + -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -2.4) || !(a <= 3.6e-11)) tmp = a ^ 4.0; else tmp = Float64(Float64(4.0 * Float64(Float64(a * a) * Float64(a + 1.0))) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -2.4) || ~((a <= 3.6e-11))) tmp = a ^ 4.0; else tmp = (4.0 * ((a * a) * (a + 1.0))) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -2.4], N[Not[LessEqual[a, 3.6e-11]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[(N[(4.0 * N[(N[(a * a), $MachinePrecision] * N[(a + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.4 \lor \neg \left(a \leq 3.6 \cdot 10^{-11}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right)\right) + -1\\
\end{array}
\end{array}
if a < -2.39999999999999991 or 3.59999999999999985e-11 < a Initial program 53.4%
associate--l+53.4%
fma-def53.4%
Simplified56.2%
Taylor expanded in a around inf 82.7%
if -2.39999999999999991 < a < 3.59999999999999985e-11Initial program 99.9%
associate--l+99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in b around 0 51.2%
associate--l+51.2%
associate-*r*51.2%
unpow251.2%
Simplified51.2%
Taylor expanded in a around 0 51.2%
sub-neg51.2%
distribute-lft-out51.2%
unpow251.2%
metadata-eval51.2%
Simplified51.2%
cube-mult51.2%
distribute-rgt1-in51.2%
Applied egg-rr51.2%
Final simplification68.7%
(FPCore (a b) :precision binary64 (if (<= a -2.4) (+ (* (* a a) 4.0) -1.0) (+ (* 4.0 (* (* a a) (+ a 1.0))) -1.0)))
double code(double a, double b) {
double tmp;
if (a <= -2.4) {
tmp = ((a * a) * 4.0) + -1.0;
} else {
tmp = (4.0 * ((a * a) * (a + 1.0))) + -1.0;
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-2.4d0)) then
tmp = ((a * a) * 4.0d0) + (-1.0d0)
else
tmp = (4.0d0 * ((a * a) * (a + 1.0d0))) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -2.4) {
tmp = ((a * a) * 4.0) + -1.0;
} else {
tmp = (4.0 * ((a * a) * (a + 1.0))) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -2.4: tmp = ((a * a) * 4.0) + -1.0 else: tmp = (4.0 * ((a * a) * (a + 1.0))) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (a <= -2.4) tmp = Float64(Float64(Float64(a * a) * 4.0) + -1.0); else tmp = Float64(Float64(4.0 * Float64(Float64(a * a) * Float64(a + 1.0))) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -2.4) tmp = ((a * a) * 4.0) + -1.0; else tmp = (4.0 * ((a * a) * (a + 1.0))) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -2.4], N[(N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(4.0 * N[(N[(a * a), $MachinePrecision] * N[(a + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.4:\\
\;\;\;\;\left(a \cdot a\right) \cdot 4 + -1\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right)\right) + -1\\
\end{array}
\end{array}
if a < -2.39999999999999991Initial program 43.4%
associate--l+43.4%
fma-def43.4%
Simplified49.9%
Taylor expanded in b around 0 23.6%
associate--l+23.6%
associate-*r*23.6%
unpow223.6%
Simplified23.6%
Taylor expanded in a around 0 0.2%
sub-neg0.2%
distribute-lft-out0.2%
unpow20.2%
metadata-eval0.2%
Simplified0.2%
Taylor expanded in a around 0 45.4%
unpow245.4%
Simplified45.4%
if -2.39999999999999991 < a Initial program 83.9%
associate--l+83.9%
fma-def83.9%
Simplified83.9%
Taylor expanded in b around 0 65.8%
associate--l+65.8%
associate-*r*65.8%
unpow265.8%
Simplified65.8%
Taylor expanded in a around 0 54.9%
sub-neg54.9%
distribute-lft-out54.9%
unpow254.9%
metadata-eval54.9%
Simplified54.9%
cube-mult54.9%
distribute-rgt1-in54.9%
Applied egg-rr54.9%
Final simplification52.6%
(FPCore (a b) :precision binary64 (+ (* (* a a) 4.0) -1.0))
double code(double a, double b) {
return ((a * a) * 4.0) + -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((a * a) * 4.0d0) + (-1.0d0)
end function
public static double code(double a, double b) {
return ((a * a) * 4.0) + -1.0;
}
def code(a, b): return ((a * a) * 4.0) + -1.0
function code(a, b) return Float64(Float64(Float64(a * a) * 4.0) + -1.0) end
function tmp = code(a, b) tmp = ((a * a) * 4.0) + -1.0; end
code[a_, b_] := N[(N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\left(a \cdot a\right) \cdot 4 + -1
\end{array}
Initial program 74.1%
associate--l+74.1%
fma-def74.1%
Simplified75.6%
Taylor expanded in b around 0 55.6%
associate--l+55.6%
associate-*r*55.6%
unpow255.6%
Simplified55.6%
Taylor expanded in a around 0 41.7%
sub-neg41.7%
distribute-lft-out41.7%
unpow241.7%
metadata-eval41.7%
Simplified41.7%
Taylor expanded in a around 0 49.8%
unpow249.8%
Simplified49.8%
Final simplification49.8%
(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 74.1%
associate--l+74.1%
fma-def74.1%
Simplified75.6%
Taylor expanded in b around 0 55.6%
associate--l+55.6%
associate-*r*55.6%
unpow255.6%
Simplified55.6%
Taylor expanded in a around 0 23.0%
Final simplification23.0%
herbie shell --seed 2023178
(FPCore (a b)
:name "Bouland and Aaronson, Equation (25)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 3.0 a)))))) 1.0))