
(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 (- (+ (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}
Initial program 99.9%
(FPCore (a b) :precision binary64 (if (<= (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 0.04) -1.0 (* (* 4.0 b) b)))
double code(double a, double b) {
double tmp;
if ((pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) <= 0.04) {
tmp = -1.0;
} else {
tmp = (4.0 * b) * b;
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * (b * b))) <= 0.04d0) then
tmp = -1.0d0
else
tmp = (4.0d0 * b) * b
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) <= 0.04) {
tmp = -1.0;
} else {
tmp = (4.0 * b) * b;
}
return tmp;
}
def code(a, b): tmp = 0 if (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) <= 0.04: tmp = -1.0 else: tmp = (4.0 * b) * b return tmp
function code(a, b) tmp = 0.0 if (Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(b * b))) <= 0.04) tmp = -1.0; else tmp = Float64(Float64(4.0 * b) * b); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (((((a * a) + (b * b)) ^ 2.0) + (4.0 * (b * b))) <= 0.04) tmp = -1.0; else tmp = (4.0 * b) * b; end tmp_2 = 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[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.04], -1.0, N[(N[(4.0 * b), $MachinePrecision] * b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right) \leq 0.04:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;\left(4 \cdot b\right) \cdot b\\
\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 b b))) < 0.0400000000000000008Initial program 100.0%
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-eval98.0
Applied rewrites98.0%
Taylor expanded in b around 0
Applied rewrites97.5%
if 0.0400000000000000008 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (*.f64 b b))) 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-eval56.4
Applied rewrites56.4%
Taylor expanded in b around 0
Applied rewrites34.4%
Taylor expanded in b around inf
Applied rewrites34.9%
Applied rewrites34.9%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e+28) (- (pow a 4.0) 1.0) (- (* (* (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) <= 1e+28) {
tmp = pow(a, 4.0) - 1.0;
} else {
tmp = ((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) <= 1e+28) tmp = Float64((a ^ 4.0) - 1.0); else tmp = Float64(Float64(Float64(fma(b, b, fma(Float64(a * a), 2.0, 4.0)) * b) * b) - 1.0); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e+28], N[(N[Power[a, 4.0], $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(N[(N[(b * b + N[(N[(a * a), $MachinePrecision] * 2.0 + 4.0), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision] - 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{+28}:\\
\;\;\;\;{a}^{4} - 1\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(b, b, \mathsf{fma}\left(a \cdot a, 2, 4\right)\right) \cdot b\right) \cdot b - 1\\
\end{array}
\end{array}
if (*.f64 b b) < 9.99999999999999958e27Initial program 99.9%
Taylor expanded in a around inf
lower-pow.f6499.8
Applied rewrites99.8%
if 9.99999999999999958e27 < (*.f64 b b) 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 rewrites96.9%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e+28) (- (* (* a a) (* a a)) 1.0) (- (* (* (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) <= 1e+28) {
tmp = ((a * a) * (a * a)) - 1.0;
} else {
tmp = ((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) <= 1e+28) tmp = Float64(Float64(Float64(a * a) * Float64(a * a)) - 1.0); else tmp = Float64(Float64(Float64(fma(b, b, fma(Float64(a * a), 2.0, 4.0)) * b) * b) - 1.0); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e+28], N[(N[(N[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(N[(N[(b * b + N[(N[(a * a), $MachinePrecision] * 2.0 + 4.0), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision] - 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{+28}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right) - 1\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(b, b, \mathsf{fma}\left(a \cdot a, 2, 4\right)\right) \cdot b\right) \cdot b - 1\\
\end{array}
\end{array}
if (*.f64 b b) < 9.99999999999999958e27Initial program 99.9%
Taylor expanded in a around inf
lower-pow.f6499.8
Applied rewrites99.8%
Applied rewrites99.6%
if 9.99999999999999958e27 < (*.f64 b b) 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 rewrites96.9%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e+28) (- (* (* 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) <= 1e+28) {
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) <= 1e+28) tmp = Float64(Float64(Float64(a * a) * Float64(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], 1e+28], N[(N[(N[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision]), $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^{+28}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right) - 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) < 9.99999999999999958e27Initial program 99.9%
Taylor expanded in a around inf
lower-pow.f6499.8
Applied rewrites99.8%
Applied rewrites99.6%
if 9.99999999999999958e27 < (*.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 rewrites96.9%
(FPCore (a b) :precision binary64 (if (<= (* a a) 5e+17) (fma (* (fma b b 4.0) b) b -1.0) (* (* (fma (* b b) 2.0 (* a a)) a) a)))
double code(double a, double b) {
double tmp;
if ((a * a) <= 5e+17) {
tmp = fma((fma(b, b, 4.0) * b), b, -1.0);
} else {
tmp = (fma((b * b), 2.0, (a * a)) * a) * a;
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(a * a) <= 5e+17) tmp = fma(Float64(fma(b, b, 4.0) * b), b, -1.0); else tmp = Float64(Float64(fma(Float64(b * b), 2.0, Float64(a * a)) * a) * a); end return tmp end
code[a_, b_] := If[LessEqual[N[(a * a), $MachinePrecision], 5e+17], N[(N[(N[(b * b + 4.0), $MachinePrecision] * b), $MachinePrecision] * b + -1.0), $MachinePrecision], N[(N[(N[(N[(b * b), $MachinePrecision] * 2.0 + N[(a * a), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot a \leq 5 \cdot 10^{+17}:\\
\;\;\;\;\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\\
\end{array}
\end{array}
if (*.f64 a a) < 5e17Initial 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 rewrites97.5%
Taylor expanded in a around 0
sub-negN/A
+-commutativeN/A
metadata-evalN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f6497.5
Applied rewrites97.5%
if 5e17 < (*.f64 a a) Initial program 99.9%
Taylor expanded in a around inf
lower-pow.f6491.8
Applied rewrites91.8%
Applied rewrites91.7%
Taylor expanded in a around inf
distribute-lft-inN/A
*-rgt-identityN/A
metadata-evalN/A
pow-sqrN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
metadata-evalN/A
pow-sqrN/A
associate-*r*N/A
*-rgt-identityN/A
associate-*r/N/A
associate-*l*N/A
lft-mult-inverseN/A
*-rgt-identityN/A
*-commutativeN/A
*-commutativeN/A
Applied rewrites97.7%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e+89) (- (* (* a a) (* a a)) 1.0) (fma (* (* b b) b) b -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e+89) {
tmp = ((a * a) * (a * a)) - 1.0;
} else {
tmp = fma(((b * b) * b), b, -1.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1e+89) tmp = Float64(Float64(Float64(a * a) * Float64(a * a)) - 1.0); else tmp = fma(Float64(Float64(b * b) * b), b, -1.0); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e+89], N[(N[(N[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(N[(b * b), $MachinePrecision] * b), $MachinePrecision] * b + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{+89}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right) - 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(b \cdot b\right) \cdot b, b, -1\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 9.99999999999999995e88Initial program 99.9%
Taylor expanded in a around inf
lower-pow.f6496.5
Applied rewrites96.5%
Applied rewrites96.4%
if 9.99999999999999995e88 < (*.f64 b b) 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 rewrites100.0%
Taylor expanded in a around 0
sub-negN/A
+-commutativeN/A
metadata-evalN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f6496.4
Applied rewrites96.4%
Taylor expanded in b around inf
Applied rewrites96.4%
(FPCore (a b) :precision binary64 (if (<= (* a a) 2e+47) (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) <= 2e+47) {
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) <= 2e+47) tmp = fma(Float64(fma(b, b, 4.0) * b), b, -1.0); else tmp = Float64(Float64(Float64(a * a) * a) * a); end return tmp end
code[a_, b_] := If[LessEqual[N[(a * a), $MachinePrecision], 2e+47], N[(N[(N[(b * b + 4.0), $MachinePrecision] * b), $MachinePrecision] * b + -1.0), $MachinePrecision], N[(N[(N[(a * a), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot a \leq 2 \cdot 10^{+47}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, b, 4\right) \cdot b, b, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(a \cdot a\right) \cdot a\right) \cdot a\\
\end{array}
\end{array}
if (*.f64 a a) < 2.0000000000000001e47Initial 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 rewrites95.4%
Taylor expanded in a around 0
sub-negN/A
+-commutativeN/A
metadata-evalN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f6495.4
Applied rewrites95.4%
if 2.0000000000000001e47 < (*.f64 a a) Initial program 99.9%
Taylor expanded in a around inf
lower-pow.f6494.6
Applied rewrites94.6%
Applied rewrites94.5%
Taylor expanded in a around inf
distribute-lft-inN/A
*-rgt-identityN/A
metadata-evalN/A
pow-sqrN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
metadata-evalN/A
pow-sqrN/A
associate-*r*N/A
*-rgt-identityN/A
associate-*r/N/A
associate-*l*N/A
lft-mult-inverseN/A
*-rgt-identityN/A
*-commutativeN/A
*-commutativeN/A
Applied rewrites98.4%
Taylor expanded in a around inf
Applied rewrites94.5%
(FPCore (a b) :precision binary64 (if (<= (* a a) 2e+47) (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) <= 2e+47) {
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) <= 2e+47) tmp = fma(Float64(b * b), fma(b, b, 4.0), -1.0); else tmp = Float64(Float64(Float64(a * a) * a) * a); end return tmp end
code[a_, b_] := If[LessEqual[N[(a * a), $MachinePrecision], 2e+47], N[(N[(b * b), $MachinePrecision] * N[(b * b + 4.0), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[(a * a), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot a \leq 2 \cdot 10^{+47}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, b, 4\right), -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(a \cdot a\right) \cdot a\right) \cdot a\\
\end{array}
\end{array}
if (*.f64 a a) < 2.0000000000000001e47Initial 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-eval95.4
Applied rewrites95.4%
if 2.0000000000000001e47 < (*.f64 a a) Initial program 99.9%
Taylor expanded in a around inf
lower-pow.f6494.6
Applied rewrites94.6%
Applied rewrites94.5%
Taylor expanded in a around inf
distribute-lft-inN/A
*-rgt-identityN/A
metadata-evalN/A
pow-sqrN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
metadata-evalN/A
pow-sqrN/A
associate-*r*N/A
*-rgt-identityN/A
associate-*r/N/A
associate-*l*N/A
lft-mult-inverseN/A
*-rgt-identityN/A
*-commutativeN/A
*-commutativeN/A
Applied rewrites98.4%
Taylor expanded in a around inf
Applied rewrites94.5%
(FPCore (a b) :precision binary64 (if (<= (* a a) 2e+47) (fma (* (* b b) b) b -1.0) (* (* (* a a) a) a)))
double code(double a, double b) {
double tmp;
if ((a * a) <= 2e+47) {
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) <= 2e+47) tmp = fma(Float64(Float64(b * b) * b), b, -1.0); else tmp = Float64(Float64(Float64(a * a) * a) * a); end return tmp end
code[a_, b_] := If[LessEqual[N[(a * a), $MachinePrecision], 2e+47], N[(N[(N[(b * b), $MachinePrecision] * b), $MachinePrecision] * b + -1.0), $MachinePrecision], N[(N[(N[(a * a), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot a \leq 2 \cdot 10^{+47}:\\
\;\;\;\;\mathsf{fma}\left(\left(b \cdot b\right) \cdot b, b, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(a \cdot a\right) \cdot a\right) \cdot a\\
\end{array}
\end{array}
if (*.f64 a a) < 2.0000000000000001e47Initial 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 rewrites95.4%
Taylor expanded in a around 0
sub-negN/A
+-commutativeN/A
metadata-evalN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f6495.4
Applied rewrites95.4%
Taylor expanded in b around inf
Applied rewrites95.2%
if 2.0000000000000001e47 < (*.f64 a a) Initial program 99.9%
Taylor expanded in a around inf
lower-pow.f6494.6
Applied rewrites94.6%
Applied rewrites94.5%
Taylor expanded in a around inf
distribute-lft-inN/A
*-rgt-identityN/A
metadata-evalN/A
pow-sqrN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
metadata-evalN/A
pow-sqrN/A
associate-*r*N/A
*-rgt-identityN/A
associate-*r/N/A
associate-*l*N/A
lft-mult-inverseN/A
*-rgt-identityN/A
*-commutativeN/A
*-commutativeN/A
Applied rewrites98.4%
Taylor expanded in a around inf
Applied rewrites94.5%
(FPCore (a b) :precision binary64 (if (<= (* a a) 2e+47) (fma (* b b) (* b b) -1.0) (* (* (* a a) a) a)))
double code(double a, double b) {
double tmp;
if ((a * a) <= 2e+47) {
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) <= 2e+47) tmp = fma(Float64(b * b), Float64(b * b), -1.0); else tmp = Float64(Float64(Float64(a * a) * a) * a); end return tmp end
code[a_, b_] := If[LessEqual[N[(a * a), $MachinePrecision], 2e+47], N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[(a * a), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot a \leq 2 \cdot 10^{+47}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot b, b \cdot b, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(a \cdot a\right) \cdot a\right) \cdot a\\
\end{array}
\end{array}
if (*.f64 a a) < 2.0000000000000001e47Initial 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 rewrites95.4%
Taylor expanded in a around 0
sub-negN/A
+-commutativeN/A
metadata-evalN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f6495.4
Applied rewrites95.4%
Taylor expanded in b around inf
Applied rewrites95.2%
Applied rewrites95.2%
if 2.0000000000000001e47 < (*.f64 a a) Initial program 99.9%
Taylor expanded in a around inf
lower-pow.f6494.6
Applied rewrites94.6%
Applied rewrites94.5%
Taylor expanded in a around inf
distribute-lft-inN/A
*-rgt-identityN/A
metadata-evalN/A
pow-sqrN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
metadata-evalN/A
pow-sqrN/A
associate-*r*N/A
*-rgt-identityN/A
associate-*r/N/A
associate-*l*N/A
lft-mult-inverseN/A
*-rgt-identityN/A
*-commutativeN/A
*-commutativeN/A
Applied rewrites98.4%
Taylor expanded in a around inf
Applied rewrites94.5%
(FPCore (a b) :precision binary64 (if (<= (* a a) 0.2) (fma (* 4.0 b) b -1.0) (* (* (* a a) a) a)))
double code(double a, double b) {
double tmp;
if ((a * a) <= 0.2) {
tmp = fma((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) <= 0.2) tmp = fma(Float64(4.0 * b), b, -1.0); else tmp = Float64(Float64(Float64(a * a) * a) * a); end return tmp end
code[a_, b_] := If[LessEqual[N[(a * a), $MachinePrecision], 0.2], N[(N[(4.0 * b), $MachinePrecision] * b + -1.0), $MachinePrecision], N[(N[(N[(a * a), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot a \leq 0.2:\\
\;\;\;\;\mathsf{fma}\left(4 \cdot b, b, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(a \cdot a\right) \cdot a\right) \cdot a\\
\end{array}
\end{array}
if (*.f64 a a) < 0.20000000000000001Initial program 100.0%
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-eval98.9
Applied rewrites98.9%
Taylor expanded in b around 0
Applied rewrites81.3%
if 0.20000000000000001 < (*.f64 a a) Initial program 99.8%
Taylor expanded in a around inf
lower-pow.f6490.6
Applied rewrites90.6%
Applied rewrites90.5%
Taylor expanded in a around inf
distribute-lft-inN/A
*-rgt-identityN/A
metadata-evalN/A
pow-sqrN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
metadata-evalN/A
pow-sqrN/A
associate-*r*N/A
*-rgt-identityN/A
associate-*r/N/A
associate-*l*N/A
lft-mult-inverseN/A
*-rgt-identityN/A
*-commutativeN/A
*-commutativeN/A
Applied rewrites95.7%
Taylor expanded in a around inf
Applied rewrites89.8%
(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(Float64(4.0 * b), b, -1.0) end
code[a_, b_] := N[(N[(4.0 * b), $MachinePrecision] * b + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(4 \cdot b, b, -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-eval66.8
Applied rewrites66.8%
Taylor expanded in b around 0
Applied rewrites50.3%
(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-eval66.8
Applied rewrites66.8%
Taylor expanded in b around 0
Applied rewrites24.9%
herbie shell --seed 2024309
(FPCore (a b)
:name "Bouland and Aaronson, Equation (26)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))