
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ 3.0 a))))) 1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * (((a * a) * (1.0d0 - a)) + ((b * b) * (3.0d0 + a))))) - 1.0d0
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + Float64(Float64(b * b) * Float64(3.0 + a))))) - 1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0; end
code[a_, b_] := N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(3.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ 3.0 a))))) 1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * (((a * a) * (1.0d0 - a)) + ((b * b) * (3.0d0 + a))))) - 1.0d0
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + Float64(Float64(b * b) * Float64(3.0 + a))))) - 1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0; end
code[a_, b_] := N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(3.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1
\end{array}
(FPCore (a b)
:precision binary64
(let* ((t_0 (pow (hypot a b) 2.0)))
(if (<=
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))
INFINITY)
(+
(fma
t_0
t_0
(* 4.0 (fma (pow b 2.0) (+ a 3.0) (* (- 1.0 a) (pow a 2.0)))))
-1.0)
(+
(* (pow a 4.0) (- 1.0 (/ (+ 4.0 (/ (* (pow b 2.0) -2.0) a)) a)))
-1.0))))
double code(double a, double b) {
double t_0 = pow(hypot(a, b), 2.0);
double tmp;
if ((pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))))) <= ((double) INFINITY)) {
tmp = fma(t_0, t_0, (4.0 * fma(pow(b, 2.0), (a + 3.0), ((1.0 - a) * pow(a, 2.0))))) + -1.0;
} else {
tmp = (pow(a, 4.0) * (1.0 - ((4.0 + ((pow(b, 2.0) * -2.0) / a)) / a))) + -1.0;
}
return tmp;
}
function code(a, b) t_0 = hypot(a, b) ^ 2.0 tmp = 0.0 if (Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + Float64(Float64(b * b) * Float64(a + 3.0))))) <= Inf) tmp = Float64(fma(t_0, t_0, Float64(4.0 * fma((b ^ 2.0), Float64(a + 3.0), Float64(Float64(1.0 - a) * (a ^ 2.0))))) + -1.0); else tmp = Float64(Float64((a ^ 4.0) * Float64(1.0 - Float64(Float64(4.0 + Float64(Float64((b ^ 2.0) * -2.0) / a)) / a))) + -1.0); end return tmp end
code[a_, b_] := Block[{t$95$0 = N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(t$95$0 * t$95$0 + N[(4.0 * N[(N[Power[b, 2.0], $MachinePrecision] * N[(a + 3.0), $MachinePrecision] + N[(N[(1.0 - a), $MachinePrecision] * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 - N[(N[(4.0 + N[(N[(N[Power[b, 2.0], $MachinePrecision] * -2.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{hypot}\left(a, b\right)\right)}^{2}\\
\mathbf{if}\;{\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(a + 3\right)\right) \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(t\_0, t\_0, 4 \cdot \mathsf{fma}\left({b}^{2}, a + 3, \left(1 - a\right) \cdot {a}^{2}\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} \cdot \left(1 - \frac{4 + \frac{{b}^{2} \cdot -2}{a}}{a}\right) + -1\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (-.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (+.f64 #s(literal 3 binary64) a))))) < +inf.0Initial program 99.8%
associate-*l*99.8%
+-commutative99.8%
fma-undefine99.8%
unpow299.8%
fma-define99.8%
Applied egg-rr99.8%
if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (-.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (+.f64 #s(literal 3 binary64) a))))) Initial program 0.0%
associate-*l*0.0%
+-commutative0.0%
fma-undefine1.7%
unpow21.7%
fma-define1.7%
Applied egg-rr8.6%
Taylor expanded in a around -inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
associate-*r/100.0%
distribute-lft-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
distribute-lft-neg-in100.0%
metadata-eval100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in b around inf 100.0%
associate-*r/100.0%
*-commutative100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))))
(if (<= t_0 INFINITY)
(+ t_0 -1.0)
(+
(* (pow a 4.0) (- 1.0 (/ (+ 4.0 (/ (* (pow b 2.0) -2.0) a)) a)))
-1.0))))
double code(double a, double b) {
double t_0 = pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0 + -1.0;
} else {
tmp = (pow(a, 4.0) * (1.0 - ((4.0 + ((pow(b, 2.0) * -2.0) / a)) / a))) + -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) * (1.0 - a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 + -1.0;
} else {
tmp = (Math.pow(a, 4.0) * (1.0 - ((4.0 + ((Math.pow(b, 2.0) * -2.0) / a)) / a))) + -1.0;
}
return tmp;
}
def code(a, b): t_0 = math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0)))) tmp = 0 if t_0 <= math.inf: tmp = t_0 + -1.0 else: tmp = (math.pow(a, 4.0) * (1.0 - ((4.0 + ((math.pow(b, 2.0) * -2.0) / a)) / a))) + -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(1.0 - a)) + Float64(Float64(b * b) * Float64(a + 3.0))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(t_0 + -1.0); else tmp = Float64(Float64((a ^ 4.0) * Float64(1.0 - Float64(Float64(4.0 + Float64(Float64((b ^ 2.0) * -2.0) / a)) / a))) + -1.0); end return tmp end
function tmp_2 = code(a, b) t_0 = (((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0)))); tmp = 0.0; if (t_0 <= Inf) tmp = t_0 + -1.0; else tmp = ((a ^ 4.0) * (1.0 - ((4.0 + (((b ^ 2.0) * -2.0) / a)) / a))) + -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[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(t$95$0 + -1.0), $MachinePrecision], N[(N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 - N[(N[(4.0 + N[(N[(N[Power[b, 2.0], $MachinePrecision] * -2.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.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(1 - a\right) + \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\\
\mathbf{if}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0 + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} \cdot \left(1 - \frac{4 + \frac{{b}^{2} \cdot -2}{a}}{a}\right) + -1\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (-.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (+.f64 #s(literal 3 binary64) a))))) < +inf.0Initial program 99.8%
if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (-.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (+.f64 #s(literal 3 binary64) a))))) Initial program 0.0%
associate-*l*0.0%
+-commutative0.0%
fma-undefine1.7%
unpow21.7%
fma-define1.7%
Applied egg-rr8.6%
Taylor expanded in a around -inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
associate-*r/100.0%
distribute-lft-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
distribute-lft-neg-in100.0%
metadata-eval100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in b around inf 100.0%
associate-*r/100.0%
*-commutative100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))))
(if (<= t_0 INFINITY) (+ t_0 -1.0) (pow a 4.0))))
double code(double a, double b) {
double t_0 = pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0 + -1.0;
} else {
tmp = 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) * (1.0 - a)) + ((b * b) * (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) * (1.0 - a)) + ((b * b) * (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(1.0 - a)) + Float64(Float64(b * b) * Float64(a + 3.0))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(t_0 + -1.0); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) t_0 = (((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0)))); tmp = 0.0; if (t_0 <= Inf) tmp = t_0 + -1.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(t$95$0 + -1.0), $MachinePrecision], N[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(1 - a\right) + \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\\
\mathbf{if}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0 + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (-.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (+.f64 #s(literal 3 binary64) a))))) < +inf.0Initial program 99.8%
if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (-.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (+.f64 #s(literal 3 binary64) a))))) Initial program 0.0%
associate--l+0.0%
fma-define0.0%
sqr-neg0.0%
fma-define0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
fma-define0.0%
sqr-neg0.0%
Simplified1.7%
Taylor expanded in a around inf 95.0%
Final simplification98.7%
(FPCore (a b)
:precision binary64
(if (<= b 5.1e-278)
(pow a 4.0)
(if (<= b 2.15e-154)
-1.0
(if (<= b 1.25e-126)
(pow a 4.0)
(if (<= b 9e-111) -1.0 (if (<= b 2.55e+22) (pow a 4.0) (pow b 4.0)))))))
double code(double a, double b) {
double tmp;
if (b <= 5.1e-278) {
tmp = pow(a, 4.0);
} else if (b <= 2.15e-154) {
tmp = -1.0;
} else if (b <= 1.25e-126) {
tmp = pow(a, 4.0);
} else if (b <= 9e-111) {
tmp = -1.0;
} else if (b <= 2.55e+22) {
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 <= 5.1d-278) then
tmp = a ** 4.0d0
else if (b <= 2.15d-154) then
tmp = -1.0d0
else if (b <= 1.25d-126) then
tmp = a ** 4.0d0
else if (b <= 9d-111) then
tmp = -1.0d0
else if (b <= 2.55d+22) 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 <= 5.1e-278) {
tmp = Math.pow(a, 4.0);
} else if (b <= 2.15e-154) {
tmp = -1.0;
} else if (b <= 1.25e-126) {
tmp = Math.pow(a, 4.0);
} else if (b <= 9e-111) {
tmp = -1.0;
} else if (b <= 2.55e+22) {
tmp = Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 5.1e-278: tmp = math.pow(a, 4.0) elif b <= 2.15e-154: tmp = -1.0 elif b <= 1.25e-126: tmp = math.pow(a, 4.0) elif b <= 9e-111: tmp = -1.0 elif b <= 2.55e+22: tmp = math.pow(a, 4.0) else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 5.1e-278) tmp = a ^ 4.0; elseif (b <= 2.15e-154) tmp = -1.0; elseif (b <= 1.25e-126) tmp = a ^ 4.0; elseif (b <= 9e-111) tmp = -1.0; elseif (b <= 2.55e+22) tmp = a ^ 4.0; else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 5.1e-278) tmp = a ^ 4.0; elseif (b <= 2.15e-154) tmp = -1.0; elseif (b <= 1.25e-126) tmp = a ^ 4.0; elseif (b <= 9e-111) tmp = -1.0; elseif (b <= 2.55e+22) tmp = a ^ 4.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 5.1e-278], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[b, 2.15e-154], -1.0, If[LessEqual[b, 1.25e-126], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[b, 9e-111], -1.0, If[LessEqual[b, 2.55e+22], N[Power[a, 4.0], $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5.1 \cdot 10^{-278}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;b \leq 2.15 \cdot 10^{-154}:\\
\;\;\;\;-1\\
\mathbf{elif}\;b \leq 1.25 \cdot 10^{-126}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;b \leq 9 \cdot 10^{-111}:\\
\;\;\;\;-1\\
\mathbf{elif}\;b \leq 2.55 \cdot 10^{+22}:\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 5.10000000000000011e-278 or 2.14999999999999996e-154 < b < 1.25000000000000001e-126 or 8.99999999999999987e-111 < b < 2.5500000000000001e22Initial program 78.3%
associate--l+78.3%
fma-define78.3%
sqr-neg78.3%
fma-define78.3%
distribute-rgt-in78.3%
sqr-neg78.3%
distribute-rgt-in78.3%
fma-define78.3%
sqr-neg78.3%
Simplified78.9%
Taylor expanded in a around inf 51.9%
if 5.10000000000000011e-278 < b < 2.14999999999999996e-154 or 1.25000000000000001e-126 < b < 8.99999999999999987e-111Initial program 99.8%
associate--l+99.7%
fma-define99.7%
sqr-neg99.7%
fma-define99.7%
distribute-rgt-in99.7%
sqr-neg99.7%
distribute-rgt-in99.7%
fma-define99.7%
sqr-neg99.7%
Simplified99.7%
Taylor expanded in a around 0 69.1%
Taylor expanded in b around 0 69.1%
if 2.5500000000000001e22 < b Initial program 69.5%
associate--l+69.5%
fma-define69.5%
sqr-neg69.5%
fma-define69.5%
distribute-rgt-in69.5%
sqr-neg69.5%
distribute-rgt-in69.5%
fma-define69.5%
sqr-neg69.5%
Simplified69.5%
Taylor expanded in b around inf 93.1%
(FPCore (a b) :precision binary64 (if (<= b 4.2e+22) (+ (* (pow a 2.0) (+ 4.0 (* a (- a 4.0)))) -1.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if (b <= 4.2e+22) {
tmp = (pow(a, 2.0) * (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 <= 4.2d+22) then
tmp = ((a ** 2.0d0) * (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 <= 4.2e+22) {
tmp = (Math.pow(a, 2.0) * (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 <= 4.2e+22: tmp = (math.pow(a, 2.0) * (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 (b <= 4.2e+22) tmp = Float64(Float64((a ^ 2.0) * Float64(4.0 + Float64(a * 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 <= 4.2e+22) tmp = ((a ^ 2.0) * (4.0 + (a * (a - 4.0)))) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 4.2e+22], N[(N[(N[Power[a, 2.0], $MachinePrecision] * N[(4.0 + N[(a * N[(a - 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4.2 \cdot 10^{+22}:\\
\;\;\;\;{a}^{2} \cdot \left(4 + a \cdot \left(a - 4\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 4.1999999999999996e22Initial program 80.1%
associate--l+80.0%
fma-define80.0%
sqr-neg80.0%
fma-define80.0%
distribute-rgt-in80.0%
sqr-neg80.0%
distribute-rgt-in80.0%
fma-define80.0%
sqr-neg80.0%
Simplified80.6%
Taylor expanded in b around 0 66.0%
Taylor expanded in a around 0 80.4%
if 4.1999999999999996e22 < b Initial program 69.5%
associate--l+69.5%
fma-define69.5%
sqr-neg69.5%
fma-define69.5%
distribute-rgt-in69.5%
sqr-neg69.5%
distribute-rgt-in69.5%
fma-define69.5%
sqr-neg69.5%
Simplified69.5%
Taylor expanded in b around inf 93.1%
Final simplification83.8%
(FPCore (a b) :precision binary64 (if (or (<= a -2.15e-20) (not (<= a 2.4))) (pow a 4.0) -1.0))
double code(double a, double b) {
double tmp;
if ((a <= -2.15e-20) || !(a <= 2.4)) {
tmp = pow(a, 4.0);
} else {
tmp = -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.15d-20)) .or. (.not. (a <= 2.4d0))) then
tmp = a ** 4.0d0
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -2.15e-20) || !(a <= 2.4)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -2.15e-20) or not (a <= 2.4): tmp = math.pow(a, 4.0) else: tmp = -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -2.15e-20) || !(a <= 2.4)) tmp = a ^ 4.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -2.15e-20) || ~((a <= 2.4))) tmp = a ^ 4.0; else tmp = -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -2.15e-20], N[Not[LessEqual[a, 2.4]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], -1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.15 \cdot 10^{-20} \lor \neg \left(a \leq 2.4\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if a < -2.15000000000000006e-20 or 2.39999999999999991 < a Initial program 56.6%
associate--l+56.6%
fma-define56.6%
sqr-neg56.6%
fma-define56.6%
distribute-rgt-in56.6%
sqr-neg56.6%
distribute-rgt-in56.6%
fma-define56.6%
sqr-neg56.6%
Simplified57.3%
Taylor expanded in a around inf 85.5%
if -2.15000000000000006e-20 < a < 2.39999999999999991Initial program 99.9%
associate--l+99.8%
fma-define99.8%
sqr-neg99.8%
fma-define99.8%
distribute-rgt-in99.8%
sqr-neg99.8%
distribute-rgt-in99.8%
fma-define99.8%
sqr-neg99.8%
Simplified99.8%
Taylor expanded in a around 0 99.4%
Taylor expanded in b around 0 47.4%
Final simplification67.3%
(FPCore (a b) :precision binary64 (if (<= b 3.7e+22) (+ (pow a 4.0) -1.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if (b <= 3.7e+22) {
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 <= 3.7d+22) 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 <= 3.7e+22) {
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 <= 3.7e+22: 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 <= 3.7e+22) 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 <= 3.7e+22) tmp = (a ^ 4.0) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 3.7e+22], 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 3.7 \cdot 10^{+22}:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 3.6999999999999998e22Initial program 80.1%
associate-*l*80.1%
+-commutative80.1%
fma-undefine80.6%
unpow280.6%
fma-define80.6%
Applied egg-rr81.1%
Taylor expanded in a around inf 79.5%
if 3.6999999999999998e22 < b Initial program 69.5%
associate--l+69.5%
fma-define69.5%
sqr-neg69.5%
fma-define69.5%
distribute-rgt-in69.5%
sqr-neg69.5%
distribute-rgt-in69.5%
fma-define69.5%
sqr-neg69.5%
Simplified69.5%
Taylor expanded in b around inf 93.1%
Final simplification83.1%
(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 77.2%
associate--l+77.2%
fma-define77.2%
sqr-neg77.2%
fma-define77.2%
distribute-rgt-in77.2%
sqr-neg77.2%
distribute-rgt-in77.2%
fma-define77.2%
sqr-neg77.2%
Simplified77.6%
Taylor expanded in a around 0 68.6%
Taylor expanded in b around 0 23.0%
herbie shell --seed 2024103
(FPCore (a b)
:name "Bouland and Aaronson, Equation (24)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ 3.0 a))))) 1.0))