
(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 11 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 (let* ((t_0 (fma a a (* b b)))) (+ (+ (/ t_0 (/ 1.0 t_0)) (* (* b b) 4.0)) -1.0)))
double code(double a, double b) {
double t_0 = fma(a, a, (b * b));
return ((t_0 / (1.0 / t_0)) + ((b * b) * 4.0)) + -1.0;
}
function code(a, b) t_0 = fma(a, a, Float64(b * b)) return Float64(Float64(Float64(t_0 / Float64(1.0 / t_0)) + Float64(Float64(b * b) * 4.0)) + -1.0) end
code[a_, b_] := Block[{t$95$0 = N[(a * a + N[(b * b), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(t$95$0 / N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(a, a, b \cdot b\right)\\
\left(\frac{t\_0}{\frac{1}{t\_0}} + \left(b \cdot b\right) \cdot 4\right) + -1
\end{array}
\end{array}
Initial program 74.5%
unpow2N/A
flip3-+N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
clear-numN/A
flip3-+N/A
/-lowering-/.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f6474.5
Applied egg-rr74.5%
Taylor expanded in a around 0
unpow2N/A
*-lowering-*.f6498.7
Simplified98.7%
Final simplification98.7%
(FPCore (a b) :precision binary64 (let* ((t_0 (fma a a (* b b)))) (fma t_0 t_0 (fma b (* b 4.0) -1.0))))
double code(double a, double b) {
double t_0 = fma(a, a, (b * b));
return fma(t_0, t_0, fma(b, (b * 4.0), -1.0));
}
function code(a, b) t_0 = fma(a, a, Float64(b * b)) return fma(t_0, t_0, fma(b, Float64(b * 4.0), -1.0)) end
code[a_, b_] := Block[{t$95$0 = N[(a * a + N[(b * b), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * t$95$0 + N[(b * N[(b * 4.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(a, a, b \cdot b\right)\\
\mathsf{fma}\left(t\_0, t\_0, \mathsf{fma}\left(b, b \cdot 4, -1\right)\right)
\end{array}
\end{array}
Initial program 74.5%
flip-+N/A
clear-numN/A
/-lowering-/.f64N/A
Applied egg-rr75.6%
Taylor expanded in a around 0
unpow2N/A
*-lowering-*.f6498.7
Simplified98.7%
sub-negN/A
remove-double-divN/A
metadata-evalN/A
associate-+l+N/A
accelerator-lowering-fma.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
associate-*r*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f6498.7
Applied egg-rr98.7%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* a (* a (* a a)))))
(if (<= a -2.85e+51)
t_0
(if (<= a -4e-6)
(* b (* b (* b b)))
(if (<= a 7400000.0) (fma 4.0 (* b b) -1.0) t_0)))))
double code(double a, double b) {
double t_0 = a * (a * (a * a));
double tmp;
if (a <= -2.85e+51) {
tmp = t_0;
} else if (a <= -4e-6) {
tmp = b * (b * (b * b));
} else if (a <= 7400000.0) {
tmp = fma(4.0, (b * b), -1.0);
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b) t_0 = Float64(a * Float64(a * Float64(a * a))) tmp = 0.0 if (a <= -2.85e+51) tmp = t_0; elseif (a <= -4e-6) tmp = Float64(b * Float64(b * Float64(b * b))); elseif (a <= 7400000.0) tmp = fma(4.0, Float64(b * b), -1.0); else tmp = t_0; end return tmp end
code[a_, b_] := Block[{t$95$0 = N[(a * N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -2.85e+51], t$95$0, If[LessEqual[a, -4e-6], N[(b * N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 7400000.0], N[(4.0 * N[(b * b), $MachinePrecision] + -1.0), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot \left(a \cdot \left(a \cdot a\right)\right)\\
\mathbf{if}\;a \leq -2.85 \cdot 10^{+51}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq -4 \cdot 10^{-6}:\\
\;\;\;\;b \cdot \left(b \cdot \left(b \cdot b\right)\right)\\
\mathbf{elif}\;a \leq 7400000:\\
\;\;\;\;\mathsf{fma}\left(4, b \cdot b, -1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -2.8500000000000001e51 or 7.4e6 < a Initial program 41.2%
flip-+N/A
clear-numN/A
/-lowering-/.f64N/A
Applied egg-rr43.9%
Taylor expanded in a around 0
unpow2N/A
*-lowering-*.f6499.0
Simplified99.0%
Taylor expanded in a around inf
metadata-evalN/A
pow-sqrN/A
unpow2N/A
associate-*l*N/A
unpow2N/A
cube-multN/A
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6490.2
Simplified90.2%
if -2.8500000000000001e51 < a < -3.99999999999999982e-6Initial program 99.7%
Taylor expanded in a around 0
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
accelerator-lowering-fma.f6473.9
Simplified73.9%
Taylor expanded in b around inf
metadata-evalN/A
pow-sqrN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6473.0
Simplified73.0%
if -3.99999999999999982e-6 < a < 7.4e6Initial program 99.1%
Taylor expanded in b around 0
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
accelerator-lowering-fma.f64N/A
Simplified74.9%
Taylor expanded in a around 0
sub-negN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6474.2
Simplified74.2%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e+23) (fma a (* a (fma a (+ a 4.0) 4.0)) -1.0) (* b (* b (* b b)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+23) {
tmp = fma(a, (a * fma(a, (a + 4.0), 4.0)), -1.0);
} else {
tmp = b * (b * (b * b));
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e+23) tmp = fma(a, Float64(a * fma(a, Float64(a + 4.0), 4.0)), -1.0); else tmp = Float64(b * Float64(b * Float64(b * b))); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e+23], N[(a * N[(a * N[(a * N[(a + 4.0), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(b * N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+23}:\\
\;\;\;\;\mathsf{fma}\left(a, a \cdot \mathsf{fma}\left(a, a + 4, 4\right), -1\right)\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(b \cdot \left(b \cdot b\right)\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 1.9999999999999998e23Initial program 80.5%
Taylor expanded in a around -inf
*-lowering-*.f64N/A
metadata-evalN/A
pow-plusN/A
*-commutativeN/A
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
associate-/r*N/A
Simplified74.4%
Taylor expanded in a around 0
sub-negN/A
unpow2N/A
associate-*l*N/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
associate-+r+N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6499.2
Simplified99.2%
Taylor expanded in b around 0
Simplified99.2%
if 1.9999999999999998e23 < (*.f64 b b) Initial program 68.3%
Taylor expanded in a around 0
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
accelerator-lowering-fma.f6495.4
Simplified95.4%
Taylor expanded in b around inf
metadata-evalN/A
pow-sqrN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6495.5
Simplified95.5%
Final simplification97.4%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e+23) (fma a (* a (* a (+ a 4.0))) -1.0) (* b (* b (* b b)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+23) {
tmp = fma(a, (a * (a * (a + 4.0))), -1.0);
} else {
tmp = b * (b * (b * b));
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e+23) tmp = fma(a, Float64(a * Float64(a * Float64(a + 4.0))), -1.0); else tmp = Float64(b * Float64(b * Float64(b * b))); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e+23], N[(a * N[(a * N[(a * N[(a + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(b * N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+23}:\\
\;\;\;\;\mathsf{fma}\left(a, a \cdot \left(a \cdot \left(a + 4\right)\right), -1\right)\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(b \cdot \left(b \cdot b\right)\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 1.9999999999999998e23Initial program 80.5%
Taylor expanded in a around -inf
*-lowering-*.f64N/A
metadata-evalN/A
pow-plusN/A
*-commutativeN/A
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
associate-/r*N/A
Simplified74.4%
Taylor expanded in a around 0
sub-negN/A
unpow2N/A
associate-*l*N/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
associate-+r+N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6499.2
Simplified99.2%
Taylor expanded in a around inf
unpow3N/A
unpow2N/A
associate-*l*N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
associate-*l*N/A
lft-mult-inverseN/A
metadata-evalN/A
unpow2N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f6497.8
Simplified97.8%
if 1.9999999999999998e23 < (*.f64 b b) Initial program 68.3%
Taylor expanded in a around 0
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
accelerator-lowering-fma.f6495.4
Simplified95.4%
Taylor expanded in b around inf
metadata-evalN/A
pow-sqrN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6495.5
Simplified95.5%
Final simplification96.7%
(FPCore (a b) :precision binary64 (let* ((t_0 (fma a a (* b b)))) (fma t_0 t_0 -1.0)))
double code(double a, double b) {
double t_0 = fma(a, a, (b * b));
return fma(t_0, t_0, -1.0);
}
function code(a, b) t_0 = fma(a, a, Float64(b * b)) return fma(t_0, t_0, -1.0) end
code[a_, b_] := Block[{t$95$0 = N[(a * a + N[(b * b), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * t$95$0 + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(a, a, b \cdot b\right)\\
\mathsf{fma}\left(t\_0, t\_0, -1\right)
\end{array}
\end{array}
Initial program 74.5%
flip-+N/A
clear-numN/A
/-lowering-/.f64N/A
Applied egg-rr75.6%
Taylor expanded in a around 0
unpow2N/A
*-lowering-*.f6498.7
Simplified98.7%
sub-negN/A
remove-double-divN/A
metadata-evalN/A
associate-+l+N/A
accelerator-lowering-fma.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
associate-*r*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f6498.7
Applied egg-rr98.7%
Taylor expanded in b around 0
Simplified98.4%
(FPCore (a b) :precision binary64 (let* ((t_0 (* a (* a (* a a))))) (if (<= a -1.45e+15) t_0 (if (<= a 12000.0) (fma 4.0 (* b b) -1.0) t_0))))
double code(double a, double b) {
double t_0 = a * (a * (a * a));
double tmp;
if (a <= -1.45e+15) {
tmp = t_0;
} else if (a <= 12000.0) {
tmp = fma(4.0, (b * b), -1.0);
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b) t_0 = Float64(a * Float64(a * Float64(a * a))) tmp = 0.0 if (a <= -1.45e+15) tmp = t_0; elseif (a <= 12000.0) tmp = fma(4.0, Float64(b * b), -1.0); else tmp = t_0; end return tmp end
code[a_, b_] := Block[{t$95$0 = N[(a * N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -1.45e+15], t$95$0, If[LessEqual[a, 12000.0], N[(4.0 * N[(b * b), $MachinePrecision] + -1.0), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot \left(a \cdot \left(a \cdot a\right)\right)\\
\mathbf{if}\;a \leq -1.45 \cdot 10^{+15}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 12000:\\
\;\;\;\;\mathsf{fma}\left(4, b \cdot b, -1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -1.45e15 or 12000 < a Initial program 45.2%
flip-+N/A
clear-numN/A
/-lowering-/.f64N/A
Applied egg-rr47.7%
Taylor expanded in a around 0
unpow2N/A
*-lowering-*.f6499.1
Simplified99.1%
Taylor expanded in a around inf
metadata-evalN/A
pow-sqrN/A
unpow2N/A
associate-*l*N/A
unpow2N/A
cube-multN/A
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6486.8
Simplified86.8%
if -1.45e15 < a < 12000Initial program 99.1%
Taylor expanded in b around 0
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
accelerator-lowering-fma.f64N/A
Simplified74.7%
Taylor expanded in a around 0
sub-negN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6472.8
Simplified72.8%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e+23) (fma (* a (* a a)) a -1.0) (* b (* b (* b b)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+23) {
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) <= 2e+23) tmp = fma(Float64(a * Float64(a * a)), a, -1.0); else tmp = Float64(b * Float64(b * Float64(b * b))); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e+23], N[(N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision] * a + -1.0), $MachinePrecision], N[(b * N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+23}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot \left(a \cdot a\right), a, -1\right)\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(b \cdot \left(b \cdot b\right)\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 1.9999999999999998e23Initial program 80.5%
Taylor expanded in a around inf
metadata-evalN/A
pow-plusN/A
*-commutativeN/A
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6496.9
Simplified96.9%
sub-negN/A
*-commutativeN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6496.9
Applied egg-rr96.9%
if 1.9999999999999998e23 < (*.f64 b b) Initial program 68.3%
Taylor expanded in a around 0
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
accelerator-lowering-fma.f6495.4
Simplified95.4%
Taylor expanded in b around inf
metadata-evalN/A
pow-sqrN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6495.5
Simplified95.5%
(FPCore (a b) :precision binary64 (if (<= b 0.48) -1.0 (* b (* b 4.0))))
double code(double a, double b) {
double tmp;
if (b <= 0.48) {
tmp = -1.0;
} else {
tmp = b * (b * 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 0.48d0) then
tmp = -1.0d0
else
tmp = b * (b * 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 0.48) {
tmp = -1.0;
} else {
tmp = b * (b * 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 0.48: tmp = -1.0 else: tmp = b * (b * 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 0.48) tmp = -1.0; else tmp = Float64(b * Float64(b * 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 0.48) tmp = -1.0; else tmp = b * (b * 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 0.48], -1.0, N[(b * N[(b * 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.48:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(b \cdot 4\right)\\
\end{array}
\end{array}
if b < 0.47999999999999998Initial program 76.9%
Taylor expanded in a around inf
metadata-evalN/A
pow-plusN/A
*-commutativeN/A
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6476.8
Simplified76.8%
Taylor expanded in a around 0
Simplified33.8%
if 0.47999999999999998 < b Initial program 67.9%
Taylor expanded in b around 0
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
accelerator-lowering-fma.f64N/A
Simplified66.3%
Taylor expanded in a around 0
sub-negN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6455.3
Simplified55.3%
Taylor expanded in b around inf
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6455.3
Simplified55.3%
(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(4.0, Float64(b * b), -1.0) end
code[a_, b_] := N[(4.0 * N[(b * b), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(4, b \cdot b, -1\right)
\end{array}
Initial program 74.5%
Taylor expanded in b around 0
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
accelerator-lowering-fma.f64N/A
Simplified78.2%
Taylor expanded in a around 0
sub-negN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6452.0
Simplified52.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.5%
Taylor expanded in a around inf
metadata-evalN/A
pow-plusN/A
*-commutativeN/A
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6464.6
Simplified64.6%
Taylor expanded in a around 0
Simplified24.9%
herbie shell --seed 2024197
(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))