
(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 10 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 (* (* a a) (+ (* a 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 + ((a * a) * ((a * 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 + Float64(Float64(a * a) * Float64(Float64(a * 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[(N[(a * a), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + 4.0), $MachinePrecision]), $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 + \left(a \cdot a\right) \cdot \left(a \cdot a + 4\right)\\
\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%
sub-neg99.8%
+-commutative99.8%
associate-+l+99.8%
fma-def99.8%
associate-*l*99.8%
fma-def99.8%
distribute-lft-out--99.8%
*-rgt-identity99.8%
+-commutative99.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%
sqr-pow0.0%
sqr-pow0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
Simplified8.0%
Taylor expanded in b around 0 27.2%
unpow227.2%
Simplified27.2%
Taylor expanded in a around 0 91.2%
unpow291.2%
Simplified91.2%
sqr-pow91.2%
metadata-eval91.2%
pow291.2%
metadata-eval91.2%
pow291.2%
distribute-rgt-out91.2%
Applied egg-rr91.2%
Final simplification97.4%
(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 (* (* a a) (+ (* a 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 + ((a * a) * ((a * 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 + ((a * a) * ((a * 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 + ((a * a) * ((a * 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 + Float64(Float64(a * a) * Float64(Float64(a * 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 * a) * ((a * 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[(N[(a * a), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + 4.0), $MachinePrecision]), $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 + \left(a \cdot a\right) \cdot \left(a \cdot a + 4\right)\\
\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%
sqr-pow0.0%
sqr-pow0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
Simplified8.0%
Taylor expanded in b around 0 27.2%
unpow227.2%
Simplified27.2%
Taylor expanded in a around 0 91.2%
unpow291.2%
Simplified91.2%
sqr-pow91.2%
metadata-eval91.2%
pow291.2%
metadata-eval91.2%
pow291.2%
distribute-rgt-out91.2%
Applied egg-rr91.2%
Final simplification97.3%
(FPCore (a b)
:precision binary64
(if (<= a -1.35)
(+ -1.0 (+ (pow a 4.0) (* 4.0 (* (* a a) (- 1.0 a)))))
(if (<= a 1.9e+18)
(+ -1.0 (+ (pow b 4.0) (* (* b b) (+ 12.0 (* a 4.0)))))
(+ -1.0 (pow a 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= -1.35) {
tmp = -1.0 + (pow(a, 4.0) + (4.0 * ((a * a) * (1.0 - a))));
} else if (a <= 1.9e+18) {
tmp = -1.0 + (pow(b, 4.0) + ((b * b) * (12.0 + (a * 4.0))));
} else {
tmp = -1.0 + pow(a, 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 <= (-1.35d0)) then
tmp = (-1.0d0) + ((a ** 4.0d0) + (4.0d0 * ((a * a) * (1.0d0 - a))))
else if (a <= 1.9d+18) then
tmp = (-1.0d0) + ((b ** 4.0d0) + ((b * b) * (12.0d0 + (a * 4.0d0))))
else
tmp = (-1.0d0) + (a ** 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -1.35) {
tmp = -1.0 + (Math.pow(a, 4.0) + (4.0 * ((a * a) * (1.0 - a))));
} else if (a <= 1.9e+18) {
tmp = -1.0 + (Math.pow(b, 4.0) + ((b * b) * (12.0 + (a * 4.0))));
} else {
tmp = -1.0 + Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -1.35: tmp = -1.0 + (math.pow(a, 4.0) + (4.0 * ((a * a) * (1.0 - a)))) elif a <= 1.9e+18: tmp = -1.0 + (math.pow(b, 4.0) + ((b * b) * (12.0 + (a * 4.0)))) else: tmp = -1.0 + math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -1.35) tmp = Float64(-1.0 + Float64((a ^ 4.0) + Float64(4.0 * Float64(Float64(a * a) * Float64(1.0 - a))))); elseif (a <= 1.9e+18) tmp = Float64(-1.0 + Float64((b ^ 4.0) + Float64(Float64(b * b) * Float64(12.0 + Float64(a * 4.0))))); else tmp = Float64(-1.0 + (a ^ 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -1.35) tmp = -1.0 + ((a ^ 4.0) + (4.0 * ((a * a) * (1.0 - a)))); elseif (a <= 1.9e+18) tmp = -1.0 + ((b ^ 4.0) + ((b * b) * (12.0 + (a * 4.0)))); else tmp = -1.0 + (a ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -1.35], N[(-1.0 + N[(N[Power[a, 4.0], $MachinePrecision] + N[(4.0 * N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.9e+18], N[(-1.0 + N[(N[Power[b, 4.0], $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(12.0 + N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.35:\\
\;\;\;\;-1 + \left({a}^{4} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right)\right)\right)\\
\mathbf{elif}\;a \leq 1.9 \cdot 10^{+18}:\\
\;\;\;\;-1 + \left({b}^{4} + \left(b \cdot b\right) \cdot \left(12 + a \cdot 4\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + {a}^{4}\\
\end{array}
\end{array}
if a < -1.3500000000000001Initial program 61.3%
sub-neg61.3%
sqr-pow61.3%
sqr-pow61.3%
sqr-neg61.3%
distribute-rgt-in61.3%
sqr-neg61.3%
distribute-rgt-in61.3%
Simplified61.3%
Taylor expanded in b around 0 90.6%
unpow290.6%
Simplified90.6%
if -1.3500000000000001 < a < 1.9e18Initial program 99.9%
sub-neg99.9%
sqr-pow99.9%
sqr-pow99.9%
sqr-neg99.9%
distribute-rgt-in99.9%
sqr-neg99.9%
distribute-rgt-in99.9%
Simplified99.9%
Taylor expanded in a around 0 89.4%
associate-+r+89.4%
associate-*r*89.4%
distribute-rgt-out99.1%
metadata-eval99.1%
distribute-lft-in99.1%
+-commutative99.1%
unpow299.1%
distribute-lft-in99.1%
metadata-eval99.1%
Simplified99.1%
if 1.9e18 < a Initial program 22.4%
sub-neg22.4%
sqr-pow22.4%
sqr-pow22.4%
sqr-neg22.4%
distribute-rgt-in22.4%
sqr-neg22.4%
distribute-rgt-in22.4%
Simplified32.1%
Taylor expanded in a around inf 98.5%
Final simplification96.6%
(FPCore (a b)
:precision binary64
(if (<= a -0.4)
(+ -1.0 (+ (pow a 4.0) (* 4.0 (* (* a a) (- 1.0 a)))))
(if (<= a 4.7e+19)
(+ -1.0 (+ (pow b 4.0) (* (* b b) 12.0)))
(+ -1.0 (pow a 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= -0.4) {
tmp = -1.0 + (pow(a, 4.0) + (4.0 * ((a * a) * (1.0 - a))));
} else if (a <= 4.7e+19) {
tmp = -1.0 + (pow(b, 4.0) + ((b * b) * 12.0));
} else {
tmp = -1.0 + pow(a, 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 <= (-0.4d0)) then
tmp = (-1.0d0) + ((a ** 4.0d0) + (4.0d0 * ((a * a) * (1.0d0 - a))))
else if (a <= 4.7d+19) then
tmp = (-1.0d0) + ((b ** 4.0d0) + ((b * b) * 12.0d0))
else
tmp = (-1.0d0) + (a ** 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -0.4) {
tmp = -1.0 + (Math.pow(a, 4.0) + (4.0 * ((a * a) * (1.0 - a))));
} else if (a <= 4.7e+19) {
tmp = -1.0 + (Math.pow(b, 4.0) + ((b * b) * 12.0));
} else {
tmp = -1.0 + Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -0.4: tmp = -1.0 + (math.pow(a, 4.0) + (4.0 * ((a * a) * (1.0 - a)))) elif a <= 4.7e+19: tmp = -1.0 + (math.pow(b, 4.0) + ((b * b) * 12.0)) else: tmp = -1.0 + math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -0.4) tmp = Float64(-1.0 + Float64((a ^ 4.0) + Float64(4.0 * Float64(Float64(a * a) * Float64(1.0 - a))))); elseif (a <= 4.7e+19) tmp = Float64(-1.0 + Float64((b ^ 4.0) + Float64(Float64(b * b) * 12.0))); else tmp = Float64(-1.0 + (a ^ 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -0.4) tmp = -1.0 + ((a ^ 4.0) + (4.0 * ((a * a) * (1.0 - a)))); elseif (a <= 4.7e+19) tmp = -1.0 + ((b ^ 4.0) + ((b * b) * 12.0)); else tmp = -1.0 + (a ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -0.4], N[(-1.0 + N[(N[Power[a, 4.0], $MachinePrecision] + N[(4.0 * N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 4.7e+19], N[(-1.0 + N[(N[Power[b, 4.0], $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.4:\\
\;\;\;\;-1 + \left({a}^{4} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right)\right)\right)\\
\mathbf{elif}\;a \leq 4.7 \cdot 10^{+19}:\\
\;\;\;\;-1 + \left({b}^{4} + \left(b \cdot b\right) \cdot 12\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + {a}^{4}\\
\end{array}
\end{array}
if a < -0.40000000000000002Initial program 61.3%
sub-neg61.3%
sqr-pow61.3%
sqr-pow61.3%
sqr-neg61.3%
distribute-rgt-in61.3%
sqr-neg61.3%
distribute-rgt-in61.3%
Simplified61.3%
Taylor expanded in b around 0 90.6%
unpow290.6%
Simplified90.6%
if -0.40000000000000002 < a < 4.7e19Initial program 99.9%
sub-neg99.9%
sqr-pow99.9%
sqr-pow99.9%
sqr-neg99.9%
distribute-rgt-in99.9%
sqr-neg99.9%
distribute-rgt-in99.9%
Simplified99.9%
Taylor expanded in a around 0 89.4%
associate-+r+89.4%
associate-*r*89.4%
distribute-rgt-out99.1%
metadata-eval99.1%
distribute-lft-in99.1%
+-commutative99.1%
unpow299.1%
distribute-lft-in99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in a around 0 99.1%
unpow299.1%
Simplified99.1%
if 4.7e19 < a Initial program 22.4%
sub-neg22.4%
sqr-pow22.4%
sqr-pow22.4%
sqr-neg22.4%
distribute-rgt-in22.4%
sqr-neg22.4%
distribute-rgt-in22.4%
Simplified32.1%
Taylor expanded in a around inf 98.5%
Final simplification96.6%
(FPCore (a b) :precision binary64 (if (or (<= a -1.35e+18) (not (<= a 4.6e+18))) (+ -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 <= -1.35e+18) || !(a <= 4.6e+18)) {
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 <= (-1.35d+18)) .or. (.not. (a <= 4.6d+18))) 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 <= -1.35e+18) || !(a <= 4.6e+18)) {
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 <= -1.35e+18) or not (a <= 4.6e+18): 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 <= -1.35e+18) || !(a <= 4.6e+18)) 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 <= -1.35e+18) || ~((a <= 4.6e+18))) 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, -1.35e+18], N[Not[LessEqual[a, 4.6e+18]], $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 -1.35 \cdot 10^{+18} \lor \neg \left(a \leq 4.6 \cdot 10^{+18}\right):\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + \left({b}^{4} + \left(b \cdot b\right) \cdot 12\right)\\
\end{array}
\end{array}
if a < -1.35e18 or 4.6e18 < a Initial program 42.9%
sub-neg42.9%
sqr-pow42.8%
sqr-pow42.9%
sqr-neg42.9%
distribute-rgt-in42.9%
sqr-neg42.9%
distribute-rgt-in42.9%
Simplified47.5%
Taylor expanded in a around inf 95.6%
if -1.35e18 < a < 4.6e18Initial program 98.3%
sub-neg98.3%
sqr-pow98.3%
sqr-pow98.3%
sqr-neg98.3%
distribute-rgt-in98.3%
sqr-neg98.3%
distribute-rgt-in98.3%
Simplified98.3%
Taylor expanded in a around 0 86.6%
associate-+r+86.6%
associate-*r*86.6%
distribute-rgt-out96.0%
metadata-eval96.0%
distribute-lft-in96.0%
+-commutative96.0%
unpow296.0%
distribute-lft-in96.0%
metadata-eval96.0%
Simplified96.0%
Taylor expanded in a around 0 97.6%
unpow297.6%
Simplified97.6%
Final simplification96.6%
(FPCore (a b) :precision binary64 (if (or (<= a -3.05e+19) (not (<= a 8.5e+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 <= -3.05e+19) || !(a <= 8.5e+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 <= (-3.05d+19)) .or. (.not. (a <= 8.5d+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 <= -3.05e+19) || !(a <= 8.5e+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 <= -3.05e+19) or not (a <= 8.5e+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 <= -3.05e+19) || !(a <= 8.5e+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 <= -3.05e+19) || ~((a <= 8.5e+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, -3.05e+19], N[Not[LessEqual[a, 8.5e+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 -3.05 \cdot 10^{+19} \lor \neg \left(a \leq 8.5 \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 < -3.05e19 or 8.5e17 < a Initial program 42.9%
sub-neg42.9%
sqr-pow42.8%
sqr-pow42.9%
sqr-neg42.9%
distribute-rgt-in42.9%
sqr-neg42.9%
distribute-rgt-in42.9%
Simplified47.5%
Taylor expanded in a around inf 95.6%
if -3.05e19 < a < 8.5e17Initial program 98.3%
sub-neg98.3%
sqr-pow98.3%
sqr-pow98.3%
sqr-neg98.3%
distribute-rgt-in98.3%
sqr-neg98.3%
distribute-rgt-in98.3%
Simplified98.3%
Taylor expanded in a around 0 86.6%
associate-+r+86.6%
associate-*r*86.6%
distribute-rgt-out96.0%
metadata-eval96.0%
distribute-lft-in96.0%
+-commutative96.0%
unpow296.0%
distribute-lft-in96.0%
metadata-eval96.0%
Simplified96.0%
Taylor expanded in a around 0 97.6%
unpow297.6%
Simplified97.6%
sqr-pow97.5%
metadata-eval97.5%
pow297.5%
metadata-eval97.5%
pow297.5%
distribute-rgt-out97.5%
Applied egg-rr97.5%
Final simplification96.5%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+272) (+ -1.0 (* (* a a) (+ (* a a) 4.0))) (+ -1.0 (* (* b b) 12.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+272) {
tmp = -1.0 + ((a * a) * ((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+272) then
tmp = (-1.0d0) + ((a * a) * ((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+272) {
tmp = -1.0 + ((a * a) * ((a * a) + 4.0));
} else {
tmp = -1.0 + ((b * b) * 12.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e+272: tmp = -1.0 + ((a * a) * ((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+272) tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(Float64(a * 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+272) tmp = -1.0 + ((a * a) * ((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+272], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + 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^{+272}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a + 4\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\end{array}
\end{array}
if (*.f64 b b) < 4.99999999999999973e272Initial program 79.0%
sub-neg79.0%
sqr-pow79.0%
sqr-pow79.0%
sqr-neg79.0%
distribute-rgt-in79.0%
sqr-neg79.0%
distribute-rgt-in79.0%
Simplified79.5%
Taylor expanded in b around 0 66.6%
unpow266.6%
Simplified66.6%
Taylor expanded in a around 0 81.8%
unpow281.8%
Simplified81.8%
sqr-pow81.7%
metadata-eval81.7%
pow281.7%
metadata-eval81.7%
pow281.7%
distribute-rgt-out81.7%
Applied egg-rr81.7%
if 4.99999999999999973e272 < (*.f64 b b) Initial program 47.8%
sub-neg47.8%
sqr-pow47.8%
sqr-pow47.8%
sqr-neg47.8%
distribute-rgt-in47.8%
sqr-neg47.8%
distribute-rgt-in47.8%
Simplified55.1%
fma-def55.1%
metadata-eval55.1%
sqrt-pow255.1%
hypot-udef55.1%
add-sqr-sqrt55.1%
unpow-prod-down55.1%
Applied egg-rr55.1%
pow-sqr55.1%
metadata-eval55.1%
Simplified55.1%
Taylor expanded in b around inf 71.3%
unpow271.3%
+-commutative71.3%
associate-*r*71.3%
Simplified71.3%
Taylor expanded in a around 0 96.1%
unpow296.1%
Simplified96.1%
Final simplification85.6%
(FPCore (a b) :precision binary64 (if (<= (* b b) 0.5) (+ -1.0 (* (* a a) (+ (* a a) 4.0))) (+ -1.0 (* (* b b) (+ (* b b) 12.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 0.5) {
tmp = -1.0 + ((a * a) * ((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) <= 0.5d0) then
tmp = (-1.0d0) + ((a * a) * ((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) <= 0.5) {
tmp = -1.0 + ((a * a) * ((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) <= 0.5: tmp = -1.0 + ((a * a) * ((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) <= 0.5) tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(Float64(a * 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) <= 0.5) tmp = -1.0 + ((a * a) * ((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], 0.5], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + 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 0.5:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a + 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) < 0.5Initial program 84.2%
sub-neg84.2%
sqr-pow84.1%
sqr-pow84.2%
sqr-neg84.2%
distribute-rgt-in84.2%
sqr-neg84.2%
distribute-rgt-in84.2%
Simplified84.2%
Taylor expanded in b around 0 83.7%
unpow283.7%
Simplified83.7%
Taylor expanded in a around 0 98.1%
unpow298.1%
Simplified98.1%
sqr-pow98.0%
metadata-eval98.0%
pow298.0%
metadata-eval98.0%
pow298.0%
distribute-rgt-out98.0%
Applied egg-rr98.0%
if 0.5 < (*.f64 b b) Initial program 57.2%
sub-neg57.2%
sqr-pow57.2%
sqr-pow57.2%
sqr-neg57.2%
distribute-rgt-in57.2%
sqr-neg57.2%
distribute-rgt-in57.2%
Simplified61.9%
Taylor expanded in a around 0 62.3%
associate-+r+62.3%
associate-*r*62.3%
distribute-rgt-out71.6%
metadata-eval71.6%
distribute-lft-in71.6%
+-commutative71.6%
unpow271.6%
distribute-lft-in71.6%
metadata-eval71.6%
Simplified71.6%
Taylor expanded in a around 0 92.0%
unpow292.0%
Simplified92.0%
sqr-pow91.9%
metadata-eval91.9%
pow291.9%
metadata-eval91.9%
pow291.9%
distribute-rgt-out91.9%
Applied egg-rr91.9%
Final simplification94.9%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+272) (+ -1.0 (* (* a a) 4.0)) (+ -1.0 (* (* b b) 12.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+272) {
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+272) 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+272) {
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+272: 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+272) tmp = Float64(-1.0 + Float64(Float64(a * 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+272) 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+272], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $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^{+272}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\end{array}
\end{array}
if (*.f64 b b) < 4.99999999999999973e272Initial program 79.0%
sub-neg79.0%
sqr-pow79.0%
sqr-pow79.0%
sqr-neg79.0%
distribute-rgt-in79.0%
sqr-neg79.0%
distribute-rgt-in79.0%
Simplified79.5%
Taylor expanded in b around 0 66.6%
unpow266.6%
Simplified66.6%
Taylor expanded in a around 0 61.5%
unpow261.5%
Simplified61.5%
if 4.99999999999999973e272 < (*.f64 b b) Initial program 47.8%
sub-neg47.8%
sqr-pow47.8%
sqr-pow47.8%
sqr-neg47.8%
distribute-rgt-in47.8%
sqr-neg47.8%
distribute-rgt-in47.8%
Simplified55.1%
fma-def55.1%
metadata-eval55.1%
sqrt-pow255.1%
hypot-udef55.1%
add-sqr-sqrt55.1%
unpow-prod-down55.1%
Applied egg-rr55.1%
pow-sqr55.1%
metadata-eval55.1%
Simplified55.1%
Taylor expanded in b around inf 71.3%
unpow271.3%
+-commutative71.3%
associate-*r*71.3%
Simplified71.3%
Taylor expanded in a around 0 96.1%
unpow296.1%
Simplified96.1%
Final simplification70.8%
(FPCore (a b) :precision binary64 (+ -1.0 (* (* a a) 4.0)))
double code(double a, double b) {
return -1.0 + ((a * a) * 4.0);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (-1.0d0) + ((a * a) * 4.0d0)
end function
public static double code(double a, double b) {
return -1.0 + ((a * a) * 4.0);
}
def code(a, b): return -1.0 + ((a * a) * 4.0)
function code(a, b) return Float64(-1.0 + Float64(Float64(a * a) * 4.0)) end
function tmp = code(a, b) tmp = -1.0 + ((a * a) * 4.0); end
code[a_, b_] := N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 + \left(a \cdot a\right) \cdot 4
\end{array}
Initial program 70.6%
sub-neg70.6%
sqr-pow70.6%
sqr-pow70.6%
sqr-neg70.6%
distribute-rgt-in70.6%
sqr-neg70.6%
distribute-rgt-in70.6%
Simplified72.9%
Taylor expanded in b around 0 53.2%
unpow253.2%
Simplified53.2%
Taylor expanded in a around 0 52.8%
unpow252.8%
Simplified52.8%
Final simplification52.8%
herbie shell --seed 2023274
(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))