
(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
(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%
Simplified5.6%
Taylor expanded in a around inf 93.1%
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%
sqr-pow0.0%
sqr-pow0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
Simplified5.6%
Taylor expanded in a around inf 93.1%
Final simplification98.4%
(FPCore (a b) :precision binary64 (if (or (<= a -68000000000.0) (not (<= a 5.5e+17))) (+ -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 <= -68000000000.0) || !(a <= 5.5e+17)) {
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 <= (-68000000000.0d0)) .or. (.not. (a <= 5.5d+17))) 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 <= -68000000000.0) || !(a <= 5.5e+17)) {
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 <= -68000000000.0) or not (a <= 5.5e+17): 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 <= -68000000000.0) || !(a <= 5.5e+17)) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = Float64(-1.0 + Float64((b ^ 4.0) + Float64(Float64(b * b) * 12.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -68000000000.0) || ~((a <= 5.5e+17))) 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, -68000000000.0], N[Not[LessEqual[a, 5.5e+17]], $MachinePrecision]], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[Power[b, 4.0], $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -68000000000 \lor \neg \left(a \leq 5.5 \cdot 10^{+17}\right):\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + \left({b}^{4} + \left(b \cdot b\right) \cdot 12\right)\\
\end{array}
\end{array}
if a < -6.8e10 or 5.5e17 < a Initial program 52.5%
sub-neg52.5%
sqr-pow52.5%
sqr-pow52.5%
sqr-neg52.5%
distribute-rgt-in52.5%
sqr-neg52.5%
distribute-rgt-in52.5%
Simplified55.2%
Taylor expanded in a around inf 92.5%
if -6.8e10 < a < 5.5e17Initial 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 81.2%
+-commutative81.2%
+-commutative81.2%
associate-+l+81.2%
unpow281.2%
unpow281.2%
associate-*r*81.2%
distribute-rgt-in97.9%
metadata-eval97.9%
distribute-lft-in97.9%
*-commutative97.9%
distribute-lft-in97.9%
metadata-eval97.9%
Simplified97.9%
Taylor expanded in a around 0 98.5%
*-commutative98.5%
unpow298.5%
Simplified98.5%
Final simplification95.9%
(FPCore (a b) :precision binary64 (if (or (<= a -1.8e+19) (not (<= a 6.4e+17))) (+ -1.0 (pow a 4.0)) (+ -1.0 (* (* b b) (+ (* b b) 12.0)))))
double code(double a, double b) {
double tmp;
if ((a <= -1.8e+19) || !(a <= 6.4e+17)) {
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 <= (-1.8d+19)) .or. (.not. (a <= 6.4d+17))) 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 <= -1.8e+19) || !(a <= 6.4e+17)) {
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 <= -1.8e+19) or not (a <= 6.4e+17): 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 <= -1.8e+19) || !(a <= 6.4e+17)) 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 <= -1.8e+19) || ~((a <= 6.4e+17))) 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, -1.8e+19], N[Not[LessEqual[a, 6.4e+17]], $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 -1.8 \cdot 10^{+19} \lor \neg \left(a \leq 6.4 \cdot 10^{+17}\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 < -1.8e19 or 6.4e17 < a Initial program 52.5%
sub-neg52.5%
sqr-pow52.5%
sqr-pow52.5%
sqr-neg52.5%
distribute-rgt-in52.5%
sqr-neg52.5%
distribute-rgt-in52.5%
Simplified55.2%
Taylor expanded in a around inf 92.5%
if -1.8e19 < a < 6.4e17Initial 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 81.2%
+-commutative81.2%
+-commutative81.2%
associate-+l+81.2%
unpow281.2%
unpow281.2%
associate-*r*81.2%
distribute-rgt-in97.9%
metadata-eval97.9%
distribute-lft-in97.9%
*-commutative97.9%
distribute-lft-in97.9%
metadata-eval97.9%
Simplified97.9%
Taylor expanded in a around 0 98.5%
*-commutative98.5%
unpow298.5%
Simplified98.5%
+-commutative98.5%
sqr-pow98.5%
metadata-eval98.5%
pow298.5%
metadata-eval98.5%
pow298.5%
distribute-lft-out98.5%
Applied egg-rr98.5%
Final simplification95.9%
(FPCore (a b) :precision binary64 (if (<= a 3.0) (+ -1.0 (* (* b b) 12.0)) (+ -1.0 (* 4.0 (* a (* b b))))))
double code(double a, double b) {
double tmp;
if (a <= 3.0) {
tmp = -1.0 + ((b * b) * 12.0);
} else {
tmp = -1.0 + (4.0 * (a * (b * b)));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= 3.0d0) then
tmp = (-1.0d0) + ((b * b) * 12.0d0)
else
tmp = (-1.0d0) + (4.0d0 * (a * (b * b)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= 3.0) {
tmp = -1.0 + ((b * b) * 12.0);
} else {
tmp = -1.0 + (4.0 * (a * (b * b)));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= 3.0: tmp = -1.0 + ((b * b) * 12.0) else: tmp = -1.0 + (4.0 * (a * (b * b))) return tmp
function code(a, b) tmp = 0.0 if (a <= 3.0) tmp = Float64(-1.0 + Float64(Float64(b * b) * 12.0)); else tmp = Float64(-1.0 + Float64(4.0 * Float64(a * Float64(b * b)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= 3.0) tmp = -1.0 + ((b * b) * 12.0); else tmp = -1.0 + (4.0 * (a * (b * b))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, 3.0], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(4.0 * N[(a * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 3:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\mathbf{else}:\\
\;\;\;\;-1 + 4 \cdot \left(a \cdot \left(b \cdot b\right)\right)\\
\end{array}
\end{array}
if a < 3Initial program 89.0%
sub-neg89.0%
sqr-pow89.0%
sqr-pow89.0%
sqr-neg89.0%
distribute-rgt-in89.0%
sqr-neg89.0%
distribute-rgt-in89.0%
Simplified89.0%
Taylor expanded in a around 0 56.3%
+-commutative56.3%
+-commutative56.3%
associate-+l+56.3%
unpow256.3%
unpow256.3%
associate-*r*56.3%
distribute-rgt-in67.7%
metadata-eval67.7%
distribute-lft-in67.7%
*-commutative67.7%
distribute-lft-in67.7%
metadata-eval67.7%
Simplified67.7%
Taylor expanded in b around 0 52.6%
unpow252.6%
+-commutative52.6%
fma-udef52.6%
associate-*l*52.6%
Simplified52.6%
Taylor expanded in a around 0 59.2%
Taylor expanded in b around 0 59.2%
unpow259.2%
Simplified59.2%
if 3 < a Initial program 32.4%
sub-neg32.4%
sqr-pow32.4%
sqr-pow32.4%
sqr-neg32.4%
distribute-rgt-in32.4%
sqr-neg32.4%
distribute-rgt-in32.4%
Simplified39.0%
Taylor expanded in a around 0 42.2%
+-commutative42.2%
+-commutative42.2%
associate-+l+42.2%
unpow242.2%
unpow242.2%
associate-*r*42.2%
distribute-rgt-in42.2%
metadata-eval42.2%
distribute-lft-in42.2%
*-commutative42.2%
distribute-lft-in42.2%
metadata-eval42.2%
Simplified42.2%
Taylor expanded in a around inf 40.2%
*-commutative40.2%
unpow240.2%
Simplified40.2%
Final simplification55.8%
(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 78.8%
sub-neg78.8%
sqr-pow78.8%
sqr-pow78.8%
sqr-neg78.8%
distribute-rgt-in78.8%
sqr-neg78.8%
distribute-rgt-in78.8%
Simplified80.0%
Taylor expanded in a around 0 53.8%
+-commutative53.8%
+-commutative53.8%
associate-+l+53.8%
unpow253.8%
unpow253.8%
associate-*r*53.8%
distribute-rgt-in63.1%
metadata-eval63.1%
distribute-lft-in63.1%
*-commutative63.1%
distribute-lft-in63.1%
metadata-eval63.1%
Simplified63.1%
Taylor expanded in a around 0 70.0%
*-commutative70.0%
unpow270.0%
Simplified70.0%
+-commutative70.0%
sqr-pow70.0%
metadata-eval70.0%
pow270.0%
metadata-eval70.0%
pow270.0%
distribute-lft-out70.0%
Applied egg-rr70.0%
Final simplification70.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 78.8%
sub-neg78.8%
sqr-pow78.8%
sqr-pow78.8%
sqr-neg78.8%
distribute-rgt-in78.8%
sqr-neg78.8%
distribute-rgt-in78.8%
Simplified80.0%
Taylor expanded in a around 0 53.8%
+-commutative53.8%
+-commutative53.8%
associate-+l+53.8%
unpow253.8%
unpow253.8%
associate-*r*53.8%
distribute-rgt-in63.1%
metadata-eval63.1%
distribute-lft-in63.1%
*-commutative63.1%
distribute-lft-in63.1%
metadata-eval63.1%
Simplified63.1%
Taylor expanded in b around 0 50.4%
unpow250.4%
+-commutative50.4%
fma-udef50.4%
associate-*l*50.4%
Simplified50.4%
Taylor expanded in a around 0 52.6%
Taylor expanded in b around 0 52.6%
unpow252.6%
Simplified52.6%
Final simplification52.6%
(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 78.8%
sub-neg78.8%
sqr-pow78.8%
sqr-pow78.8%
sqr-neg78.8%
distribute-rgt-in78.8%
sqr-neg78.8%
distribute-rgt-in78.8%
Simplified80.0%
Taylor expanded in a around inf 68.4%
Taylor expanded in a around 0 27.7%
Final simplification27.7%
herbie shell --seed 2023276
(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))