
(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 8 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 (<=
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))
INFINITY)
(+
(pow (hypot a b) 4.0)
(fma 4.0 (- (fma (* b b) (+ a 3.0) (* a a)) (pow a 3.0)) -1.0))
(+ -1.0 (pow a 4.0))))
double code(double a, double b) {
double tmp;
if ((pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))))) <= ((double) INFINITY)) {
tmp = pow(hypot(a, b), 4.0) + fma(4.0, (fma((b * b), (a + 3.0), (a * a)) - pow(a, 3.0)), -1.0);
} else {
tmp = -1.0 + pow(a, 4.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (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(a + 3.0))))) <= Inf) tmp = Float64((hypot(a, b) ^ 4.0) + fma(4.0, Float64(fma(Float64(b * b), Float64(a + 3.0), Float64(a * a)) - (a ^ 3.0)), -1.0)); else tmp = Float64(-1.0 + (a ^ 4.0)); end return tmp end
code[a_, b_] := If[LessEqual[N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision] - N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{\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(a + 3\right)\right) \leq \infty:\\
\;\;\;\;{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(4, \mathsf{fma}\left(b \cdot b, a + 3, a \cdot a\right) - {a}^{3}, -1\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + {a}^{4}\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) < +inf.0Initial program 99.9%
associate--l+99.9%
Simplified100.0%
if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) Initial program 0.0%
sub-neg0.0%
fma-def0.0%
fma-def3.9%
+-commutative3.9%
metadata-eval3.9%
Simplified3.9%
Taylor expanded in a around inf 92.5%
Final simplification98.5%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))))
(if (<= t_0 INFINITY) (+ t_0 -1.0) (+ -1.0 (pow a 4.0)))))
double code(double a, double b) {
double t_0 = pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0 + -1.0;
} else {
tmp = -1.0 + pow(a, 4.0);
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 + -1.0;
} else {
tmp = -1.0 + Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): t_0 = math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0)))) tmp = 0 if t_0 <= math.inf: tmp = t_0 + -1.0 else: tmp = -1.0 + math.pow(a, 4.0) return tmp
function code(a, b) t_0 = 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(a + 3.0))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(t_0 + -1.0); else tmp = Float64(-1.0 + (a ^ 4.0)); end return tmp end
function tmp_2 = code(a, b) t_0 = (((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0)))); tmp = 0.0; if (t_0 <= Inf) tmp = t_0 + -1.0; else tmp = -1.0 + (a ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = 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[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(t$95$0 + -1.0), $MachinePrecision], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\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(a + 3\right)\right)\\
\mathbf{if}\;t_0 \leq \infty:\\
\;\;\;\;t_0 + -1\\
\mathbf{else}:\\
\;\;\;\;-1 + {a}^{4}\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) < +inf.0Initial program 99.9%
if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) Initial program 0.0%
sub-neg0.0%
fma-def0.0%
fma-def3.9%
+-commutative3.9%
metadata-eval3.9%
Simplified3.9%
Taylor expanded in a around inf 92.5%
Final simplification98.4%
(FPCore (a b) :precision binary64 (if (or (<= a -4.4e+41) (not (<= a 5.3e+39))) (+ -1.0 (pow a 4.0)) (+ -1.0 (+ (* b (* b 12.0)) (pow b 4.0)))))
double code(double a, double b) {
double tmp;
if ((a <= -4.4e+41) || !(a <= 5.3e+39)) {
tmp = -1.0 + pow(a, 4.0);
} else {
tmp = -1.0 + ((b * (b * 12.0)) + pow(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 ((a <= (-4.4d+41)) .or. (.not. (a <= 5.3d+39))) then
tmp = (-1.0d0) + (a ** 4.0d0)
else
tmp = (-1.0d0) + ((b * (b * 12.0d0)) + (b ** 4.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -4.4e+41) || !(a <= 5.3e+39)) {
tmp = -1.0 + Math.pow(a, 4.0);
} else {
tmp = -1.0 + ((b * (b * 12.0)) + Math.pow(b, 4.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -4.4e+41) or not (a <= 5.3e+39): tmp = -1.0 + math.pow(a, 4.0) else: tmp = -1.0 + ((b * (b * 12.0)) + math.pow(b, 4.0)) return tmp
function code(a, b) tmp = 0.0 if ((a <= -4.4e+41) || !(a <= 5.3e+39)) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = Float64(-1.0 + Float64(Float64(b * Float64(b * 12.0)) + (b ^ 4.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -4.4e+41) || ~((a <= 5.3e+39))) tmp = -1.0 + (a ^ 4.0); else tmp = -1.0 + ((b * (b * 12.0)) + (b ^ 4.0)); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -4.4e+41], N[Not[LessEqual[a, 5.3e+39]], $MachinePrecision]], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * N[(b * 12.0), $MachinePrecision]), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.4 \cdot 10^{+41} \lor \neg \left(a \leq 5.3 \cdot 10^{+39}\right):\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot \left(b \cdot 12\right) + {b}^{4}\right)\\
\end{array}
\end{array}
if a < -4.3999999999999998e41 or 5.29999999999999979e39 < a Initial program 51.0%
sub-neg51.0%
fma-def51.0%
fma-def53.0%
+-commutative53.0%
metadata-eval53.0%
Simplified53.0%
Taylor expanded in a around inf 96.2%
if -4.3999999999999998e41 < a < 5.29999999999999979e39Initial program 97.4%
sub-neg97.4%
fma-def97.4%
fma-def97.4%
+-commutative97.4%
metadata-eval97.4%
Simplified97.4%
Taylor expanded in a around 0 87.9%
associate-+r+87.9%
associate-*r*87.9%
distribute-rgt-out93.6%
unpow293.6%
Simplified93.6%
Taylor expanded in a around 0 96.1%
unpow296.1%
*-commutative96.1%
associate-*r*96.1%
*-commutative96.1%
Simplified96.1%
Final simplification96.1%
(FPCore (a b) :precision binary64 (if (or (<= a -3.2e+42) (not (<= a 4.2e+39))) (+ -1.0 (pow a 4.0)) (+ -1.0 (* (* b b) (+ (* b b) 12.0)))))
double code(double a, double b) {
double tmp;
if ((a <= -3.2e+42) || !(a <= 4.2e+39)) {
tmp = -1.0 + pow(a, 4.0);
} else {
tmp = -1.0 + ((b * b) * ((b * b) + 12.0));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a <= (-3.2d+42)) .or. (.not. (a <= 4.2d+39))) then
tmp = (-1.0d0) + (a ** 4.0d0)
else
tmp = (-1.0d0) + ((b * b) * ((b * b) + 12.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -3.2e+42) || !(a <= 4.2e+39)) {
tmp = -1.0 + Math.pow(a, 4.0);
} else {
tmp = -1.0 + ((b * b) * ((b * b) + 12.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -3.2e+42) or not (a <= 4.2e+39): tmp = -1.0 + math.pow(a, 4.0) else: tmp = -1.0 + ((b * b) * ((b * b) + 12.0)) return tmp
function code(a, b) tmp = 0.0 if ((a <= -3.2e+42) || !(a <= 4.2e+39)) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = Float64(-1.0 + Float64(Float64(b * b) * Float64(Float64(b * b) + 12.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -3.2e+42) || ~((a <= 4.2e+39))) tmp = -1.0 + (a ^ 4.0); else tmp = -1.0 + ((b * b) * ((b * b) + 12.0)); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -3.2e+42], N[Not[LessEqual[a, 4.2e+39]], $MachinePrecision]], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.2 \cdot 10^{+42} \lor \neg \left(a \leq 4.2 \cdot 10^{+39}\right):\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 12\right)\\
\end{array}
\end{array}
if a < -3.20000000000000002e42 or 4.1999999999999997e39 < a Initial program 51.0%
sub-neg51.0%
fma-def51.0%
fma-def53.0%
+-commutative53.0%
metadata-eval53.0%
Simplified53.0%
Taylor expanded in a around inf 96.2%
if -3.20000000000000002e42 < a < 4.1999999999999997e39Initial program 97.4%
sub-neg97.4%
fma-def97.4%
fma-def97.4%
+-commutative97.4%
metadata-eval97.4%
Simplified97.4%
Taylor expanded in a around 0 87.9%
associate-+r+87.9%
associate-*r*87.9%
distribute-rgt-out93.6%
unpow293.6%
Simplified93.6%
sqr-pow93.5%
metadata-eval93.5%
pow293.5%
metadata-eval93.5%
pow293.5%
distribute-lft-out96.0%
+-commutative96.0%
fma-def96.0%
Applied egg-rr96.0%
Taylor expanded in a around 0 96.0%
unpow296.0%
*-commutative96.0%
unpow296.0%
Simplified96.0%
Final simplification96.0%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e-17) (+ -1.0 (* a (* a 4.0))) (+ -1.0 (* (* b b) (+ (* b b) 12.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e-17) {
tmp = -1.0 + (a * (a * 4.0));
} else {
tmp = -1.0 + ((b * b) * ((b * b) + 12.0));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 2d-17) then
tmp = (-1.0d0) + (a * (a * 4.0d0))
else
tmp = (-1.0d0) + ((b * b) * ((b * b) + 12.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2e-17) {
tmp = -1.0 + (a * (a * 4.0));
} else {
tmp = -1.0 + ((b * b) * ((b * b) + 12.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2e-17: tmp = -1.0 + (a * (a * 4.0)) else: tmp = -1.0 + ((b * b) * ((b * b) + 12.0)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e-17) tmp = Float64(-1.0 + Float64(a * Float64(a * 4.0))); else tmp = Float64(-1.0 + Float64(Float64(b * b) * Float64(Float64(b * b) + 12.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2e-17) tmp = -1.0 + (a * (a * 4.0)); else tmp = -1.0 + ((b * b) * ((b * b) + 12.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e-17], N[(-1.0 + N[(a * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{-17}:\\
\;\;\;\;-1 + a \cdot \left(a \cdot 4\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 12\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 2.00000000000000014e-17Initial program 90.0%
sub-neg90.0%
fma-def90.0%
fma-def90.0%
+-commutative90.0%
metadata-eval90.0%
Simplified90.0%
Taylor expanded in b around 0 90.1%
associate-*r*90.1%
unpow290.1%
Simplified90.1%
Taylor expanded in a around 0 81.6%
unpow281.6%
associate-*r*81.6%
Simplified81.6%
if 2.00000000000000014e-17 < (*.f64 b b) Initial program 71.0%
sub-neg71.0%
fma-def71.0%
fma-def72.5%
+-commutative72.5%
metadata-eval72.5%
Simplified72.5%
Taylor expanded in a around 0 71.5%
associate-+r+71.5%
associate-*r*71.5%
distribute-rgt-out78.2%
unpow278.2%
Simplified78.2%
sqr-pow78.1%
metadata-eval78.1%
pow278.1%
metadata-eval78.1%
pow278.1%
distribute-lft-out88.4%
+-commutative88.4%
fma-def88.4%
Applied egg-rr88.4%
Taylor expanded in a around 0 91.0%
unpow291.0%
*-commutative91.0%
unpow291.0%
Simplified91.0%
Final simplification86.6%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e-17) (+ -1.0 (* a (* a 4.0))) (+ -1.0 (* (* b b) (* b b)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e-17) {
tmp = -1.0 + (a * (a * 4.0));
} else {
tmp = -1.0 + ((b * b) * (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) <= 2d-17) then
tmp = (-1.0d0) + (a * (a * 4.0d0))
else
tmp = (-1.0d0) + ((b * b) * (b * b))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2e-17) {
tmp = -1.0 + (a * (a * 4.0));
} else {
tmp = -1.0 + ((b * b) * (b * b));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2e-17: tmp = -1.0 + (a * (a * 4.0)) else: tmp = -1.0 + ((b * b) * (b * b)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e-17) tmp = Float64(-1.0 + Float64(a * Float64(a * 4.0))); else tmp = Float64(-1.0 + Float64(Float64(b * b) * Float64(b * b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2e-17) tmp = -1.0 + (a * (a * 4.0)); else tmp = -1.0 + ((b * b) * (b * b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e-17], N[(-1.0 + N[(a * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{-17}:\\
\;\;\;\;-1 + a \cdot \left(a \cdot 4\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 2.00000000000000014e-17Initial program 90.0%
sub-neg90.0%
fma-def90.0%
fma-def90.0%
+-commutative90.0%
metadata-eval90.0%
Simplified90.0%
Taylor expanded in b around 0 90.1%
associate-*r*90.1%
unpow290.1%
Simplified90.1%
Taylor expanded in a around 0 81.6%
unpow281.6%
associate-*r*81.6%
Simplified81.6%
if 2.00000000000000014e-17 < (*.f64 b b) Initial program 71.0%
sub-neg71.0%
fma-def71.0%
fma-def72.5%
+-commutative72.5%
metadata-eval72.5%
Simplified72.5%
Taylor expanded in a around 0 71.5%
associate-+r+71.5%
associate-*r*71.5%
distribute-rgt-out78.2%
unpow278.2%
Simplified78.2%
sqr-pow78.1%
metadata-eval78.1%
pow278.1%
metadata-eval78.1%
pow278.1%
distribute-lft-out88.4%
+-commutative88.4%
fma-def88.4%
Applied egg-rr88.4%
Taylor expanded in b around inf 90.0%
unpow290.0%
Simplified90.0%
Final simplification86.0%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+293) (+ -1.0 (* a (* a 4.0))) (+ -1.0 (* (* b b) 12.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+293) {
tmp = -1.0 + (a * (a * 4.0));
} else {
tmp = -1.0 + ((b * b) * 12.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 5d+293) then
tmp = (-1.0d0) + (a * (a * 4.0d0))
else
tmp = (-1.0d0) + ((b * b) * 12.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+293) {
tmp = -1.0 + (a * (a * 4.0));
} else {
tmp = -1.0 + ((b * b) * 12.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e+293: tmp = -1.0 + (a * (a * 4.0)) else: tmp = -1.0 + ((b * b) * 12.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e+293) tmp = Float64(-1.0 + Float64(a * Float64(a * 4.0))); else tmp = Float64(-1.0 + Float64(Float64(b * b) * 12.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5e+293) tmp = -1.0 + (a * (a * 4.0)); else tmp = -1.0 + ((b * b) * 12.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e+293], N[(-1.0 + N[(a * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{+293}:\\
\;\;\;\;-1 + a \cdot \left(a \cdot 4\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\end{array}
\end{array}
if (*.f64 b b) < 5.00000000000000033e293Initial program 87.3%
sub-neg87.3%
fma-def87.3%
fma-def87.3%
+-commutative87.3%
metadata-eval87.3%
Simplified87.3%
Taylor expanded in b around 0 66.1%
associate-*r*66.1%
unpow266.1%
Simplified66.1%
Taylor expanded in a around 0 59.9%
unpow259.9%
associate-*r*59.9%
Simplified59.9%
if 5.00000000000000033e293 < (*.f64 b b) Initial program 58.5%
sub-neg58.5%
fma-def58.5%
fma-def61.5%
+-commutative61.5%
metadata-eval61.5%
Simplified61.5%
Taylor expanded in a around 0 64.6%
associate-+r+64.6%
associate-*r*64.6%
distribute-rgt-out78.5%
unpow278.5%
Simplified78.5%
Taylor expanded in b around 0 74.4%
+-commutative74.4%
fma-def74.4%
unpow274.4%
*-commutative74.4%
associate-*r*74.4%
Simplified74.4%
Taylor expanded in a around 0 94.6%
Taylor expanded in b around 0 94.6%
unpow294.6%
Simplified94.6%
Final simplification68.7%
(FPCore (a b) :precision binary64 (+ -1.0 (* (* b b) 12.0)))
double code(double a, double b) {
return -1.0 + ((b * b) * 12.0);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (-1.0d0) + ((b * b) * 12.0d0)
end function
public static double code(double a, double b) {
return -1.0 + ((b * b) * 12.0);
}
def code(a, b): return -1.0 + ((b * b) * 12.0)
function code(a, b) return Float64(-1.0 + Float64(Float64(b * b) * 12.0)) end
function tmp = code(a, b) tmp = -1.0 + ((b * b) * 12.0); end
code[a_, b_] := N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 + \left(b \cdot b\right) \cdot 12
\end{array}
Initial program 80.0%
sub-neg80.0%
fma-def80.0%
fma-def80.7%
+-commutative80.7%
metadata-eval80.7%
Simplified80.7%
Taylor expanded in a around 0 65.9%
associate-+r+65.9%
associate-*r*65.9%
distribute-rgt-out69.4%
unpow269.4%
Simplified69.4%
Taylor expanded in b around 0 51.0%
+-commutative51.0%
fma-def51.0%
unpow251.0%
*-commutative51.0%
associate-*r*51.0%
Simplified51.0%
Taylor expanded in a around 0 54.1%
Taylor expanded in b around 0 54.1%
unpow254.1%
Simplified54.1%
Final simplification54.1%
herbie shell --seed 2023194
(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))