
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ 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) * (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) * (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) * (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) * (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(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) * (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[(3.0 + a), $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(3 + a\right)\right)\right) - 1
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 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) (+ 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) * (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) * (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) * (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) * (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(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) * (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[(3.0 + a), $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(3 + a\right)\right)\right) - 1
\end{array}
(FPCore (a b)
:precision binary64
(if (<= (* b b) 2e-105)
(fma (* (fma (- a 4.0) a 4.0) a) a -1.0)
(fma
(fma a (fma 2.0 a 4.0) (fma b b 12.0))
(* b b)
(fma (* a a) (* a a) -1.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e-105) {
tmp = fma((fma((a - 4.0), a, 4.0) * a), a, -1.0);
} else {
tmp = fma(fma(a, fma(2.0, a, 4.0), fma(b, b, 12.0)), (b * b), fma((a * a), (a * a), -1.0));
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e-105) tmp = fma(Float64(fma(Float64(a - 4.0), a, 4.0) * a), a, -1.0); else tmp = fma(fma(a, fma(2.0, a, 4.0), fma(b, b, 12.0)), Float64(b * b), fma(Float64(a * a), Float64(a * a), -1.0)); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e-105], N[(N[(N[(N[(a - 4.0), $MachinePrecision] * a + 4.0), $MachinePrecision] * a), $MachinePrecision] * a + -1.0), $MachinePrecision], N[(N[(a * N[(2.0 * a + 4.0), $MachinePrecision] + N[(b * b + 12.0), $MachinePrecision]), $MachinePrecision] * N[(b * b), $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{-105}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(a - 4, a, 4\right) \cdot a, a, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(a, \mathsf{fma}\left(2, a, 4\right), \mathsf{fma}\left(b, b, 12\right)\right), b \cdot b, \mathsf{fma}\left(a \cdot a, a \cdot a, -1\right)\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 1.99999999999999993e-105Initial program 85.6%
Taylor expanded in a around 0
lower-*.f64N/A
unpow2N/A
lower-*.f6498.4
Applied rewrites98.4%
Taylor expanded in b around 0
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
distribute-lft-inN/A
metadata-evalN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites99.9%
Taylor expanded in b around inf
Applied rewrites35.9%
Taylor expanded in b around 0
Applied rewrites99.9%
if 1.99999999999999993e-105 < (*.f64 b b) Initial program 68.3%
Taylor expanded in a around 0
lower-*.f64N/A
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in b around 0
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.3%
Taylor expanded in a around inf
Applied rewrites100.0%
(FPCore (a b)
:precision binary64
(if (<=
(+
(* (+ (* (+ 3.0 a) (* b b)) (* (- 1.0 a) (* a a))) 4.0)
(pow (+ (* b b) (* a a)) 2.0))
0.1)
-1.0
(* 12.0 (* b b))))
double code(double a, double b) {
double tmp;
if ((((((3.0 + a) * (b * b)) + ((1.0 - a) * (a * a))) * 4.0) + pow(((b * b) + (a * a)), 2.0)) <= 0.1) {
tmp = -1.0;
} else {
tmp = 12.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 ((((((3.0d0 + a) * (b * b)) + ((1.0d0 - a) * (a * a))) * 4.0d0) + (((b * b) + (a * a)) ** 2.0d0)) <= 0.1d0) then
tmp = -1.0d0
else
tmp = 12.0d0 * (b * b)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((((((3.0 + a) * (b * b)) + ((1.0 - a) * (a * a))) * 4.0) + Math.pow(((b * b) + (a * a)), 2.0)) <= 0.1) {
tmp = -1.0;
} else {
tmp = 12.0 * (b * b);
}
return tmp;
}
def code(a, b): tmp = 0 if (((((3.0 + a) * (b * b)) + ((1.0 - a) * (a * a))) * 4.0) + math.pow(((b * b) + (a * a)), 2.0)) <= 0.1: tmp = -1.0 else: tmp = 12.0 * (b * b) return tmp
function code(a, b) tmp = 0.0 if (Float64(Float64(Float64(Float64(Float64(3.0 + a) * Float64(b * b)) + Float64(Float64(1.0 - a) * Float64(a * a))) * 4.0) + (Float64(Float64(b * b) + Float64(a * a)) ^ 2.0)) <= 0.1) tmp = -1.0; else tmp = Float64(12.0 * Float64(b * b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((((((3.0 + a) * (b * b)) + ((1.0 - a) * (a * a))) * 4.0) + (((b * b) + (a * a)) ^ 2.0)) <= 0.1) tmp = -1.0; else tmp = 12.0 * (b * b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(N[(N[(N[(N[(3.0 + a), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 - a), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 4.0), $MachinePrecision] + N[Power[N[(N[(b * b), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], 0.1], -1.0, N[(12.0 * N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(3 + a\right) \cdot \left(b \cdot b\right) + \left(1 - a\right) \cdot \left(a \cdot a\right)\right) \cdot 4 + {\left(b \cdot b + a \cdot a\right)}^{2} \leq 0.1:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;12 \cdot \left(b \cdot b\right)\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (-.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (+.f64 #s(literal 3 binary64) a))))) < 0.10000000000000001Initial program 100.0%
Taylor expanded in a around 0
lower-*.f64N/A
unpow2N/A
lower-*.f6498.0
Applied rewrites98.0%
Taylor expanded in b around 0
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in a around 0
sub-negN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-inN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6498.0
Applied rewrites98.0%
Taylor expanded in b around 0
Applied rewrites96.3%
if 0.10000000000000001 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (-.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (+.f64 #s(literal 3 binary64) a))))) Initial program 65.5%
Taylor expanded in a around 0
lower-*.f64N/A
unpow2N/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in b around 0
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
distribute-lft-inN/A
metadata-evalN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites81.9%
Taylor expanded in a around 0
Applied rewrites43.3%
Taylor expanded in b around inf
Applied rewrites43.6%
Final simplification58.0%
(FPCore (a b) :precision binary64 (- (+ (* (* 3.0 (* b b)) 4.0) (pow (+ (* b b) (* a a)) 2.0)) 1.0))
double code(double a, double b) {
return (((3.0 * (b * b)) * 4.0) + 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 = (((3.0d0 * (b * b)) * 4.0d0) + (((b * b) + (a * a)) ** 2.0d0)) - 1.0d0
end function
public static double code(double a, double b) {
return (((3.0 * (b * b)) * 4.0) + Math.pow(((b * b) + (a * a)), 2.0)) - 1.0;
}
def code(a, b): return (((3.0 * (b * b)) * 4.0) + math.pow(((b * b) + (a * a)), 2.0)) - 1.0
function code(a, b) return Float64(Float64(Float64(Float64(3.0 * Float64(b * b)) * 4.0) + (Float64(Float64(b * b) + Float64(a * a)) ^ 2.0)) - 1.0) end
function tmp = code(a, b) tmp = (((3.0 * (b * b)) * 4.0) + (((b * b) + (a * a)) ^ 2.0)) - 1.0; end
code[a_, b_] := N[(N[(N[(N[(3.0 * N[(b * b), $MachinePrecision]), $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}
\\
\left(\left(3 \cdot \left(b \cdot b\right)\right) \cdot 4 + {\left(b \cdot b + a \cdot a\right)}^{2}\right) - 1
\end{array}
Initial program 74.9%
Taylor expanded in a around 0
lower-*.f64N/A
unpow2N/A
lower-*.f6499.4
Applied rewrites99.4%
Final simplification99.4%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e-19) (fma (* (fma (- a 4.0) a 4.0) a) a -1.0) (- (* (* (fma b b (fma a 4.0 12.0)) b) b) 1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e-19) {
tmp = fma((fma((a - 4.0), a, 4.0) * a), a, -1.0);
} else {
tmp = ((fma(b, b, fma(a, 4.0, 12.0)) * b) * b) - 1.0;
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1e-19) tmp = fma(Float64(fma(Float64(a - 4.0), a, 4.0) * a), a, -1.0); else tmp = Float64(Float64(Float64(fma(b, b, fma(a, 4.0, 12.0)) * b) * b) - 1.0); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e-19], N[(N[(N[(N[(a - 4.0), $MachinePrecision] * a + 4.0), $MachinePrecision] * a), $MachinePrecision] * a + -1.0), $MachinePrecision], N[(N[(N[(N[(b * b + N[(a * 4.0 + 12.0), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision] - 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{-19}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(a - 4, a, 4\right) \cdot a, a, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(b, b, \mathsf{fma}\left(a, 4, 12\right)\right) \cdot b\right) \cdot b - 1\\
\end{array}
\end{array}
if (*.f64 b b) < 9.9999999999999998e-20Initial program 85.6%
Taylor expanded in a around 0
lower-*.f64N/A
unpow2N/A
lower-*.f6498.6
Applied rewrites98.6%
Taylor expanded in b around 0
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
distribute-lft-inN/A
metadata-evalN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites99.9%
Taylor expanded in b around inf
Applied rewrites43.9%
Taylor expanded in b around 0
Applied rewrites99.9%
if 9.9999999999999998e-20 < (*.f64 b b) Initial program 66.6%
Taylor expanded in a around 0
associate-+r+N/A
associate-*r*N/A
distribute-rgt-outN/A
metadata-evalN/A
distribute-lft-inN/A
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-lft-inN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites89.9%
(FPCore (a b) :precision binary64 (fma (* b b) (* b b) (fma (* a a) (* a a) -1.0)))
double code(double a, double b) {
return fma((b * b), (b * b), fma((a * a), (a * a), -1.0));
}
function code(a, b) return fma(Float64(b * b), Float64(b * b), fma(Float64(a * a), Float64(a * a), -1.0)) end
code[a_, b_] := N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(b \cdot b, b \cdot b, \mathsf{fma}\left(a \cdot a, a \cdot a, -1\right)\right)
\end{array}
Initial program 74.9%
Taylor expanded in a around 0
lower-*.f64N/A
unpow2N/A
lower-*.f6499.4
Applied rewrites99.4%
Taylor expanded in b around 0
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites94.8%
Taylor expanded in a around inf
Applied rewrites94.7%
Taylor expanded in b around inf
Applied rewrites98.4%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e+94) (fma (* (fma (- a 4.0) a 4.0) a) a -1.0) (fma (* (fma b b 12.0) b) b -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e+94) {
tmp = fma((fma((a - 4.0), a, 4.0) * a), a, -1.0);
} else {
tmp = fma((fma(b, b, 12.0) * b), b, -1.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1e+94) tmp = fma(Float64(fma(Float64(a - 4.0), a, 4.0) * a), a, -1.0); else tmp = fma(Float64(fma(b, b, 12.0) * b), b, -1.0); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e+94], N[(N[(N[(N[(a - 4.0), $MachinePrecision] * a + 4.0), $MachinePrecision] * a), $MachinePrecision] * a + -1.0), $MachinePrecision], N[(N[(N[(b * b + 12.0), $MachinePrecision] * b), $MachinePrecision] * b + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{+94}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(a - 4, a, 4\right) \cdot a, a, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, b, 12\right) \cdot b, b, -1\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 1e94Initial program 84.0%
Taylor expanded in a around 0
lower-*.f64N/A
unpow2N/A
lower-*.f6498.8
Applied rewrites98.8%
Taylor expanded in b around 0
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
distribute-lft-inN/A
metadata-evalN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites94.1%
Taylor expanded in b around inf
Applied rewrites46.6%
Taylor expanded in b around 0
Applied rewrites93.1%
if 1e94 < (*.f64 b b) Initial program 65.3%
Taylor expanded in a around 0
lower-*.f64N/A
unpow2N/A
lower-*.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.f6494.8
Applied rewrites94.8%
(FPCore (a b) :precision binary64 (if (or (<= a -2.9e+29) (not (<= a 1.85e+68))) (- (* (* a a) (* a a)) 1.0) (fma (* (fma b b 12.0) b) b -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -2.9e+29) || !(a <= 1.85e+68)) {
tmp = ((a * a) * (a * a)) - 1.0;
} else {
tmp = fma((fma(b, b, 12.0) * b), b, -1.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if ((a <= -2.9e+29) || !(a <= 1.85e+68)) tmp = Float64(Float64(Float64(a * a) * Float64(a * a)) - 1.0); else tmp = fma(Float64(fma(b, b, 12.0) * b), b, -1.0); end return tmp end
code[a_, b_] := If[Or[LessEqual[a, -2.9e+29], N[Not[LessEqual[a, 1.85e+68]], $MachinePrecision]], N[(N[(N[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(N[(b * b + 12.0), $MachinePrecision] * b), $MachinePrecision] * b + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.9 \cdot 10^{+29} \lor \neg \left(a \leq 1.85 \cdot 10^{+68}\right):\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right) - 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, b, 12\right) \cdot b, b, -1\right)\\
\end{array}
\end{array}
if a < -2.8999999999999999e29 or 1.84999999999999999e68 < a Initial program 36.0%
Taylor expanded in a around inf
lower-pow.f6494.6
Applied rewrites94.6%
Applied rewrites94.5%
if -2.8999999999999999e29 < a < 1.84999999999999999e68Initial program 98.7%
Taylor expanded in a around 0
lower-*.f64N/A
unpow2N/A
lower-*.f6499.0
Applied rewrites99.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.f6496.0
Applied rewrites96.0%
Final simplification95.4%
(FPCore (a b) :precision binary64 (if (or (<= a -8.2e+127) (not (<= a 2.3e+141))) (- (* 4.0 (* a a)) 1.0) (fma (* (fma b b 12.0) b) b -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -8.2e+127) || !(a <= 2.3e+141)) {
tmp = (4.0 * (a * a)) - 1.0;
} else {
tmp = fma((fma(b, b, 12.0) * b), b, -1.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if ((a <= -8.2e+127) || !(a <= 2.3e+141)) tmp = Float64(Float64(4.0 * Float64(a * a)) - 1.0); else tmp = fma(Float64(fma(b, b, 12.0) * b), b, -1.0); end return tmp end
code[a_, b_] := If[Or[LessEqual[a, -8.2e+127], N[Not[LessEqual[a, 2.3e+141]], $MachinePrecision]], N[(N[(4.0 * N[(a * a), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(N[(b * b + 12.0), $MachinePrecision] * b), $MachinePrecision] * b + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -8.2 \cdot 10^{+127} \lor \neg \left(a \leq 2.3 \cdot 10^{+141}\right):\\
\;\;\;\;4 \cdot \left(a \cdot a\right) - 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, b, 12\right) \cdot b, b, -1\right)\\
\end{array}
\end{array}
if a < -8.19999999999999965e127 or 2.3000000000000002e141 < a Initial program 26.8%
Taylor expanded in b around 0
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6498.2
Applied rewrites98.2%
Taylor expanded in a around 0
Applied rewrites90.2%
if -8.19999999999999965e127 < a < 2.3000000000000002e141Initial program 88.4%
Taylor expanded in a around 0
lower-*.f64N/A
unpow2N/A
lower-*.f6499.2
Applied rewrites99.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.f6487.0
Applied rewrites87.0%
Final simplification87.7%
(FPCore (a b) :precision binary64 (if (or (<= a -8.2e+127) (not (<= a 2.3e+141))) (- (* 4.0 (* a a)) 1.0) (fma (* b b) (* b b) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -8.2e+127) || !(a <= 2.3e+141)) {
tmp = (4.0 * (a * a)) - 1.0;
} else {
tmp = fma((b * b), (b * b), -1.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if ((a <= -8.2e+127) || !(a <= 2.3e+141)) tmp = Float64(Float64(4.0 * Float64(a * a)) - 1.0); else tmp = fma(Float64(b * b), Float64(b * b), -1.0); end return tmp end
code[a_, b_] := If[Or[LessEqual[a, -8.2e+127], N[Not[LessEqual[a, 2.3e+141]], $MachinePrecision]], N[(N[(4.0 * N[(a * a), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -8.2 \cdot 10^{+127} \lor \neg \left(a \leq 2.3 \cdot 10^{+141}\right):\\
\;\;\;\;4 \cdot \left(a \cdot a\right) - 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot b, b \cdot b, -1\right)\\
\end{array}
\end{array}
if a < -8.19999999999999965e127 or 2.3000000000000002e141 < a Initial program 26.8%
Taylor expanded in b around 0
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6498.2
Applied rewrites98.2%
Taylor expanded in a around 0
Applied rewrites90.2%
if -8.19999999999999965e127 < a < 2.3000000000000002e141Initial program 88.4%
Taylor expanded in a around 0
lower-*.f64N/A
unpow2N/A
lower-*.f6499.2
Applied rewrites99.2%
Taylor expanded in b around 0
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
lower-fma.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
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6487.0
Applied rewrites87.0%
Taylor expanded in b around inf
Applied rewrites86.0%
Final simplification86.9%
(FPCore (a b) :precision binary64 (if (<= (* b b) 4.12e+278) (- (* 4.0 (* a a)) 1.0) (* 12.0 (* b b))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 4.12e+278) {
tmp = (4.0 * (a * a)) - 1.0;
} else {
tmp = 12.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 ((b * b) <= 4.12d+278) then
tmp = (4.0d0 * (a * a)) - 1.0d0
else
tmp = 12.0d0 * (b * b)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 4.12e+278) {
tmp = (4.0 * (a * a)) - 1.0;
} else {
tmp = 12.0 * (b * b);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 4.12e+278: tmp = (4.0 * (a * a)) - 1.0 else: tmp = 12.0 * (b * b) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 4.12e+278) tmp = Float64(Float64(4.0 * Float64(a * a)) - 1.0); else tmp = Float64(12.0 * Float64(b * b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 4.12e+278) tmp = (4.0 * (a * a)) - 1.0; else tmp = 12.0 * (b * b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 4.12e+278], N[(N[(4.0 * N[(a * a), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], N[(12.0 * N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 4.12 \cdot 10^{+278}:\\
\;\;\;\;4 \cdot \left(a \cdot a\right) - 1\\
\mathbf{else}:\\
\;\;\;\;12 \cdot \left(b \cdot b\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 4.1199999999999998e278Initial program 79.8%
Taylor expanded in b around 0
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6481.9
Applied rewrites81.9%
Taylor expanded in a around 0
Applied rewrites63.5%
if 4.1199999999999998e278 < (*.f64 b b) Initial program 64.6%
Taylor expanded in a around 0
lower-*.f64N/A
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in b around 0
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
distribute-lft-inN/A
metadata-evalN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites93.4%
Taylor expanded in a around 0
Applied rewrites93.5%
Taylor expanded in b around inf
Applied rewrites93.5%
Final simplification73.1%
(FPCore (a b) :precision binary64 (fma 12.0 (* b b) -1.0))
double code(double a, double b) {
return fma(12.0, (b * b), -1.0);
}
function code(a, b) return fma(12.0, Float64(b * b), -1.0) end
code[a_, b_] := N[(12.0 * N[(b * b), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(12, b \cdot b, -1\right)
\end{array}
Initial program 74.9%
Taylor expanded in a around 0
lower-*.f64N/A
unpow2N/A
lower-*.f6499.4
Applied rewrites99.4%
Taylor expanded in b around 0
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
distribute-lft-inN/A
metadata-evalN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites86.6%
Taylor expanded in a around 0
Applied rewrites58.0%
(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.9%
Taylor expanded in a around 0
lower-*.f64N/A
unpow2N/A
lower-*.f6499.4
Applied rewrites99.4%
Taylor expanded in b around 0
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites94.8%
Taylor expanded in a around 0
sub-negN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-inN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.1
Applied rewrites76.1%
Taylor expanded in b around 0
Applied rewrites26.8%
herbie shell --seed 2024271
(FPCore (a b)
:name "Bouland and Aaronson, Equation (24)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ 3.0 a))))) 1.0))