
(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.8%
associate--l+99.8%
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-def7.4%
+-commutative7.4%
metadata-eval7.4%
Simplified7.4%
Taylor expanded in a around inf 95.8%
Final simplification98.9%
(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.8%
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-def7.4%
+-commutative7.4%
metadata-eval7.4%
Simplified7.4%
Taylor expanded in a around inf 95.8%
Final simplification98.7%
(FPCore (a b) :precision binary64 (if (or (<= a -2.7e+20) (not (<= a 1.15e-19))) (+ -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 <= -2.7e+20) || !(a <= 1.15e-19)) {
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 <= (-2.7d+20)) .or. (.not. (a <= 1.15d-19))) 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 <= -2.7e+20) || !(a <= 1.15e-19)) {
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 <= -2.7e+20) or not (a <= 1.15e-19): 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 <= -2.7e+20) || !(a <= 1.15e-19)) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = Float64(-1.0 + Float64(Float64(Float64(b * b) * 12.0) + (b ^ 4.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -2.7e+20) || ~((a <= 1.15e-19))) 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, -2.7e+20], N[Not[LessEqual[a, 1.15e-19]], $MachinePrecision]], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.7 \cdot 10^{+20} \lor \neg \left(a \leq 1.15 \cdot 10^{-19}\right):\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(\left(b \cdot b\right) \cdot 12 + {b}^{4}\right)\\
\end{array}
\end{array}
if a < -2.7e20 or 1.1499999999999999e-19 < a Initial program 44.9%
sub-neg44.9%
fma-def44.9%
fma-def49.0%
+-commutative49.0%
metadata-eval49.0%
Simplified49.0%
Taylor expanded in a around inf 94.8%
if -2.7e20 < a < 1.1499999999999999e-19Initial program 98.4%
sub-neg98.4%
fma-def98.4%
fma-def98.4%
+-commutative98.4%
metadata-eval98.4%
Simplified98.4%
Taylor expanded in a around 0 89.0%
associate-+r+89.0%
associate-*r*89.0%
distribute-rgt-out97.1%
metadata-eval97.1%
distribute-lft-in97.1%
unpow297.1%
distribute-rgt-in97.1%
metadata-eval97.1%
Simplified97.1%
Taylor expanded in a around 0 98.6%
unpow298.6%
Simplified98.6%
Final simplification96.8%
(FPCore (a b) :precision binary64 (if (or (<= a -6.7e+18) (not (<= a 1.15e-19))) (+ -1.0 (pow a 4.0)) (+ -1.0 (* (* b b) (+ (* b b) 12.0)))))
double code(double a, double b) {
double tmp;
if ((a <= -6.7e+18) || !(a <= 1.15e-19)) {
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 <= (-6.7d+18)) .or. (.not. (a <= 1.15d-19))) 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 <= -6.7e+18) || !(a <= 1.15e-19)) {
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 <= -6.7e+18) or not (a <= 1.15e-19): 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 <= -6.7e+18) || !(a <= 1.15e-19)) 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 <= -6.7e+18) || ~((a <= 1.15e-19))) 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, -6.7e+18], N[Not[LessEqual[a, 1.15e-19]], $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 -6.7 \cdot 10^{+18} \lor \neg \left(a \leq 1.15 \cdot 10^{-19}\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 < -6.7e18 or 1.1499999999999999e-19 < a Initial program 44.9%
sub-neg44.9%
fma-def44.9%
fma-def49.0%
+-commutative49.0%
metadata-eval49.0%
Simplified49.0%
Taylor expanded in a around inf 94.8%
if -6.7e18 < a < 1.1499999999999999e-19Initial program 98.4%
sub-neg98.4%
fma-def98.4%
fma-def98.4%
+-commutative98.4%
metadata-eval98.4%
Simplified98.4%
Taylor expanded in a around 0 89.0%
associate-+r+89.0%
associate-*r*89.0%
distribute-rgt-out97.1%
metadata-eval97.1%
distribute-lft-in97.1%
unpow297.1%
distribute-rgt-in97.1%
metadata-eval97.1%
Simplified97.1%
Taylor expanded in a around 0 98.6%
unpow298.6%
Simplified98.6%
+-commutative98.6%
sqr-pow98.4%
metadata-eval98.4%
pow298.4%
metadata-eval98.4%
pow298.4%
distribute-rgt-out98.4%
Applied egg-rr98.4%
Final simplification96.8%
(FPCore (a b) :precision binary64 (if (or (<= a -1.4e+150) (not (<= a 5.8e+153))) (+ -1.0 (* a (* a 4.0))) (+ -1.0 (* (* b b) (+ (* b b) 12.0)))))
double code(double a, double b) {
double tmp;
if ((a <= -1.4e+150) || !(a <= 5.8e+153)) {
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 ((a <= (-1.4d+150)) .or. (.not. (a <= 5.8d+153))) 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 ((a <= -1.4e+150) || !(a <= 5.8e+153)) {
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 (a <= -1.4e+150) or not (a <= 5.8e+153): 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 ((a <= -1.4e+150) || !(a <= 5.8e+153)) 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 ((a <= -1.4e+150) || ~((a <= 5.8e+153))) 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[Or[LessEqual[a, -1.4e+150], N[Not[LessEqual[a, 5.8e+153]], $MachinePrecision]], 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}\;a \leq -1.4 \cdot 10^{+150} \lor \neg \left(a \leq 5.8 \cdot 10^{+153}\right):\\
\;\;\;\;-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 a < -1.40000000000000005e150 or 5.80000000000000004e153 < a Initial program 26.9%
sub-neg26.9%
fma-def26.9%
fma-def26.9%
+-commutative26.9%
metadata-eval26.9%
Simplified26.9%
Taylor expanded in b around 0 52.2%
associate-*r*52.2%
unpow252.2%
Simplified52.2%
Taylor expanded in a around 0 98.7%
unpow298.7%
associate-*r*98.7%
*-commutative98.7%
Simplified98.7%
if -1.40000000000000005e150 < a < 5.80000000000000004e153Initial program 89.8%
sub-neg89.8%
fma-def89.8%
fma-def92.4%
+-commutative92.4%
metadata-eval92.4%
Simplified92.4%
Taylor expanded in a around 0 71.9%
associate-+r+71.9%
associate-*r*71.9%
distribute-rgt-out77.7%
metadata-eval77.7%
distribute-lft-in77.7%
unpow277.7%
distribute-rgt-in77.7%
metadata-eval77.7%
Simplified77.7%
Taylor expanded in a around 0 83.0%
unpow283.0%
Simplified83.0%
+-commutative83.0%
sqr-pow82.9%
metadata-eval82.9%
pow282.9%
metadata-eval82.9%
pow282.9%
distribute-rgt-out82.9%
Applied egg-rr82.9%
Final simplification87.0%
(FPCore (a b) :precision binary64 (if (<= (* b b) 4e+232) (+ -1.0 (* a (* a 4.0))) (+ -1.0 (* (* b b) 12.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 4e+232) {
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) <= 4d+232) 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) <= 4e+232) {
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) <= 4e+232: 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) <= 4e+232) 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) <= 4e+232) 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], 4e+232], 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 4 \cdot 10^{+232}:\\
\;\;\;\;-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) < 4.00000000000000023e232Initial program 80.5%
sub-neg80.5%
fma-def80.5%
fma-def81.0%
+-commutative81.0%
metadata-eval81.0%
Simplified81.0%
Taylor expanded in b around 0 62.3%
associate-*r*62.3%
unpow262.3%
Simplified62.3%
Taylor expanded in a around 0 62.0%
unpow262.0%
associate-*r*62.0%
*-commutative62.0%
Simplified62.0%
if 4.00000000000000023e232 < (*.f64 b b) Initial program 54.3%
sub-neg54.3%
fma-def54.3%
fma-def60.0%
+-commutative60.0%
metadata-eval60.0%
Simplified60.0%
Taylor expanded in a around 0 51.4%
associate-+r+51.4%
associate-*r*51.4%
distribute-rgt-out67.1%
metadata-eval67.1%
distribute-lft-in67.1%
unpow267.1%
distribute-rgt-in67.1%
metadata-eval67.1%
Simplified67.1%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Simplified100.0%
+-commutative100.0%
sqr-pow100.0%
metadata-eval100.0%
pow2100.0%
metadata-eval100.0%
pow2100.0%
distribute-rgt-out100.0%
Applied egg-rr100.0%
Taylor expanded in b around 0 94.8%
unpow294.8%
Simplified94.8%
Final simplification71.0%
(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 73.3%
sub-neg73.3%
fma-def73.3%
fma-def75.3%
+-commutative75.3%
metadata-eval75.3%
Simplified75.3%
Taylor expanded in a around 0 57.2%
associate-+r+57.2%
associate-*r*57.2%
distribute-rgt-out61.5%
metadata-eval61.5%
distribute-lft-in61.5%
unpow261.5%
distribute-rgt-in61.5%
metadata-eval61.5%
Simplified61.5%
Taylor expanded in a around 0 71.7%
unpow271.7%
Simplified71.7%
+-commutative71.7%
sqr-pow71.6%
metadata-eval71.6%
pow271.6%
metadata-eval71.6%
pow271.6%
distribute-rgt-out71.6%
Applied egg-rr71.6%
Taylor expanded in b around 0 52.5%
unpow252.5%
Simplified52.5%
Final simplification52.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 73.3%
sub-neg73.3%
fma-def73.3%
fma-def75.3%
+-commutative75.3%
metadata-eval75.3%
Simplified75.3%
Taylor expanded in a around 0 57.2%
associate-+r+57.2%
associate-*r*57.2%
distribute-rgt-out61.5%
metadata-eval61.5%
distribute-lft-in61.5%
unpow261.5%
distribute-rgt-in61.5%
metadata-eval61.5%
Simplified61.5%
Taylor expanded in b around 0 25.6%
Final simplification25.6%
herbie shell --seed 2023228
(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))