
(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 14 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 (fma (* b b) 2.0 (* a a)))
(t_1 (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 3.0 a)))))))
(if (<= (+ (pow (+ (* a a) (* b b)) 2.0) t_1) INFINITY)
(- (+ (fma (* t_0 a) a (pow b 4.0)) t_1) 1.0)
(fma (* b b) 4.0 (fma t_0 (* a a) -1.0)))))
double code(double a, double b) {
double t_0 = fma((b * b), 2.0, (a * a));
double t_1 = 4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a))));
double tmp;
if ((pow(((a * a) + (b * b)), 2.0) + t_1) <= ((double) INFINITY)) {
tmp = (fma((t_0 * a), a, pow(b, 4.0)) + t_1) - 1.0;
} else {
tmp = fma((b * b), 4.0, fma(t_0, (a * a), -1.0));
}
return tmp;
}
function code(a, b) t_0 = fma(Float64(b * b), 2.0, Float64(a * a)) t_1 = Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 + a)) + Float64(Float64(b * b) * Float64(1.0 - Float64(3.0 * a))))) tmp = 0.0 if (Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + t_1) <= Inf) tmp = Float64(Float64(fma(Float64(t_0 * a), a, (b ^ 4.0)) + t_1) - 1.0); else tmp = fma(Float64(b * b), 4.0, fma(t_0, Float64(a * a), -1.0)); end return tmp end
code[a_, b_] := Block[{t$95$0 = N[(N[(b * b), $MachinePrecision] * 2.0 + N[(a * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = 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]}, If[LessEqual[N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision], Infinity], N[(N[(N[(N[(t$95$0 * a), $MachinePrecision] * a + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * 4.0 + N[(t$95$0 * N[(a * a), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(b \cdot b, 2, a \cdot a\right)\\
t_1 := 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)\\
\mathbf{if}\;{\left(a \cdot a + b \cdot b\right)}^{2} + t\_1 \leq \infty:\\
\;\;\;\;\left(\mathsf{fma}\left(t\_0 \cdot a, a, {b}^{4}\right) + t\_1\right) - 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot b, 4, \mathsf{fma}\left(t\_0, a \cdot a, -1\right)\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%
Taylor expanded in a around 0
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-pow.f6499.9
Applied rewrites99.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%
Taylor expanded in b around 0
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-inN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f640.0
Applied rewrites0.0%
Taylor expanded in a around 0
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites100.0%
Taylor expanded in b around 0
sub-negN/A
metadata-evalN/A
metadata-evalN/A
pow-sqrN/A
count-2-revN/A
distribute-lft-inN/A
count-2-revN/A
distribute-lft-inN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 3.0 a))))))))
(if (<= t_0 INFINITY)
(- t_0 1.0)
(fma (* b b) 4.0 (fma (fma (* b b) 2.0 (* a a)) (* a a) -1.0)))))
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) * (1.0 - (3.0 * a)))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0 - 1.0;
} else {
tmp = fma((b * b), 4.0, fma(fma((b * b), 2.0, (a * a)), (a * a), -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(1.0 + a)) + Float64(Float64(b * b) * Float64(1.0 - Float64(3.0 * a)))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(t_0 - 1.0); else tmp = fma(Float64(b * b), 4.0, fma(fma(Float64(b * b), 2.0, Float64(a * a)), Float64(a * a), -1.0)); end return 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[(1.0 - N[(3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(t$95$0 - 1.0), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * 4.0 + N[(N[(N[(b * b), $MachinePrecision] * 2.0 + N[(a * a), $MachinePrecision]), $MachinePrecision] * N[(a * a), $MachinePrecision] + -1.0), $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(1 - 3 \cdot a\right)\right)\\
\mathbf{if}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0 - 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot b, 4, \mathsf{fma}\left(\mathsf{fma}\left(b \cdot b, 2, a \cdot a\right), a \cdot a, -1\right)\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%
Taylor expanded in b around 0
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-inN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f640.0
Applied rewrites0.0%
Taylor expanded in a around 0
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites100.0%
Taylor expanded in b around 0
sub-negN/A
metadata-evalN/A
metadata-evalN/A
pow-sqrN/A
count-2-revN/A
distribute-lft-inN/A
count-2-revN/A
distribute-lft-inN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
(FPCore (a b)
:precision binary64
(let* ((t_0 (fma (* b b) 2.0 (* a a))))
(if (<=
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 3.0 a))))))
INFINITY)
(- (+ (fma (* t_0 a) a (pow b 4.0)) (* 4.0 (* (fma a a a) a))) 1.0)
(fma (* b b) 4.0 (fma t_0 (* a a) -1.0)))))
double code(double a, double b) {
double t_0 = fma((b * b), 2.0, (a * a));
double tmp;
if ((pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) <= ((double) INFINITY)) {
tmp = (fma((t_0 * a), a, pow(b, 4.0)) + (4.0 * (fma(a, a, a) * a))) - 1.0;
} else {
tmp = fma((b * b), 4.0, fma(t_0, (a * a), -1.0));
}
return tmp;
}
function code(a, b) t_0 = fma(Float64(b * b), 2.0, Float64(a * a)) 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(1.0 - Float64(3.0 * a)))))) <= Inf) tmp = Float64(Float64(fma(Float64(t_0 * a), a, (b ^ 4.0)) + Float64(4.0 * Float64(fma(a, a, a) * a))) - 1.0); else tmp = fma(Float64(b * b), 4.0, fma(t_0, Float64(a * a), -1.0)); end return tmp end
code[a_, b_] := Block[{t$95$0 = N[(N[(b * b), $MachinePrecision] * 2.0 + N[(a * a), $MachinePrecision]), $MachinePrecision]}, 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[(1.0 - N[(3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[(N[(t$95$0 * a), $MachinePrecision] * a + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + N[(4.0 * N[(N[(a * a + a), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * 4.0 + N[(t$95$0 * N[(a * a), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(b \cdot b, 2, a \cdot a\right)\\
\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(1 - 3 \cdot a\right)\right) \leq \infty:\\
\;\;\;\;\left(\mathsf{fma}\left(t\_0 \cdot a, a, {b}^{4}\right) + 4 \cdot \left(\mathsf{fma}\left(a, a, a\right) \cdot a\right)\right) - 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot b, 4, \mathsf{fma}\left(t\_0, a \cdot a, -1\right)\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%
Taylor expanded in a around inf
unpow3N/A
unpow2N/A
associate-*l*N/A
distribute-lft-inN/A
*-rgt-identityN/A
rgt-mult-inverseN/A
unpow2N/A
+-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6498.5
Applied rewrites98.5%
Taylor expanded in a around 0
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-pow.f6498.6
Applied rewrites98.6%
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%
Taylor expanded in b around 0
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-inN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f640.0
Applied rewrites0.0%
Taylor expanded in a around 0
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites100.0%
Taylor expanded in b around 0
sub-negN/A
metadata-evalN/A
metadata-evalN/A
pow-sqrN/A
count-2-revN/A
distribute-lft-inN/A
count-2-revN/A
distribute-lft-inN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64100.0
Applied rewrites100.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) (- 1.0 (* 3.0 a))))))
INFINITY)
(- (+ t_0 (* 4.0 (* (fma a a a) a))) 1.0)
(fma (* b b) 4.0 (fma (fma (* b b) 2.0 (* a a)) (* a a) -1.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) * (1.0 - (3.0 * a)))))) <= ((double) INFINITY)) {
tmp = (t_0 + (4.0 * (fma(a, a, a) * a))) - 1.0;
} else {
tmp = fma((b * b), 4.0, fma(fma((b * b), 2.0, (a * a)), (a * a), -1.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(1.0 - Float64(3.0 * a)))))) <= Inf) tmp = Float64(Float64(t_0 + Float64(4.0 * Float64(fma(a, a, a) * a))) - 1.0); else tmp = fma(Float64(b * b), 4.0, fma(fma(Float64(b * b), 2.0, Float64(a * a)), Float64(a * a), -1.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[(1.0 - N[(3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(t$95$0 + N[(4.0 * N[(N[(a * a + a), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * 4.0 + N[(N[(N[(b * b), $MachinePrecision] * 2.0 + N[(a * a), $MachinePrecision]), $MachinePrecision] * N[(a * a), $MachinePrecision] + -1.0), $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(1 - 3 \cdot a\right)\right) \leq \infty:\\
\;\;\;\;\left(t\_0 + 4 \cdot \left(\mathsf{fma}\left(a, a, a\right) \cdot a\right)\right) - 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot b, 4, \mathsf{fma}\left(\mathsf{fma}\left(b \cdot b, 2, a \cdot a\right), a \cdot a, -1\right)\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%
Taylor expanded in a around inf
unpow3N/A
unpow2N/A
associate-*l*N/A
distribute-lft-inN/A
*-rgt-identityN/A
rgt-mult-inverseN/A
unpow2N/A
+-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6498.5
Applied rewrites98.5%
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%
Taylor expanded in b around 0
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-inN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f640.0
Applied rewrites0.0%
Taylor expanded in a around 0
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites100.0%
Taylor expanded in b around 0
sub-negN/A
metadata-evalN/A
metadata-evalN/A
pow-sqrN/A
count-2-revN/A
distribute-lft-inN/A
count-2-revN/A
distribute-lft-inN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
(FPCore (a b)
:precision binary64
(if (<=
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 3.0 a))))))
INFINITY)
(- (+ (pow (fma b b (* a a)) 2.0) (* 4.0 (* (fma a a a) a))) 1.0)
(fma (* b b) 4.0 (fma (fma (* b b) 2.0 (* a a)) (* a a) -1.0))))
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) * (1.0 - (3.0 * a)))))) <= ((double) INFINITY)) {
tmp = (pow(fma(b, b, (a * a)), 2.0) + (4.0 * (fma(a, a, a) * a))) - 1.0;
} else {
tmp = fma((b * b), 4.0, fma(fma((b * b), 2.0, (a * a)), (a * a), -1.0));
}
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(1.0 - Float64(3.0 * a)))))) <= Inf) tmp = Float64(Float64((fma(b, b, Float64(a * a)) ^ 2.0) + Float64(4.0 * Float64(fma(a, a, a) * a))) - 1.0); else tmp = fma(Float64(b * b), 4.0, fma(fma(Float64(b * b), 2.0, Float64(a * a)), Float64(a * a), -1.0)); 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[(1.0 - N[(3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[Power[N[(b * b + N[(a * a), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(a * a + a), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * 4.0 + N[(N[(N[(b * b), $MachinePrecision] * 2.0 + N[(a * a), $MachinePrecision]), $MachinePrecision] * N[(a * a), $MachinePrecision] + -1.0), $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(1 - 3 \cdot a\right)\right) \leq \infty:\\
\;\;\;\;\left({\left(\mathsf{fma}\left(b, b, a \cdot a\right)\right)}^{2} + 4 \cdot \left(\mathsf{fma}\left(a, a, a\right) \cdot a\right)\right) - 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot b, 4, \mathsf{fma}\left(\mathsf{fma}\left(b \cdot b, 2, a \cdot a\right), a \cdot a, -1\right)\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%
Taylor expanded in a around inf
unpow3N/A
unpow2N/A
associate-*l*N/A
distribute-lft-inN/A
*-rgt-identityN/A
rgt-mult-inverseN/A
unpow2N/A
+-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6498.5
Applied rewrites98.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6498.5
Applied rewrites98.5%
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%
Taylor expanded in b around 0
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-inN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f640.0
Applied rewrites0.0%
Taylor expanded in a around 0
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites100.0%
Taylor expanded in b around 0
sub-negN/A
metadata-evalN/A
metadata-evalN/A
pow-sqrN/A
count-2-revN/A
distribute-lft-inN/A
count-2-revN/A
distribute-lft-inN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
(FPCore (a b)
:precision binary64
(if (<= (* b b) 2e-20)
(fma (* a a) (fma a a (fma 4.0 a 4.0)) -1.0)
(-
(fma (fma a (fma 2.0 a -12.0) (fma b b 4.0)) (* b b) (* (* a a) 4.0))
1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e-20) {
tmp = fma((a * a), fma(a, a, fma(4.0, a, 4.0)), -1.0);
} else {
tmp = fma(fma(a, fma(2.0, a, -12.0), fma(b, b, 4.0)), (b * b), ((a * a) * 4.0)) - 1.0;
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e-20) tmp = fma(Float64(a * a), fma(a, a, fma(4.0, a, 4.0)), -1.0); else tmp = Float64(fma(fma(a, fma(2.0, a, -12.0), fma(b, b, 4.0)), Float64(b * b), Float64(Float64(a * a) * 4.0)) - 1.0); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e-20], N[(N[(a * a), $MachinePrecision] * N[(a * a + N[(4.0 * a + 4.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[(a * N[(2.0 * a + -12.0), $MachinePrecision] + N[(b * b + 4.0), $MachinePrecision]), $MachinePrecision] * N[(b * b), $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{-20}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot a, \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right), -1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(a, \mathsf{fma}\left(2, a, -12\right), \mathsf{fma}\left(b, b, 4\right)\right), b \cdot b, \left(a \cdot a\right) \cdot 4\right) - 1\\
\end{array}
\end{array}
if (*.f64 b b) < 1.99999999999999989e-20Initial program 83.4%
Taylor expanded in a around 0
+-commutativeN/A
associate-+r+N/A
distribute-lft-inN/A
associate-+r+N/A
Applied rewrites78.0%
Taylor expanded in b around 0
sub-negN/A
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-outN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-fma.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
*-commutativeN/A
lower-fma.f6499.9
Applied rewrites99.9%
if 1.99999999999999989e-20 < (*.f64 b b) Initial program 72.3%
Taylor expanded in a around 0
+-commutativeN/A
associate-+r+N/A
distribute-lft-inN/A
associate-+r+N/A
Applied rewrites97.3%
Taylor expanded in b around 0
Applied rewrites97.3%
(FPCore (a b)
:precision binary64
(if (<= (* b b) 2e-20)
(fma (* a a) (fma a a (fma 4.0 a 4.0)) -1.0)
(-
(fma (* (fma (fma 2.0 a -12.0) a (fma b b 4.0)) b) b (* (* a a) 4.0))
1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e-20) {
tmp = fma((a * a), fma(a, a, fma(4.0, a, 4.0)), -1.0);
} else {
tmp = fma((fma(fma(2.0, a, -12.0), a, fma(b, b, 4.0)) * b), b, ((a * a) * 4.0)) - 1.0;
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e-20) tmp = fma(Float64(a * a), fma(a, a, fma(4.0, a, 4.0)), -1.0); else tmp = Float64(fma(Float64(fma(fma(2.0, a, -12.0), a, fma(b, b, 4.0)) * b), b, Float64(Float64(a * a) * 4.0)) - 1.0); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e-20], N[(N[(a * a), $MachinePrecision] * N[(a * a + N[(4.0 * a + 4.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[(N[(N[(2.0 * a + -12.0), $MachinePrecision] * a + N[(b * b + 4.0), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] * b + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{-20}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot a, \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right), -1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(2, a, -12\right), a, \mathsf{fma}\left(b, b, 4\right)\right) \cdot b, b, \left(a \cdot a\right) \cdot 4\right) - 1\\
\end{array}
\end{array}
if (*.f64 b b) < 1.99999999999999989e-20Initial program 83.4%
Taylor expanded in a around 0
+-commutativeN/A
associate-+r+N/A
distribute-lft-inN/A
associate-+r+N/A
Applied rewrites78.0%
Taylor expanded in b around 0
sub-negN/A
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-outN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-fma.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
*-commutativeN/A
lower-fma.f6499.9
Applied rewrites99.9%
if 1.99999999999999989e-20 < (*.f64 b b) Initial program 72.3%
Taylor expanded in a around 0
+-commutativeN/A
associate-+r+N/A
distribute-lft-inN/A
associate-+r+N/A
Applied rewrites97.3%
Taylor expanded in b around 0
Applied rewrites97.3%
Taylor expanded in b around 0
Applied rewrites97.3%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e-20) (fma (* a a) (fma a a (fma 4.0 a 4.0)) -1.0) (fma (* b b) 4.0 (fma (* (fma (* a a) 2.0 (* b b)) b) b -1.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e-20) {
tmp = fma((a * a), fma(a, a, fma(4.0, a, 4.0)), -1.0);
} else {
tmp = fma((b * b), 4.0, fma((fma((a * a), 2.0, (b * b)) * b), b, -1.0));
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e-20) tmp = fma(Float64(a * a), fma(a, a, fma(4.0, a, 4.0)), -1.0); else tmp = fma(Float64(b * b), 4.0, fma(Float64(fma(Float64(a * a), 2.0, Float64(b * b)) * b), b, -1.0)); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e-20], N[(N[(a * a), $MachinePrecision] * N[(a * a + N[(4.0 * a + 4.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * 4.0 + N[(N[(N[(N[(a * a), $MachinePrecision] * 2.0 + N[(b * b), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] * b + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{-20}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot a, \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right), -1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot b, 4, \mathsf{fma}\left(\mathsf{fma}\left(a \cdot a, 2, b \cdot b\right) \cdot b, b, -1\right)\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 1.99999999999999989e-20Initial program 83.4%
Taylor expanded in a around 0
+-commutativeN/A
associate-+r+N/A
distribute-lft-inN/A
associate-+r+N/A
Applied rewrites78.0%
Taylor expanded in b around 0
sub-negN/A
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-outN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-fma.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
*-commutativeN/A
lower-fma.f6499.9
Applied rewrites99.9%
if 1.99999999999999989e-20 < (*.f64 b b) Initial program 72.3%
Taylor expanded in b around 0
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-inN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6439.0
Applied rewrites39.0%
Taylor expanded in a around 0
unpow2N/A
lower-*.f6466.6
Applied rewrites66.6%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites57.1%
Taylor expanded in a around 0
sub-negN/A
metadata-evalN/A
associate-*r*N/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-inN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites97.1%
(FPCore (a b) :precision binary64 (if (or (<= a -0.000115) (not (<= a 12.0))) (fma (* a a) (fma a a (fma 4.0 a 4.0)) -1.0) (fma (fma b b 4.0) (* b b) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -0.000115) || !(a <= 12.0)) {
tmp = fma((a * a), fma(a, a, fma(4.0, a, 4.0)), -1.0);
} else {
tmp = fma(fma(b, b, 4.0), (b * b), -1.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if ((a <= -0.000115) || !(a <= 12.0)) tmp = fma(Float64(a * a), fma(a, a, fma(4.0, a, 4.0)), -1.0); else tmp = fma(fma(b, b, 4.0), Float64(b * b), -1.0); end return tmp end
code[a_, b_] := If[Or[LessEqual[a, -0.000115], N[Not[LessEqual[a, 12.0]], $MachinePrecision]], N[(N[(a * a), $MachinePrecision] * N[(a * a + N[(4.0 * a + 4.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(b * b + 4.0), $MachinePrecision] * N[(b * b), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.000115 \lor \neg \left(a \leq 12\right):\\
\;\;\;\;\mathsf{fma}\left(a \cdot a, \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right), -1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, b, 4\right), b \cdot b, -1\right)\\
\end{array}
\end{array}
if a < -1.15e-4 or 12 < a Initial program 52.4%
Taylor expanded in a around 0
+-commutativeN/A
associate-+r+N/A
distribute-lft-inN/A
associate-+r+N/A
Applied rewrites70.8%
Taylor expanded in b around 0
sub-negN/A
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-outN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-fma.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
*-commutativeN/A
lower-fma.f6491.9
Applied rewrites91.9%
if -1.15e-4 < a < 12Initial program 99.9%
Taylor expanded in a around 0
+-commutativeN/A
associate-+r+N/A
distribute-lft-inN/A
associate-+r+N/A
Applied rewrites99.9%
Taylor expanded in a around 0
sub-negN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-inN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6499.9
Applied rewrites99.9%
Final simplification96.3%
(FPCore (a b) :precision binary64 (if (or (<= a -3.5e+153) (not (<= a 1.85e+147))) (- (* (* a a) 4.0) 1.0) (fma (fma b b 4.0) (* b b) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -3.5e+153) || !(a <= 1.85e+147)) {
tmp = ((a * a) * 4.0) - 1.0;
} else {
tmp = fma(fma(b, b, 4.0), (b * b), -1.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if ((a <= -3.5e+153) || !(a <= 1.85e+147)) tmp = Float64(Float64(Float64(a * a) * 4.0) - 1.0); else tmp = fma(fma(b, b, 4.0), Float64(b * b), -1.0); end return tmp end
code[a_, b_] := If[Or[LessEqual[a, -3.5e+153], N[Not[LessEqual[a, 1.85e+147]], $MachinePrecision]], N[(N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(b * b + 4.0), $MachinePrecision] * N[(b * b), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.5 \cdot 10^{+153} \lor \neg \left(a \leq 1.85 \cdot 10^{+147}\right):\\
\;\;\;\;\left(a \cdot a\right) \cdot 4 - 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, b, 4\right), b \cdot b, -1\right)\\
\end{array}
\end{array}
if a < -3.4999999999999999e153 or 1.85e147 < a Initial program 37.9%
Taylor expanded in a around 0
+-commutativeN/A
associate-+r+N/A
distribute-lft-inN/A
associate-+r+N/A
Applied rewrites95.5%
Taylor expanded in b around 0
Applied rewrites95.5%
if -3.4999999999999999e153 < a < 1.85e147Initial program 90.2%
Taylor expanded in a around 0
+-commutativeN/A
associate-+r+N/A
distribute-lft-inN/A
associate-+r+N/A
Applied rewrites84.2%
Taylor expanded in a around 0
sub-negN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-inN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6482.1
Applied rewrites82.1%
Final simplification85.1%
(FPCore (a b) :precision binary64 (if (or (<= a -3.5e+153) (not (<= a 1.85e+147))) (- (* (* a a) 4.0) 1.0) (fma (* (fma b b 4.0) b) b -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -3.5e+153) || !(a <= 1.85e+147)) {
tmp = ((a * a) * 4.0) - 1.0;
} else {
tmp = fma((fma(b, b, 4.0) * b), b, -1.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if ((a <= -3.5e+153) || !(a <= 1.85e+147)) tmp = Float64(Float64(Float64(a * a) * 4.0) - 1.0); else tmp = fma(Float64(fma(b, b, 4.0) * b), b, -1.0); end return tmp end
code[a_, b_] := If[Or[LessEqual[a, -3.5e+153], N[Not[LessEqual[a, 1.85e+147]], $MachinePrecision]], N[(N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(N[(b * b + 4.0), $MachinePrecision] * b), $MachinePrecision] * b + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.5 \cdot 10^{+153} \lor \neg \left(a \leq 1.85 \cdot 10^{+147}\right):\\
\;\;\;\;\left(a \cdot a\right) \cdot 4 - 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, b, 4\right) \cdot b, b, -1\right)\\
\end{array}
\end{array}
if a < -3.4999999999999999e153 or 1.85e147 < a Initial program 37.9%
Taylor expanded in a around 0
+-commutativeN/A
associate-+r+N/A
distribute-lft-inN/A
associate-+r+N/A
Applied rewrites95.5%
Taylor expanded in b around 0
Applied rewrites95.5%
if -3.4999999999999999e153 < a < 1.85e147Initial program 90.2%
Taylor expanded in a around inf
unpow3N/A
unpow2N/A
associate-*l*N/A
distribute-lft-inN/A
*-rgt-identityN/A
rgt-mult-inverseN/A
unpow2N/A
+-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6494.4
Applied rewrites94.4%
Taylor expanded in a around 0
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-pow.f6494.5
Applied rewrites94.5%
Taylor expanded in a around 0
sub-negN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-inN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f6482.1
Applied rewrites82.1%
Final simplification85.1%
(FPCore (a b) :precision binary64 (if (<= (* b b) 4e+306) (- (* (* a a) 4.0) 1.0) (fma 4.0 (* b b) -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 4e+306) {
tmp = ((a * a) * 4.0) - 1.0;
} else {
tmp = fma(4.0, (b * b), -1.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 4e+306) tmp = Float64(Float64(Float64(a * a) * 4.0) - 1.0); else tmp = fma(4.0, Float64(b * b), -1.0); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 4e+306], N[(N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision] - 1.0), $MachinePrecision], N[(4.0 * N[(b * b), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 4 \cdot 10^{+306}:\\
\;\;\;\;\left(a \cdot a\right) \cdot 4 - 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(4, b \cdot b, -1\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 4.00000000000000007e306Initial program 82.3%
Taylor expanded in a around 0
+-commutativeN/A
associate-+r+N/A
distribute-lft-inN/A
associate-+r+N/A
Applied rewrites83.9%
Taylor expanded in b around 0
Applied rewrites60.8%
if 4.00000000000000007e306 < (*.f64 b b) Initial program 60.0%
Taylor expanded in a around 0
+-commutativeN/A
associate-+r+N/A
distribute-lft-inN/A
associate-+r+N/A
Applied rewrites100.0%
Taylor expanded in a around 0
sub-negN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-inN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in b around 0
Applied rewrites100.0%
(FPCore (a b) :precision binary64 (fma 4.0 (* b b) -1.0))
double code(double a, double b) {
return fma(4.0, (b * b), -1.0);
}
function code(a, b) return fma(4.0, Float64(b * b), -1.0) end
code[a_, b_] := N[(4.0 * N[(b * b), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(4, b \cdot b, -1\right)
\end{array}
Initial program 78.4%
Taylor expanded in a around 0
+-commutativeN/A
associate-+r+N/A
distribute-lft-inN/A
associate-+r+N/A
Applied rewrites86.8%
Taylor expanded in a around 0
sub-negN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-inN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6468.8
Applied rewrites68.8%
Taylor expanded in b around 0
Applied rewrites50.2%
(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 78.4%
Taylor expanded in a around 0
+-commutativeN/A
associate-+r+N/A
distribute-lft-inN/A
associate-+r+N/A
Applied rewrites86.8%
Taylor expanded in a around 0
sub-negN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-inN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6468.8
Applied rewrites68.8%
Taylor expanded in b around 0
Applied rewrites30.8%
herbie shell --seed 2024305
(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))