
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ 3.0 a))))) 1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * (((a * a) * (1.0d0 - a)) + ((b * b) * (3.0d0 + a))))) - 1.0d0
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + Float64(Float64(b * b) * Float64(3.0 + a))))) - 1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0; end
code[a_, b_] := N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(3.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 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) (+ 3.0 a))))) 1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * (((a * a) * (1.0d0 - a)) + ((b * b) * (3.0d0 + a))))) - 1.0d0
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + Float64(Float64(b * b) * Float64(3.0 + a))))) - 1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0; end
code[a_, b_] := N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(3.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1
\end{array}
(FPCore (a b)
:precision binary64
(if (<=
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))
INFINITY)
(+
(pow (hypot a b) 4.0)
(fma 4.0 (- (fma (* b b) (+ a 3.0) (* a a)) (pow a 3.0)) -1.0))
(+ -1.0 (* (* a a) (* a a)))))
double code(double a, double b) {
double tmp;
if ((pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))))) <= ((double) INFINITY)) {
tmp = pow(hypot(a, b), 4.0) + fma(4.0, (fma((b * b), (a + 3.0), (a * a)) - pow(a, 3.0)), -1.0);
} else {
tmp = -1.0 + ((a * a) * (a * 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(1.0 - a)) + Float64(Float64(b * b) * Float64(a + 3.0))))) <= Inf) tmp = Float64((hypot(a, b) ^ 4.0) + fma(4.0, Float64(fma(Float64(b * b), Float64(a + 3.0), Float64(a * a)) - (a ^ 3.0)), -1.0)); else tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(a * 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[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision] - N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(a * 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(1 - a\right) + \left(b \cdot b\right) \cdot \left(a + 3\right)\right) \leq \infty:\\
\;\;\;\;{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(4, \mathsf{fma}\left(b \cdot b, a + 3, a \cdot a\right) - {a}^{3}, -1\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a\right)\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) < +inf.0Initial program 99.9%
associate--l+99.9%
Simplified100.0%
if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) Initial program 0.0%
sub-neg0.0%
fma-def0.0%
fma-def1.6%
+-commutative1.6%
metadata-eval1.6%
Simplified1.6%
Taylor expanded in b around 0 25.3%
associate-*r*25.3%
unpow225.3%
Simplified25.3%
sqr-pow25.3%
metadata-eval25.3%
pow225.3%
metadata-eval25.3%
pow225.3%
fma-def25.3%
*-commutative25.3%
associate-*l*25.3%
Applied egg-rr25.3%
fma-udef25.3%
distribute-lft-out95.6%
fma-def95.6%
*-commutative95.6%
Applied egg-rr95.6%
Taylor expanded in a around inf 95.6%
unpow295.6%
Simplified95.6%
Final simplification98.9%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))))
(if (<= t_0 INFINITY) (+ t_0 -1.0) (+ -1.0 (* (* a a) (* a a))))))
double code(double a, double b) {
double t_0 = pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0 + -1.0;
} else {
tmp = -1.0 + ((a * a) * (a * 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) * (1.0 - a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 + -1.0;
} else {
tmp = -1.0 + ((a * a) * (a * a));
}
return tmp;
}
def code(a, b): t_0 = math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0)))) tmp = 0 if t_0 <= math.inf: tmp = t_0 + -1.0 else: tmp = -1.0 + ((a * a) * (a * 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(1.0 - a)) + Float64(Float64(b * b) * Float64(a + 3.0))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(t_0 + -1.0); else tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(a * a))); end return tmp end
function tmp_2 = code(a, b) t_0 = (((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0)))); tmp = 0.0; if (t_0 <= Inf) tmp = t_0 + -1.0; else tmp = -1.0 + ((a * a) * (a * 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[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(t$95$0 + -1.0), $MachinePrecision], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(a * 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(1 - a\right) + \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\\
\mathbf{if}\;t_0 \leq \infty:\\
\;\;\;\;t_0 + -1\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a\right)\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) < +inf.0Initial program 99.9%
if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) Initial program 0.0%
sub-neg0.0%
fma-def0.0%
fma-def1.6%
+-commutative1.6%
metadata-eval1.6%
Simplified1.6%
Taylor expanded in b around 0 25.3%
associate-*r*25.3%
unpow225.3%
Simplified25.3%
sqr-pow25.3%
metadata-eval25.3%
pow225.3%
metadata-eval25.3%
pow225.3%
fma-def25.3%
*-commutative25.3%
associate-*l*25.3%
Applied egg-rr25.3%
fma-udef25.3%
distribute-lft-out95.6%
fma-def95.6%
*-commutative95.6%
Applied egg-rr95.6%
Taylor expanded in a around inf 95.6%
unpow295.6%
Simplified95.6%
Final simplification98.8%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+26) (+ -1.0 (* (* a a) (fma a a (* 4.0 (- 1.0 a))))) (+ -1.0 (pow b 4.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+26) {
tmp = -1.0 + ((a * a) * fma(a, a, (4.0 * (1.0 - a))));
} else {
tmp = -1.0 + pow(b, 4.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e+26) tmp = Float64(-1.0 + Float64(Float64(a * a) * fma(a, a, Float64(4.0 * Float64(1.0 - a))))); else tmp = Float64(-1.0 + (b ^ 4.0)); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e+26], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(a * a + N[(4.0 * N[(1.0 - a), $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 5 \cdot 10^{+26}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, 4 \cdot \left(1 - a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + {b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 5.0000000000000001e26Initial program 79.6%
sub-neg79.6%
fma-def79.6%
fma-def79.6%
+-commutative79.6%
metadata-eval79.6%
Simplified79.6%
Taylor expanded in b around 0 79.3%
associate-*r*79.3%
unpow279.3%
Simplified79.3%
sqr-pow79.2%
metadata-eval79.2%
pow279.2%
metadata-eval79.2%
pow279.2%
fma-def79.2%
*-commutative79.2%
associate-*l*79.2%
Applied egg-rr79.2%
fma-udef79.2%
distribute-lft-out98.8%
fma-def98.8%
*-commutative98.8%
Applied egg-rr98.8%
if 5.0000000000000001e26 < (*.f64 b b) Initial program 68.9%
sub-neg68.9%
fma-def68.9%
fma-def69.8%
+-commutative69.8%
metadata-eval69.8%
Simplified69.8%
Taylor expanded in b around inf 96.6%
Final simplification97.9%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+26) (+ -1.0 (* (* a a) (+ (* a a) (* 4.0 (- 1.0 a))))) (+ -1.0 (pow b 4.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+26) {
tmp = -1.0 + ((a * a) * ((a * a) + (4.0 * (1.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) <= 5d+26) then
tmp = (-1.0d0) + ((a * a) * ((a * a) + (4.0d0 * (1.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) <= 5e+26) {
tmp = -1.0 + ((a * a) * ((a * a) + (4.0 * (1.0 - a))));
} else {
tmp = -1.0 + Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e+26: tmp = -1.0 + ((a * a) * ((a * a) + (4.0 * (1.0 - a)))) else: tmp = -1.0 + math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e+26) tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(Float64(a * a) + Float64(4.0 * Float64(1.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) <= 5e+26) tmp = -1.0 + ((a * a) * ((a * a) + (4.0 * (1.0 - a)))); else tmp = -1.0 + (b ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e+26], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + N[(4.0 * N[(1.0 - a), $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 5 \cdot 10^{+26}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a + 4 \cdot \left(1 - a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + {b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 5.0000000000000001e26Initial program 79.6%
sub-neg79.6%
fma-def79.6%
fma-def79.6%
+-commutative79.6%
metadata-eval79.6%
Simplified79.6%
Taylor expanded in b around 0 79.3%
associate-*r*79.3%
unpow279.3%
Simplified79.3%
sqr-pow79.2%
metadata-eval79.2%
pow279.2%
metadata-eval79.2%
pow279.2%
fma-def79.2%
*-commutative79.2%
associate-*l*79.2%
Applied egg-rr79.2%
fma-udef79.2%
distribute-lft-out98.8%
fma-def98.8%
*-commutative98.8%
Applied egg-rr98.8%
fma-udef98.8%
Applied egg-rr98.8%
if 5.0000000000000001e26 < (*.f64 b b) Initial program 68.9%
sub-neg68.9%
fma-def68.9%
fma-def69.8%
+-commutative69.8%
metadata-eval69.8%
Simplified69.8%
Taylor expanded in b around inf 96.6%
Final simplification97.8%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+26) (+ -1.0 (* (* a a) (+ (* a a) (* 4.0 (- 1.0 a))))) (+ -1.0 (* (* b b) (+ (* b b) 12.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+26) {
tmp = -1.0 + ((a * a) * ((a * a) + (4.0 * (1.0 - a))));
} else {
tmp = -1.0 + ((b * b) * ((b * b) + 12.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+26) then
tmp = (-1.0d0) + ((a * a) * ((a * a) + (4.0d0 * (1.0d0 - a))))
else
tmp = (-1.0d0) + ((b * b) * ((b * b) + 12.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+26) {
tmp = -1.0 + ((a * a) * ((a * a) + (4.0 * (1.0 - a))));
} else {
tmp = -1.0 + ((b * b) * ((b * b) + 12.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e+26: tmp = -1.0 + ((a * a) * ((a * a) + (4.0 * (1.0 - a)))) else: tmp = -1.0 + ((b * b) * ((b * b) + 12.0)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e+26) tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(Float64(a * a) + Float64(4.0 * Float64(1.0 - a))))); else tmp = Float64(-1.0 + Float64(Float64(b * b) * Float64(Float64(b * b) + 12.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5e+26) tmp = -1.0 + ((a * a) * ((a * a) + (4.0 * (1.0 - a)))); else tmp = -1.0 + ((b * b) * ((b * b) + 12.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e+26], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + N[(4.0 * N[(1.0 - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{+26}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a + 4 \cdot \left(1 - a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 12\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 5.0000000000000001e26Initial program 79.6%
sub-neg79.6%
fma-def79.6%
fma-def79.6%
+-commutative79.6%
metadata-eval79.6%
Simplified79.6%
Taylor expanded in b around 0 79.3%
associate-*r*79.3%
unpow279.3%
Simplified79.3%
sqr-pow79.2%
metadata-eval79.2%
pow279.2%
metadata-eval79.2%
pow279.2%
fma-def79.2%
*-commutative79.2%
associate-*l*79.2%
Applied egg-rr79.2%
fma-udef79.2%
distribute-lft-out98.8%
fma-def98.8%
*-commutative98.8%
Applied egg-rr98.8%
fma-udef98.8%
Applied egg-rr98.8%
if 5.0000000000000001e26 < (*.f64 b b) Initial program 68.9%
sub-neg68.9%
fma-def68.9%
fma-def69.8%
+-commutative69.8%
metadata-eval69.8%
Simplified69.8%
Taylor expanded in a around 0 63.0%
associate-+r+63.0%
associate-*r*63.0%
distribute-rgt-out82.5%
metadata-eval82.5%
distribute-lft-in82.5%
+-commutative82.5%
unpow282.5%
distribute-lft-in82.5%
metadata-eval82.5%
Simplified82.5%
Taylor expanded in a around 0 96.6%
unpow296.6%
Simplified96.6%
+-commutative96.6%
sqr-pow96.5%
metadata-eval96.5%
pow296.5%
metadata-eval96.5%
pow296.5%
distribute-rgt-out96.5%
Applied egg-rr96.5%
Final simplification97.8%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+301) (+ -1.0 (* (* a a) (* a (+ a -4.0)))) (+ -1.0 (* (* b b) 12.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+301) {
tmp = -1.0 + ((a * a) * (a * (a + -4.0)));
} else {
tmp = -1.0 + ((b * b) * 12.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+301) then
tmp = (-1.0d0) + ((a * a) * (a * (a + (-4.0d0))))
else
tmp = (-1.0d0) + ((b * b) * 12.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+301) {
tmp = -1.0 + ((a * a) * (a * (a + -4.0)));
} else {
tmp = -1.0 + ((b * b) * 12.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e+301: tmp = -1.0 + ((a * a) * (a * (a + -4.0))) else: tmp = -1.0 + ((b * b) * 12.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e+301) tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(a * Float64(a + -4.0)))); else tmp = Float64(-1.0 + Float64(Float64(b * b) * 12.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5e+301) tmp = -1.0 + ((a * a) * (a * (a + -4.0))); else tmp = -1.0 + ((b * b) * 12.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e+301], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(a * N[(a + -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{+301}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot \left(a + -4\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\end{array}
\end{array}
if (*.f64 b b) < 5.0000000000000004e301Initial program 77.9%
sub-neg77.9%
fma-def77.9%
fma-def77.9%
+-commutative77.9%
metadata-eval77.9%
Simplified77.9%
Taylor expanded in b around 0 62.2%
associate-*r*62.2%
unpow262.2%
Simplified62.2%
sqr-pow62.2%
metadata-eval62.2%
pow262.2%
metadata-eval62.2%
pow262.2%
fma-def62.2%
*-commutative62.2%
associate-*l*62.2%
Applied egg-rr62.2%
fma-udef62.2%
distribute-lft-out80.5%
fma-def80.5%
*-commutative80.5%
Applied egg-rr80.5%
Taylor expanded in a around inf 79.9%
unpow279.9%
distribute-rgt-out79.9%
Simplified79.9%
if 5.0000000000000004e301 < (*.f64 b b) Initial program 65.0%
sub-neg65.0%
fma-def65.0%
fma-def66.7%
+-commutative66.7%
metadata-eval66.7%
Simplified66.7%
Taylor expanded in a around 0 43.3%
associate-+r+43.3%
associate-*r*43.3%
distribute-rgt-out80.0%
metadata-eval80.0%
distribute-lft-in80.0%
+-commutative80.0%
unpow280.0%
distribute-lft-in80.0%
metadata-eval80.0%
Simplified80.0%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Simplified100.0%
+-commutative100.0%
sqr-pow100.0%
metadata-eval100.0%
pow2100.0%
metadata-eval100.0%
pow2100.0%
distribute-rgt-out100.0%
Applied egg-rr100.0%
Taylor expanded in b around 0 98.5%
unpow298.5%
Simplified98.5%
Final simplification84.3%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+26) (+ -1.0 (* (* a a) (* a (+ a -4.0)))) (+ -1.0 (* (* b b) (+ (* b b) 12.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+26) {
tmp = -1.0 + ((a * a) * (a * (a + -4.0)));
} else {
tmp = -1.0 + ((b * b) * ((b * b) + 12.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+26) then
tmp = (-1.0d0) + ((a * a) * (a * (a + (-4.0d0))))
else
tmp = (-1.0d0) + ((b * b) * ((b * b) + 12.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+26) {
tmp = -1.0 + ((a * a) * (a * (a + -4.0)));
} else {
tmp = -1.0 + ((b * b) * ((b * b) + 12.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e+26: tmp = -1.0 + ((a * a) * (a * (a + -4.0))) else: tmp = -1.0 + ((b * b) * ((b * b) + 12.0)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e+26) tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(a * Float64(a + -4.0)))); else tmp = Float64(-1.0 + Float64(Float64(b * b) * Float64(Float64(b * b) + 12.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5e+26) tmp = -1.0 + ((a * a) * (a * (a + -4.0))); else tmp = -1.0 + ((b * b) * ((b * b) + 12.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e+26], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(a * N[(a + -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{+26}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot \left(a + -4\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 12\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 5.0000000000000001e26Initial program 79.6%
sub-neg79.6%
fma-def79.6%
fma-def79.6%
+-commutative79.6%
metadata-eval79.6%
Simplified79.6%
Taylor expanded in b around 0 79.3%
associate-*r*79.3%
unpow279.3%
Simplified79.3%
sqr-pow79.2%
metadata-eval79.2%
pow279.2%
metadata-eval79.2%
pow279.2%
fma-def79.2%
*-commutative79.2%
associate-*l*79.2%
Applied egg-rr79.2%
fma-udef79.2%
distribute-lft-out98.8%
fma-def98.8%
*-commutative98.8%
Applied egg-rr98.8%
Taylor expanded in a around inf 98.0%
unpow298.0%
distribute-rgt-out98.0%
Simplified98.0%
if 5.0000000000000001e26 < (*.f64 b b) Initial program 68.9%
sub-neg68.9%
fma-def68.9%
fma-def69.8%
+-commutative69.8%
metadata-eval69.8%
Simplified69.8%
Taylor expanded in a around 0 63.0%
associate-+r+63.0%
associate-*r*63.0%
distribute-rgt-out82.5%
metadata-eval82.5%
distribute-lft-in82.5%
+-commutative82.5%
unpow282.5%
distribute-lft-in82.5%
metadata-eval82.5%
Simplified82.5%
Taylor expanded in a around 0 96.6%
unpow296.6%
Simplified96.6%
+-commutative96.6%
sqr-pow96.5%
metadata-eval96.5%
pow296.5%
metadata-eval96.5%
pow296.5%
distribute-rgt-out96.5%
Applied egg-rr96.5%
Final simplification97.3%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+301) (+ -1.0 (* (* a a) (* a a))) (+ -1.0 (* (* b b) 12.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+301) {
tmp = -1.0 + ((a * a) * (a * a));
} else {
tmp = -1.0 + ((b * b) * 12.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+301) then
tmp = (-1.0d0) + ((a * a) * (a * a))
else
tmp = (-1.0d0) + ((b * b) * 12.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+301) {
tmp = -1.0 + ((a * a) * (a * a));
} else {
tmp = -1.0 + ((b * b) * 12.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e+301: tmp = -1.0 + ((a * a) * (a * a)) else: tmp = -1.0 + ((b * b) * 12.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e+301) tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(a * a))); else tmp = Float64(-1.0 + Float64(Float64(b * b) * 12.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5e+301) tmp = -1.0 + ((a * a) * (a * a)); else tmp = -1.0 + ((b * b) * 12.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e+301], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{+301}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\end{array}
\end{array}
if (*.f64 b b) < 5.0000000000000004e301Initial program 77.9%
sub-neg77.9%
fma-def77.9%
fma-def77.9%
+-commutative77.9%
metadata-eval77.9%
Simplified77.9%
Taylor expanded in b around 0 62.2%
associate-*r*62.2%
unpow262.2%
Simplified62.2%
sqr-pow62.2%
metadata-eval62.2%
pow262.2%
metadata-eval62.2%
pow262.2%
fma-def62.2%
*-commutative62.2%
associate-*l*62.2%
Applied egg-rr62.2%
fma-udef62.2%
distribute-lft-out80.5%
fma-def80.5%
*-commutative80.5%
Applied egg-rr80.5%
Taylor expanded in a around inf 79.6%
unpow279.6%
Simplified79.6%
if 5.0000000000000004e301 < (*.f64 b b) Initial program 65.0%
sub-neg65.0%
fma-def65.0%
fma-def66.7%
+-commutative66.7%
metadata-eval66.7%
Simplified66.7%
Taylor expanded in a around 0 43.3%
associate-+r+43.3%
associate-*r*43.3%
distribute-rgt-out80.0%
metadata-eval80.0%
distribute-lft-in80.0%
+-commutative80.0%
unpow280.0%
distribute-lft-in80.0%
metadata-eval80.0%
Simplified80.0%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Simplified100.0%
+-commutative100.0%
sqr-pow100.0%
metadata-eval100.0%
pow2100.0%
metadata-eval100.0%
pow2100.0%
distribute-rgt-out100.0%
Applied egg-rr100.0%
Taylor expanded in b around 0 98.5%
unpow298.5%
Simplified98.5%
Final simplification84.1%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+301) (+ -1.0 (* (* a a) 4.0)) (+ -1.0 (* (* b b) 12.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+301) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = -1.0 + ((b * b) * 12.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+301) then
tmp = (-1.0d0) + ((a * a) * 4.0d0)
else
tmp = (-1.0d0) + ((b * b) * 12.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+301) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = -1.0 + ((b * b) * 12.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e+301: tmp = -1.0 + ((a * a) * 4.0) else: tmp = -1.0 + ((b * b) * 12.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e+301) tmp = Float64(-1.0 + Float64(Float64(a * a) * 4.0)); else tmp = Float64(-1.0 + Float64(Float64(b * b) * 12.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5e+301) tmp = -1.0 + ((a * a) * 4.0); else tmp = -1.0 + ((b * b) * 12.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e+301], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{+301}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\end{array}
\end{array}
if (*.f64 b b) < 5.0000000000000004e301Initial program 77.9%
sub-neg77.9%
fma-def77.9%
fma-def77.9%
+-commutative77.9%
metadata-eval77.9%
Simplified77.9%
Taylor expanded in b around 0 62.2%
associate-*r*62.2%
unpow262.2%
Simplified62.2%
Taylor expanded in a around 0 65.3%
unpow265.3%
Simplified65.3%
if 5.0000000000000004e301 < (*.f64 b b) Initial program 65.0%
sub-neg65.0%
fma-def65.0%
fma-def66.7%
+-commutative66.7%
metadata-eval66.7%
Simplified66.7%
Taylor expanded in a around 0 43.3%
associate-+r+43.3%
associate-*r*43.3%
distribute-rgt-out80.0%
metadata-eval80.0%
distribute-lft-in80.0%
+-commutative80.0%
unpow280.0%
distribute-lft-in80.0%
metadata-eval80.0%
Simplified80.0%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Simplified100.0%
+-commutative100.0%
sqr-pow100.0%
metadata-eval100.0%
pow2100.0%
metadata-eval100.0%
pow2100.0%
distribute-rgt-out100.0%
Applied egg-rr100.0%
Taylor expanded in b around 0 98.5%
unpow298.5%
Simplified98.5%
Final simplification73.1%
(FPCore (a b) :precision binary64 (+ -1.0 (* (* a a) 4.0)))
double code(double a, double b) {
return -1.0 + ((a * a) * 4.0);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (-1.0d0) + ((a * a) * 4.0d0)
end function
public static double code(double a, double b) {
return -1.0 + ((a * a) * 4.0);
}
def code(a, b): return -1.0 + ((a * a) * 4.0)
function code(a, b) return Float64(-1.0 + Float64(Float64(a * a) * 4.0)) end
function tmp = code(a, b) tmp = -1.0 + ((a * a) * 4.0); end
code[a_, b_] := N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 + \left(a \cdot a\right) \cdot 4
\end{array}
Initial program 74.9%
sub-neg74.9%
fma-def74.9%
fma-def75.3%
+-commutative75.3%
metadata-eval75.3%
Simplified75.3%
Taylor expanded in b around 0 52.1%
associate-*r*52.1%
unpow252.1%
Simplified52.1%
Taylor expanded in a around 0 55.7%
unpow255.7%
Simplified55.7%
Final simplification55.7%
(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.9%
sub-neg74.9%
fma-def74.9%
fma-def75.3%
+-commutative75.3%
metadata-eval75.3%
Simplified75.3%
Taylor expanded in a around 0 56.4%
associate-+r+56.4%
associate-*r*56.4%
distribute-rgt-out65.0%
metadata-eval65.0%
distribute-lft-in65.0%
+-commutative65.0%
unpow265.0%
distribute-lft-in65.0%
metadata-eval65.0%
Simplified65.0%
Taylor expanded in a around 0 71.2%
unpow271.2%
Simplified71.2%
Taylor expanded in b around 0 28.2%
Final simplification28.2%
herbie shell --seed 2023182
(FPCore (a b)
:name "Bouland and Aaronson, Equation (24)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ 3.0 a))))) 1.0))