
(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 (<= (* b b) 5e-64)
(+ -1.0 (* (pow a 4.0) (+ 1.0 (/ 4.0 a))))
(+
-1.0
(+
(pow a 4.0)
(* (pow b 2.0) (+ 4.0 (+ (pow b 2.0) (* 2.0 (pow a 2.0)))))))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e-64) {
tmp = -1.0 + (pow(a, 4.0) * (1.0 + (4.0 / a)));
} else {
tmp = -1.0 + (pow(a, 4.0) + (pow(b, 2.0) * (4.0 + (pow(b, 2.0) + (2.0 * pow(a, 2.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-64) then
tmp = (-1.0d0) + ((a ** 4.0d0) * (1.0d0 + (4.0d0 / a)))
else
tmp = (-1.0d0) + ((a ** 4.0d0) + ((b ** 2.0d0) * (4.0d0 + ((b ** 2.0d0) + (2.0d0 * (a ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 5e-64) {
tmp = -1.0 + (Math.pow(a, 4.0) * (1.0 + (4.0 / a)));
} else {
tmp = -1.0 + (Math.pow(a, 4.0) + (Math.pow(b, 2.0) * (4.0 + (Math.pow(b, 2.0) + (2.0 * Math.pow(a, 2.0))))));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e-64: tmp = -1.0 + (math.pow(a, 4.0) * (1.0 + (4.0 / a))) else: tmp = -1.0 + (math.pow(a, 4.0) + (math.pow(b, 2.0) * (4.0 + (math.pow(b, 2.0) + (2.0 * math.pow(a, 2.0)))))) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e-64) tmp = Float64(-1.0 + Float64((a ^ 4.0) * Float64(1.0 + Float64(4.0 / a)))); else tmp = Float64(-1.0 + Float64((a ^ 4.0) + Float64((b ^ 2.0) * Float64(4.0 + Float64((b ^ 2.0) + Float64(2.0 * (a ^ 2.0))))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5e-64) tmp = -1.0 + ((a ^ 4.0) * (1.0 + (4.0 / a))); else tmp = -1.0 + ((a ^ 4.0) + ((b ^ 2.0) * (4.0 + ((b ^ 2.0) + (2.0 * (a ^ 2.0)))))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e-64], N[(-1.0 + N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 + N[(4.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[Power[a, 4.0], $MachinePrecision] + N[(N[Power[b, 2.0], $MachinePrecision] * N[(4.0 + N[(N[Power[b, 2.0], $MachinePrecision] + N[(2.0 * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{-64}:\\
\;\;\;\;-1 + {a}^{4} \cdot \left(1 + \frac{4}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left({a}^{4} + {b}^{2} \cdot \left(4 + \left({b}^{2} + 2 \cdot {a}^{2}\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 5.00000000000000033e-64Initial program 82.4%
sub-neg82.4%
+-commutative82.4%
fma-define82.4%
+-commutative82.4%
associate-*l*82.4%
cancel-sign-sub-inv82.4%
metadata-eval82.4%
fma-define82.4%
metadata-eval82.4%
Simplified82.4%
Taylor expanded in a around inf 99.9%
associate-*r/99.9%
metadata-eval99.9%
Simplified99.9%
if 5.00000000000000033e-64 < (*.f64 b b) Initial program 65.9%
sub-neg65.9%
+-commutative65.9%
fma-define67.9%
+-commutative67.9%
associate-*l*67.9%
cancel-sign-sub-inv67.9%
metadata-eval67.9%
fma-define67.9%
metadata-eval67.9%
Simplified67.9%
Taylor expanded in a around 0 57.1%
+-commutative57.1%
distribute-lft-in57.1%
associate-*r*57.1%
*-commutative57.1%
associate-*r*57.1%
pow-sqr57.1%
metadata-eval57.1%
fma-define57.1%
unpow257.1%
unpow257.1%
swap-sqr68.0%
unpow268.0%
*-commutative68.0%
Simplified68.0%
unpow268.0%
*-commutative68.0%
*-commutative68.0%
Applied egg-rr68.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 99.9%
Final simplification99.9%
(FPCore (a b) :precision binary64 (+ (+ (* 4.0 (pow b 2.0)) (+ (pow b 4.0) (+ (* 2.0 (pow (* b a) 2.0)) (pow a 4.0)))) -1.0))
double code(double a, double b) {
return ((4.0 * pow(b, 2.0)) + (pow(b, 4.0) + ((2.0 * pow((b * a), 2.0)) + pow(a, 4.0)))) + -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((4.0d0 * (b ** 2.0d0)) + ((b ** 4.0d0) + ((2.0d0 * ((b * a) ** 2.0d0)) + (a ** 4.0d0)))) + (-1.0d0)
end function
public static double code(double a, double b) {
return ((4.0 * Math.pow(b, 2.0)) + (Math.pow(b, 4.0) + ((2.0 * Math.pow((b * a), 2.0)) + Math.pow(a, 4.0)))) + -1.0;
}
def code(a, b): return ((4.0 * math.pow(b, 2.0)) + (math.pow(b, 4.0) + ((2.0 * math.pow((b * a), 2.0)) + math.pow(a, 4.0)))) + -1.0
function code(a, b) return Float64(Float64(Float64(4.0 * (b ^ 2.0)) + Float64((b ^ 4.0) + Float64(Float64(2.0 * (Float64(b * a) ^ 2.0)) + (a ^ 4.0)))) + -1.0) end
function tmp = code(a, b) tmp = ((4.0 * (b ^ 2.0)) + ((b ^ 4.0) + ((2.0 * ((b * a) ^ 2.0)) + (a ^ 4.0)))) + -1.0; end
code[a_, b_] := N[(N[(N[(4.0 * N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[Power[b, 4.0], $MachinePrecision] + N[(N[(2.0 * N[Power[N[(b * a), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\left(4 \cdot {b}^{2} + \left({b}^{4} + \left(2 \cdot {\left(b \cdot a\right)}^{2} + {a}^{4}\right)\right)\right) + -1
\end{array}
Initial program 72.9%
sub-neg72.9%
+-commutative72.9%
fma-define74.1%
+-commutative74.1%
associate-*l*74.1%
cancel-sign-sub-inv74.1%
metadata-eval74.1%
fma-define74.1%
metadata-eval74.1%
Simplified74.1%
Taylor expanded in a around 0 67.9%
+-commutative67.9%
distribute-lft-in62.8%
associate-*r*62.8%
*-commutative62.8%
associate-*r*62.8%
pow-sqr62.9%
metadata-eval62.9%
fma-define62.9%
unpow262.9%
unpow262.9%
swap-sqr74.2%
unpow274.2%
*-commutative74.2%
Simplified74.2%
unpow274.2%
*-commutative74.2%
*-commutative74.2%
Applied egg-rr74.2%
Taylor expanded in a around 0 99.7%
fma-undefine99.7%
pow299.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (a b)
:precision binary64
(let* ((t_0
(-
(pow (+ (* b b) (* a a)) 2.0)
(* 4.0 (- (* (* b b) (+ -1.0 (* a 3.0))) (* (* a a) (+ a 1.0)))))))
(if (<= t_0 INFINITY)
(+ -1.0 t_0)
(+
-1.0
(* (pow a 4.0) (+ 1.0 (/ (+ 4.0 (* 2.0 (/ (pow b 2.0) a))) a)))))))
double code(double a, double b) {
double t_0 = pow(((b * b) + (a * a)), 2.0) - (4.0 * (((b * b) * (-1.0 + (a * 3.0))) - ((a * a) * (a + 1.0))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = -1.0 + t_0;
} else {
tmp = -1.0 + (pow(a, 4.0) * (1.0 + ((4.0 + (2.0 * (pow(b, 2.0) / a))) / a)));
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = Math.pow(((b * b) + (a * a)), 2.0) - (4.0 * (((b * b) * (-1.0 + (a * 3.0))) - ((a * a) * (a + 1.0))));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = -1.0 + t_0;
} else {
tmp = -1.0 + (Math.pow(a, 4.0) * (1.0 + ((4.0 + (2.0 * (Math.pow(b, 2.0) / a))) / a)));
}
return tmp;
}
def code(a, b): t_0 = math.pow(((b * b) + (a * a)), 2.0) - (4.0 * (((b * b) * (-1.0 + (a * 3.0))) - ((a * a) * (a + 1.0)))) tmp = 0 if t_0 <= math.inf: tmp = -1.0 + t_0 else: tmp = -1.0 + (math.pow(a, 4.0) * (1.0 + ((4.0 + (2.0 * (math.pow(b, 2.0) / a))) / a))) return tmp
function code(a, b) t_0 = Float64((Float64(Float64(b * b) + Float64(a * a)) ^ 2.0) - Float64(4.0 * Float64(Float64(Float64(b * b) * Float64(-1.0 + Float64(a * 3.0))) - Float64(Float64(a * a) * Float64(a + 1.0))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(-1.0 + t_0); else tmp = Float64(-1.0 + Float64((a ^ 4.0) * Float64(1.0 + Float64(Float64(4.0 + Float64(2.0 * Float64((b ^ 2.0) / a))) / a)))); end return tmp end
function tmp_2 = code(a, b) t_0 = (((b * b) + (a * a)) ^ 2.0) - (4.0 * (((b * b) * (-1.0 + (a * 3.0))) - ((a * a) * (a + 1.0)))); tmp = 0.0; if (t_0 <= Inf) tmp = -1.0 + t_0; else tmp = -1.0 + ((a ^ 4.0) * (1.0 + ((4.0 + (2.0 * ((b ^ 2.0) / a))) / a))); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[Power[N[(N[(b * b), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] - N[(4.0 * N[(N[(N[(b * b), $MachinePrecision] * N[(-1.0 + N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(a * a), $MachinePrecision] * N[(a + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(-1.0 + t$95$0), $MachinePrecision], N[(-1.0 + N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 + N[(N[(4.0 + N[(2.0 * N[(N[Power[b, 2.0], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(b \cdot b + a \cdot a\right)}^{2} - 4 \cdot \left(\left(b \cdot b\right) \cdot \left(-1 + a \cdot 3\right) - \left(a \cdot a\right) \cdot \left(a + 1\right)\right)\\
\mathbf{if}\;t\_0 \leq \infty:\\
\;\;\;\;-1 + t\_0\\
\mathbf{else}:\\
\;\;\;\;-1 + {a}^{4} \cdot \left(1 + \frac{4 + 2 \cdot \frac{{b}^{2}}{a}}{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.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%
+-commutative0.0%
fma-define4.3%
+-commutative4.3%
associate-*l*4.3%
cancel-sign-sub-inv4.3%
metadata-eval4.3%
fma-define4.3%
metadata-eval4.3%
Simplified4.3%
Taylor expanded in a around -inf 100.0%
Taylor expanded in b around inf 100.0%
Final simplification99.9%
(FPCore (a b)
:precision binary64
(let* ((t_0
(-
(pow (+ (* b b) (* a a)) 2.0)
(* 4.0 (- (* (* b b) (+ -1.0 (* a 3.0))) (* (* a a) (+ a 1.0)))))))
(if (<= t_0 INFINITY) (+ -1.0 t_0) (+ (pow a 4.0) -1.0))))
double code(double a, double b) {
double t_0 = pow(((b * b) + (a * a)), 2.0) - (4.0 * (((b * b) * (-1.0 + (a * 3.0))) - ((a * a) * (a + 1.0))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = -1.0 + t_0;
} else {
tmp = pow(a, 4.0) + -1.0;
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = Math.pow(((b * b) + (a * a)), 2.0) - (4.0 * (((b * b) * (-1.0 + (a * 3.0))) - ((a * a) * (a + 1.0))));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = -1.0 + t_0;
} else {
tmp = Math.pow(a, 4.0) + -1.0;
}
return tmp;
}
def code(a, b): t_0 = math.pow(((b * b) + (a * a)), 2.0) - (4.0 * (((b * b) * (-1.0 + (a * 3.0))) - ((a * a) * (a + 1.0)))) tmp = 0 if t_0 <= math.inf: tmp = -1.0 + t_0 else: tmp = math.pow(a, 4.0) + -1.0 return tmp
function code(a, b) t_0 = Float64((Float64(Float64(b * b) + Float64(a * a)) ^ 2.0) - Float64(4.0 * Float64(Float64(Float64(b * b) * Float64(-1.0 + Float64(a * 3.0))) - Float64(Float64(a * a) * Float64(a + 1.0))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(-1.0 + t_0); else tmp = Float64((a ^ 4.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) t_0 = (((b * b) + (a * a)) ^ 2.0) - (4.0 * (((b * b) * (-1.0 + (a * 3.0))) - ((a * a) * (a + 1.0)))); tmp = 0.0; if (t_0 <= Inf) tmp = -1.0 + t_0; else tmp = (a ^ 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[Power[N[(N[(b * b), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] - N[(4.0 * N[(N[(N[(b * b), $MachinePrecision] * N[(-1.0 + N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(a * a), $MachinePrecision] * N[(a + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(-1.0 + t$95$0), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(b \cdot b + a \cdot a\right)}^{2} - 4 \cdot \left(\left(b \cdot b\right) \cdot \left(-1 + a \cdot 3\right) - \left(a \cdot a\right) \cdot \left(a + 1\right)\right)\\
\mathbf{if}\;t\_0 \leq \infty:\\
\;\;\;\;-1 + t\_0\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} + -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%
+-commutative0.0%
fma-define4.3%
+-commutative4.3%
associate-*l*4.3%
cancel-sign-sub-inv4.3%
metadata-eval4.3%
fma-define4.3%
metadata-eval4.3%
Simplified4.3%
Taylor expanded in a around inf 93.1%
Final simplification98.0%
(FPCore (a b) :precision binary64 (if (<= b 1.95e+17) (+ -1.0 (* (pow a 4.0) (+ 1.0 (/ 4.0 a)))) (+ (pow b 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if (b <= 1.95e+17) {
tmp = -1.0 + (pow(a, 4.0) * (1.0 + (4.0 / a)));
} else {
tmp = 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 <= 1.95d+17) then
tmp = (-1.0d0) + ((a ** 4.0d0) * (1.0d0 + (4.0d0 / a)))
else
tmp = (b ** 4.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 1.95e+17) {
tmp = -1.0 + (Math.pow(a, 4.0) * (1.0 + (4.0 / a)));
} else {
tmp = Math.pow(b, 4.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 1.95e+17: tmp = -1.0 + (math.pow(a, 4.0) * (1.0 + (4.0 / a))) else: tmp = math.pow(b, 4.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (b <= 1.95e+17) tmp = Float64(-1.0 + Float64((a ^ 4.0) * Float64(1.0 + Float64(4.0 / a)))); else tmp = Float64((b ^ 4.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 1.95e+17) tmp = -1.0 + ((a ^ 4.0) * (1.0 + (4.0 / a))); else tmp = (b ^ 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 1.95e+17], N[(-1.0 + N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 + N[(4.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.95 \cdot 10^{+17}:\\
\;\;\;\;-1 + {a}^{4} \cdot \left(1 + \frac{4}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;{b}^{4} + -1\\
\end{array}
\end{array}
if b < 1.95e17Initial program 74.5%
sub-neg74.5%
+-commutative74.5%
fma-define76.0%
+-commutative76.0%
associate-*l*76.0%
cancel-sign-sub-inv76.0%
metadata-eval76.0%
fma-define76.0%
metadata-eval76.0%
Simplified76.0%
Taylor expanded in a around inf 78.6%
associate-*r/78.6%
metadata-eval78.6%
Simplified78.6%
if 1.95e17 < b Initial program 68.5%
sub-neg68.5%
+-commutative68.5%
fma-define68.5%
+-commutative68.5%
associate-*l*68.5%
cancel-sign-sub-inv68.5%
metadata-eval68.5%
fma-define68.5%
metadata-eval68.5%
Simplified68.5%
Taylor expanded in b around inf 92.4%
Final simplification82.2%
(FPCore (a b) :precision binary64 (if (<= b 5.2e+16) (+ -1.0 (* (pow a 3.0) (+ 4.0 a))) (+ (pow b 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if (b <= 5.2e+16) {
tmp = -1.0 + (pow(a, 3.0) * (4.0 + a));
} else {
tmp = 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 <= 5.2d+16) then
tmp = (-1.0d0) + ((a ** 3.0d0) * (4.0d0 + a))
else
tmp = (b ** 4.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 5.2e+16) {
tmp = -1.0 + (Math.pow(a, 3.0) * (4.0 + a));
} else {
tmp = Math.pow(b, 4.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 5.2e+16: tmp = -1.0 + (math.pow(a, 3.0) * (4.0 + a)) else: tmp = math.pow(b, 4.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (b <= 5.2e+16) tmp = Float64(-1.0 + Float64((a ^ 3.0) * Float64(4.0 + a))); else tmp = Float64((b ^ 4.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 5.2e+16) tmp = -1.0 + ((a ^ 3.0) * (4.0 + a)); else tmp = (b ^ 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 5.2e+16], N[(-1.0 + N[(N[Power[a, 3.0], $MachinePrecision] * N[(4.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5.2 \cdot 10^{+16}:\\
\;\;\;\;-1 + {a}^{3} \cdot \left(4 + a\right)\\
\mathbf{else}:\\
\;\;\;\;{b}^{4} + -1\\
\end{array}
\end{array}
if b < 5.2e16Initial program 74.5%
sub-neg74.5%
+-commutative74.5%
fma-define76.0%
+-commutative76.0%
associate-*l*76.0%
cancel-sign-sub-inv76.0%
metadata-eval76.0%
fma-define76.0%
metadata-eval76.0%
Simplified76.0%
Taylor expanded in a around inf 78.6%
associate-*r/78.6%
metadata-eval78.6%
Simplified78.6%
Taylor expanded in a around 0 78.6%
if 5.2e16 < b Initial program 68.5%
sub-neg68.5%
+-commutative68.5%
fma-define68.5%
+-commutative68.5%
associate-*l*68.5%
cancel-sign-sub-inv68.5%
metadata-eval68.5%
fma-define68.5%
metadata-eval68.5%
Simplified68.5%
Taylor expanded in b around inf 92.4%
Final simplification82.2%
(FPCore (a b) :precision binary64 (if (<= b 1.55e+17) (+ (pow a 4.0) -1.0) (+ (pow b 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if (b <= 1.55e+17) {
tmp = pow(a, 4.0) + -1.0;
} else {
tmp = 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 <= 1.55d+17) then
tmp = (a ** 4.0d0) + (-1.0d0)
else
tmp = (b ** 4.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 1.55e+17) {
tmp = Math.pow(a, 4.0) + -1.0;
} else {
tmp = Math.pow(b, 4.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 1.55e+17: tmp = math.pow(a, 4.0) + -1.0 else: tmp = math.pow(b, 4.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (b <= 1.55e+17) tmp = Float64((a ^ 4.0) + -1.0); else tmp = Float64((b ^ 4.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 1.55e+17) tmp = (a ^ 4.0) + -1.0; else tmp = (b ^ 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 1.55e+17], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.55 \cdot 10^{+17}:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4} + -1\\
\end{array}
\end{array}
if b < 1.55e17Initial program 74.5%
sub-neg74.5%
+-commutative74.5%
fma-define76.0%
+-commutative76.0%
associate-*l*76.0%
cancel-sign-sub-inv76.0%
metadata-eval76.0%
fma-define76.0%
metadata-eval76.0%
Simplified76.0%
Taylor expanded in a around inf 78.3%
if 1.55e17 < b Initial program 68.5%
sub-neg68.5%
+-commutative68.5%
fma-define68.5%
+-commutative68.5%
associate-*l*68.5%
cancel-sign-sub-inv68.5%
metadata-eval68.5%
fma-define68.5%
metadata-eval68.5%
Simplified68.5%
Taylor expanded in b around inf 92.4%
Final simplification82.0%
(FPCore (a b) :precision binary64 (+ (pow a 4.0) -1.0))
double code(double a, double b) {
return pow(a, 4.0) + -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (a ** 4.0d0) + (-1.0d0)
end function
public static double code(double a, double b) {
return Math.pow(a, 4.0) + -1.0;
}
def code(a, b): return math.pow(a, 4.0) + -1.0
function code(a, b) return Float64((a ^ 4.0) + -1.0) end
function tmp = code(a, b) tmp = (a ^ 4.0) + -1.0; end
code[a_, b_] := N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
{a}^{4} + -1
\end{array}
Initial program 72.9%
sub-neg72.9%
+-commutative72.9%
fma-define74.1%
+-commutative74.1%
associate-*l*74.1%
cancel-sign-sub-inv74.1%
metadata-eval74.1%
fma-define74.1%
metadata-eval74.1%
Simplified74.1%
Taylor expanded in a around inf 67.0%
Final simplification67.0%
herbie shell --seed 2024075
(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))