
(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 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) (- 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))))))
INFINITY)
(+
(+
(* 4.0 (fma (* a a) (+ (+ a 2.0) -1.0) (* b (* b (+ 1.0 (* a -3.0))))))
(pow (fma a a (* b b)) 2.0))
-1.0)
(* (pow a 4.0) (+ 1.0 (/ 4.0 a)))))
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)))))) <= ((double) INFINITY)) {
tmp = ((4.0 * fma((a * a), ((a + 2.0) + -1.0), (b * (b * (1.0 + (a * -3.0)))))) + pow(fma(a, a, (b * b)), 2.0)) + -1.0;
} else {
tmp = pow(a, 4.0) * (1.0 + (4.0 / a));
}
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)))))) <= Inf) tmp = Float64(Float64(Float64(4.0 * fma(Float64(a * a), Float64(Float64(a + 2.0) + -1.0), Float64(b * Float64(b * Float64(1.0 + Float64(a * -3.0)))))) + (fma(a, a, Float64(b * b)) ^ 2.0)) + -1.0); else tmp = Float64((a ^ 4.0) * Float64(1.0 + Float64(4.0 / a))); 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], Infinity], N[(N[(N[(4.0 * N[(N[(a * a), $MachinePrecision] * N[(N[(a + 2.0), $MachinePrecision] + -1.0), $MachinePrecision] + N[(b * N[(b * N[(1.0 + N[(a * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[(a * a + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 + N[(4.0 / a), $MachinePrecision]), $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 \infty:\\
\;\;\;\;\left(4 \cdot \mathsf{fma}\left(a \cdot a, \left(a + 2\right) + -1, b \cdot \left(b \cdot \left(1 + a \cdot -3\right)\right)\right) + {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} \cdot \left(1 + \frac{4}{a}\right)\\
\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 1 binary64) (*.f64 #s(literal 3 binary64) a)))))) < +inf.0Initial program 99.9%
sub-neg99.9%
Simplified99.9%
+-commutative99.9%
expm1-log1p-u90.8%
expm1-undefine90.9%
+-commutative90.9%
Applied egg-rr90.9%
sub-neg90.9%
metadata-eval90.9%
+-commutative90.9%
log1p-undefine90.9%
rem-exp-log99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
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 1 binary64) (*.f64 #s(literal 3 binary64) a)))))) Initial program 0.0%
associate--l+0.0%
+-commutative0.0%
+-commutative0.0%
sub-neg0.0%
associate-+l+0.0%
+-commutative0.0%
associate-+l+0.0%
Simplified3.5%
Taylor expanded in a around inf 83.2%
associate-*r/83.2%
metadata-eval83.2%
Simplified83.2%
Final simplification96.2%
(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) (+ 1.0 (/ 4.0 a))))))
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) * (1.0 + (4.0 / a));
}
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) * (1.0 + (4.0 / a));
}
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) * (1.0 + (4.0 / a)) 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 = Float64((a ^ 4.0) * Float64(1.0 + Float64(4.0 / a))); 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) * (1.0 + (4.0 / a)); 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[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 + N[(4.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(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} \cdot \left(1 + \frac{4}{a}\right)\\
\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 1 binary64) (*.f64 #s(literal 3 binary64) a)))))) < +inf.0Initial program 99.9%
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 1 binary64) (*.f64 #s(literal 3 binary64) a)))))) Initial program 0.0%
associate--l+0.0%
+-commutative0.0%
+-commutative0.0%
sub-neg0.0%
associate-+l+0.0%
+-commutative0.0%
associate-+l+0.0%
Simplified3.5%
Taylor expanded in a around inf 83.2%
associate-*r/83.2%
metadata-eval83.2%
Simplified83.2%
Final simplification96.2%
(FPCore (a b)
:precision binary64
(if (<= a -2.7e+17)
(pow a 4.0)
(if (<= a -5.4e-8)
(pow b 4.0)
(if (<= a 1.8e-146)
(+ (* b (* b 4.0)) -1.0)
(if (<= a 9.5e+18) (pow b 4.0) (pow a 4.0))))))
double code(double a, double b) {
double tmp;
if (a <= -2.7e+17) {
tmp = pow(a, 4.0);
} else if (a <= -5.4e-8) {
tmp = pow(b, 4.0);
} else if (a <= 1.8e-146) {
tmp = (b * (b * 4.0)) + -1.0;
} else if (a <= 9.5e+18) {
tmp = 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 <= (-2.7d+17)) then
tmp = a ** 4.0d0
else if (a <= (-5.4d-8)) then
tmp = b ** 4.0d0
else if (a <= 1.8d-146) then
tmp = (b * (b * 4.0d0)) + (-1.0d0)
else if (a <= 9.5d+18) then
tmp = 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 <= -2.7e+17) {
tmp = Math.pow(a, 4.0);
} else if (a <= -5.4e-8) {
tmp = Math.pow(b, 4.0);
} else if (a <= 1.8e-146) {
tmp = (b * (b * 4.0)) + -1.0;
} else if (a <= 9.5e+18) {
tmp = Math.pow(b, 4.0);
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -2.7e+17: tmp = math.pow(a, 4.0) elif a <= -5.4e-8: tmp = math.pow(b, 4.0) elif a <= 1.8e-146: tmp = (b * (b * 4.0)) + -1.0 elif a <= 9.5e+18: tmp = math.pow(b, 4.0) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -2.7e+17) tmp = a ^ 4.0; elseif (a <= -5.4e-8) tmp = b ^ 4.0; elseif (a <= 1.8e-146) tmp = Float64(Float64(b * Float64(b * 4.0)) + -1.0); elseif (a <= 9.5e+18) tmp = b ^ 4.0; else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -2.7e+17) tmp = a ^ 4.0; elseif (a <= -5.4e-8) tmp = b ^ 4.0; elseif (a <= 1.8e-146) tmp = (b * (b * 4.0)) + -1.0; elseif (a <= 9.5e+18) tmp = b ^ 4.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -2.7e+17], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, -5.4e-8], N[Power[b, 4.0], $MachinePrecision], If[LessEqual[a, 1.8e-146], N[(N[(b * N[(b * 4.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[a, 9.5e+18], N[Power[b, 4.0], $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.7 \cdot 10^{+17}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq -5.4 \cdot 10^{-8}:\\
\;\;\;\;{b}^{4}\\
\mathbf{elif}\;a \leq 1.8 \cdot 10^{-146}:\\
\;\;\;\;b \cdot \left(b \cdot 4\right) + -1\\
\mathbf{elif}\;a \leq 9.5 \cdot 10^{+18}:\\
\;\;\;\;{b}^{4}\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -2.7e17 or 9.5e18 < a Initial program 51.3%
associate--l+51.3%
+-commutative51.3%
+-commutative51.3%
sub-neg51.3%
associate-+l+51.3%
+-commutative51.3%
associate-+l+51.3%
Simplified53.1%
Taylor expanded in a around inf 92.9%
associate-*r/92.9%
metadata-eval92.9%
Simplified92.9%
Taylor expanded in a around inf 92.9%
if -2.7e17 < a < -5.40000000000000005e-8 or 1.79999999999999989e-146 < a < 9.5e18Initial program 90.3%
associate--l+90.3%
+-commutative90.3%
+-commutative90.3%
sub-neg90.3%
associate-+l+90.3%
+-commutative90.3%
associate-+l+90.3%
Simplified90.3%
Taylor expanded in a around 0 93.8%
pow293.8%
Applied egg-rr93.8%
Taylor expanded in b around inf 76.5%
if -5.40000000000000005e-8 < a < 1.79999999999999989e-146Initial program 99.9%
associate--l+99.9%
+-commutative99.9%
+-commutative99.9%
sub-neg99.9%
associate-+l+99.9%
+-commutative99.9%
associate-+l+99.9%
Simplified99.9%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 77.8%
metadata-eval77.8%
unpow277.8%
swap-sqr77.8%
unpow277.8%
Simplified77.8%
unpow-prod-down77.8%
metadata-eval77.8%
pow277.8%
associate-*r*77.8%
Applied egg-rr77.8%
Final simplification83.9%
(FPCore (a b) :precision binary64 (if (or (<= a -7.2e+16) (not (<= a 6.4e+19))) (pow a 4.0) (+ (+ (* (* b b) 4.0) (pow b 4.0)) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -7.2e+16) || !(a <= 6.4e+19)) {
tmp = pow(a, 4.0);
} else {
tmp = (((b * b) * 4.0) + pow(b, 4.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 <= (-7.2d+16)) .or. (.not. (a <= 6.4d+19))) then
tmp = a ** 4.0d0
else
tmp = (((b * b) * 4.0d0) + (b ** 4.0d0)) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -7.2e+16) || !(a <= 6.4e+19)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = (((b * b) * 4.0) + Math.pow(b, 4.0)) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -7.2e+16) or not (a <= 6.4e+19): tmp = math.pow(a, 4.0) else: tmp = (((b * b) * 4.0) + math.pow(b, 4.0)) + -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -7.2e+16) || !(a <= 6.4e+19)) tmp = a ^ 4.0; else tmp = Float64(Float64(Float64(Float64(b * b) * 4.0) + (b ^ 4.0)) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -7.2e+16) || ~((a <= 6.4e+19))) tmp = a ^ 4.0; else tmp = (((b * b) * 4.0) + (b ^ 4.0)) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -7.2e+16], N[Not[LessEqual[a, 6.4e+19]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[(N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -7.2 \cdot 10^{+16} \lor \neg \left(a \leq 6.4 \cdot 10^{+19}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(b \cdot b\right) \cdot 4 + {b}^{4}\right) + -1\\
\end{array}
\end{array}
if a < -7.2e16 or 6.4e19 < a Initial program 51.3%
associate--l+51.3%
+-commutative51.3%
+-commutative51.3%
sub-neg51.3%
associate-+l+51.3%
+-commutative51.3%
associate-+l+51.3%
Simplified53.1%
Taylor expanded in a around inf 92.9%
associate-*r/92.9%
metadata-eval92.9%
Simplified92.9%
Taylor expanded in a around inf 92.9%
if -7.2e16 < a < 6.4e19Initial program 96.6%
associate--l+96.6%
+-commutative96.6%
+-commutative96.6%
sub-neg96.6%
associate-+l+96.6%
+-commutative96.6%
associate-+l+96.6%
Simplified96.6%
Taylor expanded in a around 0 97.9%
pow297.9%
Applied egg-rr97.9%
Final simplification95.8%
(FPCore (a b) :precision binary64 (if (or (<= a -20000000.0) (not (<= a 2.8e+18))) (pow a 4.0) (+ (* b (* b 4.0)) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -20000000.0) || !(a <= 2.8e+18)) {
tmp = pow(a, 4.0);
} else {
tmp = (b * (b * 4.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 <= (-20000000.0d0)) .or. (.not. (a <= 2.8d+18))) then
tmp = a ** 4.0d0
else
tmp = (b * (b * 4.0d0)) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -20000000.0) || !(a <= 2.8e+18)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = (b * (b * 4.0)) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -20000000.0) or not (a <= 2.8e+18): tmp = math.pow(a, 4.0) else: tmp = (b * (b * 4.0)) + -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -20000000.0) || !(a <= 2.8e+18)) tmp = a ^ 4.0; else tmp = Float64(Float64(b * Float64(b * 4.0)) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -20000000.0) || ~((a <= 2.8e+18))) tmp = a ^ 4.0; else tmp = (b * (b * 4.0)) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -20000000.0], N[Not[LessEqual[a, 2.8e+18]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[(N[(b * N[(b * 4.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -20000000 \lor \neg \left(a \leq 2.8 \cdot 10^{+18}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(b \cdot 4\right) + -1\\
\end{array}
\end{array}
if a < -2e7 or 2.8e18 < a Initial program 52.6%
associate--l+52.6%
+-commutative52.6%
+-commutative52.6%
sub-neg52.6%
associate-+l+52.6%
+-commutative52.6%
associate-+l+52.6%
Simplified54.4%
Taylor expanded in a around inf 91.3%
associate-*r/91.3%
metadata-eval91.3%
Simplified91.3%
Taylor expanded in a around inf 90.9%
if -2e7 < a < 2.8e18Initial program 96.5%
associate--l+96.5%
+-commutative96.5%
+-commutative96.5%
sub-neg96.5%
associate-+l+96.5%
+-commutative96.5%
associate-+l+96.5%
Simplified96.5%
Taylor expanded in a around 0 98.5%
Taylor expanded in b around 0 72.3%
metadata-eval72.3%
unpow272.3%
swap-sqr72.3%
unpow272.3%
Simplified72.3%
unpow-prod-down72.3%
metadata-eval72.3%
pow272.3%
associate-*r*72.3%
Applied egg-rr72.3%
Final simplification80.3%
(FPCore (a b) :precision binary64 (+ (* b (* b 4.0)) -1.0))
double code(double a, double b) {
return (b * (b * 4.0)) + -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (b * (b * 4.0d0)) + (-1.0d0)
end function
public static double code(double a, double b) {
return (b * (b * 4.0)) + -1.0;
}
def code(a, b): return (b * (b * 4.0)) + -1.0
function code(a, b) return Float64(Float64(b * Float64(b * 4.0)) + -1.0) end
function tmp = code(a, b) tmp = (b * (b * 4.0)) + -1.0; end
code[a_, b_] := N[(N[(b * N[(b * 4.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
b \cdot \left(b \cdot 4\right) + -1
\end{array}
Initial program 77.6%
associate--l+77.6%
+-commutative77.6%
+-commutative77.6%
sub-neg77.6%
associate-+l+77.6%
+-commutative77.6%
associate-+l+77.6%
Simplified78.4%
Taylor expanded in a around 0 71.4%
Taylor expanded in b around 0 53.9%
metadata-eval53.9%
unpow253.9%
swap-sqr53.9%
unpow253.9%
Simplified53.9%
unpow-prod-down53.9%
metadata-eval53.9%
pow253.9%
associate-*r*53.9%
Applied egg-rr53.9%
Final simplification53.9%
(FPCore (a b) :precision binary64 (+ (* b 2.0) -1.0))
double code(double a, double b) {
return (b * 2.0) + -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (b * 2.0d0) + (-1.0d0)
end function
public static double code(double a, double b) {
return (b * 2.0) + -1.0;
}
def code(a, b): return (b * 2.0) + -1.0
function code(a, b) return Float64(Float64(b * 2.0) + -1.0) end
function tmp = code(a, b) tmp = (b * 2.0) + -1.0; end
code[a_, b_] := N[(N[(b * 2.0), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
b \cdot 2 + -1
\end{array}
Initial program 77.6%
associate--l+77.6%
+-commutative77.6%
+-commutative77.6%
sub-neg77.6%
associate-+l+77.6%
+-commutative77.6%
associate-+l+77.6%
Simplified78.4%
Taylor expanded in a around 0 71.4%
Taylor expanded in b around 0 53.9%
metadata-eval53.9%
unpow253.9%
swap-sqr53.9%
unpow253.9%
Simplified53.9%
unpow253.9%
difference-of-sqr-153.8%
*-commutative53.8%
*-commutative53.8%
Applied egg-rr53.8%
Taylor expanded in b around 0 23.6%
Final simplification23.6%
(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.6%
associate--l+77.6%
+-commutative77.6%
+-commutative77.6%
sub-neg77.6%
associate-+l+77.6%
+-commutative77.6%
associate-+l+77.6%
Simplified78.4%
Taylor expanded in a around 0 71.4%
Taylor expanded in b around 0 22.6%
herbie shell --seed 2024177
(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))