
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 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 * (b * b))) - 1.0d0
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(b * b))) - 1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (b * b))) - 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[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 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 * (b * b))) - 1.0d0
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(b * b))) - 1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (b * b))) - 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[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1
\end{array}
(FPCore (a b) :precision binary64 (+ (pow (hypot a b) 4.0) (fma b (* b 4.0) -1.0)))
double code(double a, double b) {
return pow(hypot(a, b), 4.0) + fma(b, (b * 4.0), -1.0);
}
function code(a, b) return Float64((hypot(a, b) ^ 4.0) + fma(b, Float64(b * 4.0), -1.0)) end
code[a_, b_] := N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + N[(b * N[(b * 4.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(b, b \cdot 4, -1\right)
\end{array}
Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*99.9%
unpow199.9%
sqr-pow99.9%
unpow399.9%
pow-plus100.0%
metadata-eval100.0%
unpow1/2100.0%
hypot-def100.0%
metadata-eval100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (a b) :precision binary64 (+ (pow (fma a a (* b b)) 2.0) (+ -1.0 (* 4.0 (* b b)))))
double code(double a, double b) {
return pow(fma(a, a, (b * b)), 2.0) + (-1.0 + (4.0 * (b * b)));
}
function code(a, b) return Float64((fma(a, a, Float64(b * b)) ^ 2.0) + Float64(-1.0 + Float64(4.0 * Float64(b * b)))) end
code[a_, b_] := N[(N[Power[N[(a * a + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(-1.0 + N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + \left(-1 + 4 \cdot \left(b \cdot b\right)\right)
\end{array}
Initial program 99.9%
associate--l+99.9%
sqr-pow99.9%
sqr-pow99.9%
fma-def99.9%
*-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (a b)
:precision binary64
(if (<= (* b b) 0.0)
-1.0
(if (<= (* b b) 4.9e-174)
(pow a 4.0)
(if (<= (* b b) 7e-11)
-1.0
(if (<= (* b b) 4.7e+61) (pow a 4.0) (* (* b b) (+ 4.0 (* b b))))))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 0.0) {
tmp = -1.0;
} else if ((b * b) <= 4.9e-174) {
tmp = pow(a, 4.0);
} else if ((b * b) <= 7e-11) {
tmp = -1.0;
} else if ((b * b) <= 4.7e+61) {
tmp = pow(a, 4.0);
} else {
tmp = (b * b) * (4.0 + (b * b));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 0.0d0) then
tmp = -1.0d0
else if ((b * b) <= 4.9d-174) then
tmp = a ** 4.0d0
else if ((b * b) <= 7d-11) then
tmp = -1.0d0
else if ((b * b) <= 4.7d+61) then
tmp = a ** 4.0d0
else
tmp = (b * b) * (4.0d0 + (b * b))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 0.0) {
tmp = -1.0;
} else if ((b * b) <= 4.9e-174) {
tmp = Math.pow(a, 4.0);
} else if ((b * b) <= 7e-11) {
tmp = -1.0;
} else if ((b * b) <= 4.7e+61) {
tmp = Math.pow(a, 4.0);
} else {
tmp = (b * b) * (4.0 + (b * b));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 0.0: tmp = -1.0 elif (b * b) <= 4.9e-174: tmp = math.pow(a, 4.0) elif (b * b) <= 7e-11: tmp = -1.0 elif (b * b) <= 4.7e+61: tmp = math.pow(a, 4.0) else: tmp = (b * b) * (4.0 + (b * b)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 0.0) tmp = -1.0; elseif (Float64(b * b) <= 4.9e-174) tmp = a ^ 4.0; elseif (Float64(b * b) <= 7e-11) tmp = -1.0; elseif (Float64(b * b) <= 4.7e+61) tmp = a ^ 4.0; else tmp = Float64(Float64(b * b) * Float64(4.0 + Float64(b * b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 0.0) tmp = -1.0; elseif ((b * b) <= 4.9e-174) tmp = a ^ 4.0; elseif ((b * b) <= 7e-11) tmp = -1.0; elseif ((b * b) <= 4.7e+61) tmp = a ^ 4.0; else tmp = (b * b) * (4.0 + (b * b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 0.0], -1.0, If[LessEqual[N[(b * b), $MachinePrecision], 4.9e-174], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[N[(b * b), $MachinePrecision], 7e-11], -1.0, If[LessEqual[N[(b * b), $MachinePrecision], 4.7e+61], N[Power[a, 4.0], $MachinePrecision], N[(N[(b * b), $MachinePrecision] * N[(4.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 0:\\
\;\;\;\;-1\\
\mathbf{elif}\;b \cdot b \leq 4.9 \cdot 10^{-174}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;b \cdot b \leq 7 \cdot 10^{-11}:\\
\;\;\;\;-1\\
\mathbf{elif}\;b \cdot b \leq 4.7 \cdot 10^{+61}:\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(4 + b \cdot b\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 0.0 or 4.90000000000000009e-174 < (*.f64 b b) < 7.00000000000000038e-11Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*100.0%
unpow1100.0%
sqr-pow100.0%
unpow399.9%
pow-plus100.0%
metadata-eval100.0%
unpow1/2100.0%
hypot-def100.0%
metadata-eval100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in a around 0 59.9%
sub-neg59.9%
+-commutative59.9%
unpow259.9%
*-commutative59.9%
associate-*r*59.9%
metadata-eval59.9%
associate-+l+59.9%
associate-*r*59.9%
*-commutative59.9%
fma-udef59.9%
Simplified59.9%
+-commutative59.9%
metadata-eval59.9%
fma-neg59.9%
*-commutative59.9%
associate-+l-59.9%
associate-*l*59.9%
Applied egg-rr59.9%
Taylor expanded in b around 0 59.3%
if 0.0 < (*.f64 b b) < 4.90000000000000009e-174 or 7.00000000000000038e-11 < (*.f64 b b) < 4.6999999999999998e61Initial program 99.7%
associate--l+99.7%
unpow299.7%
unpow199.7%
sqr-pow99.7%
associate-*r*99.7%
unpow199.7%
sqr-pow99.7%
unpow399.8%
pow-plus99.9%
metadata-eval99.9%
unpow1/299.9%
hypot-def99.9%
metadata-eval99.9%
associate-*r*99.9%
*-commutative99.9%
Simplified100.0%
Taylor expanded in a around inf 68.4%
if 4.6999999999999998e61 < (*.f64 b b) Initial program 100.0%
associate--l+100.0%
unpow2100.0%
unpow1100.0%
sqr-pow100.0%
associate-*r*100.0%
unpow1100.0%
sqr-pow100.0%
unpow3100.0%
pow-plus100.0%
metadata-eval100.0%
unpow1/2100.0%
hypot-def100.0%
metadata-eval100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in a around 0 92.7%
sub-neg92.7%
+-commutative92.7%
unpow292.7%
*-commutative92.7%
associate-*r*92.7%
metadata-eval92.7%
associate-+l+92.7%
associate-*r*92.7%
*-commutative92.7%
fma-udef92.7%
Simplified92.7%
Taylor expanded in b around inf 92.7%
unpow292.7%
Simplified92.7%
sqr-pow92.7%
metadata-eval92.7%
pow292.7%
metadata-eval92.7%
pow292.7%
distribute-rgt-out92.7%
Applied egg-rr92.7%
Final simplification75.9%
(FPCore (a b)
:precision binary64
(if (<= (* b b) 0.0)
-1.0
(if (<= (* b b) 4e-175)
(pow a 4.0)
(if (<= (* b b) 2e-11)
-1.0
(if (<= (* b b) 2e+61) (pow a 4.0) (pow b 4.0))))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 0.0) {
tmp = -1.0;
} else if ((b * b) <= 4e-175) {
tmp = pow(a, 4.0);
} else if ((b * b) <= 2e-11) {
tmp = -1.0;
} else if ((b * b) <= 2e+61) {
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) <= 0.0d0) then
tmp = -1.0d0
else if ((b * b) <= 4d-175) then
tmp = a ** 4.0d0
else if ((b * b) <= 2d-11) then
tmp = -1.0d0
else if ((b * b) <= 2d+61) 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) <= 0.0) {
tmp = -1.0;
} else if ((b * b) <= 4e-175) {
tmp = Math.pow(a, 4.0);
} else if ((b * b) <= 2e-11) {
tmp = -1.0;
} else if ((b * b) <= 2e+61) {
tmp = Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 0.0: tmp = -1.0 elif (b * b) <= 4e-175: tmp = math.pow(a, 4.0) elif (b * b) <= 2e-11: tmp = -1.0 elif (b * b) <= 2e+61: 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) <= 0.0) tmp = -1.0; elseif (Float64(b * b) <= 4e-175) tmp = a ^ 4.0; elseif (Float64(b * b) <= 2e-11) tmp = -1.0; elseif (Float64(b * b) <= 2e+61) 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) <= 0.0) tmp = -1.0; elseif ((b * b) <= 4e-175) tmp = a ^ 4.0; elseif ((b * b) <= 2e-11) tmp = -1.0; elseif ((b * b) <= 2e+61) tmp = a ^ 4.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 0.0], -1.0, If[LessEqual[N[(b * b), $MachinePrecision], 4e-175], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[N[(b * b), $MachinePrecision], 2e-11], -1.0, If[LessEqual[N[(b * b), $MachinePrecision], 2e+61], N[Power[a, 4.0], $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 0:\\
\;\;\;\;-1\\
\mathbf{elif}\;b \cdot b \leq 4 \cdot 10^{-175}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;b \cdot b \leq 2 \cdot 10^{-11}:\\
\;\;\;\;-1\\
\mathbf{elif}\;b \cdot b \leq 2 \cdot 10^{+61}:\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 0.0 or 4e-175 < (*.f64 b b) < 1.99999999999999988e-11Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*100.0%
unpow1100.0%
sqr-pow100.0%
unpow399.9%
pow-plus100.0%
metadata-eval100.0%
unpow1/2100.0%
hypot-def100.0%
metadata-eval100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in a around 0 59.9%
sub-neg59.9%
+-commutative59.9%
unpow259.9%
*-commutative59.9%
associate-*r*59.9%
metadata-eval59.9%
associate-+l+59.9%
associate-*r*59.9%
*-commutative59.9%
fma-udef59.9%
Simplified59.9%
+-commutative59.9%
metadata-eval59.9%
fma-neg59.9%
*-commutative59.9%
associate-+l-59.9%
associate-*l*59.9%
Applied egg-rr59.9%
Taylor expanded in b around 0 59.3%
if 0.0 < (*.f64 b b) < 4e-175 or 1.99999999999999988e-11 < (*.f64 b b) < 1.9999999999999999e61Initial program 99.7%
associate--l+99.7%
unpow299.7%
unpow199.7%
sqr-pow99.7%
associate-*r*99.7%
unpow199.7%
sqr-pow99.7%
unpow399.8%
pow-plus99.9%
metadata-eval99.9%
unpow1/299.9%
hypot-def99.9%
metadata-eval99.9%
associate-*r*99.9%
*-commutative99.9%
Simplified100.0%
Taylor expanded in a around inf 68.4%
if 1.9999999999999999e61 < (*.f64 b b) Initial program 100.0%
associate--l+100.0%
unpow2100.0%
unpow1100.0%
sqr-pow100.0%
associate-*r*100.0%
unpow1100.0%
sqr-pow100.0%
unpow3100.0%
pow-plus100.0%
metadata-eval100.0%
unpow1/2100.0%
hypot-def100.0%
metadata-eval100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in b around inf 92.7%
Final simplification75.9%
(FPCore (a b) :precision binary64 (+ -1.0 (+ (pow (+ (* b b) (* a a)) 2.0) (* 4.0 (* b b)))))
double code(double a, double b) {
return -1.0 + (pow(((b * b) + (a * a)), 2.0) + (4.0 * (b * b)));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (-1.0d0) + ((((b * b) + (a * a)) ** 2.0d0) + (4.0d0 * (b * b)))
end function
public static double code(double a, double b) {
return -1.0 + (Math.pow(((b * b) + (a * a)), 2.0) + (4.0 * (b * b)));
}
def code(a, b): return -1.0 + (math.pow(((b * b) + (a * a)), 2.0) + (4.0 * (b * b)))
function code(a, b) return Float64(-1.0 + Float64((Float64(Float64(b * b) + Float64(a * a)) ^ 2.0) + Float64(4.0 * Float64(b * b)))) end
function tmp = code(a, b) tmp = -1.0 + ((((b * b) + (a * a)) ^ 2.0) + (4.0 * (b * b))); end
code[a_, b_] := N[(-1.0 + N[(N[Power[N[(N[(b * b), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 + \left({\left(b \cdot b + a \cdot a\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right)
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (a b) :precision binary64 (if (<= a 480000000.0) (+ (* b (* b 4.0)) (+ -1.0 (pow b 4.0))) (pow a 4.0)))
double code(double a, double b) {
double tmp;
if (a <= 480000000.0) {
tmp = (b * (b * 4.0)) + (-1.0 + pow(b, 4.0));
} else {
tmp = pow(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 <= 480000000.0d0) then
tmp = (b * (b * 4.0d0)) + ((-1.0d0) + (b ** 4.0d0))
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= 480000000.0) {
tmp = (b * (b * 4.0)) + (-1.0 + Math.pow(b, 4.0));
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= 480000000.0: tmp = (b * (b * 4.0)) + (-1.0 + math.pow(b, 4.0)) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= 480000000.0) tmp = Float64(Float64(b * Float64(b * 4.0)) + Float64(-1.0 + (b ^ 4.0))); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= 480000000.0) tmp = (b * (b * 4.0)) + (-1.0 + (b ^ 4.0)); else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, 480000000.0], N[(N[(b * N[(b * 4.0), $MachinePrecision]), $MachinePrecision] + N[(-1.0 + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 480000000:\\
\;\;\;\;b \cdot \left(b \cdot 4\right) + \left(-1 + {b}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < 4.8e8Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*99.9%
unpow199.9%
sqr-pow99.9%
unpow399.9%
pow-plus100.0%
metadata-eval100.0%
unpow1/2100.0%
hypot-def100.0%
metadata-eval100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in a around 0 79.4%
sub-neg79.4%
+-commutative79.4%
unpow279.4%
*-commutative79.4%
associate-*r*79.4%
metadata-eval79.4%
associate-+l+79.4%
associate-*r*79.4%
*-commutative79.4%
fma-udef79.4%
Simplified79.4%
+-commutative79.4%
metadata-eval79.4%
fma-neg79.4%
*-commutative79.4%
associate-+l-79.4%
associate-*l*79.4%
Applied egg-rr79.4%
if 4.8e8 < a Initial program 99.8%
associate--l+99.8%
unpow299.8%
unpow199.8%
sqr-pow99.8%
associate-*r*99.9%
unpow199.9%
sqr-pow99.9%
unpow399.9%
pow-plus100.0%
metadata-eval100.0%
unpow1/2100.0%
hypot-def100.0%
metadata-eval100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in a around inf 91.5%
Final simplification82.0%
(FPCore (a b) :precision binary64 (if (<= a 550000000.0) (+ -1.0 (* (* b b) (fma b b 4.0))) (pow a 4.0)))
double code(double a, double b) {
double tmp;
if (a <= 550000000.0) {
tmp = -1.0 + ((b * b) * fma(b, b, 4.0));
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (a <= 550000000.0) tmp = Float64(-1.0 + Float64(Float64(b * b) * fma(b, b, 4.0))); else tmp = a ^ 4.0; end return tmp end
code[a_, b_] := If[LessEqual[a, 550000000.0], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(b * b + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 550000000:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \mathsf{fma}\left(b, b, 4\right)\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < 5.5e8Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*99.9%
unpow199.9%
sqr-pow99.9%
unpow399.9%
pow-plus100.0%
metadata-eval100.0%
unpow1/2100.0%
hypot-def100.0%
metadata-eval100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in a around 0 79.4%
sub-neg79.4%
+-commutative79.4%
unpow279.4%
*-commutative79.4%
associate-*r*79.4%
metadata-eval79.4%
associate-+l+79.4%
associate-*r*79.4%
*-commutative79.4%
fma-udef79.4%
Simplified79.4%
+-commutative79.4%
metadata-eval79.4%
fma-neg79.4%
*-commutative79.4%
associate-+l-79.4%
associate-*l*79.4%
Applied egg-rr79.4%
Taylor expanded in b around 0 79.4%
sub-neg79.4%
fma-def79.4%
unpow279.4%
metadata-eval79.4%
+-commutative79.4%
fma-udef79.4%
metadata-eval79.4%
pow-plus79.4%
unpow379.4%
associate-*r*79.4%
distribute-rgt-in79.4%
+-commutative79.4%
fma-def79.4%
Simplified79.4%
if 5.5e8 < a Initial program 99.8%
associate--l+99.8%
unpow299.8%
unpow199.8%
sqr-pow99.8%
associate-*r*99.9%
unpow199.9%
sqr-pow99.9%
unpow399.9%
pow-plus100.0%
metadata-eval100.0%
unpow1/2100.0%
hypot-def100.0%
metadata-eval100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in a around inf 91.5%
Final simplification82.0%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e+61) (+ -1.0 (pow a 4.0)) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+61) {
tmp = -1.0 + 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) <= 2d+61) then
tmp = (-1.0d0) + (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) <= 2e+61) {
tmp = -1.0 + Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2e+61: tmp = -1.0 + 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) <= 2e+61) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2e+61) tmp = -1.0 + (a ^ 4.0); else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e+61], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+61}:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 1.9999999999999999e61Initial program 99.8%
associate--l+99.8%
unpow299.8%
unpow199.8%
sqr-pow99.8%
associate-*r*99.9%
unpow199.9%
sqr-pow99.9%
unpow399.9%
pow-plus100.0%
metadata-eval100.0%
unpow1/2100.0%
hypot-def100.0%
metadata-eval100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in b around 0 96.1%
if 1.9999999999999999e61 < (*.f64 b b) Initial program 100.0%
associate--l+100.0%
unpow2100.0%
unpow1100.0%
sqr-pow100.0%
associate-*r*100.0%
unpow1100.0%
sqr-pow100.0%
unpow3100.0%
pow-plus100.0%
metadata-eval100.0%
unpow1/2100.0%
hypot-def100.0%
metadata-eval100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in b around inf 92.7%
Final simplification94.6%
(FPCore (a b) :precision binary64 (if (<= b 0.00155) -1.0 (* (* b b) (+ 4.0 (* b b)))))
double code(double a, double b) {
double tmp;
if (b <= 0.00155) {
tmp = -1.0;
} else {
tmp = (b * b) * (4.0 + (b * b));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 0.00155d0) then
tmp = -1.0d0
else
tmp = (b * b) * (4.0d0 + (b * b))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 0.00155) {
tmp = -1.0;
} else {
tmp = (b * b) * (4.0 + (b * b));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 0.00155: tmp = -1.0 else: tmp = (b * b) * (4.0 + (b * b)) return tmp
function code(a, b) tmp = 0.0 if (b <= 0.00155) tmp = -1.0; else tmp = Float64(Float64(b * b) * Float64(4.0 + Float64(b * b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 0.00155) tmp = -1.0; else tmp = (b * b) * (4.0 + (b * b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 0.00155], -1.0, N[(N[(b * b), $MachinePrecision] * N[(4.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.00155:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(4 + b \cdot b\right)\\
\end{array}
\end{array}
if b < 0.00154999999999999995Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*99.9%
unpow199.9%
sqr-pow99.9%
unpow399.9%
pow-plus100.0%
metadata-eval100.0%
unpow1/2100.0%
hypot-def100.0%
metadata-eval100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in a around 0 66.8%
sub-neg66.8%
+-commutative66.8%
unpow266.8%
*-commutative66.8%
associate-*r*66.8%
metadata-eval66.8%
associate-+l+66.8%
associate-*r*66.8%
*-commutative66.8%
fma-udef66.8%
Simplified66.8%
+-commutative66.8%
metadata-eval66.8%
fma-neg66.8%
*-commutative66.8%
associate-+l-66.8%
associate-*l*66.8%
Applied egg-rr66.8%
Taylor expanded in b around 0 35.4%
if 0.00154999999999999995 < b Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*99.9%
unpow199.9%
sqr-pow99.9%
unpow399.9%
pow-plus100.0%
metadata-eval100.0%
unpow1/2100.0%
hypot-def100.0%
metadata-eval100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in a around 0 81.3%
sub-neg81.3%
+-commutative81.3%
unpow281.3%
*-commutative81.3%
associate-*r*81.3%
metadata-eval81.3%
associate-+l+81.3%
associate-*r*81.3%
*-commutative81.3%
fma-udef81.3%
Simplified81.3%
Taylor expanded in b around inf 78.1%
unpow278.1%
Simplified78.1%
sqr-pow78.0%
metadata-eval78.0%
pow278.0%
metadata-eval78.0%
pow278.0%
distribute-rgt-out78.0%
Applied egg-rr78.0%
Final simplification46.4%
(FPCore (a b) :precision binary64 (if (<= b 0.00155) -1.0 (* 4.0 (* b b))))
double code(double a, double b) {
double tmp;
if (b <= 0.00155) {
tmp = -1.0;
} else {
tmp = 4.0 * (b * b);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 0.00155d0) then
tmp = -1.0d0
else
tmp = 4.0d0 * (b * b)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 0.00155) {
tmp = -1.0;
} else {
tmp = 4.0 * (b * b);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 0.00155: tmp = -1.0 else: tmp = 4.0 * (b * b) return tmp
function code(a, b) tmp = 0.0 if (b <= 0.00155) tmp = -1.0; else tmp = Float64(4.0 * Float64(b * b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 0.00155) tmp = -1.0; else tmp = 4.0 * (b * b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 0.00155], -1.0, N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.00155:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(b \cdot b\right)\\
\end{array}
\end{array}
if b < 0.00154999999999999995Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*99.9%
unpow199.9%
sqr-pow99.9%
unpow399.9%
pow-plus100.0%
metadata-eval100.0%
unpow1/2100.0%
hypot-def100.0%
metadata-eval100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in a around 0 66.8%
sub-neg66.8%
+-commutative66.8%
unpow266.8%
*-commutative66.8%
associate-*r*66.8%
metadata-eval66.8%
associate-+l+66.8%
associate-*r*66.8%
*-commutative66.8%
fma-udef66.8%
Simplified66.8%
+-commutative66.8%
metadata-eval66.8%
fma-neg66.8%
*-commutative66.8%
associate-+l-66.8%
associate-*l*66.8%
Applied egg-rr66.8%
Taylor expanded in b around 0 35.4%
if 0.00154999999999999995 < b Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*99.9%
unpow199.9%
sqr-pow99.9%
unpow399.9%
pow-plus100.0%
metadata-eval100.0%
unpow1/2100.0%
hypot-def100.0%
metadata-eval100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in a around 0 81.3%
sub-neg81.3%
+-commutative81.3%
unpow281.3%
*-commutative81.3%
associate-*r*81.3%
metadata-eval81.3%
associate-+l+81.3%
associate-*r*81.3%
*-commutative81.3%
fma-udef81.3%
Simplified81.3%
Taylor expanded in b around inf 78.1%
unpow278.1%
Simplified78.1%
sqr-pow78.0%
metadata-eval78.0%
pow278.0%
metadata-eval78.0%
pow278.0%
distribute-rgt-out78.0%
Applied egg-rr78.0%
Taylor expanded in b around 0 49.2%
unpow249.2%
Simplified49.2%
Final simplification39.0%
(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 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*99.9%
unpow199.9%
sqr-pow99.9%
unpow399.9%
pow-plus100.0%
metadata-eval100.0%
unpow1/2100.0%
hypot-def100.0%
metadata-eval100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in a around 0 70.5%
sub-neg70.5%
+-commutative70.5%
unpow270.5%
*-commutative70.5%
associate-*r*70.5%
metadata-eval70.5%
associate-+l+70.5%
associate-*r*70.5%
*-commutative70.5%
fma-udef70.5%
Simplified70.5%
+-commutative70.5%
metadata-eval70.5%
fma-neg70.5%
*-commutative70.5%
associate-+l-70.5%
associate-*l*70.5%
Applied egg-rr70.5%
Taylor expanded in b around 0 26.5%
Final simplification26.5%
herbie shell --seed 2023293
(FPCore (a b)
:name "Bouland and Aaronson, Equation (26)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))