
(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 11 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) 5e-56) (fma (* (fma b b 4.0) b) b -1.0) (- (fma (* b b) 4.0 (* (* (fma (* b b) 2.0 (* a a)) a) a)) 1.0)))
double code(double a, double b) {
double tmp;
if ((a * a) <= 5e-56) {
tmp = fma((fma(b, b, 4.0) * b), b, -1.0);
} else {
tmp = fma((b * b), 4.0, ((fma((b * b), 2.0, (a * a)) * a) * a)) - 1.0;
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(a * a) <= 5e-56) tmp = fma(Float64(fma(b, b, 4.0) * b), b, -1.0); else tmp = Float64(fma(Float64(b * b), 4.0, 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], 5e-56], N[(N[(N[(b * b + 4.0), $MachinePrecision] * b), $MachinePrecision] * b + -1.0), $MachinePrecision], N[(N[(N[(b * b), $MachinePrecision] * 4.0 + N[(N[(N[(N[(b * b), $MachinePrecision] * 2.0 + N[(a * a), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot a \leq 5 \cdot 10^{-56}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, b, 4\right) \cdot b, b, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot b, 4, \left(\mathsf{fma}\left(b \cdot b, 2, a \cdot a\right) \cdot a\right) \cdot a\right) - 1\\
\end{array}
\end{array}
if (*.f64 a a) < 4.99999999999999997e-56Initial program 99.9%
Taylor expanded in a around inf
lower-pow.f6479.2
Applied rewrites79.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6479.2
Applied rewrites79.2%
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.9
Applied rewrites99.9%
if 4.99999999999999997e-56 < (*.f64 a a) Initial program 99.9%
Taylor expanded in a around inf
lower-pow.f6497.3
Applied rewrites97.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6497.3
Applied rewrites97.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
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6498.7
Applied rewrites98.7%
(FPCore (a b) :precision binary64 (if (<= (* a a) 5e-56) (fma (* (fma b b 4.0) b) b -1.0) (- (+ (* (* (* a a) (- a b)) (- a b)) (* 4.0 (* b b))) 1.0)))
double code(double a, double b) {
double tmp;
if ((a * a) <= 5e-56) {
tmp = fma((fma(b, b, 4.0) * b), b, -1.0);
} else {
tmp = ((((a * a) * (a - b)) * (a - b)) + (4.0 * (b * b))) - 1.0;
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(a * a) <= 5e-56) tmp = fma(Float64(fma(b, b, 4.0) * b), b, -1.0); else tmp = Float64(Float64(Float64(Float64(Float64(a * a) * Float64(a - b)) * Float64(a - b)) + Float64(4.0 * Float64(b * b))) - 1.0); end return tmp end
code[a_, b_] := If[LessEqual[N[(a * a), $MachinePrecision], 5e-56], N[(N[(N[(b * b + 4.0), $MachinePrecision] * b), $MachinePrecision] * b + -1.0), $MachinePrecision], N[(N[(N[(N[(N[(a * a), $MachinePrecision] * N[(a - b), $MachinePrecision]), $MachinePrecision] * N[(a - b), $MachinePrecision]), $MachinePrecision] + N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot a \leq 5 \cdot 10^{-56}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, b, 4\right) \cdot b, b, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(a \cdot a\right) \cdot \left(a - b\right)\right) \cdot \left(a - b\right) + 4 \cdot \left(b \cdot b\right)\right) - 1\\
\end{array}
\end{array}
if (*.f64 a a) < 4.99999999999999997e-56Initial program 99.9%
Taylor expanded in a around inf
lower-pow.f6479.2
Applied rewrites79.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6479.2
Applied rewrites79.2%
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.9
Applied rewrites99.9%
if 4.99999999999999997e-56 < (*.f64 a a) Initial program 99.9%
Applied rewrites99.7%
Taylor expanded in a around inf
unpow2N/A
lower-*.f6498.3
Applied rewrites98.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6498.4
Applied rewrites98.4%
Final simplification99.0%
(FPCore (a b) :precision binary64 (if (<= (* a a) 5e-56) (fma (* (fma b b 4.0) b) b -1.0) (- (- (* 4.0 (* b b)) (* (* (- b a) (- a b)) (* a a))) 1.0)))
double code(double a, double b) {
double tmp;
if ((a * a) <= 5e-56) {
tmp = fma((fma(b, b, 4.0) * b), b, -1.0);
} else {
tmp = ((4.0 * (b * b)) - (((b - a) * (a - b)) * (a * a))) - 1.0;
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(a * a) <= 5e-56) tmp = fma(Float64(fma(b, b, 4.0) * b), b, -1.0); else tmp = Float64(Float64(Float64(4.0 * Float64(b * b)) - Float64(Float64(Float64(b - a) * Float64(a - b)) * Float64(a * a))) - 1.0); end return tmp end
code[a_, b_] := If[LessEqual[N[(a * a), $MachinePrecision], 5e-56], N[(N[(N[(b * b + 4.0), $MachinePrecision] * b), $MachinePrecision] * b + -1.0), $MachinePrecision], N[(N[(N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(b - a), $MachinePrecision] * N[(a - b), $MachinePrecision]), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot a \leq 5 \cdot 10^{-56}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, b, 4\right) \cdot b, b, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(4 \cdot \left(b \cdot b\right) - \left(\left(b - a\right) \cdot \left(a - b\right)\right) \cdot \left(a \cdot a\right)\right) - 1\\
\end{array}
\end{array}
if (*.f64 a a) < 4.99999999999999997e-56Initial program 99.9%
Taylor expanded in a around inf
lower-pow.f6479.2
Applied rewrites79.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6479.2
Applied rewrites79.2%
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.9
Applied rewrites99.9%
if 4.99999999999999997e-56 < (*.f64 a a) Initial program 99.9%
Applied rewrites99.7%
Taylor expanded in a around inf
unpow2N/A
lower-*.f6498.3
Applied rewrites98.3%
Final simplification99.0%
(FPCore (a b) :precision binary64 (- (- (* 4.0 (* b b)) (* (* (- b a) (- a b)) (* (+ b a) (+ b a)))) 1.0))
double code(double a, double b) {
return ((4.0 * (b * b)) - (((b - a) * (a - b)) * ((b + a) * (b + a)))) - 1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((4.0d0 * (b * b)) - (((b - a) * (a - b)) * ((b + a) * (b + a)))) - 1.0d0
end function
public static double code(double a, double b) {
return ((4.0 * (b * b)) - (((b - a) * (a - b)) * ((b + a) * (b + a)))) - 1.0;
}
def code(a, b): return ((4.0 * (b * b)) - (((b - a) * (a - b)) * ((b + a) * (b + a)))) - 1.0
function code(a, b) return Float64(Float64(Float64(4.0 * Float64(b * b)) - Float64(Float64(Float64(b - a) * Float64(a - b)) * Float64(Float64(b + a) * Float64(b + a)))) - 1.0) end
function tmp = code(a, b) tmp = ((4.0 * (b * b)) - (((b - a) * (a - b)) * ((b + a) * (b + a)))) - 1.0; end
code[a_, b_] := N[(N[(N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(b - a), $MachinePrecision] * N[(a - b), $MachinePrecision]), $MachinePrecision] * N[(N[(b + a), $MachinePrecision] * N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left(4 \cdot \left(b \cdot b\right) - \left(\left(b - a\right) \cdot \left(a - b\right)\right) \cdot \left(\left(b + a\right) \cdot \left(b + a\right)\right)\right) - 1
\end{array}
Initial program 99.9%
Applied rewrites99.8%
Final simplification99.8%
(FPCore (a b) :precision binary64 (if (<= (* a a) 5e-56) (fma (* (fma b b 4.0) b) b -1.0) (- (fma (* b b) 4.0 (* (* (* a a) a) a)) 1.0)))
double code(double a, double b) {
double tmp;
if ((a * a) <= 5e-56) {
tmp = fma((fma(b, b, 4.0) * b), b, -1.0);
} else {
tmp = fma((b * b), 4.0, (((a * a) * a) * a)) - 1.0;
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(a * a) <= 5e-56) tmp = fma(Float64(fma(b, b, 4.0) * b), b, -1.0); else tmp = Float64(fma(Float64(b * b), 4.0, Float64(Float64(Float64(a * a) * a) * a)) - 1.0); end return tmp end
code[a_, b_] := If[LessEqual[N[(a * a), $MachinePrecision], 5e-56], N[(N[(N[(b * b + 4.0), $MachinePrecision] * b), $MachinePrecision] * b + -1.0), $MachinePrecision], N[(N[(N[(b * b), $MachinePrecision] * 4.0 + N[(N[(N[(a * a), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot a \leq 5 \cdot 10^{-56}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, b, 4\right) \cdot b, b, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot b, 4, \left(\left(a \cdot a\right) \cdot a\right) \cdot a\right) - 1\\
\end{array}
\end{array}
if (*.f64 a a) < 4.99999999999999997e-56Initial program 99.9%
Taylor expanded in a around inf
lower-pow.f6479.2
Applied rewrites79.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6479.2
Applied rewrites79.2%
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.9
Applied rewrites99.9%
if 4.99999999999999997e-56 < (*.f64 a a) Initial program 99.9%
Taylor expanded in a around inf
lower-pow.f6497.3
Applied rewrites97.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6497.3
Applied rewrites97.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
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6498.7
Applied rewrites98.7%
Taylor expanded in a around inf
Applied rewrites97.3%
(FPCore (a b) :precision binary64 (if (<= (* b b) 10.0) (fma (* a a) (* a a) -1.0) (fma (fma (* 2.0 a) a (fma b b 4.0)) (* b b) -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 10.0) {
tmp = fma((a * a), (a * a), -1.0);
} else {
tmp = fma(fma((2.0 * a), a, 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 = fma(Float64(a * a), Float64(a * a), -1.0); else tmp = fma(fma(Float64(2.0 * a), a, fma(b, b, 4.0)), Float64(b * b), -1.0); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 10.0], N[(N[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[(2.0 * a), $MachinePrecision] * a + N[(b * b + 4.0), $MachinePrecision]), $MachinePrecision] * N[(b * b), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10:\\
\;\;\;\;\mathsf{fma}\left(a \cdot a, a \cdot a, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(2 \cdot a, a, \mathsf{fma}\left(b, b, 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
lower-pow.f64100.0
Applied rewrites100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in b around 0
lower--.f64N/A
lower-pow.f64100.0
Applied rewrites100.0%
Applied rewrites99.9%
if 10 < (*.f64 b b) Initial program 99.9%
Taylor expanded in a around inf
lower-pow.f6476.5
Applied rewrites76.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6476.5
Applied rewrites76.5%
Taylor expanded in a around 0
associate-+r-N/A
associate--l+N/A
associate-+r+N/A
associate-*r*N/A
distribute-rgt-inN/A
+-commutativeN/A
sub-negN/A
metadata-evalN/A
associate-+l+N/A
metadata-evalN/A
pow-sqrN/A
distribute-lft-inN/A
associate-+r+N/A
*-commutativeN/A
Applied rewrites95.8%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e+15) (fma (* 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) <= 1e+15) {
tmp = fma((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) <= 1e+15) tmp = fma(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], 1e+15], N[(N[(a * a), $MachinePrecision] * N[(a * 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^{+15}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot a, a \cdot a, -1\right)\\
\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) < 1e15Initial program 99.9%
Taylor expanded in a around inf
lower-pow.f64100.0
Applied rewrites100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in b around 0
lower--.f64N/A
lower-pow.f64100.0
Applied rewrites100.0%
Applied rewrites99.9%
if 1e15 < (*.f64 b b) Initial program 99.9%
Taylor expanded in a around inf
lower-pow.f6476.3
Applied rewrites76.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6476.3
Applied rewrites76.3%
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.f6490.6
Applied rewrites90.6%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+306) (fma (* a a) (* a a) -1.0) (fma (* 4.0 b) b -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+306) {
tmp = fma((a * a), (a * a), -1.0);
} else {
tmp = fma((4.0 * b), b, -1.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e+306) tmp = fma(Float64(a * a), Float64(a * a), -1.0); else tmp = fma(Float64(4.0 * b), b, -1.0); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e+306], N[(N[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(4.0 * b), $MachinePrecision] * b + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{+306}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot a, a \cdot a, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(4 \cdot b, b, -1\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 4.99999999999999993e306Initial program 99.9%
Taylor expanded in a around inf
lower-pow.f6486.1
Applied rewrites86.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6486.1
Applied rewrites86.1%
Taylor expanded in b around 0
lower--.f64N/A
lower-pow.f6485.3
Applied rewrites85.3%
Applied rewrites85.2%
if 4.99999999999999993e306 < (*.f64 b b) Initial program 100.0%
Taylor expanded in a around inf
lower-pow.f64100.0
Applied rewrites100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
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.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(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 inf
lower-pow.f6489.7
Applied rewrites89.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6489.7
Applied rewrites89.7%
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.f6463.5
Applied rewrites63.5%
Taylor expanded in b around 0
Applied rewrites51.5%
(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 inf
lower-pow.f6489.7
Applied rewrites89.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6489.7
Applied rewrites89.7%
Taylor expanded in b around 0
lower--.f64N/A
lower-pow.f6474.2
Applied rewrites74.2%
Taylor expanded in a around 0
Applied rewrites24.5%
herbie shell --seed 2024312
(FPCore (a b)
:name "Bouland and Aaronson, Equation (26)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))