
(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 10 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
(let* ((t_0 (* (* b b) (+ a 3.0))) (t_1 (pow (+ (* a a) (* b b)) 2.0)))
(if (<= (+ t_1 (* 4.0 (+ (* (* a a) (- 1.0 a)) t_0))) 5e+305)
(fma 4.0 (fma a (- a (* a a)) t_0) (+ (pow (hypot a b) 4.0) -1.0))
(+ -1.0 (+ t_1 (* (* a a) 4.0))))))
double code(double a, double b) {
double t_0 = (b * b) * (a + 3.0);
double t_1 = pow(((a * a) + (b * b)), 2.0);
double tmp;
if ((t_1 + (4.0 * (((a * a) * (1.0 - a)) + t_0))) <= 5e+305) {
tmp = fma(4.0, fma(a, (a - (a * a)), t_0), (pow(hypot(a, b), 4.0) + -1.0));
} else {
tmp = -1.0 + (t_1 + ((a * a) * 4.0));
}
return tmp;
}
function code(a, b) t_0 = Float64(Float64(b * b) * Float64(a + 3.0)) t_1 = Float64(Float64(a * a) + Float64(b * b)) ^ 2.0 tmp = 0.0 if (Float64(t_1 + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + t_0))) <= 5e+305) tmp = fma(4.0, fma(a, Float64(a - Float64(a * a)), t_0), Float64((hypot(a, b) ^ 4.0) + -1.0)); else tmp = Float64(-1.0 + Float64(t_1 + Float64(Float64(a * a) * 4.0))); end return tmp end
code[a_, b_] := Block[{t$95$0 = N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[N[(t$95$1 + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+305], N[(4.0 * N[(a * N[(a - N[(a * a), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision] + N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(t$95$1 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(b \cdot b\right) \cdot \left(a + 3\right)\\
t_1 := {\left(a \cdot a + b \cdot b\right)}^{2}\\
\mathbf{if}\;t_1 + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + t_0\right) \leq 5 \cdot 10^{+305}:\\
\;\;\;\;\mathsf{fma}\left(4, \mathsf{fma}\left(a, a - a \cdot a, t_0\right), {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(t_1 + \left(a \cdot a\right) \cdot 4\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))))) < 5.00000000000000009e305Initial program 99.7%
sub-neg99.7%
+-commutative99.7%
associate-+l+99.7%
fma-def99.7%
associate-*l*99.7%
fma-def99.7%
distribute-lft-out--99.7%
*-rgt-identity99.7%
+-commutative99.7%
Simplified99.9%
if 5.00000000000000009e305 < (+.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 62.0%
+-commutative62.0%
+-commutative62.0%
*-commutative62.0%
fma-def66.9%
associate-*l*66.9%
Applied egg-rr66.9%
Taylor expanded in a around 0 84.9%
unpow284.9%
Simplified84.9%
Taylor expanded in a around inf 100.0%
unpow2100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (a b)
:precision binary64
(let* ((t_0 (pow (+ (* a a) (* b b)) 2.0)))
(if (<=
(+ t_0 (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))
1e+64)
(+ -1.0 (+ t_0 (* 4.0 (fma (+ a 3.0) (* b b) (* a (* a (- 1.0 a)))))))
(+ -1.0 (+ t_0 (* (* a a) 4.0))))))
double code(double a, double b) {
double t_0 = pow(((a * a) + (b * b)), 2.0);
double tmp;
if ((t_0 + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))))) <= 1e+64) {
tmp = -1.0 + (t_0 + (4.0 * fma((a + 3.0), (b * b), (a * (a * (1.0 - a))))));
} else {
tmp = -1.0 + (t_0 + ((a * a) * 4.0));
}
return tmp;
}
function code(a, b) t_0 = Float64(Float64(a * a) + Float64(b * b)) ^ 2.0 tmp = 0.0 if (Float64(t_0 + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + Float64(Float64(b * b) * Float64(a + 3.0))))) <= 1e+64) tmp = Float64(-1.0 + Float64(t_0 + Float64(4.0 * fma(Float64(a + 3.0), Float64(b * b), Float64(a * Float64(a * Float64(1.0 - a))))))); else tmp = Float64(-1.0 + Float64(t_0 + Float64(Float64(a * a) * 4.0))); end return tmp end
code[a_, b_] := Block[{t$95$0 = N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[N[(t$95$0 + 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], 1e+64], N[(-1.0 + N[(t$95$0 + N[(4.0 * N[(N[(a + 3.0), $MachinePrecision] * N[(b * b), $MachinePrecision] + N[(a * N[(a * N[(1.0 - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(t$95$0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(a \cdot a + b \cdot b\right)}^{2}\\
\mathbf{if}\;t_0 + 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 10^{+64}:\\
\;\;\;\;-1 + \left(t_0 + 4 \cdot \mathsf{fma}\left(a + 3, b \cdot b, a \cdot \left(a \cdot \left(1 - a\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(t_0 + \left(a \cdot a\right) \cdot 4\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))))) < 1.00000000000000002e64Initial program 99.9%
+-commutative99.9%
+-commutative99.9%
*-commutative99.9%
fma-def99.9%
associate-*l*99.9%
Applied egg-rr99.9%
if 1.00000000000000002e64 < (+.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 67.1%
+-commutative67.1%
+-commutative67.1%
*-commutative67.1%
fma-def71.2%
associate-*l*71.2%
Applied egg-rr71.2%
Taylor expanded in a around 0 86.9%
unpow286.9%
Simplified86.9%
Taylor expanded in a around inf 99.9%
unpow299.9%
Simplified99.9%
Final simplification99.9%
(FPCore (a b)
:precision binary64
(let* ((t_0 (pow (+ (* a a) (* b b)) 2.0))
(t_1 (+ t_0 (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))))
(if (<= t_1 1e+64) (+ t_1 -1.0) (+ -1.0 (+ t_0 (* (* a a) 4.0))))))
double code(double a, double b) {
double t_0 = pow(((a * a) + (b * b)), 2.0);
double t_1 = t_0 + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_1 <= 1e+64) {
tmp = t_1 + -1.0;
} else {
tmp = -1.0 + (t_0 + ((a * a) * 4.0));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((a * a) + (b * b)) ** 2.0d0
t_1 = t_0 + (4.0d0 * (((a * a) * (1.0d0 - a)) + ((b * b) * (a + 3.0d0))))
if (t_1 <= 1d+64) then
tmp = t_1 + (-1.0d0)
else
tmp = (-1.0d0) + (t_0 + ((a * a) * 4.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double t_0 = Math.pow(((a * a) + (b * b)), 2.0);
double t_1 = t_0 + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_1 <= 1e+64) {
tmp = t_1 + -1.0;
} else {
tmp = -1.0 + (t_0 + ((a * a) * 4.0));
}
return tmp;
}
def code(a, b): t_0 = math.pow(((a * a) + (b * b)), 2.0) t_1 = t_0 + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0)))) tmp = 0 if t_1 <= 1e+64: tmp = t_1 + -1.0 else: tmp = -1.0 + (t_0 + ((a * a) * 4.0)) return tmp
function code(a, b) t_0 = Float64(Float64(a * a) + Float64(b * b)) ^ 2.0 t_1 = Float64(t_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_1 <= 1e+64) tmp = Float64(t_1 + -1.0); else tmp = Float64(-1.0 + Float64(t_0 + Float64(Float64(a * a) * 4.0))); end return tmp end
function tmp_2 = code(a, b) t_0 = ((a * a) + (b * b)) ^ 2.0; t_1 = t_0 + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0)))); tmp = 0.0; if (t_1 <= 1e+64) tmp = t_1 + -1.0; else tmp = -1.0 + (t_0 + ((a * a) * 4.0)); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 + 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$1, 1e+64], N[(t$95$1 + -1.0), $MachinePrecision], N[(-1.0 + N[(t$95$0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(a \cdot a + b \cdot b\right)}^{2}\\
t_1 := t_0 + 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_1 \leq 10^{+64}:\\
\;\;\;\;t_1 + -1\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(t_0 + \left(a \cdot a\right) \cdot 4\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))))) < 1.00000000000000002e64Initial program 99.9%
if 1.00000000000000002e64 < (+.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 67.1%
+-commutative67.1%
+-commutative67.1%
*-commutative67.1%
fma-def71.2%
associate-*l*71.2%
Applied egg-rr71.2%
Taylor expanded in a around 0 86.9%
unpow286.9%
Simplified86.9%
Taylor expanded in a around inf 99.9%
unpow299.9%
Simplified99.9%
Final simplification99.9%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e-9) (+ -1.0 (pow a 4.0)) (+ -1.0 (+ (* (* a a) 4.0) (pow (* b b) 2.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e-9) {
tmp = -1.0 + pow(a, 4.0);
} else {
tmp = -1.0 + (((a * a) * 4.0) + pow((b * b), 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-9) then
tmp = (-1.0d0) + (a ** 4.0d0)
else
tmp = (-1.0d0) + (((a * a) * 4.0d0) + ((b * b) ** 2.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 5e-9) {
tmp = -1.0 + Math.pow(a, 4.0);
} else {
tmp = -1.0 + (((a * a) * 4.0) + Math.pow((b * b), 2.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e-9: tmp = -1.0 + math.pow(a, 4.0) else: tmp = -1.0 + (((a * a) * 4.0) + math.pow((b * b), 2.0)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e-9) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = Float64(-1.0 + Float64(Float64(Float64(a * a) * 4.0) + (Float64(b * b) ^ 2.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5e-9) tmp = -1.0 + (a ^ 4.0); else tmp = -1.0 + (((a * a) * 4.0) + ((b * b) ^ 2.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e-9], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision] + N[Power[N[(b * b), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{-9}:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(\left(a \cdot a\right) \cdot 4 + {\left(b \cdot b\right)}^{2}\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 5.0000000000000001e-9Initial program 83.9%
sub-neg83.9%
sqr-pow83.9%
sqr-pow83.9%
sqr-neg83.9%
distribute-rgt-in83.9%
sqr-neg83.9%
distribute-rgt-in83.9%
Simplified83.9%
Taylor expanded in a around inf 98.2%
if 5.0000000000000001e-9 < (*.f64 b b) Initial program 67.0%
+-commutative67.0%
+-commutative67.0%
*-commutative67.0%
fma-def73.2%
associate-*l*73.2%
Applied egg-rr73.2%
Taylor expanded in a around 0 80.8%
unpow280.8%
Simplified80.8%
Taylor expanded in a around inf 98.2%
unpow298.2%
Simplified98.2%
Taylor expanded in a around 0 94.0%
unpow294.0%
Simplified94.0%
Final simplification96.0%
(FPCore (a b) :precision binary64 (+ -1.0 (+ (pow (+ (* a a) (* b b)) 2.0) (* (* a a) 4.0))))
double code(double a, double b) {
return -1.0 + (pow(((a * a) + (b * b)), 2.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) + (b * b)) ** 2.0d0) + ((a * a) * 4.0d0))
end function
public static double code(double a, double b) {
return -1.0 + (Math.pow(((a * a) + (b * b)), 2.0) + ((a * a) * 4.0));
}
def code(a, b): return -1.0 + (math.pow(((a * a) + (b * b)), 2.0) + ((a * a) * 4.0))
function code(a, b) return Float64(-1.0 + Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(Float64(a * a) * 4.0))) end
function tmp = code(a, b) tmp = -1.0 + ((((a * a) + (b * b)) ^ 2.0) + ((a * a) * 4.0)); end
code[a_, b_] := N[(-1.0 + N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 + \left({\left(a \cdot a + b \cdot b\right)}^{2} + \left(a \cdot a\right) \cdot 4\right)
\end{array}
Initial program 75.3%
+-commutative75.3%
+-commutative75.3%
*-commutative75.3%
fma-def78.4%
associate-*l*78.4%
Applied egg-rr78.4%
Taylor expanded in a around 0 89.4%
unpow289.4%
Simplified89.4%
Taylor expanded in a around inf 98.3%
unpow298.3%
Simplified98.3%
Final simplification98.3%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e-9) (+ -1.0 (pow a 4.0)) (+ -1.0 (+ (pow b 4.0) (* (* b b) 12.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e-9) {
tmp = -1.0 + pow(a, 4.0);
} else {
tmp = -1.0 + (pow(b, 4.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-9) then
tmp = (-1.0d0) + (a ** 4.0d0)
else
tmp = (-1.0d0) + ((b ** 4.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-9) {
tmp = -1.0 + Math.pow(a, 4.0);
} else {
tmp = -1.0 + (Math.pow(b, 4.0) + ((b * b) * 12.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e-9: tmp = -1.0 + math.pow(a, 4.0) else: tmp = -1.0 + (math.pow(b, 4.0) + ((b * b) * 12.0)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e-9) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = Float64(-1.0 + Float64((b ^ 4.0) + Float64(Float64(b * b) * 12.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5e-9) tmp = -1.0 + (a ^ 4.0); else tmp = -1.0 + ((b ^ 4.0) + ((b * b) * 12.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e-9], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[Power[b, 4.0], $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^{-9}:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + \left({b}^{4} + \left(b \cdot b\right) \cdot 12\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 5.0000000000000001e-9Initial program 83.9%
sub-neg83.9%
sqr-pow83.9%
sqr-pow83.9%
sqr-neg83.9%
distribute-rgt-in83.9%
sqr-neg83.9%
distribute-rgt-in83.9%
Simplified83.9%
Taylor expanded in a around inf 98.2%
if 5.0000000000000001e-9 < (*.f64 b b) Initial program 67.0%
sub-neg67.0%
sqr-pow67.0%
sqr-pow67.0%
sqr-neg67.0%
distribute-rgt-in67.0%
sqr-neg67.0%
distribute-rgt-in67.0%
Simplified69.3%
Taylor expanded in a around 0 58.2%
+-commutative58.2%
+-commutative58.2%
associate-+l+58.2%
unpow258.2%
unpow258.2%
associate-*r*58.2%
distribute-rgt-in72.0%
metadata-eval72.0%
distribute-lft-in72.0%
*-commutative72.0%
distribute-lft-in72.0%
metadata-eval72.0%
Simplified72.0%
Taylor expanded in a around 0 91.0%
unpow291.0%
Simplified91.0%
Final simplification94.5%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e-9) (+ -1.0 (pow a 4.0)) (+ -1.0 (* (* b b) (+ (* b b) 12.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e-9) {
tmp = -1.0 + pow(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-9) then
tmp = (-1.0d0) + (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-9) {
tmp = -1.0 + Math.pow(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-9: tmp = -1.0 + math.pow(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-9) tmp = Float64(-1.0 + (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-9) tmp = -1.0 + (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-9], N[(-1.0 + N[Power[a, 4.0], $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^{-9}:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 12\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 5.0000000000000001e-9Initial program 83.9%
sub-neg83.9%
sqr-pow83.9%
sqr-pow83.9%
sqr-neg83.9%
distribute-rgt-in83.9%
sqr-neg83.9%
distribute-rgt-in83.9%
Simplified83.9%
Taylor expanded in a around inf 98.2%
if 5.0000000000000001e-9 < (*.f64 b b) Initial program 67.0%
sub-neg67.0%
sqr-pow67.0%
sqr-pow67.0%
sqr-neg67.0%
distribute-rgt-in67.0%
sqr-neg67.0%
distribute-rgt-in67.0%
Simplified69.3%
Taylor expanded in a around 0 58.2%
+-commutative58.2%
+-commutative58.2%
associate-+l+58.2%
unpow258.2%
unpow258.2%
associate-*r*58.2%
distribute-rgt-in72.0%
metadata-eval72.0%
distribute-lft-in72.0%
*-commutative72.0%
distribute-lft-in72.0%
metadata-eval72.0%
Simplified72.0%
Taylor expanded in a around 0 91.0%
unpow291.0%
Simplified91.0%
metadata-eval91.0%
pow-prod-up90.9%
pow290.9%
pow290.9%
distribute-rgt-out90.9%
Applied egg-rr90.9%
Final simplification94.5%
(FPCore (a b) :precision binary64 (if (<= a 6.9e-6) (+ -1.0 (* (* b b) 12.0)) (+ -1.0 (* b (* b (* a 4.0))))))
double code(double a, double b) {
double tmp;
if (a <= 6.9e-6) {
tmp = -1.0 + ((b * b) * 12.0);
} else {
tmp = -1.0 + (b * (b * (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 <= 6.9d-6) then
tmp = (-1.0d0) + ((b * b) * 12.0d0)
else
tmp = (-1.0d0) + (b * (b * (a * 4.0d0)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= 6.9e-6) {
tmp = -1.0 + ((b * b) * 12.0);
} else {
tmp = -1.0 + (b * (b * (a * 4.0)));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= 6.9e-6: tmp = -1.0 + ((b * b) * 12.0) else: tmp = -1.0 + (b * (b * (a * 4.0))) return tmp
function code(a, b) tmp = 0.0 if (a <= 6.9e-6) tmp = Float64(-1.0 + Float64(Float64(b * b) * 12.0)); else tmp = Float64(-1.0 + Float64(b * Float64(b * Float64(a * 4.0)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= 6.9e-6) tmp = -1.0 + ((b * b) * 12.0); else tmp = -1.0 + (b * (b * (a * 4.0))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, 6.9e-6], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(b * N[(b * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 6.9 \cdot 10^{-6}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\mathbf{else}:\\
\;\;\;\;-1 + b \cdot \left(b \cdot \left(a \cdot 4\right)\right)\\
\end{array}
\end{array}
if a < 6.9e-6Initial program 85.4%
sub-neg85.4%
sqr-pow85.4%
sqr-pow85.4%
sqr-neg85.4%
distribute-rgt-in85.4%
sqr-neg85.4%
distribute-rgt-in85.4%
Simplified85.4%
Taylor expanded in a around 0 53.1%
+-commutative53.1%
+-commutative53.1%
associate-+l+53.1%
unpow253.1%
unpow253.1%
associate-*r*53.1%
distribute-rgt-in62.1%
metadata-eval62.1%
distribute-lft-in62.1%
*-commutative62.1%
distribute-lft-in62.1%
metadata-eval62.1%
Simplified62.1%
Taylor expanded in b around 0 42.7%
+-commutative42.7%
*-commutative42.7%
fma-udef42.7%
unpow242.7%
associate-*l*42.7%
Simplified42.7%
Taylor expanded in a around 0 53.8%
unpow253.8%
Simplified53.8%
if 6.9e-6 < a Initial program 39.2%
sub-neg39.2%
sqr-pow39.2%
sqr-pow39.2%
sqr-neg39.2%
distribute-rgt-in39.2%
sqr-neg39.2%
distribute-rgt-in39.2%
Simplified44.6%
Taylor expanded in a around 0 41.8%
+-commutative41.8%
+-commutative41.8%
associate-+l+41.8%
unpow241.8%
unpow241.8%
associate-*r*41.8%
distribute-rgt-in41.8%
metadata-eval41.8%
distribute-lft-in41.8%
*-commutative41.8%
distribute-lft-in41.8%
metadata-eval41.8%
Simplified41.8%
Taylor expanded in b around 0 35.2%
+-commutative35.2%
*-commutative35.2%
fma-udef35.2%
unpow235.2%
associate-*l*35.2%
Simplified35.2%
Taylor expanded in a around inf 35.2%
associate-*r*35.2%
*-commutative35.2%
*-commutative35.2%
*-commutative35.2%
Simplified35.2%
Final simplification49.7%
(FPCore (a b) :precision binary64 (+ -1.0 (* (* b b) (+ (* b b) 12.0))))
double code(double a, double b) {
return -1.0 + ((b * b) * ((b * b) + 12.0));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (-1.0d0) + ((b * b) * ((b * b) + 12.0d0))
end function
public static double code(double a, double b) {
return -1.0 + ((b * b) * ((b * b) + 12.0));
}
def code(a, b): return -1.0 + ((b * b) * ((b * b) + 12.0))
function code(a, b) return Float64(-1.0 + Float64(Float64(b * b) * Float64(Float64(b * b) + 12.0))) end
function tmp = code(a, b) tmp = -1.0 + ((b * b) * ((b * b) + 12.0)); end
code[a_, b_] := N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 12\right)
\end{array}
Initial program 75.3%
sub-neg75.3%
sqr-pow75.3%
sqr-pow75.3%
sqr-neg75.3%
distribute-rgt-in75.3%
sqr-neg75.3%
distribute-rgt-in75.3%
Simplified76.4%
Taylor expanded in a around 0 50.7%
+-commutative50.7%
+-commutative50.7%
associate-+l+50.7%
unpow250.7%
unpow250.7%
associate-*r*50.7%
distribute-rgt-in57.7%
metadata-eval57.7%
distribute-lft-in57.7%
*-commutative57.7%
distribute-lft-in57.7%
metadata-eval57.7%
Simplified57.7%
Taylor expanded in a around 0 67.4%
unpow267.4%
Simplified67.4%
metadata-eval67.4%
pow-prod-up67.3%
pow267.3%
pow267.3%
distribute-rgt-out67.3%
Applied egg-rr67.3%
Final simplification67.3%
(FPCore (a b) :precision binary64 (+ -1.0 (* (* b b) 12.0)))
double code(double a, double b) {
return -1.0 + ((b * b) * 12.0);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (-1.0d0) + ((b * b) * 12.0d0)
end function
public static double code(double a, double b) {
return -1.0 + ((b * b) * 12.0);
}
def code(a, b): return -1.0 + ((b * b) * 12.0)
function code(a, b) return Float64(-1.0 + Float64(Float64(b * b) * 12.0)) end
function tmp = code(a, b) tmp = -1.0 + ((b * b) * 12.0); end
code[a_, b_] := N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 + \left(b \cdot b\right) \cdot 12
\end{array}
Initial program 75.3%
sub-neg75.3%
sqr-pow75.3%
sqr-pow75.3%
sqr-neg75.3%
distribute-rgt-in75.3%
sqr-neg75.3%
distribute-rgt-in75.3%
Simplified76.4%
Taylor expanded in a around 0 50.7%
+-commutative50.7%
+-commutative50.7%
associate-+l+50.7%
unpow250.7%
unpow250.7%
associate-*r*50.7%
distribute-rgt-in57.7%
metadata-eval57.7%
distribute-lft-in57.7%
*-commutative57.7%
distribute-lft-in57.7%
metadata-eval57.7%
Simplified57.7%
Taylor expanded in b around 0 41.1%
+-commutative41.1%
*-commutative41.1%
fma-udef41.1%
unpow241.1%
associate-*l*41.1%
Simplified41.1%
Taylor expanded in a around 0 47.3%
unpow247.3%
Simplified47.3%
Final simplification47.3%
herbie shell --seed 2023299
(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))