
(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
(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)
(+ (* (* a a) (+ 4.0 (* a (+ a 4.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 <= ((double) INFINITY)) {
tmp = t_0 + -1.0;
} else {
tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0;
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((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 = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.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 = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0 return tmp
function code(a, b) t_0 = Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(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(Float64(Float64(a * a) * Float64(4.0 + Float64(a * Float64(a + 4.0)))) + -1.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 * a) * (4.0 + (a * (a + 4.0)))) + -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[(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[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * N[(a + 4.0), $MachinePrecision]), $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(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}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + 4\right)\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 1 binary64) (*.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 1 binary64) (*.f64 #s(literal 3 binary64) a)))))) Initial program 0.0%
sub-neg0.0%
Simplified6.2%
Taylor expanded in b around 0 32.8%
add-cbrt-cube38.5%
pow338.5%
fma-define38.5%
pow238.5%
distribute-rgt-in38.5%
*-un-lft-identity38.5%
fma-define38.5%
cube-unmult38.5%
Applied egg-rr38.5%
Taylor expanded in a around 0 92.8%
pow292.8%
Applied egg-rr92.8%
Final simplification98.0%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e-5) (+ (* (* a a) (+ 4.0 (* a (+ a 4.0)))) -1.0) (+ (+ (* (* b b) 4.0) (pow b 4.0)) -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e-5) {
tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.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 ((b * b) <= 5d-5) then
tmp = ((a * a) * (4.0d0 + (a * (a + 4.0d0)))) + (-1.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 ((b * b) <= 5e-5) {
tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0;
} else {
tmp = (((b * b) * 4.0) + Math.pow(b, 4.0)) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e-5: tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0 else: tmp = (((b * b) * 4.0) + math.pow(b, 4.0)) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e-5) tmp = Float64(Float64(Float64(a * a) * Float64(4.0 + Float64(a * Float64(a + 4.0)))) + -1.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 ((b * b) <= 5e-5) tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0; else tmp = (((b * b) * 4.0) + (b ^ 4.0)) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e-5], N[(N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * N[(a + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.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}\;b \cdot b \leq 5 \cdot 10^{-5}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + 4\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left(\left(b \cdot b\right) \cdot 4 + {b}^{4}\right) + -1\\
\end{array}
\end{array}
if (*.f64 b b) < 5.00000000000000024e-5Initial program 83.3%
sub-neg83.3%
Simplified83.3%
Taylor expanded in b around 0 83.0%
add-cbrt-cube76.3%
pow376.4%
fma-define76.4%
pow276.4%
distribute-rgt-in76.4%
*-un-lft-identity76.4%
fma-define76.4%
cube-unmult76.4%
Applied egg-rr76.4%
Taylor expanded in a around 0 99.4%
pow299.4%
Applied egg-rr99.4%
if 5.00000000000000024e-5 < (*.f64 b b) Initial program 65.7%
associate--l+65.7%
+-commutative65.7%
+-commutative65.7%
sub-neg65.7%
associate-+l+65.7%
+-commutative65.7%
associate-+l+65.7%
Simplified71.2%
Taylor expanded in a around 0 91.9%
unpow291.9%
Applied egg-rr91.9%
Final simplification95.6%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+17) (+ (* (* a a) (+ 4.0 (* a (+ a 4.0)))) -1.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+17) {
tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0;
} else {
tmp = pow(b, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 5d+17) then
tmp = ((a * a) * (4.0d0 + (a * (a + 4.0d0)))) + (-1.0d0)
else
tmp = b ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+17) {
tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0;
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e+17: tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e+17) tmp = Float64(Float64(Float64(a * a) * 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 * b) <= 5e+17) tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e+17], N[(N[(N[(a * a), $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 \cdot b \leq 5 \cdot 10^{+17}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + 4\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 5e17Initial program 83.2%
sub-neg83.2%
Simplified83.2%
Taylor expanded in b around 0 81.1%
add-cbrt-cube74.6%
pow374.7%
fma-define74.7%
pow274.7%
distribute-rgt-in74.7%
*-un-lft-identity74.7%
fma-define74.7%
cube-unmult74.7%
Applied egg-rr74.7%
Taylor expanded in a around 0 97.6%
pow297.6%
Applied egg-rr97.6%
if 5e17 < (*.f64 b b) Initial program 65.2%
associate--l+65.2%
+-commutative65.2%
+-commutative65.2%
sub-neg65.2%
associate-+l+65.2%
+-commutative65.2%
associate-+l+65.2%
Simplified70.8%
Taylor expanded in a around 0 93.1%
unpow293.1%
Applied egg-rr93.1%
Taylor expanded in b around inf 93.1%
Final simplification95.4%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e+303) (+ (* (* a a) (+ 4.0 (* a (+ a 4.0)))) -1.0) (+ (* (* b b) 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e+303) {
tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.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 ((b * b) <= 1d+303) then
tmp = ((a * a) * (4.0d0 + (a * (a + 4.0d0)))) + (-1.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 ((b * b) <= 1e+303) {
tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0;
} else {
tmp = ((b * b) * 4.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 1e+303: tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0 else: tmp = ((b * b) * 4.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1e+303) tmp = Float64(Float64(Float64(a * a) * Float64(4.0 + Float64(a * Float64(a + 4.0)))) + -1.0); else tmp = Float64(Float64(Float64(b * b) * 4.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 1e+303) tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0; else tmp = ((b * b) * 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e+303], N[(N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * N[(a + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{+303}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + 4\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 4 + -1\\
\end{array}
\end{array}
if (*.f64 b b) < 1e303Initial program 78.9%
sub-neg78.9%
Simplified79.9%
Taylor expanded in b around 0 59.6%
add-cbrt-cube57.3%
pow357.3%
fma-define57.3%
pow257.3%
distribute-rgt-in57.3%
*-un-lft-identity57.3%
fma-define57.3%
cube-unmult57.3%
Applied egg-rr57.3%
Taylor expanded in a around 0 75.4%
pow275.4%
Applied egg-rr75.4%
if 1e303 < (*.f64 b b) Initial program 58.2%
associate--l+58.2%
+-commutative58.2%
+-commutative58.2%
sub-neg58.2%
associate-+l+58.2%
+-commutative58.2%
associate-+l+58.2%
Simplified58.2%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 100.0%
unpow2100.0%
Applied egg-rr100.0%
Final simplification80.7%
(FPCore (a b) :precision binary64 (if (<= a 8.2e+99) (* (+ 1.0 (* b 2.0)) (+ (* b 2.0) -1.0)) (+ (* (* a a) (+ 4.0 (* a 4.0))) -1.0)))
double code(double a, double b) {
double tmp;
if (a <= 8.2e+99) {
tmp = (1.0 + (b * 2.0)) * ((b * 2.0) + -1.0);
} else {
tmp = ((a * a) * (4.0 + (a * 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 <= 8.2d+99) then
tmp = (1.0d0 + (b * 2.0d0)) * ((b * 2.0d0) + (-1.0d0))
else
tmp = ((a * a) * (4.0d0 + (a * 4.0d0))) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= 8.2e+99) {
tmp = (1.0 + (b * 2.0)) * ((b * 2.0) + -1.0);
} else {
tmp = ((a * a) * (4.0 + (a * 4.0))) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if a <= 8.2e+99: tmp = (1.0 + (b * 2.0)) * ((b * 2.0) + -1.0) else: tmp = ((a * a) * (4.0 + (a * 4.0))) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (a <= 8.2e+99) tmp = Float64(Float64(1.0 + Float64(b * 2.0)) * Float64(Float64(b * 2.0) + -1.0)); else tmp = Float64(Float64(Float64(a * a) * Float64(4.0 + Float64(a * 4.0))) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= 8.2e+99) tmp = (1.0 + (b * 2.0)) * ((b * 2.0) + -1.0); else tmp = ((a * a) * (4.0 + (a * 4.0))) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, 8.2e+99], N[(N[(1.0 + N[(b * 2.0), $MachinePrecision]), $MachinePrecision] * N[(N[(b * 2.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 8.2 \cdot 10^{+99}:\\
\;\;\;\;\left(1 + b \cdot 2\right) \cdot \left(b \cdot 2 + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot 4\right) + -1\\
\end{array}
\end{array}
if a < 8.19999999999999959e99Initial program 78.0%
associate--l+78.0%
+-commutative78.0%
+-commutative78.0%
sub-neg78.0%
associate-+l+78.0%
+-commutative78.0%
associate-+l+78.0%
Simplified78.0%
Taylor expanded in a around 0 78.6%
Taylor expanded in b around 0 53.3%
pow253.3%
add-sqr-sqrt53.3%
difference-of-sqr-153.3%
*-commutative53.3%
sqrt-prod53.3%
sqrt-prod29.1%
add-sqr-sqrt44.1%
metadata-eval44.1%
*-commutative44.1%
sqrt-prod44.1%
sqrt-prod29.1%
add-sqr-sqrt53.3%
metadata-eval53.3%
Applied egg-rr53.3%
if 8.19999999999999959e99 < a Initial program 57.8%
sub-neg57.8%
Simplified57.8%
Taylor expanded in b around 0 100.0%
add-cbrt-cube100.0%
pow3100.0%
fma-define100.0%
pow2100.0%
distribute-rgt-in100.0%
*-un-lft-identity100.0%
fma-define100.0%
cube-unmult100.0%
Applied egg-rr100.0%
Taylor expanded in a around 0 98.0%
pow2100.0%
Applied egg-rr98.0%
Final simplification61.1%
(FPCore (a b) :precision binary64 (* (+ 1.0 (* b 2.0)) (+ (* b 2.0) -1.0)))
double code(double a, double b) {
return (1.0 + (b * 2.0)) * ((b * 2.0) + -1.0);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (1.0d0 + (b * 2.0d0)) * ((b * 2.0d0) + (-1.0d0))
end function
public static double code(double a, double b) {
return (1.0 + (b * 2.0)) * ((b * 2.0) + -1.0);
}
def code(a, b): return (1.0 + (b * 2.0)) * ((b * 2.0) + -1.0)
function code(a, b) return Float64(Float64(1.0 + Float64(b * 2.0)) * Float64(Float64(b * 2.0) + -1.0)) end
function tmp = code(a, b) tmp = (1.0 + (b * 2.0)) * ((b * 2.0) + -1.0); end
code[a_, b_] := N[(N[(1.0 + N[(b * 2.0), $MachinePrecision]), $MachinePrecision] * N[(N[(b * 2.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 + b \cdot 2\right) \cdot \left(b \cdot 2 + -1\right)
\end{array}
Initial program 74.5%
associate--l+74.5%
+-commutative74.5%
+-commutative74.5%
sub-neg74.5%
associate-+l+74.5%
+-commutative74.5%
associate-+l+74.5%
Simplified77.2%
Taylor expanded in a around 0 71.2%
Taylor expanded in b around 0 48.4%
pow248.4%
add-sqr-sqrt48.4%
difference-of-sqr-148.4%
*-commutative48.4%
sqrt-prod48.4%
sqrt-prod25.6%
add-sqr-sqrt38.1%
metadata-eval38.1%
*-commutative38.1%
sqrt-prod38.1%
sqrt-prod25.6%
add-sqr-sqrt48.4%
metadata-eval48.4%
Applied egg-rr48.4%
Final simplification48.4%
(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(Float64(b * b) * 4.0) + -1.0) end
function tmp = code(a, b) tmp = ((b * b) * 4.0) + -1.0; end
code[a_, b_] := N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\left(b \cdot b\right) \cdot 4 + -1
\end{array}
Initial program 74.5%
associate--l+74.5%
+-commutative74.5%
+-commutative74.5%
sub-neg74.5%
associate-+l+74.5%
+-commutative74.5%
associate-+l+74.5%
Simplified77.2%
Taylor expanded in a around 0 71.2%
Taylor expanded in b around 0 48.4%
unpow271.2%
Applied egg-rr48.4%
Final simplification48.4%
(FPCore (a b) :precision binary64 -1.0)
double code(double a, double b) {
return -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = -1.0d0
end function
public static double code(double a, double b) {
return -1.0;
}
def code(a, b): return -1.0
function code(a, b) return -1.0 end
function tmp = code(a, b) tmp = -1.0; end
code[a_, b_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 74.5%
associate--l+74.5%
+-commutative74.5%
+-commutative74.5%
sub-neg74.5%
associate-+l+74.5%
+-commutative74.5%
associate-+l+74.5%
Simplified77.2%
Taylor expanded in a around 0 71.2%
Taylor expanded in b around 0 25.2%
herbie shell --seed 2024158
(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))