
(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 7 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
(let* ((t_0 (* (* b b) (+ a 3.0))))
(if (<=
(+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (- 1.0 a)) t_0)))
INFINITY)
(fma 4.0 (fma a (- a (* a a)) t_0) (+ (pow (hypot a b) 4.0) -1.0))
(+ -1.0 (pow a 4.0)))))
double code(double a, double b) {
double t_0 = (b * b) * (a + 3.0);
double tmp;
if ((pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + t_0))) <= ((double) INFINITY)) {
tmp = fma(4.0, fma(a, (a - (a * a)), t_0), (pow(hypot(a, b), 4.0) + -1.0));
} else {
tmp = -1.0 + pow(a, 4.0);
}
return tmp;
}
function code(a, b) t_0 = Float64(Float64(b * b) * Float64(a + 3.0)) 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)) + t_0))) <= Inf) tmp = fma(4.0, fma(a, Float64(a - Float64(a * a)), t_0), Float64((hypot(a, b) ^ 4.0) + -1.0)); else tmp = Float64(-1.0 + (a ^ 4.0)); end return tmp end
code[a_, b_] := Block[{t$95$0 = N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]}, 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] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(4.0 * N[(a * N[(a - N[(a * a), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision] + N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(b \cdot b\right) \cdot \left(a + 3\right)\\
\mathbf{if}\;{\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + t_0\right) \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(4, \mathsf{fma}\left(a, a - a \cdot a, t_0\right), {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + -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%
sub-neg99.9%
+-commutative99.9%
associate-+l+99.9%
fma-def99.9%
associate-*l*99.9%
fma-def99.9%
distribute-lft-out--99.9%
*-rgt-identity99.9%
+-commutative99.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%
sqr-pow0.0%
sqr-pow0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
Simplified8.2%
Taylor expanded in a around inf 95.3%
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.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%
sqr-pow0.0%
sqr-pow0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
Simplified8.2%
Taylor expanded in a around inf 95.3%
Final simplification98.8%
(FPCore (a b) :precision binary64 (if (or (<= a -2.4e+31) (not (<= a 4.5e+38))) (+ -1.0 (pow a 4.0)) (+ -1.0 (+ (pow b 4.0) (* b (* b 12.0))))))
double code(double a, double b) {
double tmp;
if ((a <= -2.4e+31) || !(a <= 4.5e+38)) {
tmp = -1.0 + pow(a, 4.0);
} else {
tmp = -1.0 + (pow(b, 4.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 ((a <= (-2.4d+31)) .or. (.not. (a <= 4.5d+38))) then
tmp = (-1.0d0) + (a ** 4.0d0)
else
tmp = (-1.0d0) + ((b ** 4.0d0) + (b * (b * 12.0d0)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -2.4e+31) || !(a <= 4.5e+38)) {
tmp = -1.0 + Math.pow(a, 4.0);
} else {
tmp = -1.0 + (Math.pow(b, 4.0) + (b * (b * 12.0)));
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -2.4e+31) or not (a <= 4.5e+38): tmp = -1.0 + math.pow(a, 4.0) else: tmp = -1.0 + (math.pow(b, 4.0) + (b * (b * 12.0))) return tmp
function code(a, b) tmp = 0.0 if ((a <= -2.4e+31) || !(a <= 4.5e+38)) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = Float64(-1.0 + Float64((b ^ 4.0) + Float64(b * Float64(b * 12.0)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -2.4e+31) || ~((a <= 4.5e+38))) tmp = -1.0 + (a ^ 4.0); else tmp = -1.0 + ((b ^ 4.0) + (b * (b * 12.0))); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -2.4e+31], N[Not[LessEqual[a, 4.5e+38]], $MachinePrecision]], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[Power[b, 4.0], $MachinePrecision] + N[(b * N[(b * 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.4 \cdot 10^{+31} \lor \neg \left(a \leq 4.5 \cdot 10^{+38}\right):\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + \left({b}^{4} + b \cdot \left(b \cdot 12\right)\right)\\
\end{array}
\end{array}
if a < -2.39999999999999982e31 or 4.4999999999999998e38 < a Initial program 42.8%
sub-neg42.8%
sqr-pow42.8%
sqr-pow42.8%
sqr-neg42.8%
distribute-rgt-in42.8%
sqr-neg42.8%
distribute-rgt-in42.8%
Simplified47.5%
Taylor expanded in a around inf 96.6%
if -2.39999999999999982e31 < a < 4.4999999999999998e38Initial program 99.2%
sub-neg99.2%
sqr-pow99.2%
sqr-pow99.2%
sqr-neg99.2%
distribute-rgt-in99.2%
sqr-neg99.2%
distribute-rgt-in99.2%
Simplified99.2%
Taylor expanded in a around 0 91.4%
+-commutative91.4%
+-commutative91.4%
associate-+l+91.4%
unpow291.4%
unpow291.4%
associate-*r*91.4%
distribute-rgt-in98.0%
metadata-eval98.0%
distribute-lft-in98.0%
associate-*l*98.0%
distribute-lft-in98.0%
metadata-eval98.0%
Simplified98.0%
Taylor expanded in a around 0 98.7%
unpow298.7%
*-commutative98.7%
associate-*r*98.7%
Simplified98.7%
Final simplification97.8%
(FPCore (a b) :precision binary64 (if (or (<= a -8e+25) (not (<= a 1.5e+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 <= -8e+25) || !(a <= 1.5e+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 <= (-8d+25)) .or. (.not. (a <= 1.5d+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 <= -8e+25) || !(a <= 1.5e+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 <= -8e+25) or not (a <= 1.5e+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 <= -8e+25) || !(a <= 1.5e+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 <= -8e+25) || ~((a <= 1.5e+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, -8e+25], N[Not[LessEqual[a, 1.5e+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 -8 \cdot 10^{+25} \lor \neg \left(a \leq 1.5 \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 < -8.00000000000000072e25 or 1.5e39 < a Initial program 42.8%
sub-neg42.8%
sqr-pow42.8%
sqr-pow42.8%
sqr-neg42.8%
distribute-rgt-in42.8%
sqr-neg42.8%
distribute-rgt-in42.8%
Simplified47.5%
Taylor expanded in a around inf 96.6%
if -8.00000000000000072e25 < a < 1.5e39Initial program 99.2%
sub-neg99.2%
sqr-pow99.2%
sqr-pow99.2%
sqr-neg99.2%
distribute-rgt-in99.2%
sqr-neg99.2%
distribute-rgt-in99.2%
Simplified99.2%
Taylor expanded in a around 0 91.4%
+-commutative91.4%
+-commutative91.4%
associate-+l+91.4%
unpow291.4%
unpow291.4%
associate-*r*91.4%
distribute-rgt-in98.0%
metadata-eval98.0%
distribute-lft-in98.0%
associate-*l*98.0%
distribute-lft-in98.0%
metadata-eval98.0%
Simplified98.0%
Taylor expanded in a around 0 98.7%
unpow298.7%
*-commutative98.7%
associate-*r*98.7%
Simplified98.7%
+-commutative98.7%
associate-*r*98.7%
sqr-pow98.6%
metadata-eval98.6%
pow298.6%
metadata-eval98.6%
pow298.6%
distribute-lft-out98.6%
Applied egg-rr98.6%
Final simplification97.8%
(FPCore (a b) :precision binary64 (if (<= a 3.6e-20) (+ -1.0 (* (* b b) 12.0)) (+ -1.0 (* a (* b (* b 4.0))))))
double code(double a, double b) {
double tmp;
if (a <= 3.6e-20) {
tmp = -1.0 + ((b * b) * 12.0);
} else {
tmp = -1.0 + (a * (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 (a <= 3.6d-20) then
tmp = (-1.0d0) + ((b * b) * 12.0d0)
else
tmp = (-1.0d0) + (a * (b * (b * 4.0d0)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= 3.6e-20) {
tmp = -1.0 + ((b * b) * 12.0);
} else {
tmp = -1.0 + (a * (b * (b * 4.0)));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= 3.6e-20: tmp = -1.0 + ((b * b) * 12.0) else: tmp = -1.0 + (a * (b * (b * 4.0))) return tmp
function code(a, b) tmp = 0.0 if (a <= 3.6e-20) tmp = Float64(-1.0 + Float64(Float64(b * b) * 12.0)); else tmp = Float64(-1.0 + Float64(a * Float64(b * Float64(b * 4.0)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= 3.6e-20) tmp = -1.0 + ((b * b) * 12.0); else tmp = -1.0 + (a * (b * (b * 4.0))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, 3.6e-20], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(a * N[(b * N[(b * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 3.6 \cdot 10^{-20}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\mathbf{else}:\\
\;\;\;\;-1 + a \cdot \left(b \cdot \left(b \cdot 4\right)\right)\\
\end{array}
\end{array}
if a < 3.59999999999999974e-20Initial program 87.2%
sub-neg87.2%
sqr-pow87.2%
sqr-pow87.2%
sqr-neg87.2%
distribute-rgt-in87.2%
sqr-neg87.2%
distribute-rgt-in87.2%
Simplified87.2%
Taylor expanded in a around 0 65.9%
+-commutative65.9%
+-commutative65.9%
associate-+l+65.9%
unpow265.9%
unpow265.9%
associate-*r*65.9%
distribute-rgt-in71.0%
metadata-eval71.0%
distribute-lft-in71.0%
associate-*l*71.0%
distribute-lft-in71.0%
metadata-eval71.0%
Simplified71.0%
Taylor expanded in b around 0 50.4%
unpow250.4%
*-commutative50.4%
+-commutative50.4%
*-commutative50.4%
fma-udef50.4%
Simplified50.4%
Taylor expanded in a around 0 58.1%
unpow258.1%
Simplified58.1%
if 3.59999999999999974e-20 < a Initial program 39.8%
sub-neg39.8%
sqr-pow39.8%
sqr-pow39.8%
sqr-neg39.8%
distribute-rgt-in39.8%
sqr-neg39.8%
distribute-rgt-in39.8%
Simplified48.2%
Taylor expanded in a around 0 44.7%
+-commutative44.7%
+-commutative44.7%
associate-+l+44.7%
unpow244.7%
unpow244.7%
associate-*r*44.7%
distribute-rgt-in44.7%
metadata-eval44.7%
distribute-lft-in44.7%
associate-*l*44.7%
distribute-lft-in44.7%
metadata-eval44.7%
Simplified44.7%
Taylor expanded in a around inf 38.6%
*-commutative38.6%
unpow238.6%
associate-*l*38.6%
*-commutative38.6%
associate-*r*38.6%
Simplified38.6%
Final simplification53.5%
(FPCore (a b) :precision binary64 (+ -1.0 (* (* b b) (+ (* b b) 12.0))))
double code(double a, double b) {
return -1.0 + ((b * b) * ((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) * ((b * b) + 12.0d0))
end function
public static double code(double a, double b) {
return -1.0 + ((b * b) * ((b * b) + 12.0));
}
def code(a, b): return -1.0 + ((b * b) * ((b * b) + 12.0))
function code(a, b) return Float64(-1.0 + Float64(Float64(b * b) * Float64(Float64(b * b) + 12.0))) end
function tmp = code(a, b) tmp = -1.0 + ((b * b) * ((b * b) + 12.0)); end
code[a_, b_] := N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 12\right)
\end{array}
Initial program 76.1%
sub-neg76.1%
sqr-pow76.1%
sqr-pow76.1%
sqr-neg76.1%
distribute-rgt-in76.1%
sqr-neg76.1%
distribute-rgt-in76.1%
Simplified78.0%
Taylor expanded in a around 0 60.9%
+-commutative60.9%
+-commutative60.9%
associate-+l+60.9%
unpow260.9%
unpow260.9%
associate-*r*60.9%
distribute-rgt-in64.8%
metadata-eval64.8%
distribute-lft-in64.8%
associate-*l*64.8%
distribute-lft-in64.8%
metadata-eval64.8%
Simplified64.8%
Taylor expanded in a around 0 73.5%
unpow273.5%
*-commutative73.5%
associate-*r*73.5%
Simplified73.5%
+-commutative73.5%
associate-*r*73.5%
sqr-pow73.4%
metadata-eval73.4%
pow273.4%
metadata-eval73.4%
pow273.4%
distribute-lft-out73.4%
Applied egg-rr73.4%
Final simplification73.4%
(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 76.1%
sub-neg76.1%
sqr-pow76.1%
sqr-pow76.1%
sqr-neg76.1%
distribute-rgt-in76.1%
sqr-neg76.1%
distribute-rgt-in76.1%
Simplified78.0%
Taylor expanded in a around 0 60.9%
+-commutative60.9%
+-commutative60.9%
associate-+l+60.9%
unpow260.9%
unpow260.9%
associate-*r*60.9%
distribute-rgt-in64.8%
metadata-eval64.8%
distribute-lft-in64.8%
associate-*l*64.8%
distribute-lft-in64.8%
metadata-eval64.8%
Simplified64.8%
Taylor expanded in b around 0 47.6%
unpow247.6%
*-commutative47.6%
+-commutative47.6%
*-commutative47.6%
fma-udef47.6%
Simplified47.6%
Taylor expanded in a around 0 51.9%
unpow251.9%
Simplified51.9%
Final simplification51.9%
herbie shell --seed 2023285
(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))