
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 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) * (1.0 - (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) * (1.0d0 - (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) * (1.0 - (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) * (1.0 - (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(1.0 - 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) * (1.0 - (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[(1.0 - N[(3.0 * a), $MachinePrecision]), $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(1 - 3 \cdot 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) (- 1.0 (* 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) * (1.0 - (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) * (1.0d0 - (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) * (1.0 - (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) * (1.0 - (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(1.0 - 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) * (1.0 - (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[(1.0 - N[(3.0 * a), $MachinePrecision]), $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(1 - 3 \cdot 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) -1.0)))))
INFINITY)
(+
(+
(* 4.0 (fma (* a a) (+ a 1.0) (* b (* b (+ 1.0 (* a -3.0))))))
(pow (fma a a (* b b)) 2.0))
-1.0)
(* (pow a 4.0) (+ 1.0 (/ (+ 4.0 (/ (+ 4.0 (* (* b b) 2.0)) a)) a)))))
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) + -1.0))))) <= ((double) INFINITY)) {
tmp = ((4.0 * fma((a * a), (a + 1.0), (b * (b * (1.0 + (a * -3.0)))))) + pow(fma(a, a, (b * b)), 2.0)) + -1.0;
} else {
tmp = pow(a, 4.0) * (1.0 + ((4.0 + ((4.0 + ((b * b) * 2.0)) / a)) / a));
}
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(Float64(a * 3.0) + -1.0))))) <= Inf) tmp = Float64(Float64(Float64(4.0 * fma(Float64(a * a), Float64(a + 1.0), Float64(b * Float64(b * Float64(1.0 + Float64(a * -3.0)))))) + (fma(a, a, Float64(b * b)) ^ 2.0)) + -1.0); else tmp = Float64((a ^ 4.0) * Float64(1.0 + Float64(Float64(4.0 + Float64(Float64(4.0 + Float64(Float64(b * b) * 2.0)) / a)) / a))); 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[(N[(a * 3.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[(4.0 * N[(N[(a * a), $MachinePrecision] * N[(a + 1.0), $MachinePrecision] + N[(b * N[(b * N[(1.0 + N[(a * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[(a * a + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 + N[(N[(4.0 + N[(N[(4.0 + N[(N[(b * b), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $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 \cdot 3 + -1\right)\right) \leq \infty:\\
\;\;\;\;\left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + a \cdot -3\right)\right)\right) + {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} \cdot \left(1 + \frac{4 + \frac{4 + \left(b \cdot b\right) \cdot 2}{a}}{a}\right)\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (+.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (-.f64 #s(literal 1 binary64) (*.f64 #s(literal 3 binary64) a)))))) < +inf.0Initial program 99.8%
sub-neg99.8%
Simplified99.8%
if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (+.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (-.f64 #s(literal 1 binary64) (*.f64 #s(literal 3 binary64) a)))))) Initial program 0.0%
associate--l+0.0%
+-commutative0.0%
+-commutative0.0%
sub-neg0.0%
associate-+l+0.0%
+-commutative0.0%
fma-define0.0%
Simplified8.2%
Taylor expanded in a around -inf 100.0%
pow2100.0%
Applied egg-rr100.0%
Final simplification99.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) -1.0)))))))
(if (<= t_0 INFINITY)
(+ t_0 -1.0)
(* (pow a 4.0) (+ 1.0 (/ (+ 4.0 (/ (+ 4.0 (* (* b b) 2.0)) a)) a))))))
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) + -1.0))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0 + -1.0;
} else {
tmp = pow(a, 4.0) * (1.0 + ((4.0 + ((4.0 + ((b * b) * 2.0)) / a)) / a));
}
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) + -1.0))));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 + -1.0;
} else {
tmp = Math.pow(a, 4.0) * (1.0 + ((4.0 + ((4.0 + ((b * b) * 2.0)) / a)) / a));
}
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) + -1.0)))) tmp = 0 if t_0 <= math.inf: tmp = t_0 + -1.0 else: tmp = math.pow(a, 4.0) * (1.0 + ((4.0 + ((4.0 + ((b * b) * 2.0)) / a)) / a)) 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(Float64(a * 3.0) + -1.0))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(t_0 + -1.0); else tmp = Float64((a ^ 4.0) * Float64(1.0 + Float64(Float64(4.0 + Float64(Float64(4.0 + Float64(Float64(b * b) * 2.0)) / a)) / a))); 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) + -1.0)))); tmp = 0.0; if (t_0 <= Inf) tmp = t_0 + -1.0; else tmp = (a ^ 4.0) * (1.0 + ((4.0 + ((4.0 + ((b * b) * 2.0)) / a)) / a)); 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[(N[(a * 3.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(t$95$0 + -1.0), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 + N[(N[(4.0 + N[(N[(4.0 + N[(N[(b * b), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / a), $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 \cdot 3 + -1\right)\right)\\
\mathbf{if}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0 + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} \cdot \left(1 + \frac{4 + \frac{4 + \left(b \cdot b\right) \cdot 2}{a}}{a}\right)\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (+.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (-.f64 #s(literal 1 binary64) (*.f64 #s(literal 3 binary64) a)))))) < +inf.0Initial program 99.8%
if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (+.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (-.f64 #s(literal 1 binary64) (*.f64 #s(literal 3 binary64) a)))))) Initial program 0.0%
associate--l+0.0%
+-commutative0.0%
+-commutative0.0%
sub-neg0.0%
associate-+l+0.0%
+-commutative0.0%
fma-define0.0%
Simplified8.2%
Taylor expanded in a around -inf 100.0%
pow2100.0%
Applied egg-rr100.0%
Final simplification99.9%
(FPCore (a b) :precision binary64 (if (or (<= a -5.8) (not (<= a 2.6))) (* (pow a 4.0) (+ 1.0 (/ (+ 4.0 (/ (+ 4.0 (* (* b b) 2.0)) a)) a))) (+ -1.0 (+ (* (* b b) 4.0) (pow b 4.0)))))
double code(double a, double b) {
double tmp;
if ((a <= -5.8) || !(a <= 2.6)) {
tmp = pow(a, 4.0) * (1.0 + ((4.0 + ((4.0 + ((b * b) * 2.0)) / a)) / a));
} else {
tmp = -1.0 + (((b * b) * 4.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 <= (-5.8d0)) .or. (.not. (a <= 2.6d0))) then
tmp = (a ** 4.0d0) * (1.0d0 + ((4.0d0 + ((4.0d0 + ((b * b) * 2.0d0)) / a)) / a))
else
tmp = (-1.0d0) + (((b * b) * 4.0d0) + (b ** 4.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -5.8) || !(a <= 2.6)) {
tmp = Math.pow(a, 4.0) * (1.0 + ((4.0 + ((4.0 + ((b * b) * 2.0)) / a)) / a));
} else {
tmp = -1.0 + (((b * b) * 4.0) + Math.pow(b, 4.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -5.8) or not (a <= 2.6): tmp = math.pow(a, 4.0) * (1.0 + ((4.0 + ((4.0 + ((b * b) * 2.0)) / a)) / a)) else: tmp = -1.0 + (((b * b) * 4.0) + math.pow(b, 4.0)) return tmp
function code(a, b) tmp = 0.0 if ((a <= -5.8) || !(a <= 2.6)) tmp = Float64((a ^ 4.0) * Float64(1.0 + Float64(Float64(4.0 + Float64(Float64(4.0 + Float64(Float64(b * b) * 2.0)) / a)) / a))); else tmp = Float64(-1.0 + Float64(Float64(Float64(b * b) * 4.0) + (b ^ 4.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -5.8) || ~((a <= 2.6))) tmp = (a ^ 4.0) * (1.0 + ((4.0 + ((4.0 + ((b * b) * 2.0)) / a)) / a)); else tmp = -1.0 + (((b * b) * 4.0) + (b ^ 4.0)); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -5.8], N[Not[LessEqual[a, 2.6]], $MachinePrecision]], N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 + N[(N[(4.0 + N[(N[(4.0 + N[(N[(b * b), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5.8 \lor \neg \left(a \leq 2.6\right):\\
\;\;\;\;{a}^{4} \cdot \left(1 + \frac{4 + \frac{4 + \left(b \cdot b\right) \cdot 2}{a}}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(\left(b \cdot b\right) \cdot 4 + {b}^{4}\right)\\
\end{array}
\end{array}
if a < -5.79999999999999982 or 2.60000000000000009 < a Initial program 52.2%
associate--l+52.2%
+-commutative52.2%
+-commutative52.2%
sub-neg52.2%
associate-+l+52.2%
+-commutative52.2%
fma-define52.2%
Simplified56.1%
Taylor expanded in a around -inf 97.0%
pow297.0%
Applied egg-rr97.0%
if -5.79999999999999982 < a < 2.60000000000000009Initial program 99.9%
associate--l+99.9%
+-commutative99.9%
+-commutative99.9%
sub-neg99.9%
associate-+l+99.9%
+-commutative99.9%
fma-define99.9%
Simplified99.9%
Taylor expanded in a around 0 100.0%
pow211.1%
Applied egg-rr100.0%
Final simplification98.5%
(FPCore (a b)
:precision binary64
(if (<= a -1.8e+22)
(pow a 4.0)
(if (<= a 500000.0)
(+ -1.0 (+ (* (* b b) 4.0) (pow b 4.0)))
(* (pow a 4.0) (+ -1.0 (+ -1.0 (+ 3.0 (/ 4.0 a))))))))
double code(double a, double b) {
double tmp;
if (a <= -1.8e+22) {
tmp = pow(a, 4.0);
} else if (a <= 500000.0) {
tmp = -1.0 + (((b * b) * 4.0) + pow(b, 4.0));
} else {
tmp = pow(a, 4.0) * (-1.0 + (-1.0 + (3.0 + (4.0 / a))));
}
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+22)) then
tmp = a ** 4.0d0
else if (a <= 500000.0d0) then
tmp = (-1.0d0) + (((b * b) * 4.0d0) + (b ** 4.0d0))
else
tmp = (a ** 4.0d0) * ((-1.0d0) + ((-1.0d0) + (3.0d0 + (4.0d0 / a))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -1.8e+22) {
tmp = Math.pow(a, 4.0);
} else if (a <= 500000.0) {
tmp = -1.0 + (((b * b) * 4.0) + Math.pow(b, 4.0));
} else {
tmp = Math.pow(a, 4.0) * (-1.0 + (-1.0 + (3.0 + (4.0 / a))));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -1.8e+22: tmp = math.pow(a, 4.0) elif a <= 500000.0: tmp = -1.0 + (((b * b) * 4.0) + math.pow(b, 4.0)) else: tmp = math.pow(a, 4.0) * (-1.0 + (-1.0 + (3.0 + (4.0 / a)))) return tmp
function code(a, b) tmp = 0.0 if (a <= -1.8e+22) tmp = a ^ 4.0; elseif (a <= 500000.0) tmp = Float64(-1.0 + Float64(Float64(Float64(b * b) * 4.0) + (b ^ 4.0))); else tmp = Float64((a ^ 4.0) * Float64(-1.0 + Float64(-1.0 + Float64(3.0 + Float64(4.0 / a))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -1.8e+22) tmp = a ^ 4.0; elseif (a <= 500000.0) tmp = -1.0 + (((b * b) * 4.0) + (b ^ 4.0)); else tmp = (a ^ 4.0) * (-1.0 + (-1.0 + (3.0 + (4.0 / a)))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -1.8e+22], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 500000.0], N[(-1.0 + N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] * N[(-1.0 + N[(-1.0 + N[(3.0 + N[(4.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.8 \cdot 10^{+22}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 500000:\\
\;\;\;\;-1 + \left(\left(b \cdot b\right) \cdot 4 + {b}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} \cdot \left(-1 + \left(-1 + \left(3 + \frac{4}{a}\right)\right)\right)\\
\end{array}
\end{array}
if a < -1.8e22Initial program 17.2%
associate--l+17.2%
+-commutative17.2%
+-commutative17.2%
sub-neg17.2%
associate-+l+17.2%
+-commutative17.2%
fma-define17.2%
Simplified17.2%
Taylor expanded in a around -inf 98.3%
Taylor expanded in a around inf 94.6%
if -1.8e22 < a < 5e5Initial program 98.4%
associate--l+98.4%
+-commutative98.4%
+-commutative98.4%
sub-neg98.4%
associate-+l+98.4%
+-commutative98.4%
fma-define98.4%
Simplified98.4%
Taylor expanded in a around 0 97.2%
pow217.3%
Applied egg-rr97.2%
if 5e5 < a Initial program 75.3%
associate--l+75.3%
+-commutative75.3%
+-commutative75.3%
sub-neg75.3%
associate-+l+75.3%
+-commutative75.3%
fma-define75.3%
Simplified83.0%
Taylor expanded in a around inf 95.3%
associate-*r/95.3%
metadata-eval95.3%
Simplified95.3%
expm1-log1p-u95.3%
expm1-undefine95.3%
Applied egg-rr95.3%
sub-neg95.3%
metadata-eval95.3%
+-commutative95.3%
log1p-undefine95.3%
rem-exp-log95.3%
associate-+r+95.3%
metadata-eval95.3%
Simplified95.3%
expm1-log1p-u94.9%
expm1-undefine94.9%
Applied egg-rr94.9%
sub-neg94.9%
log1p-undefine94.9%
rem-exp-log95.3%
remove-double-neg95.3%
sub-neg95.3%
metadata-eval95.3%
+-commutative95.3%
sub-neg95.3%
remove-double-neg95.3%
associate-+r+95.3%
metadata-eval95.3%
Simplified95.3%
Final simplification96.2%
(FPCore (a b)
:precision binary64
(if (<= a -1.6e+22)
(pow a 4.0)
(if (<= a 140000000000.0)
(+ -1.0 (+ (* (* b b) 4.0) (pow b 4.0)))
(* (pow a 4.0) (+ -1.0 (+ 2.0 (/ 4.0 a)))))))
double code(double a, double b) {
double tmp;
if (a <= -1.6e+22) {
tmp = pow(a, 4.0);
} else if (a <= 140000000000.0) {
tmp = -1.0 + (((b * b) * 4.0) + pow(b, 4.0));
} else {
tmp = pow(a, 4.0) * (-1.0 + (2.0 + (4.0 / a)));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-1.6d+22)) then
tmp = a ** 4.0d0
else if (a <= 140000000000.0d0) then
tmp = (-1.0d0) + (((b * b) * 4.0d0) + (b ** 4.0d0))
else
tmp = (a ** 4.0d0) * ((-1.0d0) + (2.0d0 + (4.0d0 / a)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -1.6e+22) {
tmp = Math.pow(a, 4.0);
} else if (a <= 140000000000.0) {
tmp = -1.0 + (((b * b) * 4.0) + Math.pow(b, 4.0));
} else {
tmp = Math.pow(a, 4.0) * (-1.0 + (2.0 + (4.0 / a)));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -1.6e+22: tmp = math.pow(a, 4.0) elif a <= 140000000000.0: tmp = -1.0 + (((b * b) * 4.0) + math.pow(b, 4.0)) else: tmp = math.pow(a, 4.0) * (-1.0 + (2.0 + (4.0 / a))) return tmp
function code(a, b) tmp = 0.0 if (a <= -1.6e+22) tmp = a ^ 4.0; elseif (a <= 140000000000.0) tmp = Float64(-1.0 + Float64(Float64(Float64(b * b) * 4.0) + (b ^ 4.0))); else tmp = Float64((a ^ 4.0) * Float64(-1.0 + Float64(2.0 + Float64(4.0 / a)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -1.6e+22) tmp = a ^ 4.0; elseif (a <= 140000000000.0) tmp = -1.0 + (((b * b) * 4.0) + (b ^ 4.0)); else tmp = (a ^ 4.0) * (-1.0 + (2.0 + (4.0 / a))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -1.6e+22], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 140000000000.0], N[(-1.0 + N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] * N[(-1.0 + N[(2.0 + N[(4.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.6 \cdot 10^{+22}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 140000000000:\\
\;\;\;\;-1 + \left(\left(b \cdot b\right) \cdot 4 + {b}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} \cdot \left(-1 + \left(2 + \frac{4}{a}\right)\right)\\
\end{array}
\end{array}
if a < -1.6e22Initial program 17.2%
associate--l+17.2%
+-commutative17.2%
+-commutative17.2%
sub-neg17.2%
associate-+l+17.2%
+-commutative17.2%
fma-define17.2%
Simplified17.2%
Taylor expanded in a around -inf 98.3%
Taylor expanded in a around inf 94.6%
if -1.6e22 < a < 1.4e11Initial program 98.4%
associate--l+98.4%
+-commutative98.4%
+-commutative98.4%
sub-neg98.4%
associate-+l+98.4%
+-commutative98.4%
fma-define98.4%
Simplified98.4%
Taylor expanded in a around 0 97.2%
pow217.3%
Applied egg-rr97.2%
if 1.4e11 < a Initial program 75.3%
associate--l+75.3%
+-commutative75.3%
+-commutative75.3%
sub-neg75.3%
associate-+l+75.3%
+-commutative75.3%
fma-define75.3%
Simplified83.0%
Taylor expanded in a around inf 95.3%
associate-*r/95.3%
metadata-eval95.3%
Simplified95.3%
expm1-log1p-u95.3%
expm1-undefine95.3%
Applied egg-rr95.3%
sub-neg95.3%
metadata-eval95.3%
+-commutative95.3%
log1p-undefine95.3%
rem-exp-log95.3%
associate-+r+95.3%
metadata-eval95.3%
Simplified95.3%
Final simplification96.2%
(FPCore (a b)
:precision binary64
(if (<= a -1.6e+22)
(pow a 4.0)
(if (<= a 3.3e-152)
(+ -1.0 (* b (* b 4.0)))
(if (<= a 540000000.0) (pow b 4.0) (pow a 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= -1.6e+22) {
tmp = pow(a, 4.0);
} else if (a <= 3.3e-152) {
tmp = -1.0 + (b * (b * 4.0));
} else if (a <= 540000000.0) {
tmp = pow(b, 4.0);
} else {
tmp = 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.6d+22)) then
tmp = a ** 4.0d0
else if (a <= 3.3d-152) then
tmp = (-1.0d0) + (b * (b * 4.0d0))
else if (a <= 540000000.0d0) then
tmp = b ** 4.0d0
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -1.6e+22) {
tmp = Math.pow(a, 4.0);
} else if (a <= 3.3e-152) {
tmp = -1.0 + (b * (b * 4.0));
} else if (a <= 540000000.0) {
tmp = Math.pow(b, 4.0);
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -1.6e+22: tmp = math.pow(a, 4.0) elif a <= 3.3e-152: tmp = -1.0 + (b * (b * 4.0)) elif a <= 540000000.0: tmp = math.pow(b, 4.0) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -1.6e+22) tmp = a ^ 4.0; elseif (a <= 3.3e-152) tmp = Float64(-1.0 + Float64(b * Float64(b * 4.0))); elseif (a <= 540000000.0) tmp = b ^ 4.0; else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -1.6e+22) tmp = a ^ 4.0; elseif (a <= 3.3e-152) tmp = -1.0 + (b * (b * 4.0)); elseif (a <= 540000000.0) tmp = b ^ 4.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -1.6e+22], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 3.3e-152], N[(-1.0 + N[(b * N[(b * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 540000000.0], N[Power[b, 4.0], $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.6 \cdot 10^{+22}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 3.3 \cdot 10^{-152}:\\
\;\;\;\;-1 + b \cdot \left(b \cdot 4\right)\\
\mathbf{elif}\;a \leq 540000000:\\
\;\;\;\;{b}^{4}\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -1.6e22 or 5.4e8 < a Initial program 49.5%
associate--l+49.5%
+-commutative49.5%
+-commutative49.5%
sub-neg49.5%
associate-+l+49.5%
+-commutative49.5%
fma-define49.5%
Simplified53.7%
Taylor expanded in a around -inf 97.6%
Taylor expanded in a around inf 94.9%
if -1.6e22 < a < 3.29999999999999998e-152Initial program 99.9%
associate--l+99.9%
+-commutative99.9%
+-commutative99.9%
sub-neg99.9%
associate-+l+99.9%
+-commutative99.9%
fma-define99.9%
Simplified99.9%
Taylor expanded in a around 0 97.3%
Taylor expanded in b around 0 76.3%
metadata-eval76.3%
unpow276.3%
swap-sqr76.3%
unpow276.3%
Simplified76.3%
unpow-prod-down76.3%
metadata-eval76.3%
pow276.3%
associate-*r*76.3%
Applied egg-rr76.3%
if 3.29999999999999998e-152 < a < 5.4e8Initial program 93.8%
associate--l+93.8%
+-commutative93.8%
+-commutative93.8%
sub-neg93.8%
associate-+l+93.8%
+-commutative93.8%
fma-define93.8%
Simplified93.8%
Taylor expanded in a around 0 97.0%
Taylor expanded in b around inf 73.5%
Final simplification84.4%
(FPCore (a b) :precision binary64 (if (or (<= a -1.6e+22) (not (<= a 1150000.0))) (pow a 4.0) (+ -1.0 (* b (* b 4.0)))))
double code(double a, double b) {
double tmp;
if ((a <= -1.6e+22) || !(a <= 1150000.0)) {
tmp = pow(a, 4.0);
} else {
tmp = -1.0 + (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 <= (-1.6d+22)) .or. (.not. (a <= 1150000.0d0))) then
tmp = a ** 4.0d0
else
tmp = (-1.0d0) + (b * (b * 4.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -1.6e+22) || !(a <= 1150000.0)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = -1.0 + (b * (b * 4.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -1.6e+22) or not (a <= 1150000.0): tmp = math.pow(a, 4.0) else: tmp = -1.0 + (b * (b * 4.0)) return tmp
function code(a, b) tmp = 0.0 if ((a <= -1.6e+22) || !(a <= 1150000.0)) tmp = a ^ 4.0; else tmp = Float64(-1.0 + Float64(b * Float64(b * 4.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -1.6e+22) || ~((a <= 1150000.0))) tmp = a ^ 4.0; else tmp = -1.0 + (b * (b * 4.0)); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -1.6e+22], N[Not[LessEqual[a, 1150000.0]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[(-1.0 + N[(b * N[(b * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.6 \cdot 10^{+22} \lor \neg \left(a \leq 1150000\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + b \cdot \left(b \cdot 4\right)\\
\end{array}
\end{array}
if a < -1.6e22 or 1.15e6 < a Initial program 49.5%
associate--l+49.5%
+-commutative49.5%
+-commutative49.5%
sub-neg49.5%
associate-+l+49.5%
+-commutative49.5%
fma-define49.5%
Simplified53.7%
Taylor expanded in a around -inf 97.6%
Taylor expanded in a around inf 94.9%
if -1.6e22 < a < 1.15e6Initial program 98.4%
associate--l+98.4%
+-commutative98.4%
+-commutative98.4%
sub-neg98.4%
associate-+l+98.4%
+-commutative98.4%
fma-define98.4%
Simplified98.4%
Taylor expanded in a around 0 97.2%
Taylor expanded in b around 0 72.0%
metadata-eval72.0%
unpow272.0%
swap-sqr72.0%
unpow272.0%
Simplified72.0%
unpow-prod-down72.0%
metadata-eval72.0%
pow272.0%
associate-*r*72.0%
Applied egg-rr72.0%
Final simplification82.4%
(FPCore (a b) :precision binary64 (if (<= b 33000000.0) (+ -1.0 (pow a 4.0)) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if (b <= 33000000.0) {
tmp = -1.0 + pow(a, 4.0);
} else {
tmp = 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 (b <= 33000000.0d0) then
tmp = (-1.0d0) + (a ** 4.0d0)
else
tmp = b ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 33000000.0) {
tmp = -1.0 + Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 33000000.0: tmp = -1.0 + math.pow(a, 4.0) else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 33000000.0) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 33000000.0) tmp = -1.0 + (a ^ 4.0); else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 33000000.0], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 33000000:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 3.3e7Initial program 78.5%
add-sqr-sqrt78.5%
sqrt-unprod77.6%
pow277.6%
pow277.6%
pow-prod-up77.6%
metadata-eval77.6%
Applied egg-rr77.6%
Taylor expanded in a around -inf 64.2%
Taylor expanded in a around inf 75.7%
if 3.3e7 < b Initial program 65.8%
associate--l+65.8%
+-commutative65.8%
+-commutative65.8%
sub-neg65.8%
associate-+l+65.8%
+-commutative65.8%
fma-define65.8%
Simplified67.8%
Taylor expanded in a around 0 86.9%
Taylor expanded in b around inf 86.9%
Final simplification77.9%
(FPCore (a b) :precision binary64 (+ -1.0 (* b (* b 4.0))))
double code(double a, double b) {
return -1.0 + (b * (b * 4.0));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (-1.0d0) + (b * (b * 4.0d0))
end function
public static double code(double a, double b) {
return -1.0 + (b * (b * 4.0));
}
def code(a, b): return -1.0 + (b * (b * 4.0))
function code(a, b) return Float64(-1.0 + Float64(b * Float64(b * 4.0))) end
function tmp = code(a, b) tmp = -1.0 + (b * (b * 4.0)); end
code[a_, b_] := N[(-1.0 + N[(b * N[(b * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 + b \cdot \left(b \cdot 4\right)
\end{array}
Initial program 76.0%
associate--l+76.0%
+-commutative76.0%
+-commutative76.0%
sub-neg76.0%
associate-+l+76.0%
+-commutative76.0%
fma-define76.0%
Simplified78.0%
Taylor expanded in a around 0 64.6%
Taylor expanded in b around 0 46.8%
metadata-eval46.8%
unpow246.8%
swap-sqr46.8%
unpow246.8%
Simplified46.8%
unpow-prod-down46.8%
metadata-eval46.8%
pow246.8%
associate-*r*46.8%
Applied egg-rr46.8%
Final simplification46.8%
(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 76.0%
associate--l+76.0%
+-commutative76.0%
+-commutative76.0%
sub-neg76.0%
associate-+l+76.0%
+-commutative76.0%
fma-define76.0%
Simplified78.0%
Taylor expanded in a around 0 64.6%
Taylor expanded in b around 0 25.2%
herbie shell --seed 2024148
(FPCore (a b)
:name "Bouland and Aaronson, Equation (25)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 3.0 a)))))) 1.0))