
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 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 * (b * b))) - 1.0d0
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(b * b))) - 1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (b * b))) - 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[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\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 (* b b))) 1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 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 * (b * b))) - 1.0d0
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(b * b))) - 1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (b * b))) - 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[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1
\end{array}
(FPCore (a b) :precision binary64 (- (+ (* 4.0 (* b b)) (pow (+ (* b b) (* a a)) 2.0)) 1.0))
double code(double a, double b) {
return ((4.0 * (b * b)) + pow(((b * b) + (a * a)), 2.0)) - 1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((4.0d0 * (b * b)) + (((b * b) + (a * a)) ** 2.0d0)) - 1.0d0
end function
public static double code(double a, double b) {
return ((4.0 * (b * b)) + Math.pow(((b * b) + (a * a)), 2.0)) - 1.0;
}
def code(a, b): return ((4.0 * (b * b)) + math.pow(((b * b) + (a * a)), 2.0)) - 1.0
function code(a, b) return Float64(Float64(Float64(4.0 * Float64(b * b)) + (Float64(Float64(b * b) + Float64(a * a)) ^ 2.0)) - 1.0) end
function tmp = code(a, b) tmp = ((4.0 * (b * b)) + (((b * b) + (a * a)) ^ 2.0)) - 1.0; end
code[a_, b_] := N[(N[(N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(b * b), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left(4 \cdot \left(b \cdot b\right) + {\left(b \cdot b + a \cdot a\right)}^{2}\right) - 1
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (a b) :precision binary64 (if (<= (* a a) 100000000.0) (- (fma (* b b) 4.0 (pow b 4.0)) 1.0) (- (* (* (fma (* b b) 2.0 (* a a)) a) a) 1.0)))
double code(double a, double b) {
double tmp;
if ((a * a) <= 100000000.0) {
tmp = fma((b * b), 4.0, pow(b, 4.0)) - 1.0;
} else {
tmp = ((fma((b * b), 2.0, (a * a)) * a) * a) - 1.0;
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(a * a) <= 100000000.0) tmp = Float64(fma(Float64(b * b), 4.0, (b ^ 4.0)) - 1.0); else tmp = Float64(Float64(Float64(fma(Float64(b * b), 2.0, Float64(a * a)) * a) * a) - 1.0); end return tmp end
code[a_, b_] := If[LessEqual[N[(a * a), $MachinePrecision], 100000000.0], N[(N[(N[(b * b), $MachinePrecision] * 4.0 + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(N[(N[(N[(b * b), $MachinePrecision] * 2.0 + N[(a * a), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision] - 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot a \leq 100000000:\\
\;\;\;\;\mathsf{fma}\left(b \cdot b, 4, {b}^{4}\right) - 1\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(b \cdot b, 2, a \cdot a\right) \cdot a\right) \cdot a - 1\\
\end{array}
\end{array}
if (*.f64 a a) < 1e8Initial program 99.9%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-pow.f6499.4
Applied rewrites99.4%
if 1e8 < (*.f64 a a) Initial program 99.9%
Taylor expanded in a around inf
*-commutativeN/A
+-commutativeN/A
distribute-lft1-inN/A
associate-*r/N/A
associate-*l/N/A
associate-/l*N/A
metadata-evalN/A
pow-sqrN/A
associate-/l*N/A
*-inversesN/A
*-rgt-identityN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-inN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
Applied rewrites98.4%
(FPCore (a b) :precision binary64 (if (<= (* a a) 100000000.0) (- (* (+ (* 4.0 b) (* (fma (* a a) 2.0 (* b b)) b)) b) 1.0) (- (* (* (fma (* b b) 2.0 (* a a)) a) a) 1.0)))
double code(double a, double b) {
double tmp;
if ((a * a) <= 100000000.0) {
tmp = (((4.0 * b) + (fma((a * a), 2.0, (b * b)) * b)) * b) - 1.0;
} else {
tmp = ((fma((b * b), 2.0, (a * a)) * a) * a) - 1.0;
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(a * a) <= 100000000.0) tmp = Float64(Float64(Float64(Float64(4.0 * b) + Float64(fma(Float64(a * a), 2.0, Float64(b * b)) * b)) * b) - 1.0); else tmp = Float64(Float64(Float64(fma(Float64(b * b), 2.0, Float64(a * a)) * a) * a) - 1.0); end return tmp end
code[a_, b_] := If[LessEqual[N[(a * a), $MachinePrecision], 100000000.0], N[(N[(N[(N[(4.0 * b), $MachinePrecision] + N[(N[(N[(a * a), $MachinePrecision] * 2.0 + N[(b * b), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(N[(N[(N[(b * b), $MachinePrecision] * 2.0 + N[(a * a), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision] - 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot a \leq 100000000:\\
\;\;\;\;\left(4 \cdot b + \mathsf{fma}\left(a \cdot a, 2, b \cdot b\right) \cdot b\right) \cdot b - 1\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(b \cdot b, 2, a \cdot a\right) \cdot a\right) \cdot a - 1\\
\end{array}
\end{array}
if (*.f64 a a) < 1e8Initial program 99.9%
Taylor expanded in a around 0
associate-+r+N/A
associate-*r*N/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-lft-inN/A
associate-+r+N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites99.3%
Applied rewrites99.3%
if 1e8 < (*.f64 a a) Initial program 99.9%
Taylor expanded in a around inf
*-commutativeN/A
+-commutativeN/A
distribute-lft1-inN/A
associate-*r/N/A
associate-*l/N/A
associate-/l*N/A
metadata-evalN/A
pow-sqrN/A
associate-/l*N/A
*-inversesN/A
*-rgt-identityN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-inN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
Applied rewrites98.4%
Final simplification98.9%
(FPCore (a b) :precision binary64 (if (<= (* a a) 100000000.0) (fma (* (fma b b 4.0) b) b -1.0) (- (* (* (fma (* b b) 2.0 (* a a)) a) a) 1.0)))
double code(double a, double b) {
double tmp;
if ((a * a) <= 100000000.0) {
tmp = fma((fma(b, b, 4.0) * b), b, -1.0);
} else {
tmp = ((fma((b * b), 2.0, (a * a)) * a) * a) - 1.0;
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(a * a) <= 100000000.0) tmp = fma(Float64(fma(b, b, 4.0) * b), b, -1.0); else tmp = Float64(Float64(Float64(fma(Float64(b * b), 2.0, Float64(a * a)) * a) * a) - 1.0); end return tmp end
code[a_, b_] := If[LessEqual[N[(a * a), $MachinePrecision], 100000000.0], N[(N[(N[(b * b + 4.0), $MachinePrecision] * b), $MachinePrecision] * b + -1.0), $MachinePrecision], N[(N[(N[(N[(N[(b * b), $MachinePrecision] * 2.0 + N[(a * a), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision] - 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot a \leq 100000000:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, b, 4\right) \cdot b, b, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(b \cdot b, 2, a \cdot a\right) \cdot a\right) \cdot a - 1\\
\end{array}
\end{array}
if (*.f64 a a) < 1e8Initial program 99.9%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/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
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.f6499.3
Applied rewrites99.3%
if 1e8 < (*.f64 a a) Initial program 99.9%
Taylor expanded in a around inf
*-commutativeN/A
+-commutativeN/A
distribute-lft1-inN/A
associate-*r/N/A
associate-*l/N/A
associate-/l*N/A
metadata-evalN/A
pow-sqrN/A
associate-/l*N/A
*-inversesN/A
*-rgt-identityN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-inN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
Applied rewrites98.4%
(FPCore (a b) :precision binary64 (if (<= (* b b) 10.0) (- (* (* (* a a) a) a) 1.0) (fma (fma b b (fma (* a a) 2.0 4.0)) (* b b) -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 10.0) {
tmp = (((a * a) * a) * a) - 1.0;
} else {
tmp = fma(fma(b, b, fma((a * a), 2.0, 4.0)), (b * b), -1.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 10.0) tmp = Float64(Float64(Float64(Float64(a * a) * a) * a) - 1.0); else tmp = fma(fma(b, b, fma(Float64(a * a), 2.0, 4.0)), Float64(b * b), -1.0); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 10.0], N[(N[(N[(N[(a * a), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(b * b + N[(N[(a * a), $MachinePrecision] * 2.0 + 4.0), $MachinePrecision]), $MachinePrecision] * N[(b * b), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10:\\
\;\;\;\;\left(\left(a \cdot a\right) \cdot a\right) \cdot a - 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, b, \mathsf{fma}\left(a \cdot a, 2, 4\right)\right), b \cdot b, -1\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 10Initial program 99.9%
Taylor expanded in a around inf
*-commutativeN/A
+-commutativeN/A
distribute-lft1-inN/A
associate-*r/N/A
associate-*l/N/A
associate-/l*N/A
metadata-evalN/A
pow-sqrN/A
associate-/l*N/A
*-inversesN/A
*-rgt-identityN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-inN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
Applied rewrites99.6%
Applied rewrites99.5%
Taylor expanded in a around inf
Applied rewrites99.5%
Applied rewrites99.6%
if 10 < (*.f64 b b) Initial program 99.9%
Taylor expanded in a around 0
sub-negN/A
associate-+r+N/A
associate-*r*N/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-lft-inN/A
associate-+r+N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites97.2%
(FPCore (a b) :precision binary64 (if (<= (* a a) 1.2e-13) (fma (* b b) 4.0 -1.0) (if (<= (* a a) 120000000000.0) (* (* b b) (* b b)) (* (* a a) (* a a)))))
double code(double a, double b) {
double tmp;
if ((a * a) <= 1.2e-13) {
tmp = fma((b * b), 4.0, -1.0);
} else if ((a * a) <= 120000000000.0) {
tmp = (b * b) * (b * b);
} else {
tmp = (a * a) * (a * a);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(a * a) <= 1.2e-13) tmp = fma(Float64(b * b), 4.0, -1.0); elseif (Float64(a * a) <= 120000000000.0) tmp = Float64(Float64(b * b) * Float64(b * b)); else tmp = Float64(Float64(a * a) * Float64(a * a)); end return tmp end
code[a_, b_] := If[LessEqual[N[(a * a), $MachinePrecision], 1.2e-13], N[(N[(b * b), $MachinePrecision] * 4.0 + -1.0), $MachinePrecision], If[LessEqual[N[(a * a), $MachinePrecision], 120000000000.0], N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision], N[(N[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot a \leq 1.2 \cdot 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot b, 4, -1\right)\\
\mathbf{elif}\;a \cdot a \leq 120000000000:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right)\\
\end{array}
\end{array}
if (*.f64 a a) < 1.1999999999999999e-13Initial program 99.9%
Taylor expanded in a around 0
sub-negN/A
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-outN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-fma.f64N/A
metadata-eval99.9
Applied rewrites99.9%
Taylor expanded in b around 0
Applied rewrites74.5%
if 1.1999999999999999e-13 < (*.f64 a a) < 1.2e11Initial program 99.8%
Taylor expanded in a around 0
associate-+r+N/A
associate-*r*N/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-lft-inN/A
associate-+r+N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites88.8%
Applied rewrites88.8%
Taylor expanded in b around inf
lower-pow.f6486.0
Applied rewrites86.0%
Applied rewrites85.8%
if 1.2e11 < (*.f64 a a) Initial program 99.9%
Taylor expanded in a around 0
associate-+r+N/A
associate-*r*N/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-lft-inN/A
associate-+r+N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites74.3%
Applied rewrites74.3%
Taylor expanded in a around inf
lower-pow.f6490.1
Applied rewrites90.1%
Applied rewrites90.0%
(FPCore (a b) :precision binary64 (if (<= (* b b) 10.0) (- (* (* (* a a) a) a) 1.0) (fma (* (fma b b 4.0) b) b -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 10.0) {
tmp = (((a * a) * a) * a) - 1.0;
} else {
tmp = fma((fma(b, b, 4.0) * b), b, -1.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 10.0) tmp = Float64(Float64(Float64(Float64(a * a) * a) * a) - 1.0); else tmp = fma(Float64(fma(b, b, 4.0) * b), b, -1.0); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 10.0], N[(N[(N[(N[(a * a), $MachinePrecision] * a), $MachinePrecision] * a), $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}\;b \cdot b \leq 10:\\
\;\;\;\;\left(\left(a \cdot a\right) \cdot a\right) \cdot a - 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, b, 4\right) \cdot b, b, -1\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 10Initial program 99.9%
Taylor expanded in a around inf
*-commutativeN/A
+-commutativeN/A
distribute-lft1-inN/A
associate-*r/N/A
associate-*l/N/A
associate-/l*N/A
metadata-evalN/A
pow-sqrN/A
associate-/l*N/A
*-inversesN/A
*-rgt-identityN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-inN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
Applied rewrites99.6%
Applied rewrites99.5%
Taylor expanded in a around inf
Applied rewrites99.5%
Applied rewrites99.6%
if 10 < (*.f64 b b) Initial program 99.9%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/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
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.f6492.3
Applied rewrites92.3%
(FPCore (a b) :precision binary64 (if (<= (* b b) 10.0) (- (* (* a a) (* a a)) 1.0) (fma (* (fma b b 4.0) b) b -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 10.0) {
tmp = ((a * a) * (a * a)) - 1.0;
} else {
tmp = fma((fma(b, b, 4.0) * b), b, -1.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 10.0) tmp = Float64(Float64(Float64(a * a) * Float64(a * a)) - 1.0); else tmp = fma(Float64(fma(b, b, 4.0) * b), b, -1.0); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 10.0], N[(N[(N[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision]), $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}\;b \cdot b \leq 10:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right) - 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, b, 4\right) \cdot b, b, -1\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 10Initial program 99.9%
Taylor expanded in a around inf
*-commutativeN/A
+-commutativeN/A
distribute-lft1-inN/A
associate-*r/N/A
associate-*l/N/A
associate-/l*N/A
metadata-evalN/A
pow-sqrN/A
associate-/l*N/A
*-inversesN/A
*-rgt-identityN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-inN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
Applied rewrites99.6%
Applied rewrites99.5%
Taylor expanded in a around inf
Applied rewrites99.5%
if 10 < (*.f64 b b) Initial program 99.9%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/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
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.f6492.3
Applied rewrites92.3%
(FPCore (a b) :precision binary64 (if (<= (* a a) 106000000000.0) (fma (* (fma b b 4.0) b) b -1.0) (* (* a a) (* a a))))
double code(double a, double b) {
double tmp;
if ((a * a) <= 106000000000.0) {
tmp = fma((fma(b, b, 4.0) * b), b, -1.0);
} else {
tmp = (a * a) * (a * a);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(a * a) <= 106000000000.0) tmp = fma(Float64(fma(b, b, 4.0) * b), b, -1.0); else tmp = Float64(Float64(a * a) * Float64(a * a)); end return tmp end
code[a_, b_] := If[LessEqual[N[(a * a), $MachinePrecision], 106000000000.0], N[(N[(N[(b * b + 4.0), $MachinePrecision] * b), $MachinePrecision] * b + -1.0), $MachinePrecision], N[(N[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot a \leq 106000000000:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, b, 4\right) \cdot b, b, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right)\\
\end{array}
\end{array}
if (*.f64 a a) < 1.06e11Initial program 99.9%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/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
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.f6499.3
Applied rewrites99.3%
if 1.06e11 < (*.f64 a a) Initial program 99.9%
Taylor expanded in a around 0
associate-+r+N/A
associate-*r*N/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-lft-inN/A
associate-+r+N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites74.3%
Applied rewrites74.3%
Taylor expanded in a around inf
lower-pow.f6490.1
Applied rewrites90.1%
Applied rewrites90.0%
(FPCore (a b) :precision binary64 (if (<= (* a a) 106000000000.0) (fma (* b b) (fma b b 4.0) -1.0) (* (* a a) (* a a))))
double code(double a, double b) {
double tmp;
if ((a * a) <= 106000000000.0) {
tmp = fma((b * b), fma(b, b, 4.0), -1.0);
} else {
tmp = (a * a) * (a * a);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(a * a) <= 106000000000.0) tmp = fma(Float64(b * b), fma(b, b, 4.0), -1.0); else tmp = Float64(Float64(a * a) * Float64(a * a)); end return tmp end
code[a_, b_] := If[LessEqual[N[(a * a), $MachinePrecision], 106000000000.0], N[(N[(b * b), $MachinePrecision] * N[(b * b + 4.0), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot a \leq 106000000000:\\
\;\;\;\;\mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, b, 4\right), -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right)\\
\end{array}
\end{array}
if (*.f64 a a) < 1.06e11Initial program 99.9%
Taylor expanded in a around 0
sub-negN/A
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-outN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-fma.f64N/A
metadata-eval99.3
Applied rewrites99.3%
if 1.06e11 < (*.f64 a a) Initial program 99.9%
Taylor expanded in a around 0
associate-+r+N/A
associate-*r*N/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-lft-inN/A
associate-+r+N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites74.3%
Applied rewrites74.3%
Taylor expanded in a around inf
lower-pow.f6490.1
Applied rewrites90.1%
Applied rewrites90.0%
(FPCore (a b) :precision binary64 (if (<= (* a a) 106000000000.0) (fma (* (* b b) b) b -1.0) (* (* a a) (* a a))))
double code(double a, double b) {
double tmp;
if ((a * a) <= 106000000000.0) {
tmp = fma(((b * b) * b), b, -1.0);
} else {
tmp = (a * a) * (a * a);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(a * a) <= 106000000000.0) tmp = fma(Float64(Float64(b * b) * b), b, -1.0); else tmp = Float64(Float64(a * a) * Float64(a * a)); end return tmp end
code[a_, b_] := If[LessEqual[N[(a * a), $MachinePrecision], 106000000000.0], N[(N[(N[(b * b), $MachinePrecision] * b), $MachinePrecision] * b + -1.0), $MachinePrecision], N[(N[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot a \leq 106000000000:\\
\;\;\;\;\mathsf{fma}\left(\left(b \cdot b\right) \cdot b, b, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right)\\
\end{array}
\end{array}
if (*.f64 a a) < 1.06e11Initial program 99.9%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/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
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.f6499.3
Applied rewrites99.3%
Taylor expanded in b around 0
Applied rewrites71.7%
Taylor expanded in b around inf
Applied rewrites98.6%
if 1.06e11 < (*.f64 a a) Initial program 99.9%
Taylor expanded in a around 0
associate-+r+N/A
associate-*r*N/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-lft-inN/A
associate-+r+N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites74.3%
Applied rewrites74.3%
Taylor expanded in a around inf
lower-pow.f6490.1
Applied rewrites90.1%
Applied rewrites90.0%
(FPCore (a b) :precision binary64 (if (<= (* a a) 22000000000.0) (fma (* b b) 4.0 -1.0) (* (* a a) (* a a))))
double code(double a, double b) {
double tmp;
if ((a * a) <= 22000000000.0) {
tmp = fma((b * b), 4.0, -1.0);
} else {
tmp = (a * a) * (a * a);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(a * a) <= 22000000000.0) tmp = fma(Float64(b * b), 4.0, -1.0); else tmp = Float64(Float64(a * a) * Float64(a * a)); end return tmp end
code[a_, b_] := If[LessEqual[N[(a * a), $MachinePrecision], 22000000000.0], N[(N[(b * b), $MachinePrecision] * 4.0 + -1.0), $MachinePrecision], N[(N[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot a \leq 22000000000:\\
\;\;\;\;\mathsf{fma}\left(b \cdot b, 4, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right)\\
\end{array}
\end{array}
if (*.f64 a a) < 2.2e10Initial program 99.9%
Taylor expanded in a around 0
sub-negN/A
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-outN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-fma.f64N/A
metadata-eval99.3
Applied rewrites99.3%
Taylor expanded in b around 0
Applied rewrites71.7%
if 2.2e10 < (*.f64 a a) Initial program 99.9%
Taylor expanded in a around 0
associate-+r+N/A
associate-*r*N/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-lft-inN/A
associate-+r+N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites74.3%
Applied rewrites74.3%
Taylor expanded in a around inf
lower-pow.f6490.1
Applied rewrites90.1%
Applied rewrites90.0%
(FPCore (a b) :precision binary64 (fma (* b b) 4.0 -1.0))
double code(double a, double b) {
return fma((b * b), 4.0, -1.0);
}
function code(a, b) return fma(Float64(b * b), 4.0, -1.0) end
code[a_, b_] := N[(N[(b * b), $MachinePrecision] * 4.0 + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(b \cdot b, 4, -1\right)
\end{array}
Initial program 99.9%
Taylor expanded in a around 0
sub-negN/A
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-outN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-fma.f64N/A
metadata-eval73.5
Applied rewrites73.5%
Taylor expanded in b around 0
Applied rewrites52.8%
(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 99.9%
Taylor expanded in a around 0
sub-negN/A
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-outN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-fma.f64N/A
metadata-eval73.5
Applied rewrites73.5%
Taylor expanded in b around 0
Applied rewrites24.7%
herbie shell --seed 2024295
(FPCore (a b)
:name "Bouland and Aaronson, Equation (26)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))