
(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 11 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
(let* ((t_0
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (+ a 1.0)) (* (* b b) (- 1.0 (* a 3.0))))))))
(if (<= t_0 INFINITY)
(+ t_0 -1.0)
(+ (* (* a a) (+ 4.0 (* a (+ a 4.0)))) -1.0))))
double code(double a, double b) {
double t_0 = pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0 + -1.0;
} else {
tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.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) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 + -1.0;
} else {
tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0;
}
return tmp;
}
def code(a, b): t_0 = math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0))))) tmp = 0 if t_0 <= math.inf: tmp = t_0 + -1.0 else: tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.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(a + 1.0)) + Float64(Float64(b * b) * Float64(1.0 - Float64(a * 3.0)))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(t_0 + -1.0); else tmp = Float64(Float64(Float64(a * a) * Float64(4.0 + Float64(a * Float64(a + 4.0)))) + -1.0); end return tmp end
function tmp_2 = code(a, b) t_0 = (((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0))))); tmp = 0.0; if (t_0 <= Inf) tmp = t_0 + -1.0; else tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.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[(a + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(t$95$0 + -1.0), $MachinePrecision], N[(N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * N[(a + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $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(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right)\\
\mathbf{if}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0 + -1\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + 4\right)\right) + -1\\
\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.9%
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%
sub-neg0.0%
Simplified9.6%
Taylor expanded in b around 0 36.1%
Taylor expanded in a around 0 92.3%
unpow292.3%
Applied egg-rr92.3%
Final simplification97.7%
(FPCore (a b)
:precision binary64
(if (<= a -2e+40)
(+ -1.0 (* a (pow a 3.0)))
(if (<= a 1.65e+24)
(+ -1.0 (+ (* (* b b) 4.0) (pow b 4.0)))
(+ -1.0 (pow a 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= -2e+40) {
tmp = -1.0 + (a * pow(a, 3.0));
} else if (a <= 1.65e+24) {
tmp = -1.0 + (((b * b) * 4.0) + pow(b, 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 <= (-2d+40)) then
tmp = (-1.0d0) + (a * (a ** 3.0d0))
else if (a <= 1.65d+24) then
tmp = (-1.0d0) + (((b * b) * 4.0d0) + (b ** 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 <= -2e+40) {
tmp = -1.0 + (a * Math.pow(a, 3.0));
} else if (a <= 1.65e+24) {
tmp = -1.0 + (((b * b) * 4.0) + Math.pow(b, 4.0));
} else {
tmp = -1.0 + Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -2e+40: tmp = -1.0 + (a * math.pow(a, 3.0)) elif a <= 1.65e+24: tmp = -1.0 + (((b * b) * 4.0) + math.pow(b, 4.0)) else: tmp = -1.0 + math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -2e+40) tmp = Float64(-1.0 + Float64(a * (a ^ 3.0))); elseif (a <= 1.65e+24) tmp = Float64(-1.0 + Float64(Float64(Float64(b * b) * 4.0) + (b ^ 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 <= -2e+40) tmp = -1.0 + (a * (a ^ 3.0)); elseif (a <= 1.65e+24) tmp = -1.0 + (((b * b) * 4.0) + (b ^ 4.0)); else tmp = -1.0 + (a ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -2e+40], N[(-1.0 + N[(a * N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.65e+24], N[(-1.0 + N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2 \cdot 10^{+40}:\\
\;\;\;\;-1 + a \cdot {a}^{3}\\
\mathbf{elif}\;a \leq 1.65 \cdot 10^{+24}:\\
\;\;\;\;-1 + \left(\left(b \cdot b\right) \cdot 4 + {b}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + {a}^{4}\\
\end{array}
\end{array}
if a < -2.00000000000000006e40Initial program 16.3%
sub-neg16.3%
Simplified30.6%
Taylor expanded in a around inf 98.9%
metadata-eval98.9%
pow-prod-up98.9%
unpow298.9%
associate-*r*98.9%
unpow298.9%
pow398.9%
Applied egg-rr98.9%
if -2.00000000000000006e40 < a < 1.6499999999999999e24Initial 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.0%
unpow297.0%
Applied egg-rr97.0%
if 1.6499999999999999e24 < a Initial program 60.0%
sub-neg60.0%
Simplified60.0%
Taylor expanded in a around inf 93.3%
Final simplification96.3%
(FPCore (a b) :precision binary64 (if (or (<= a -1e+39) (not (<= a 1.7e+24))) (+ -1.0 (pow a 4.0)) (+ -1.0 (pow b 4.0))))
double code(double a, double b) {
double tmp;
if ((a <= -1e+39) || !(a <= 1.7e+24)) {
tmp = -1.0 + pow(a, 4.0);
} else {
tmp = -1.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 <= (-1d+39)) .or. (.not. (a <= 1.7d+24))) then
tmp = (-1.0d0) + (a ** 4.0d0)
else
tmp = (-1.0d0) + (b ** 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -1e+39) || !(a <= 1.7e+24)) {
tmp = -1.0 + Math.pow(a, 4.0);
} else {
tmp = -1.0 + Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -1e+39) or not (a <= 1.7e+24): tmp = -1.0 + math.pow(a, 4.0) else: tmp = -1.0 + math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if ((a <= -1e+39) || !(a <= 1.7e+24)) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = Float64(-1.0 + (b ^ 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -1e+39) || ~((a <= 1.7e+24))) tmp = -1.0 + (a ^ 4.0); else tmp = -1.0 + (b ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -1e+39], N[Not[LessEqual[a, 1.7e+24]], $MachinePrecision]], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1 \cdot 10^{+39} \lor \neg \left(a \leq 1.7 \cdot 10^{+24}\right):\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + {b}^{4}\\
\end{array}
\end{array}
if a < -9.9999999999999994e38 or 1.7e24 < a Initial program 42.7%
sub-neg42.7%
Simplified48.4%
Taylor expanded in a around inf 95.5%
if -9.9999999999999994e38 < a < 1.7e24Initial program 98.4%
sub-neg98.4%
Simplified98.4%
Taylor expanded in b around inf 94.2%
Final simplification94.9%
(FPCore (a b) :precision binary64 (if (<= a -9e+40) (+ -1.0 (* a (pow a 3.0))) (if (<= a 5.6e+25) (+ -1.0 (pow b 4.0)) (+ -1.0 (pow a 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= -9e+40) {
tmp = -1.0 + (a * pow(a, 3.0));
} else if (a <= 5.6e+25) {
tmp = -1.0 + pow(b, 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 <= (-9d+40)) then
tmp = (-1.0d0) + (a * (a ** 3.0d0))
else if (a <= 5.6d+25) then
tmp = (-1.0d0) + (b ** 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 <= -9e+40) {
tmp = -1.0 + (a * Math.pow(a, 3.0));
} else if (a <= 5.6e+25) {
tmp = -1.0 + Math.pow(b, 4.0);
} else {
tmp = -1.0 + Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -9e+40: tmp = -1.0 + (a * math.pow(a, 3.0)) elif a <= 5.6e+25: tmp = -1.0 + math.pow(b, 4.0) else: tmp = -1.0 + math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -9e+40) tmp = Float64(-1.0 + Float64(a * (a ^ 3.0))); elseif (a <= 5.6e+25) tmp = Float64(-1.0 + (b ^ 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 <= -9e+40) tmp = -1.0 + (a * (a ^ 3.0)); elseif (a <= 5.6e+25) tmp = -1.0 + (b ^ 4.0); else tmp = -1.0 + (a ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -9e+40], N[(-1.0 + N[(a * N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 5.6e+25], N[(-1.0 + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -9 \cdot 10^{+40}:\\
\;\;\;\;-1 + a \cdot {a}^{3}\\
\mathbf{elif}\;a \leq 5.6 \cdot 10^{+25}:\\
\;\;\;\;-1 + {b}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + {a}^{4}\\
\end{array}
\end{array}
if a < -9.00000000000000064e40Initial program 16.3%
sub-neg16.3%
Simplified30.6%
Taylor expanded in a around inf 98.9%
metadata-eval98.9%
pow-prod-up98.9%
unpow298.9%
associate-*r*98.9%
unpow298.9%
pow398.9%
Applied egg-rr98.9%
if -9.00000000000000064e40 < a < 5.6000000000000003e25Initial program 98.4%
sub-neg98.4%
Simplified98.4%
Taylor expanded in b around inf 94.2%
if 5.6000000000000003e25 < a Initial program 60.0%
sub-neg60.0%
Simplified60.0%
Taylor expanded in a around inf 93.3%
Final simplification94.9%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e+53) (+ (* (* a a) (+ 4.0 (* a (+ a 4.0)))) -1.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e+53) {
tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.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 * b) <= 1d+53) then
tmp = ((a * a) * (4.0d0 + (a * (a + 4.0d0)))) + (-1.0d0)
else
tmp = b ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 1e+53) {
tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0;
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 1e+53: tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1e+53) tmp = Float64(Float64(Float64(a * a) * Float64(4.0 + Float64(a * Float64(a + 4.0)))) + -1.0); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 1e+53) tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e+53], N[(N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * N[(a + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{+53}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + 4\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 9.9999999999999999e52Initial program 84.3%
sub-neg84.3%
Simplified84.3%
Taylor expanded in b around 0 78.2%
Taylor expanded in a around 0 93.1%
unpow293.1%
Applied egg-rr93.1%
if 9.9999999999999999e52 < (*.f64 b b) Initial program 54.1%
sub-neg54.1%
Simplified60.5%
Taylor expanded in b around inf 92.6%
Taylor expanded in b around inf 92.6%
Final simplification92.9%
(FPCore (a b)
:precision binary64
(if (<= a -5.4e+144)
(+ -1.0 (* (* a a) 4.0))
(if (<= a 4e+86)
(+ -1.0 (* (* b b) 4.0))
(+ -1.0 (* (* a a) (+ 4.0 (* a 4.0)))))))
double code(double a, double b) {
double tmp;
if (a <= -5.4e+144) {
tmp = -1.0 + ((a * a) * 4.0);
} else if (a <= 4e+86) {
tmp = -1.0 + ((b * b) * 4.0);
} else {
tmp = -1.0 + ((a * a) * (4.0 + (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 <= (-5.4d+144)) then
tmp = (-1.0d0) + ((a * a) * 4.0d0)
else if (a <= 4d+86) then
tmp = (-1.0d0) + ((b * b) * 4.0d0)
else
tmp = (-1.0d0) + ((a * a) * (4.0d0 + (a * 4.0d0)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -5.4e+144) {
tmp = -1.0 + ((a * a) * 4.0);
} else if (a <= 4e+86) {
tmp = -1.0 + ((b * b) * 4.0);
} else {
tmp = -1.0 + ((a * a) * (4.0 + (a * 4.0)));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -5.4e+144: tmp = -1.0 + ((a * a) * 4.0) elif a <= 4e+86: tmp = -1.0 + ((b * b) * 4.0) else: tmp = -1.0 + ((a * a) * (4.0 + (a * 4.0))) return tmp
function code(a, b) tmp = 0.0 if (a <= -5.4e+144) tmp = Float64(-1.0 + Float64(Float64(a * a) * 4.0)); elseif (a <= 4e+86) tmp = Float64(-1.0 + Float64(Float64(b * b) * 4.0)); else tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(4.0 + Float64(a * 4.0)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -5.4e+144) tmp = -1.0 + ((a * a) * 4.0); elseif (a <= 4e+86) tmp = -1.0 + ((b * b) * 4.0); else tmp = -1.0 + ((a * a) * (4.0 + (a * 4.0))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -5.4e+144], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 4e+86], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5.4 \cdot 10^{+144}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\
\mathbf{elif}\;a \leq 4 \cdot 10^{+86}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot 4\right)\\
\end{array}
\end{array}
if a < -5.4000000000000003e144Initial program 0.0%
sub-neg0.0%
Simplified0.0%
Taylor expanded in b around 0 0.0%
Taylor expanded in a around 0 94.4%
unpow2100.0%
Applied egg-rr94.4%
if -5.4000000000000003e144 < a < 4.0000000000000001e86Initial program 89.8%
associate--l+89.8%
+-commutative89.8%
+-commutative89.8%
sub-neg89.8%
associate-+l+89.8%
+-commutative89.8%
fma-define89.8%
Simplified89.8%
Taylor expanded in a around 0 84.9%
Taylor expanded in b around 0 64.7%
unpow284.9%
Applied egg-rr64.7%
if 4.0000000000000001e86 < a Initial program 57.1%
sub-neg57.1%
Simplified57.1%
Taylor expanded in b around 0 100.0%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Applied egg-rr100.0%
Taylor expanded in a around 0 90.4%
Final simplification74.0%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+297) (+ (* (* a a) (+ 4.0 (* a (+ a 4.0)))) -1.0) (+ -1.0 (* (* b b) 4.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+297) {
tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.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 ((b * b) <= 5d+297) then
tmp = ((a * a) * (4.0d0 + (a * (a + 4.0d0)))) + (-1.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 ((b * b) <= 5e+297) {
tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0;
} else {
tmp = -1.0 + ((b * b) * 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e+297: tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0 else: tmp = -1.0 + ((b * b) * 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e+297) tmp = Float64(Float64(Float64(a * a) * Float64(4.0 + Float64(a * Float64(a + 4.0)))) + -1.0); else tmp = Float64(-1.0 + Float64(Float64(b * b) * 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5e+297) tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0; else tmp = -1.0 + ((b * b) * 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e+297], N[(N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * N[(a + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{+297}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + 4\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 4\\
\end{array}
\end{array}
if (*.f64 b b) < 4.9999999999999998e297Initial program 79.8%
sub-neg79.8%
Simplified80.8%
Taylor expanded in b around 0 66.4%
Taylor expanded in a around 0 81.2%
unpow281.2%
Applied egg-rr81.2%
if 4.9999999999999998e297 < (*.f64 b b) Initial program 47.8%
associate--l+47.8%
+-commutative47.8%
+-commutative47.8%
sub-neg47.8%
associate-+l+47.8%
+-commutative47.8%
fma-define47.8%
Simplified47.8%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 100.0%
unpow2100.0%
Applied egg-rr100.0%
Final simplification86.1%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+297) (+ -1.0 (* (* a a) (+ (* a a) 4.0))) (+ -1.0 (* (* b b) 4.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+297) {
tmp = -1.0 + ((a * a) * ((a * 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 ((b * b) <= 5d+297) then
tmp = (-1.0d0) + ((a * a) * ((a * 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 ((b * b) <= 5e+297) {
tmp = -1.0 + ((a * a) * ((a * a) + 4.0));
} else {
tmp = -1.0 + ((b * b) * 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e+297: tmp = -1.0 + ((a * a) * ((a * a) + 4.0)) else: tmp = -1.0 + ((b * b) * 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e+297) tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(Float64(a * a) + 4.0))); else tmp = Float64(-1.0 + Float64(Float64(b * b) * 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5e+297) tmp = -1.0 + ((a * a) * ((a * a) + 4.0)); else tmp = -1.0 + ((b * b) * 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e+297], 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] * 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{+297}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a + 4\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 4\\
\end{array}
\end{array}
if (*.f64 b b) < 4.9999999999999998e297Initial program 79.8%
sub-neg79.8%
Simplified80.8%
Taylor expanded in b around 0 66.4%
Taylor expanded in a around 0 81.2%
unpow281.2%
Applied egg-rr81.2%
Taylor expanded in a around inf 80.4%
if 4.9999999999999998e297 < (*.f64 b b) Initial program 47.8%
associate--l+47.8%
+-commutative47.8%
+-commutative47.8%
sub-neg47.8%
associate-+l+47.8%
+-commutative47.8%
fma-define47.8%
Simplified47.8%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 100.0%
unpow2100.0%
Applied egg-rr100.0%
Final simplification85.5%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e+297) (+ -1.0 (* (* a a) 4.0)) (+ -1.0 (* (* b b) 4.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e+297) {
tmp = -1.0 + ((a * 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 ((b * b) <= 1d+297) then
tmp = (-1.0d0) + ((a * 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 ((b * b) <= 1e+297) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = -1.0 + ((b * b) * 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 1e+297: tmp = -1.0 + ((a * a) * 4.0) else: tmp = -1.0 + ((b * b) * 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1e+297) tmp = Float64(-1.0 + Float64(Float64(a * a) * 4.0)); else tmp = Float64(-1.0 + Float64(Float64(b * b) * 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 1e+297) tmp = -1.0 + ((a * a) * 4.0); else tmp = -1.0 + ((b * b) * 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e+297], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{+297}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 4\\
\end{array}
\end{array}
if (*.f64 b b) < 1e297Initial program 80.2%
sub-neg80.2%
Simplified81.3%
Taylor expanded in b around 0 66.3%
Taylor expanded in a around 0 60.8%
unpow281.1%
Applied egg-rr60.8%
if 1e297 < (*.f64 b b) Initial program 47.1%
associate--l+47.1%
+-commutative47.1%
+-commutative47.1%
sub-neg47.1%
associate-+l+47.1%
+-commutative47.1%
fma-define47.1%
Simplified48.5%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 98.7%
unpow2100.0%
Applied egg-rr98.7%
Final simplification70.9%
(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 71.4%
sub-neg71.4%
Simplified74.1%
Taylor expanded in b around 0 56.3%
Taylor expanded in a around 0 52.6%
unpow272.3%
Applied egg-rr52.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 71.4%
sub-neg71.4%
Simplified74.1%
Taylor expanded in a around inf 71.7%
associate-*r/71.7%
metadata-eval71.7%
Simplified71.7%
Taylor expanded in a around 0 24.7%
herbie shell --seed 2024123
(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))