
(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 11 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.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%
sub-neg0.0%
Simplified7.5%
Taylor expanded in b around 0 34.6%
Taylor expanded in a around 0 92.8%
unpow292.8%
Applied egg-rr92.8%
Final simplification98.0%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e-6) (+ -1.0 (* (* a a) (+ 4.0 (* a (* a (+ 1.0 (/ 4.0 a))))))) (+ -1.0 (+ (* (* b b) 4.0) (pow b 4.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e-6) {
tmp = -1.0 + ((a * a) * (4.0 + (a * (a * (1.0 + (4.0 / a))))));
} else {
tmp = -1.0 + (((b * b) * 4.0) + 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) <= 1d-6) then
tmp = (-1.0d0) + ((a * a) * (4.0d0 + (a * (a * (1.0d0 + (4.0d0 / a))))))
else
tmp = (-1.0d0) + (((b * b) * 4.0d0) + (b ** 4.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 1e-6) {
tmp = -1.0 + ((a * a) * (4.0 + (a * (a * (1.0 + (4.0 / a))))));
} else {
tmp = -1.0 + (((b * b) * 4.0) + Math.pow(b, 4.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 1e-6: tmp = -1.0 + ((a * a) * (4.0 + (a * (a * (1.0 + (4.0 / a)))))) else: tmp = -1.0 + (((b * b) * 4.0) + math.pow(b, 4.0)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1e-6) tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(4.0 + Float64(a * Float64(a * Float64(1.0 + Float64(4.0 / a))))))); else tmp = Float64(-1.0 + Float64(Float64(Float64(b * b) * 4.0) + (b ^ 4.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 1e-6) tmp = -1.0 + ((a * a) * (4.0 + (a * (a * (1.0 + (4.0 / a)))))); else tmp = -1.0 + (((b * b) * 4.0) + (b ^ 4.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e-6], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * N[(a * N[(1.0 + N[(4.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{-6}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a \cdot \left(1 + \frac{4}{a}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(\left(b \cdot b\right) \cdot 4 + {b}^{4}\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 9.99999999999999955e-7Initial program 83.8%
sub-neg83.8%
Simplified83.8%
Taylor expanded in b around 0 83.8%
Taylor expanded in a around 0 99.9%
unpow299.9%
Applied egg-rr99.9%
Taylor expanded in a around inf 100.0%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
if 9.99999999999999955e-7 < (*.f64 b b) Initial program 62.4%
associate--l+62.4%
+-commutative62.4%
+-commutative62.4%
sub-neg62.4%
associate-+l+62.4%
+-commutative62.4%
fma-define62.4%
Simplified69.0%
Taylor expanded in a around 0 89.7%
unpow289.7%
Applied egg-rr89.7%
Final simplification95.1%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e+26) (+ -1.0 (* (* a a) (+ 4.0 (* a (* a (+ 1.0 (/ 4.0 a))))))) (+ -1.0 (pow b 4.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+26) {
tmp = -1.0 + ((a * a) * (4.0 + (a * (a * (1.0 + (4.0 / a))))));
} else {
tmp = -1.0 + pow(b, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 2d+26) then
tmp = (-1.0d0) + ((a * a) * (4.0d0 + (a * (a * (1.0d0 + (4.0d0 / a))))))
else
tmp = (-1.0d0) + (b ** 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+26) {
tmp = -1.0 + ((a * a) * (4.0 + (a * (a * (1.0 + (4.0 / a))))));
} else {
tmp = -1.0 + Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2e+26: tmp = -1.0 + ((a * a) * (4.0 + (a * (a * (1.0 + (4.0 / a)))))) else: tmp = -1.0 + math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e+26) tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(4.0 + Float64(a * Float64(a * Float64(1.0 + Float64(4.0 / a))))))); else tmp = Float64(-1.0 + (b ^ 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2e+26) tmp = -1.0 + ((a * a) * (4.0 + (a * (a * (1.0 + (4.0 / a)))))); else tmp = -1.0 + (b ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e+26], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * N[(a * N[(1.0 + N[(4.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+26}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a \cdot \left(1 + \frac{4}{a}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + {b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 2.0000000000000001e26Initial program 84.6%
sub-neg84.6%
Simplified84.6%
Taylor expanded in b around 0 81.9%
Taylor expanded in a around 0 97.2%
unpow297.2%
Applied egg-rr97.2%
Taylor expanded in a around inf 97.2%
associate-*r/97.2%
metadata-eval97.2%
Simplified97.2%
if 2.0000000000000001e26 < (*.f64 b b) Initial program 60.0%
sub-neg60.0%
Simplified64.5%
Taylor expanded in b around inf 91.6%
Final simplification94.7%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e+26) (+ -1.0 (* (* a a) (+ 4.0 (* a (* a (+ 1.0 (/ 4.0 a))))))) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+26) {
tmp = -1.0 + ((a * a) * (4.0 + (a * (a * (1.0 + (4.0 / a))))));
} else {
tmp = pow(b, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 2d+26) then
tmp = (-1.0d0) + ((a * a) * (4.0d0 + (a * (a * (1.0d0 + (4.0d0 / a))))))
else
tmp = b ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+26) {
tmp = -1.0 + ((a * a) * (4.0 + (a * (a * (1.0 + (4.0 / a))))));
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2e+26: tmp = -1.0 + ((a * a) * (4.0 + (a * (a * (1.0 + (4.0 / a)))))) else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e+26) tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(4.0 + Float64(a * Float64(a * Float64(1.0 + Float64(4.0 / a))))))); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2e+26) tmp = -1.0 + ((a * a) * (4.0 + (a * (a * (1.0 + (4.0 / a)))))); else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e+26], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * N[(a * N[(1.0 + N[(4.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+26}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a \cdot \left(1 + \frac{4}{a}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 2.0000000000000001e26Initial program 84.6%
sub-neg84.6%
Simplified84.6%
Taylor expanded in b around 0 81.9%
Taylor expanded in a around 0 97.2%
unpow297.2%
Applied egg-rr97.2%
Taylor expanded in a around inf 97.2%
associate-*r/97.2%
metadata-eval97.2%
Simplified97.2%
if 2.0000000000000001e26 < (*.f64 b b) Initial program 60.0%
sub-neg60.0%
Simplified64.5%
Taylor expanded in b around inf 91.6%
Taylor expanded in b around inf 91.6%
Final simplification94.7%
(FPCore (a b) :precision binary64 (if (<= (* b b) 8.5e+295) (+ -1.0 (* (* a a) (+ 4.0 (* a (* a (+ 1.0 (/ 4.0 a))))))) (* (* b b) 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 8.5e+295) {
tmp = -1.0 + ((a * a) * (4.0 + (a * (a * (1.0 + (4.0 / a))))));
} else {
tmp = (b * 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) <= 8.5d+295) then
tmp = (-1.0d0) + ((a * a) * (4.0d0 + (a * (a * (1.0d0 + (4.0d0 / a))))))
else
tmp = (b * b) * 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 8.5e+295) {
tmp = -1.0 + ((a * a) * (4.0 + (a * (a * (1.0 + (4.0 / a))))));
} else {
tmp = (b * b) * 4.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 8.5e+295: tmp = -1.0 + ((a * a) * (4.0 + (a * (a * (1.0 + (4.0 / a)))))) else: tmp = (b * b) * 4.0 return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 8.5e+295) tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(4.0 + Float64(a * Float64(a * Float64(1.0 + Float64(4.0 / a))))))); else tmp = Float64(Float64(b * b) * 4.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 8.5e+295) tmp = -1.0 + ((a * a) * (4.0 + (a * (a * (1.0 + (4.0 / a)))))); else tmp = (b * b) * 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 8.5e+295], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * N[(a * N[(1.0 + N[(4.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 8.5 \cdot 10^{+295}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a \cdot \left(1 + \frac{4}{a}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 4\\
\end{array}
\end{array}
if (*.f64 b b) < 8.5000000000000003e295Initial program 79.3%
sub-neg79.3%
Simplified79.8%
Taylor expanded in b around 0 67.2%
Taylor expanded in a around 0 83.2%
unpow283.2%
Applied egg-rr83.2%
Taylor expanded in a around inf 83.2%
associate-*r/83.2%
metadata-eval83.2%
Simplified83.2%
if 8.5000000000000003e295 < (*.f64 b b) Initial program 56.5%
associate--l+56.5%
+-commutative56.5%
+-commutative56.5%
sub-neg56.5%
associate-+l+56.5%
+-commutative56.5%
fma-define56.5%
Simplified56.5%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 92.9%
Taylor expanded in b around inf 92.9%
unpow2100.0%
Applied egg-rr92.9%
Final simplification85.5%
(FPCore (a b) :precision binary64 (if (<= (* b b) 8.5e+295) (+ (* (* a a) (+ 4.0 (* a (+ a 4.0)))) -1.0) (* (* b b) 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 8.5e+295) {
tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0;
} else {
tmp = (b * 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) <= 8.5d+295) then
tmp = ((a * a) * (4.0d0 + (a * (a + 4.0d0)))) + (-1.0d0)
else
tmp = (b * b) * 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 8.5e+295) {
tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0;
} else {
tmp = (b * b) * 4.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 8.5e+295: tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0 else: tmp = (b * b) * 4.0 return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 8.5e+295) tmp = Float64(Float64(Float64(a * a) * Float64(4.0 + Float64(a * Float64(a + 4.0)))) + -1.0); else tmp = Float64(Float64(b * b) * 4.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 8.5e+295) tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0; else tmp = (b * b) * 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 8.5e+295], N[(N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * N[(a + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 8.5 \cdot 10^{+295}:\\
\;\;\;\;\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\\
\end{array}
\end{array}
if (*.f64 b b) < 8.5000000000000003e295Initial program 79.3%
sub-neg79.3%
Simplified79.8%
Taylor expanded in b around 0 67.2%
Taylor expanded in a around 0 83.2%
unpow283.2%
Applied egg-rr83.2%
if 8.5000000000000003e295 < (*.f64 b b) Initial program 56.5%
associate--l+56.5%
+-commutative56.5%
+-commutative56.5%
sub-neg56.5%
associate-+l+56.5%
+-commutative56.5%
fma-define56.5%
Simplified56.5%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 92.9%
Taylor expanded in b around inf 92.9%
unpow2100.0%
Applied egg-rr92.9%
Final simplification85.5%
(FPCore (a b) :precision binary64 (if (<= (* b b) 8.5e+295) (+ -1.0 (* (* a a) (+ (* a a) 4.0))) (* (* b b) 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 8.5e+295) {
tmp = -1.0 + ((a * a) * ((a * a) + 4.0));
} else {
tmp = (b * 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) <= 8.5d+295) then
tmp = (-1.0d0) + ((a * a) * ((a * a) + 4.0d0))
else
tmp = (b * b) * 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 8.5e+295) {
tmp = -1.0 + ((a * a) * ((a * a) + 4.0));
} else {
tmp = (b * b) * 4.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 8.5e+295: tmp = -1.0 + ((a * a) * ((a * a) + 4.0)) else: tmp = (b * b) * 4.0 return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 8.5e+295) tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(Float64(a * a) + 4.0))); else tmp = Float64(Float64(b * b) * 4.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 8.5e+295) tmp = -1.0 + ((a * a) * ((a * a) + 4.0)); else tmp = (b * b) * 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 8.5e+295], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 8.5 \cdot 10^{+295}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a + 4\right)\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 4\\
\end{array}
\end{array}
if (*.f64 b b) < 8.5000000000000003e295Initial program 79.3%
sub-neg79.3%
Simplified79.8%
Taylor expanded in b around 0 67.2%
Taylor expanded in a around 0 83.2%
unpow283.2%
Applied egg-rr83.2%
Taylor expanded in a around inf 82.1%
if 8.5000000000000003e295 < (*.f64 b b) Initial program 56.5%
associate--l+56.5%
+-commutative56.5%
+-commutative56.5%
sub-neg56.5%
associate-+l+56.5%
+-commutative56.5%
fma-define56.5%
Simplified56.5%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 92.9%
Taylor expanded in b around inf 92.9%
unpow2100.0%
Applied egg-rr92.9%
Final simplification84.7%
(FPCore (a b) :precision binary64 (if (<= a 1.7e+83) (+ -1.0 (* (* b b) 4.0)) (+ -1.0 (* (* a a) (+ 4.0 (* a 4.0))))))
double code(double a, double b) {
double tmp;
if (a <= 1.7e+83) {
tmp = -1.0 + ((b * b) * 4.0);
} else {
tmp = -1.0 + ((a * a) * (4.0 + (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 <= 1.7d+83) then
tmp = (-1.0d0) + ((b * b) * 4.0d0)
else
tmp = (-1.0d0) + ((a * a) * (4.0d0 + (a * 4.0d0)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= 1.7e+83) {
tmp = -1.0 + ((b * b) * 4.0);
} else {
tmp = -1.0 + ((a * a) * (4.0 + (a * 4.0)));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= 1.7e+83: tmp = -1.0 + ((b * b) * 4.0) else: tmp = -1.0 + ((a * a) * (4.0 + (a * 4.0))) return tmp
function code(a, b) tmp = 0.0 if (a <= 1.7e+83) tmp = Float64(-1.0 + Float64(Float64(b * b) * 4.0)); else tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(4.0 + Float64(a * 4.0)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= 1.7e+83) tmp = -1.0 + ((b * b) * 4.0); else tmp = -1.0 + ((a * a) * (4.0 + (a * 4.0))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, 1.7e+83], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.7 \cdot 10^{+83}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot 4\right)\\
\end{array}
\end{array}
if a < 1.6999999999999999e83Initial program 77.5%
associate--l+77.5%
+-commutative77.5%
+-commutative77.5%
sub-neg77.5%
associate-+l+77.5%
+-commutative77.5%
fma-define77.5%
Simplified77.5%
Taylor expanded in a around 0 79.5%
Taylor expanded in b around 0 59.2%
unpow279.5%
Applied egg-rr59.2%
if 1.6999999999999999e83 < a Initial program 60.0%
sub-neg60.0%
Simplified60.0%
Taylor expanded in b around 0 100.0%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Applied egg-rr100.0%
Taylor expanded in a around 0 90.3%
Final simplification65.9%
(FPCore (a b) :precision binary64 (if (<= (* b b) 8.2e-7) -1.0 (* (* b b) 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 8.2e-7) {
tmp = -1.0;
} else {
tmp = (b * 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) <= 8.2d-7) then
tmp = -1.0d0
else
tmp = (b * b) * 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 8.2e-7) {
tmp = -1.0;
} else {
tmp = (b * b) * 4.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 8.2e-7: tmp = -1.0 else: tmp = (b * b) * 4.0 return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 8.2e-7) tmp = -1.0; else tmp = Float64(Float64(b * b) * 4.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 8.2e-7) tmp = -1.0; else tmp = (b * b) * 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 8.2e-7], -1.0, N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 8.2 \cdot 10^{-7}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 4\\
\end{array}
\end{array}
if (*.f64 b b) < 8.1999999999999998e-7Initial program 84.4%
sub-neg84.4%
Simplified84.4%
Taylor expanded in a around inf 99.1%
associate-*r/99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in a around 0 53.1%
if 8.1999999999999998e-7 < (*.f64 b b) Initial program 61.8%
associate--l+61.8%
+-commutative61.8%
+-commutative61.8%
sub-neg61.8%
associate-+l+61.8%
+-commutative61.8%
fma-define61.8%
Simplified68.5%
Taylor expanded in a around 0 88.9%
Taylor expanded in b around 0 50.6%
Taylor expanded in b around inf 50.6%
unpow288.9%
Applied egg-rr50.6%
Final simplification51.9%
(FPCore (a b) :precision binary64 (+ -1.0 (* (* b b) 4.0)))
double code(double a, double b) {
return -1.0 + ((b * b) * 4.0);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (-1.0d0) + ((b * b) * 4.0d0)
end function
public static double code(double a, double b) {
return -1.0 + ((b * b) * 4.0);
}
def code(a, b): return -1.0 + ((b * b) * 4.0)
function code(a, b) return Float64(-1.0 + Float64(Float64(b * b) * 4.0)) end
function tmp = code(a, b) tmp = -1.0 + ((b * b) * 4.0); end
code[a_, b_] := N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 + \left(b \cdot b\right) \cdot 4
\end{array}
Initial program 73.7%
associate--l+73.7%
+-commutative73.7%
+-commutative73.7%
sub-neg73.7%
associate-+l+73.7%
+-commutative73.7%
fma-define73.7%
Simplified76.9%
Taylor expanded in a around 0 70.0%
Taylor expanded in b around 0 51.9%
unpow270.0%
Applied egg-rr51.9%
Final simplification51.9%
(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 73.7%
sub-neg73.7%
Simplified75.7%
Taylor expanded in a around inf 72.2%
associate-*r/72.2%
metadata-eval72.2%
Simplified72.2%
Taylor expanded in a around 0 28.3%
herbie shell --seed 2024110
(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))