
(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 10 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 (+ (* (* a a) (+ a 1.0)) (* (* b b) (- 1.0 (* a 3.0))))))
5e+305)
(+
(+
(* -12.0 (* a (pow b 2.0)))
(+
(* 4.0 (+ (pow b 2.0) (pow a 3.0)))
(+
(* (pow a 2.0) (+ 4.0 (* 2.0 (pow b 2.0))))
(+ (pow a 4.0) (pow b 4.0)))))
-1.0)
(+ (pow (cbrt (pow (hypot a b) 4.0)) 3.0) (+ (* 4.0 (pow b 2.0)) -1.0))))
double code(double a, double b) {
double tmp;
if ((pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))))) <= 5e+305) {
tmp = ((-12.0 * (a * pow(b, 2.0))) + ((4.0 * (pow(b, 2.0) + pow(a, 3.0))) + ((pow(a, 2.0) * (4.0 + (2.0 * pow(b, 2.0)))) + (pow(a, 4.0) + pow(b, 4.0))))) + -1.0;
} else {
tmp = pow(cbrt(pow(hypot(a, b), 4.0)), 3.0) + ((4.0 * pow(b, 2.0)) + -1.0);
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if ((Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))))) <= 5e+305) {
tmp = ((-12.0 * (a * Math.pow(b, 2.0))) + ((4.0 * (Math.pow(b, 2.0) + Math.pow(a, 3.0))) + ((Math.pow(a, 2.0) * (4.0 + (2.0 * Math.pow(b, 2.0)))) + (Math.pow(a, 4.0) + Math.pow(b, 4.0))))) + -1.0;
} else {
tmp = Math.pow(Math.cbrt(Math.pow(Math.hypot(a, b), 4.0)), 3.0) + ((4.0 * Math.pow(b, 2.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(a * a) * Float64(a + 1.0)) + Float64(Float64(b * b) * Float64(1.0 - Float64(a * 3.0)))))) <= 5e+305) tmp = Float64(Float64(Float64(-12.0 * Float64(a * (b ^ 2.0))) + Float64(Float64(4.0 * Float64((b ^ 2.0) + (a ^ 3.0))) + Float64(Float64((a ^ 2.0) * Float64(4.0 + Float64(2.0 * (b ^ 2.0)))) + Float64((a ^ 4.0) + (b ^ 4.0))))) + -1.0); else tmp = Float64((cbrt((hypot(a, b) ^ 4.0)) ^ 3.0) + Float64(Float64(4.0 * (b ^ 2.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[(a * a), $MachinePrecision] * N[(a + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+305], N[(N[(N[(-12.0 * N[(a * N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(4.0 * N[(N[Power[b, 2.0], $MachinePrecision] + N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[a, 2.0], $MachinePrecision] * N[(4.0 + N[(2.0 * N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[a, 4.0], $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[N[Power[N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision] + N[(N[(4.0 * N[Power[b, 2.0], $MachinePrecision]), $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(a \cdot a\right) \cdot \left(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right) \leq 5 \cdot 10^{+305}:\\
\;\;\;\;\left(-12 \cdot \left(a \cdot {b}^{2}\right) + \left(4 \cdot \left({b}^{2} + {a}^{3}\right) + \left({a}^{2} \cdot \left(4 + 2 \cdot {b}^{2}\right) + \left({a}^{4} + {b}^{4}\right)\right)\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt[3]{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}}\right)}^{3} + \left(4 \cdot {b}^{2} + -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)))))) < 5.00000000000000009e305Initial program 99.6%
associate--l+99.6%
+-commutative99.6%
+-commutative99.6%
sub-neg99.6%
associate-+l+99.6%
+-commutative99.6%
fma-def99.6%
Simplified99.6%
fma-udef99.6%
*-un-lft-identity99.6%
cube-mult99.6%
distribute-rgt-in99.6%
add-sqr-sqrt86.7%
pow286.7%
distribute-rgt-in86.7%
*-un-lft-identity86.7%
cube-mult86.7%
sqr-pow51.6%
hypot-def51.6%
metadata-eval51.6%
Applied egg-rr51.6%
Taylor expanded in a around 0 99.9%
if 5.00000000000000009e305 < (+.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 59.5%
associate--l+59.5%
fma-def59.5%
distribute-rgt-in59.5%
sqr-neg59.5%
distribute-rgt-in59.5%
Simplified61.5%
fma-def61.5%
unpow261.5%
add-sqr-sqrt61.5%
associate-*l*61.5%
hypot-def61.5%
hypot-def61.5%
add-sqr-sqrt61.5%
pow261.5%
hypot-def61.5%
Applied egg-rr61.5%
add-cube-cbrt61.5%
pow361.5%
associate-*r*61.5%
unpow261.5%
pow-prod-up61.5%
metadata-eval61.5%
Applied egg-rr61.5%
Taylor expanded in a around 0 100.0%
Final simplification100.0%
(FPCore (a b)
:precision binary64
(if (<=
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (+ a 1.0)) (* (* b b) (- 1.0 (* a 3.0))))))
5e+305)
(+
(+ (pow b 4.0) (fma 2.0 (pow (* a b) 2.0) (pow a 4.0)))
(+ (* 4.0 (fma (* a a) (+ a 1.0) (* (* b b) (+ 1.0 (* a -3.0))))) -1.0))
(+ (pow (cbrt (pow (hypot a b) 4.0)) 3.0) (+ (* 4.0 (pow b 2.0)) -1.0))))
double code(double a, double b) {
double tmp;
if ((pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))))) <= 5e+305) {
tmp = (pow(b, 4.0) + fma(2.0, pow((a * b), 2.0), pow(a, 4.0))) + ((4.0 * fma((a * a), (a + 1.0), ((b * b) * (1.0 + (a * -3.0))))) + -1.0);
} else {
tmp = pow(cbrt(pow(hypot(a, b), 4.0)), 3.0) + ((4.0 * pow(b, 2.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(a * a) * Float64(a + 1.0)) + Float64(Float64(b * b) * Float64(1.0 - Float64(a * 3.0)))))) <= 5e+305) tmp = Float64(Float64((b ^ 4.0) + fma(2.0, (Float64(a * b) ^ 2.0), (a ^ 4.0))) + Float64(Float64(4.0 * fma(Float64(a * a), Float64(a + 1.0), Float64(Float64(b * b) * Float64(1.0 + Float64(a * -3.0))))) + -1.0)); else tmp = Float64((cbrt((hypot(a, b) ^ 4.0)) ^ 3.0) + Float64(Float64(4.0 * (b ^ 2.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[(a * a), $MachinePrecision] * N[(a + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+305], N[(N[(N[Power[b, 4.0], $MachinePrecision] + N[(2.0 * N[Power[N[(a * b), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(4.0 * N[(N[(a * a), $MachinePrecision] * N[(a + 1.0), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 + N[(a * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[Power[N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision] + N[(N[(4.0 * N[Power[b, 2.0], $MachinePrecision]), $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(a \cdot a\right) \cdot \left(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right) \leq 5 \cdot 10^{+305}:\\
\;\;\;\;\left({b}^{4} + \mathsf{fma}\left(2, {\left(a \cdot b\right)}^{2}, {a}^{4}\right)\right) + \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, \left(b \cdot b\right) \cdot \left(1 + a \cdot -3\right)\right) + -1\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt[3]{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}}\right)}^{3} + \left(4 \cdot {b}^{2} + -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)))))) < 5.00000000000000009e305Initial program 99.6%
associate--l+99.6%
fma-def99.6%
distribute-rgt-in99.6%
sqr-neg99.6%
distribute-rgt-in99.6%
Simplified99.6%
Taylor expanded in a around 0 99.9%
associate-+r+99.9%
+-commutative99.9%
fma-def99.9%
unpow299.9%
unpow299.9%
swap-sqr99.9%
unpow299.9%
*-commutative99.9%
Simplified99.9%
if 5.00000000000000009e305 < (+.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 59.5%
associate--l+59.5%
fma-def59.5%
distribute-rgt-in59.5%
sqr-neg59.5%
distribute-rgt-in59.5%
Simplified61.5%
fma-def61.5%
unpow261.5%
add-sqr-sqrt61.5%
associate-*l*61.5%
hypot-def61.5%
hypot-def61.5%
add-sqr-sqrt61.5%
pow261.5%
hypot-def61.5%
Applied egg-rr61.5%
add-cube-cbrt61.5%
pow361.5%
associate-*r*61.5%
unpow261.5%
pow-prod-up61.5%
metadata-eval61.5%
Applied egg-rr61.5%
Taylor expanded in a around 0 100.0%
Final simplification99.9%
(FPCore (a b)
:precision binary64
(if (<=
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (+ a 1.0)) (* (* b b) (- 1.0 (* a 3.0))))))
5e+305)
(+
(+ (* 4.0 (fma (* a a) (+ a 1.0) (* (* b b) (+ 1.0 (* a -3.0))))) -1.0)
(* (hypot a b) (* (hypot a b) (pow (hypot a b) 2.0))))
(+ (pow (cbrt (pow (hypot a b) 4.0)) 3.0) (+ (* 4.0 (pow b 2.0)) -1.0))))
double code(double a, double b) {
double tmp;
if ((pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))))) <= 5e+305) {
tmp = ((4.0 * fma((a * a), (a + 1.0), ((b * b) * (1.0 + (a * -3.0))))) + -1.0) + (hypot(a, b) * (hypot(a, b) * pow(hypot(a, b), 2.0)));
} else {
tmp = pow(cbrt(pow(hypot(a, b), 4.0)), 3.0) + ((4.0 * pow(b, 2.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(a * a) * Float64(a + 1.0)) + Float64(Float64(b * b) * Float64(1.0 - Float64(a * 3.0)))))) <= 5e+305) tmp = Float64(Float64(Float64(4.0 * fma(Float64(a * a), Float64(a + 1.0), Float64(Float64(b * b) * Float64(1.0 + Float64(a * -3.0))))) + -1.0) + Float64(hypot(a, b) * Float64(hypot(a, b) * (hypot(a, b) ^ 2.0)))); else tmp = Float64((cbrt((hypot(a, b) ^ 4.0)) ^ 3.0) + Float64(Float64(4.0 * (b ^ 2.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[(a * a), $MachinePrecision] * N[(a + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+305], N[(N[(N[(4.0 * N[(N[(a * a), $MachinePrecision] * N[(a + 1.0), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 + N[(a * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision] + N[(N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision] * N[(N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision] * N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[Power[N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision] + N[(N[(4.0 * N[Power[b, 2.0], $MachinePrecision]), $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(a \cdot a\right) \cdot \left(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right) \leq 5 \cdot 10^{+305}:\\
\;\;\;\;\left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, \left(b \cdot b\right) \cdot \left(1 + a \cdot -3\right)\right) + -1\right) + \mathsf{hypot}\left(a, b\right) \cdot \left(\mathsf{hypot}\left(a, b\right) \cdot {\left(\mathsf{hypot}\left(a, b\right)\right)}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt[3]{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}}\right)}^{3} + \left(4 \cdot {b}^{2} + -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)))))) < 5.00000000000000009e305Initial program 99.6%
associate--l+99.6%
fma-def99.6%
distribute-rgt-in99.6%
sqr-neg99.6%
distribute-rgt-in99.6%
Simplified99.6%
fma-def99.6%
unpow299.6%
add-sqr-sqrt99.6%
associate-*l*99.7%
hypot-def99.7%
hypot-def99.7%
add-sqr-sqrt99.7%
pow299.7%
hypot-def99.7%
Applied egg-rr99.7%
if 5.00000000000000009e305 < (+.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 59.5%
associate--l+59.5%
fma-def59.5%
distribute-rgt-in59.5%
sqr-neg59.5%
distribute-rgt-in59.5%
Simplified61.5%
fma-def61.5%
unpow261.5%
add-sqr-sqrt61.5%
associate-*l*61.5%
hypot-def61.5%
hypot-def61.5%
add-sqr-sqrt61.5%
pow261.5%
hypot-def61.5%
Applied egg-rr61.5%
add-cube-cbrt61.5%
pow361.5%
associate-*r*61.5%
unpow261.5%
pow-prod-up61.5%
metadata-eval61.5%
Applied egg-rr61.5%
Taylor expanded in a around 0 100.0%
Final simplification99.9%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (+ a 1.0)) (* (* b b) (- 1.0 (* a 3.0))))))))
(if (<= t_0 5e+305)
(+ t_0 -1.0)
(+ (pow (cbrt (pow (hypot a b) 4.0)) 3.0) (+ (* 4.0 (pow b 2.0)) -1.0)))))
double code(double a, double b) {
double t_0 = pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))));
double tmp;
if (t_0 <= 5e+305) {
tmp = t_0 + -1.0;
} else {
tmp = pow(cbrt(pow(hypot(a, b), 4.0)), 3.0) + ((4.0 * pow(b, 2.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 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))));
double tmp;
if (t_0 <= 5e+305) {
tmp = t_0 + -1.0;
} else {
tmp = Math.pow(Math.cbrt(Math.pow(Math.hypot(a, b), 4.0)), 3.0) + ((4.0 * Math.pow(b, 2.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(a * a) * Float64(a + 1.0)) + Float64(Float64(b * b) * Float64(1.0 - Float64(a * 3.0)))))) tmp = 0.0 if (t_0 <= 5e+305) tmp = Float64(t_0 + -1.0); else tmp = Float64((cbrt((hypot(a, b) ^ 4.0)) ^ 3.0) + Float64(Float64(4.0 * (b ^ 2.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[(a * a), $MachinePrecision] * N[(a + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e+305], N[(t$95$0 + -1.0), $MachinePrecision], N[(N[Power[N[Power[N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision] + N[(N[(4.0 * N[Power[b, 2.0], $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(a \cdot a\right) \cdot \left(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right)\\
\mathbf{if}\;t_0 \leq 5 \cdot 10^{+305}:\\
\;\;\;\;t_0 + -1\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt[3]{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}}\right)}^{3} + \left(4 \cdot {b}^{2} + -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)))))) < 5.00000000000000009e305Initial program 99.6%
if 5.00000000000000009e305 < (+.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 59.5%
associate--l+59.5%
fma-def59.5%
distribute-rgt-in59.5%
sqr-neg59.5%
distribute-rgt-in59.5%
Simplified61.5%
fma-def61.5%
unpow261.5%
add-sqr-sqrt61.5%
associate-*l*61.5%
hypot-def61.5%
hypot-def61.5%
add-sqr-sqrt61.5%
pow261.5%
hypot-def61.5%
Applied egg-rr61.5%
add-cube-cbrt61.5%
pow361.5%
associate-*r*61.5%
unpow261.5%
pow-prod-up61.5%
metadata-eval61.5%
Applied egg-rr61.5%
Taylor expanded in a around 0 100.0%
Final simplification99.8%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (+ a 1.0)) (* (* b b) (- 1.0 (* a 3.0))))))))
(if (<= t_0 INFINITY) (+ t_0 -1.0) (pow a 4.0))))
double code(double a, double b) {
double t_0 = pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0 + -1.0;
} else {
tmp = pow(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) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 + -1.0;
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): t_0 = math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0))))) tmp = 0 if t_0 <= math.inf: tmp = t_0 + -1.0 else: tmp = math.pow(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(a + 1.0)) + Float64(Float64(b * b) * Float64(1.0 - Float64(a * 3.0)))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(t_0 + -1.0); else tmp = 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) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0))))); tmp = 0.0; if (t_0 <= Inf) tmp = t_0 + -1.0; else tmp = 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[(a + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(t$95$0 + -1.0), $MachinePrecision], N[Power[a, 4.0], $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(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right)\\
\mathbf{if}\;t_0 \leq \infty:\\
\;\;\;\;t_0 + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\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%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
Simplified5.0%
Taylor expanded in a around inf 92.1%
Final simplification98.0%
(FPCore (a b) :precision binary64 (if (or (<= a -1.95) (not (<= a 1.95))) (pow a 4.0) (* (+ 1.0 (* a 2.0)) (+ (* a 2.0) -1.0))))
double code(double a, double b) {
double tmp;
if ((a <= -1.95) || !(a <= 1.95)) {
tmp = pow(a, 4.0);
} else {
tmp = (1.0 + (a * 2.0)) * ((a * 2.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 <= (-1.95d0)) .or. (.not. (a <= 1.95d0))) then
tmp = a ** 4.0d0
else
tmp = (1.0d0 + (a * 2.0d0)) * ((a * 2.0d0) + (-1.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -1.95) || !(a <= 1.95)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -1.95) or not (a <= 1.95): tmp = math.pow(a, 4.0) else: tmp = (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0) return tmp
function code(a, b) tmp = 0.0 if ((a <= -1.95) || !(a <= 1.95)) tmp = a ^ 4.0; else tmp = Float64(Float64(1.0 + Float64(a * 2.0)) * Float64(Float64(a * 2.0) + -1.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -1.95) || ~((a <= 1.95))) tmp = a ^ 4.0; else tmp = (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -1.95], N[Not[LessEqual[a, 1.95]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[(N[(1.0 + N[(a * 2.0), $MachinePrecision]), $MachinePrecision] * N[(N[(a * 2.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.95 \lor \neg \left(a \leq 1.95\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + a \cdot 2\right) \cdot \left(a \cdot 2 + -1\right)\\
\end{array}
\end{array}
if a < -1.94999999999999996 or 1.94999999999999996 < a Initial program 54.0%
associate--l+54.0%
fma-def54.0%
distribute-rgt-in54.0%
sqr-neg54.0%
distribute-rgt-in54.0%
Simplified56.3%
Taylor expanded in a around inf 78.2%
if -1.94999999999999996 < a < 1.94999999999999996Initial program 99.8%
associate--l+99.8%
fma-def99.8%
distribute-rgt-in99.8%
sqr-neg99.8%
distribute-rgt-in99.8%
Simplified99.8%
Taylor expanded in b around 0 51.0%
Taylor expanded in a around 0 49.4%
add-sqr-sqrt49.4%
difference-of-sqr-149.4%
*-commutative49.4%
sqrt-prod49.4%
unpow249.4%
sqrt-prod23.9%
add-sqr-sqrt49.1%
metadata-eval49.1%
*-commutative49.1%
sqrt-prod49.1%
unpow249.1%
sqrt-prod23.9%
add-sqr-sqrt49.4%
metadata-eval49.4%
Applied egg-rr49.4%
Final simplification64.1%
(FPCore (a b) :precision binary64 (if (<= b 6.5) (+ (pow a 4.0) -1.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if (b <= 6.5) {
tmp = pow(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 <= 6.5d0) then
tmp = (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 <= 6.5) {
tmp = Math.pow(a, 4.0) + -1.0;
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 6.5: tmp = math.pow(a, 4.0) + -1.0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 6.5) tmp = Float64((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 <= 6.5) tmp = (a ^ 4.0) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 6.5], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.5:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 6.5Initial program 77.8%
associate--l+77.8%
fma-def77.8%
distribute-rgt-in77.8%
sqr-neg77.8%
distribute-rgt-in77.8%
Simplified78.8%
fma-def78.8%
unpow278.8%
add-sqr-sqrt78.8%
associate-*l*78.9%
hypot-def78.9%
hypot-def78.9%
add-sqr-sqrt78.9%
pow278.9%
hypot-def78.9%
Applied egg-rr78.9%
add-cube-cbrt78.6%
pow378.6%
associate-*r*78.6%
unpow278.6%
pow-prod-up78.7%
metadata-eval78.7%
Applied egg-rr78.7%
Taylor expanded in a around 0 95.8%
Taylor expanded in b around 0 74.5%
sub-neg74.5%
pow-base-174.5%
*-lft-identity74.5%
metadata-eval74.5%
Simplified74.5%
if 6.5 < b Initial program 71.9%
associate--l+71.9%
fma-def71.9%
distribute-rgt-in71.9%
sqr-neg71.9%
distribute-rgt-in71.9%
Simplified73.6%
Taylor expanded in b around inf 88.1%
Final simplification77.7%
(FPCore (a b) :precision binary64 (if (<= b 4.8) (* (+ 1.0 (* a 2.0)) (+ (* a 2.0) -1.0)) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if (b <= 4.8) {
tmp = (1.0 + (a * 2.0)) * ((a * 2.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 <= 4.8d0) then
tmp = (1.0d0 + (a * 2.0d0)) * ((a * 2.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 <= 4.8) {
tmp = (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0);
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 4.8: tmp = (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0) else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 4.8) tmp = Float64(Float64(1.0 + Float64(a * 2.0)) * Float64(Float64(a * 2.0) + -1.0)); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 4.8) tmp = (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0); else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 4.8], N[(N[(1.0 + N[(a * 2.0), $MachinePrecision]), $MachinePrecision] * N[(N[(a * 2.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4.8:\\
\;\;\;\;\left(1 + a \cdot 2\right) \cdot \left(a \cdot 2 + -1\right)\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 4.79999999999999982Initial program 77.8%
associate--l+77.8%
fma-def77.8%
distribute-rgt-in77.8%
sqr-neg77.8%
distribute-rgt-in77.8%
Simplified78.8%
Taylor expanded in b around 0 63.6%
Taylor expanded in a around 0 56.1%
add-sqr-sqrt56.1%
difference-of-sqr-156.1%
*-commutative56.1%
sqrt-prod56.1%
unpow256.1%
sqrt-prod28.9%
add-sqr-sqrt45.1%
metadata-eval45.1%
*-commutative45.1%
sqrt-prod45.1%
unpow245.1%
sqrt-prod28.9%
add-sqr-sqrt56.1%
metadata-eval56.1%
Applied egg-rr56.1%
if 4.79999999999999982 < b Initial program 71.9%
associate--l+71.9%
fma-def71.9%
distribute-rgt-in71.9%
sqr-neg71.9%
distribute-rgt-in71.9%
Simplified73.6%
Taylor expanded in b around inf 88.1%
Final simplification63.7%
(FPCore (a b) :precision binary64 (* (+ 1.0 (* a 2.0)) (+ (* a 2.0) -1.0)))
double code(double a, double b) {
return (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (1.0d0 + (a * 2.0d0)) * ((a * 2.0d0) + (-1.0d0))
end function
public static double code(double a, double b) {
return (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0);
}
def code(a, b): return (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0)
function code(a, b) return Float64(Float64(1.0 + Float64(a * 2.0)) * Float64(Float64(a * 2.0) + -1.0)) end
function tmp = code(a, b) tmp = (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0); end
code[a_, b_] := N[(N[(1.0 + N[(a * 2.0), $MachinePrecision]), $MachinePrecision] * N[(N[(a * 2.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 + a \cdot 2\right) \cdot \left(a \cdot 2 + -1\right)
\end{array}
Initial program 76.4%
associate--l+76.4%
fma-def76.4%
distribute-rgt-in76.4%
sqr-neg76.4%
distribute-rgt-in76.4%
Simplified77.6%
Taylor expanded in b around 0 52.8%
Taylor expanded in a around 0 46.0%
add-sqr-sqrt46.0%
difference-of-sqr-146.0%
*-commutative46.0%
sqrt-prod46.0%
unpow246.0%
sqrt-prod23.5%
add-sqr-sqrt35.9%
metadata-eval35.9%
*-commutative35.9%
sqrt-prod35.9%
unpow235.9%
sqrt-prod23.5%
add-sqr-sqrt46.0%
metadata-eval46.0%
Applied egg-rr46.0%
Final simplification46.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 76.4%
associate--l+76.4%
fma-def76.4%
distribute-rgt-in76.4%
sqr-neg76.4%
distribute-rgt-in76.4%
Simplified77.6%
Taylor expanded in b around 0 52.8%
Taylor expanded in a around 0 24.1%
Final simplification24.1%
herbie shell --seed 2023337
(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))