
(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 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 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 (if (<= a -1e+107) (fma (* (* a a) a) a -1.0) (- (+ (* (* (fma a a a) a) 4.0) (pow (+ (* b b) (* a a)) 2.0)) 1.0)))
double code(double a, double b) {
double tmp;
if (a <= -1e+107) {
tmp = fma(((a * a) * a), a, -1.0);
} else {
tmp = (((fma(a, a, a) * a) * 4.0) + pow(((b * b) + (a * a)), 2.0)) - 1.0;
}
return tmp;
}
function code(a, b) tmp = 0.0 if (a <= -1e+107) tmp = fma(Float64(Float64(a * a) * a), a, -1.0); else tmp = Float64(Float64(Float64(Float64(fma(a, a, a) * a) * 4.0) + (Float64(Float64(b * b) + Float64(a * a)) ^ 2.0)) - 1.0); end return tmp end
code[a_, b_] := If[LessEqual[a, -1e+107], N[(N[(N[(a * a), $MachinePrecision] * a), $MachinePrecision] * a + -1.0), $MachinePrecision], N[(N[(N[(N[(N[(a * a + a), $MachinePrecision] * a), $MachinePrecision] * 4.0), $MachinePrecision] + N[Power[N[(N[(b * b), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1 \cdot 10^{+107}:\\
\;\;\;\;\mathsf{fma}\left(\left(a \cdot a\right) \cdot a, a, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(a, a, a\right) \cdot a\right) \cdot 4 + {\left(b \cdot b + a \cdot a\right)}^{2}\right) - 1\\
\end{array}
\end{array}
if a < -9.9999999999999997e106Initial program 0.0%
Taylor expanded in b around 0
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f640.0
Applied rewrites0.0%
Taylor expanded in b around 0
sub-negN/A
*-commutativeN/A
associate-*l*N/A
+-commutativeN/A
distribute-rgt1-inN/A
*-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-lft-inN/A
associate-+r+N/A
unpow2N/A
distribute-rgt-inN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
metadata-evalN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in a around inf
Applied rewrites100.0%
if -9.9999999999999997e106 < a Initial program 86.3%
Taylor expanded in b around 0
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6499.3
Applied rewrites99.3%
Final simplification99.4%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e-30) (fma (* (fma (+ 4.0 a) a 4.0) a) a -1.0) (fma (* b b) 4.0 (- (* (* (fma (* a a) 2.0 (* b b)) b) b) 1.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e-30) {
tmp = fma((fma((4.0 + a), a, 4.0) * a), a, -1.0);
} else {
tmp = fma((b * b), 4.0, (((fma((a * a), 2.0, (b * b)) * b) * b) - 1.0));
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e-30) tmp = fma(Float64(fma(Float64(4.0 + a), a, 4.0) * a), a, -1.0); else tmp = fma(Float64(b * b), 4.0, Float64(Float64(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], 5e-30], N[(N[(N[(N[(4.0 + a), $MachinePrecision] * a + 4.0), $MachinePrecision] * a), $MachinePrecision] * a + -1.0), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * 4.0 + N[(N[(N[(N[(N[(a * a), $MachinePrecision] * 2.0 + N[(b * b), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{-30}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(4 + a, a, 4\right) \cdot a, a, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot b, 4, \left(\mathsf{fma}\left(a \cdot a, 2, b \cdot b\right) \cdot b\right) \cdot b - 1\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 4.99999999999999972e-30Initial program 88.1%
Taylor expanded in b around 0
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6488.1
Applied rewrites88.1%
Taylor expanded in b around 0
sub-negN/A
*-commutativeN/A
associate-*l*N/A
+-commutativeN/A
distribute-rgt1-inN/A
*-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-lft-inN/A
associate-+r+N/A
unpow2N/A
distribute-rgt-inN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
metadata-evalN/A
lower-fma.f64N/A
Applied rewrites100.0%
if 4.99999999999999972e-30 < (*.f64 b b) Initial program 60.4%
Taylor expanded in a around 0
associate-*r*N/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-inN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6460.3
Applied rewrites60.3%
Taylor expanded in a around 0
unpow2N/A
lower-*.f6498.5
Applied rewrites98.5%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites98.5%
(FPCore (a b) :precision binary64 (if (<= (* b b) 0.5) (fma (* (fma (+ 4.0 a) a 4.0) a) a -1.0) (fma (* b b) (fma b b 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 0.5) {
tmp = fma((fma((4.0 + a), a, 4.0) * a), a, -1.0);
} else {
tmp = fma((b * b), fma(b, b, 4.0), -1.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 0.5) tmp = fma(Float64(fma(Float64(4.0 + a), a, 4.0) * a), a, -1.0); else tmp = fma(Float64(b * b), fma(b, b, 4.0), -1.0); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 0.5], N[(N[(N[(N[(4.0 + a), $MachinePrecision] * a + 4.0), $MachinePrecision] * a), $MachinePrecision] * a + -1.0), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * N[(b * b + 4.0), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 0.5:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(4 + a, a, 4\right) \cdot a, a, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, b, 4\right), -1\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 0.5Initial program 88.2%
Taylor expanded in b around 0
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6488.2
Applied rewrites88.2%
Taylor expanded in b around 0
sub-negN/A
*-commutativeN/A
associate-*l*N/A
+-commutativeN/A
distribute-rgt1-inN/A
*-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-lft-inN/A
associate-+r+N/A
unpow2N/A
distribute-rgt-inN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
metadata-evalN/A
lower-fma.f64N/A
Applied rewrites100.0%
if 0.5 < (*.f64 b b) Initial program 60.1%
Taylor expanded in b around 0
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6482.4
Applied rewrites82.4%
Taylor expanded in a around 0
sub-negN/A
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-outN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-fma.f6492.5
Applied rewrites92.5%
(FPCore (a b) :precision binary64 (if (<= (* b b) 0.5) (fma (* (* (+ 4.0 a) a) a) a -1.0) (fma (* b b) (fma b b 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 0.5) {
tmp = fma((((4.0 + a) * a) * a), a, -1.0);
} else {
tmp = fma((b * b), fma(b, b, 4.0), -1.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 0.5) tmp = fma(Float64(Float64(Float64(4.0 + a) * a) * a), a, -1.0); else tmp = fma(Float64(b * b), fma(b, b, 4.0), -1.0); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 0.5], N[(N[(N[(N[(4.0 + a), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision] * a + -1.0), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * N[(b * b + 4.0), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 0.5:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(4 + a\right) \cdot a\right) \cdot a, a, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, b, 4\right), -1\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 0.5Initial program 88.2%
Taylor expanded in b around 0
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6488.2
Applied rewrites88.2%
Taylor expanded in b around 0
sub-negN/A
*-commutativeN/A
associate-*l*N/A
+-commutativeN/A
distribute-rgt1-inN/A
*-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-lft-inN/A
associate-+r+N/A
unpow2N/A
distribute-rgt-inN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
metadata-evalN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in a around inf
Applied rewrites99.2%
if 0.5 < (*.f64 b b) Initial program 60.1%
Taylor expanded in b around 0
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6482.4
Applied rewrites82.4%
Taylor expanded in a around 0
sub-negN/A
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-outN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-fma.f6492.5
Applied rewrites92.5%
(FPCore (a b) :precision binary64 (if (<= (* b b) 0.5) (fma (* (* a a) a) a -1.0) (fma (* b b) (fma b b 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 0.5) {
tmp = fma(((a * a) * a), a, -1.0);
} else {
tmp = fma((b * b), fma(b, b, 4.0), -1.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 0.5) tmp = fma(Float64(Float64(a * a) * a), a, -1.0); else tmp = fma(Float64(b * b), fma(b, b, 4.0), -1.0); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 0.5], N[(N[(N[(a * a), $MachinePrecision] * a), $MachinePrecision] * a + -1.0), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * N[(b * b + 4.0), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 0.5:\\
\;\;\;\;\mathsf{fma}\left(\left(a \cdot a\right) \cdot a, a, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, b, 4\right), -1\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 0.5Initial program 88.2%
Taylor expanded in b around 0
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6488.2
Applied rewrites88.2%
Taylor expanded in b around 0
sub-negN/A
*-commutativeN/A
associate-*l*N/A
+-commutativeN/A
distribute-rgt1-inN/A
*-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-lft-inN/A
associate-+r+N/A
unpow2N/A
distribute-rgt-inN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
metadata-evalN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in a around inf
Applied rewrites98.9%
if 0.5 < (*.f64 b b) Initial program 60.1%
Taylor expanded in b around 0
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6482.4
Applied rewrites82.4%
Taylor expanded in a around 0
sub-negN/A
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-outN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-fma.f6492.5
Applied rewrites92.5%
(FPCore (a b) :precision binary64 (if (<= (* b b) 9e+27) (fma (* (* a a) a) a -1.0) (* (* b b) (* b b))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 9e+27) {
tmp = fma(((a * a) * a), a, -1.0);
} else {
tmp = (b * b) * (b * b);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 9e+27) tmp = fma(Float64(Float64(a * a) * a), a, -1.0); else tmp = Float64(Float64(b * b) * Float64(b * b)); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 9e+27], N[(N[(N[(a * a), $MachinePrecision] * a), $MachinePrecision] * a + -1.0), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 9 \cdot 10^{+27}:\\
\;\;\;\;\mathsf{fma}\left(\left(a \cdot a\right) \cdot a, a, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 8.9999999999999998e27Initial program 87.4%
Taylor expanded in b around 0
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6487.1
Applied rewrites87.1%
Taylor expanded in b around 0
sub-negN/A
*-commutativeN/A
associate-*l*N/A
+-commutativeN/A
distribute-rgt1-inN/A
*-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-lft-inN/A
associate-+r+N/A
unpow2N/A
distribute-rgt-inN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
metadata-evalN/A
lower-fma.f64N/A
Applied rewrites97.1%
Taylor expanded in a around inf
Applied rewrites96.1%
if 8.9999999999999998e27 < (*.f64 b b) Initial program 59.1%
Taylor expanded in b around 0
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6483.3
Applied rewrites83.3%
Taylor expanded in b around inf
lower-pow.f6495.3
Applied rewrites95.3%
Applied rewrites95.2%
(FPCore (a b) :precision binary64 (if (<= b 21500.0) (fma (* 4.0 a) a -1.0) (* (* b b) (* b b))))
double code(double a, double b) {
double tmp;
if (b <= 21500.0) {
tmp = fma((4.0 * a), a, -1.0);
} else {
tmp = (b * b) * (b * b);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 21500.0) tmp = fma(Float64(4.0 * a), a, -1.0); else tmp = Float64(Float64(b * b) * Float64(b * b)); end return tmp end
code[a_, b_] := If[LessEqual[b, 21500.0], N[(N[(4.0 * a), $MachinePrecision] * a + -1.0), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 21500:\\
\;\;\;\;\mathsf{fma}\left(4 \cdot a, a, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b\right)\\
\end{array}
\end{array}
if b < 21500Initial program 78.5%
Taylor expanded in b around 0
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6487.0
Applied rewrites87.0%
Taylor expanded in b around 0
sub-negN/A
*-commutativeN/A
associate-*l*N/A
+-commutativeN/A
distribute-rgt1-inN/A
*-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-lft-inN/A
associate-+r+N/A
unpow2N/A
distribute-rgt-inN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
metadata-evalN/A
lower-fma.f64N/A
Applied rewrites78.9%
Taylor expanded in a around 0
Applied rewrites59.9%
if 21500 < b Initial program 59.9%
Taylor expanded in b around 0
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6479.7
Applied rewrites79.7%
Taylor expanded in b around inf
lower-pow.f6495.0
Applied rewrites95.0%
Applied rewrites94.9%
(FPCore (a b) :precision binary64 (if (<= b 1.35e+145) (fma (* 4.0 a) a -1.0) (fma (* b b) 4.0 -1.0)))
double code(double a, double b) {
double tmp;
if (b <= 1.35e+145) {
tmp = fma((4.0 * a), a, -1.0);
} else {
tmp = fma((b * b), 4.0, -1.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 1.35e+145) tmp = fma(Float64(4.0 * a), a, -1.0); else tmp = fma(Float64(b * b), 4.0, -1.0); end return tmp end
code[a_, b_] := If[LessEqual[b, 1.35e+145], N[(N[(4.0 * a), $MachinePrecision] * a + -1.0), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * 4.0 + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.35 \cdot 10^{+145}:\\
\;\;\;\;\mathsf{fma}\left(4 \cdot a, a, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot b, 4, -1\right)\\
\end{array}
\end{array}
if b < 1.35000000000000011e145Initial program 77.6%
Taylor expanded in b around 0
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6485.0
Applied rewrites85.0%
Taylor expanded in b around 0
sub-negN/A
*-commutativeN/A
associate-*l*N/A
+-commutativeN/A
distribute-rgt1-inN/A
*-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-lft-inN/A
associate-+r+N/A
unpow2N/A
distribute-rgt-inN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
metadata-evalN/A
lower-fma.f64N/A
Applied rewrites73.2%
Taylor expanded in a around 0
Applied rewrites56.1%
if 1.35000000000000011e145 < b Initial program 50.0%
Taylor expanded in b around 0
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6487.5
Applied rewrites87.5%
Taylor expanded in a around 0
sub-negN/A
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-outN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in b around 0
Applied rewrites100.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 74.1%
Taylor expanded in b around 0
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6485.3
Applied rewrites85.3%
Taylor expanded in a around 0
sub-negN/A
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-outN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-fma.f6472.5
Applied rewrites72.5%
Taylor expanded in b around 0
Applied rewrites54.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 74.1%
Taylor expanded in b around 0
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6485.3
Applied rewrites85.3%
Taylor expanded in b around 0
sub-negN/A
*-commutativeN/A
associate-*l*N/A
+-commutativeN/A
distribute-rgt1-inN/A
*-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-lft-inN/A
associate-+r+N/A
unpow2N/A
distribute-rgt-inN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
metadata-evalN/A
lower-fma.f64N/A
Applied rewrites69.6%
Taylor expanded in a around 0
Applied rewrites26.6%
herbie shell --seed 2024276
(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))