
(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 (if (<= a 2e+66) (+ (pow (hypot a b) 4.0) (+ (* 4.0 (- (pow a 2.0) (pow a 3.0))) -1.0)) (pow a 4.0)))
double code(double a, double b) {
double tmp;
if (a <= 2e+66) {
tmp = pow(hypot(a, b), 4.0) + ((4.0 * (pow(a, 2.0) - pow(a, 3.0))) + -1.0);
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (a <= 2e+66) {
tmp = Math.pow(Math.hypot(a, b), 4.0) + ((4.0 * (Math.pow(a, 2.0) - Math.pow(a, 3.0))) + -1.0);
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= 2e+66: tmp = math.pow(math.hypot(a, b), 4.0) + ((4.0 * (math.pow(a, 2.0) - math.pow(a, 3.0))) + -1.0) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= 2e+66) tmp = Float64((hypot(a, b) ^ 4.0) + Float64(Float64(4.0 * Float64((a ^ 2.0) - (a ^ 3.0))) + -1.0)); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= 2e+66) tmp = (hypot(a, b) ^ 4.0) + ((4.0 * ((a ^ 2.0) - (a ^ 3.0))) + -1.0); else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, 2e+66], N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + N[(N[(4.0 * N[(N[Power[a, 2.0], $MachinePrecision] - N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2 \cdot 10^{+66}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \left(4 \cdot \left({a}^{2} - {a}^{3}\right) + -1\right)\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < 1.99999999999999989e66Initial program 85.2%
associate--l+85.2%
fma-def85.2%
distribute-rgt-in85.2%
sqr-neg85.2%
distribute-rgt-in85.2%
fma-def85.2%
sqr-neg85.2%
+-commutative85.2%
Simplified85.2%
Taylor expanded in a around inf 99.0%
+-commutative99.0%
mul-1-neg99.0%
unsub-neg99.0%
Simplified99.0%
associate-+r-99.0%
metadata-eval99.0%
sqrt-pow299.1%
fma-udef99.1%
hypot-udef99.1%
Applied egg-rr99.1%
associate--l+99.1%
Simplified99.1%
if 1.99999999999999989e66 < a Initial program 19.5%
associate--l+19.5%
fma-def19.5%
distribute-rgt-in19.5%
sqr-neg19.5%
distribute-rgt-in19.5%
fma-def25.4%
sqr-neg25.4%
+-commutative25.4%
Simplified25.4%
Taylor expanded in a around inf 100.0%
Final simplification99.3%
(FPCore (a b) :precision binary64 (if (<= a 2e+66) (+ (pow (fma a a (* b b)) 2.0) (+ (* 4.0 (* (pow a 2.0) (- 1.0 a))) -1.0)) (pow a 4.0)))
double code(double a, double b) {
double tmp;
if (a <= 2e+66) {
tmp = pow(fma(a, a, (b * b)), 2.0) + ((4.0 * (pow(a, 2.0) * (1.0 - a))) + -1.0);
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (a <= 2e+66) tmp = Float64((fma(a, a, Float64(b * b)) ^ 2.0) + Float64(Float64(4.0 * Float64((a ^ 2.0) * Float64(1.0 - a))) + -1.0)); else tmp = a ^ 4.0; end return tmp end
code[a_, b_] := If[LessEqual[a, 2e+66], N[(N[Power[N[(a * a + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(4.0 * N[(N[Power[a, 2.0], $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2 \cdot 10^{+66}:\\
\;\;\;\;{\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + \left(4 \cdot \left({a}^{2} \cdot \left(1 - a\right)\right) + -1\right)\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < 1.99999999999999989e66Initial program 85.2%
associate--l+85.2%
fma-def85.2%
distribute-rgt-in85.2%
sqr-neg85.2%
distribute-rgt-in85.2%
fma-def85.2%
sqr-neg85.2%
+-commutative85.2%
Simplified85.2%
Taylor expanded in b around 0 99.0%
if 1.99999999999999989e66 < a Initial program 19.5%
associate--l+19.5%
fma-def19.5%
distribute-rgt-in19.5%
sqr-neg19.5%
distribute-rgt-in19.5%
fma-def25.4%
sqr-neg25.4%
+-commutative25.4%
Simplified25.4%
Taylor expanded in a around inf 100.0%
Final simplification99.2%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* b b) (* a a)) 2.0)
(* 4.0 (+ (* (- 1.0 a) (* a a)) (* (* b b) (+ a 3.0)))))))
(if (<= t_0 INFINITY) (+ t_0 -1.0) (pow a 4.0))))
double code(double a, double b) {
double t_0 = pow(((b * b) + (a * a)), 2.0) + (4.0 * (((1.0 - a) * (a * a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0 + -1.0;
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = Math.pow(((b * b) + (a * a)), 2.0) + (4.0 * (((1.0 - a) * (a * a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 + -1.0;
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): t_0 = math.pow(((b * b) + (a * a)), 2.0) + (4.0 * (((1.0 - a) * (a * a)) + ((b * b) * (a + 3.0)))) tmp = 0 if t_0 <= math.inf: tmp = t_0 + -1.0 else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) t_0 = Float64((Float64(Float64(b * b) + Float64(a * a)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(1.0 - a) * Float64(a * a)) + Float64(Float64(b * b) * Float64(a + 3.0))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(t_0 + -1.0); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) t_0 = (((b * b) + (a * a)) ^ 2.0) + (4.0 * (((1.0 - a) * (a * a)) + ((b * b) * (a + 3.0)))); tmp = 0.0; if (t_0 <= Inf) tmp = t_0 + -1.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[Power[N[(N[(b * b), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(1.0 - a), $MachinePrecision] * N[(a * 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[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(b \cdot b + a \cdot a\right)}^{2} + 4 \cdot \left(\left(1 - a\right) \cdot \left(a \cdot a\right) + \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\\
\mathbf{if}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0 + -1\\
\mathbf{else}:\\
\;\;\;\;{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.7%
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%
associate--l+0.0%
fma-def0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
fma-def4.2%
sqr-neg4.2%
+-commutative4.2%
Simplified4.2%
Taylor expanded in a around inf 93.3%
Final simplification98.0%
(FPCore (a b) :precision binary64 (if (<= b 2.7e-134) -1.0 (if (<= b 6.4e-53) (pow a 4.0) (if (<= b 0.19) -1.0 (pow b 4.0)))))
double code(double a, double b) {
double tmp;
if (b <= 2.7e-134) {
tmp = -1.0;
} else if (b <= 6.4e-53) {
tmp = pow(a, 4.0);
} else if (b <= 0.19) {
tmp = -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 <= 2.7d-134) then
tmp = -1.0d0
else if (b <= 6.4d-53) then
tmp = a ** 4.0d0
else if (b <= 0.19d0) then
tmp = -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 <= 2.7e-134) {
tmp = -1.0;
} else if (b <= 6.4e-53) {
tmp = Math.pow(a, 4.0);
} else if (b <= 0.19) {
tmp = -1.0;
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 2.7e-134: tmp = -1.0 elif b <= 6.4e-53: tmp = math.pow(a, 4.0) elif b <= 0.19: tmp = -1.0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 2.7e-134) tmp = -1.0; elseif (b <= 6.4e-53) tmp = a ^ 4.0; elseif (b <= 0.19) tmp = -1.0; else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 2.7e-134) tmp = -1.0; elseif (b <= 6.4e-53) tmp = a ^ 4.0; elseif (b <= 0.19) tmp = -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 2.7e-134], -1.0, If[LessEqual[b, 6.4e-53], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[b, 0.19], -1.0, N[Power[b, 4.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.7 \cdot 10^{-134}:\\
\;\;\;\;-1\\
\mathbf{elif}\;b \leq 6.4 \cdot 10^{-53}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;b \leq 0.19:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 2.6999999999999998e-134 or 6.4000000000000002e-53 < b < 0.19Initial program 75.1%
associate--l+75.1%
fma-def75.1%
distribute-rgt-in75.1%
sqr-neg75.1%
distribute-rgt-in75.1%
fma-def76.2%
sqr-neg76.2%
+-commutative76.2%
Simplified76.2%
Taylor expanded in b around 0 62.2%
associate--l+62.2%
associate-*r*62.2%
fma-def64.4%
sub-neg64.4%
metadata-eval64.4%
Simplified64.4%
Taylor expanded in a around 0 31.5%
if 2.6999999999999998e-134 < b < 6.4000000000000002e-53Initial program 80.0%
associate--l+80.0%
fma-def80.0%
distribute-rgt-in80.0%
sqr-neg80.0%
distribute-rgt-in80.0%
fma-def80.0%
sqr-neg80.0%
+-commutative80.0%
Simplified80.0%
Taylor expanded in a around inf 61.1%
if 0.19 < b Initial program 63.0%
associate--l+63.0%
fma-def63.0%
distribute-rgt-in63.0%
sqr-neg63.0%
distribute-rgt-in63.0%
fma-def64.5%
sqr-neg64.5%
+-commutative64.5%
Simplified64.5%
Taylor expanded in b around inf 87.8%
Final simplification47.6%
(FPCore (a b) :precision binary64 (if (or (<= a -2.75e+26) (not (<= a 2.25e+25))) (pow a 4.0) (+ (pow b 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -2.75e+26) || !(a <= 2.25e+25)) {
tmp = pow(a, 4.0);
} else {
tmp = pow(b, 4.0) + -1.0;
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a <= (-2.75d+26)) .or. (.not. (a <= 2.25d+25))) then
tmp = a ** 4.0d0
else
tmp = (b ** 4.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -2.75e+26) || !(a <= 2.25e+25)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -2.75e+26) or not (a <= 2.25e+25): tmp = math.pow(a, 4.0) else: tmp = math.pow(b, 4.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -2.75e+26) || !(a <= 2.25e+25)) tmp = a ^ 4.0; else tmp = Float64((b ^ 4.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -2.75e+26) || ~((a <= 2.25e+25))) tmp = a ^ 4.0; else tmp = (b ^ 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -2.75e+26], N[Not[LessEqual[a, 2.25e+25]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.75 \cdot 10^{+26} \lor \neg \left(a \leq 2.25 \cdot 10^{+25}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4} + -1\\
\end{array}
\end{array}
if a < -2.7499999999999998e26 or 2.25000000000000015e25 < a Initial program 40.9%
associate--l+40.9%
fma-def40.9%
distribute-rgt-in40.9%
sqr-neg40.9%
distribute-rgt-in40.9%
fma-def43.4%
sqr-neg43.4%
+-commutative43.4%
Simplified43.4%
Taylor expanded in a around inf 94.2%
if -2.7499999999999998e26 < a < 2.25000000000000015e25Initial program 98.3%
associate--l+98.3%
fma-def98.3%
distribute-rgt-in98.3%
sqr-neg98.3%
distribute-rgt-in98.3%
fma-def98.3%
sqr-neg98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in a around inf 98.6%
+-commutative98.6%
mul-1-neg98.6%
unsub-neg98.6%
Simplified98.6%
Taylor expanded in a around 0 94.5%
Final simplification94.4%
(FPCore (a b) :precision binary64 (if (or (<= a -6e-13) (not (<= a 2.45))) (pow a 4.0) -1.0))
double code(double a, double b) {
double tmp;
if ((a <= -6e-13) || !(a <= 2.45)) {
tmp = pow(a, 4.0);
} else {
tmp = -1.0;
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a <= (-6d-13)) .or. (.not. (a <= 2.45d0))) then
tmp = a ** 4.0d0
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -6e-13) || !(a <= 2.45)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -6e-13) or not (a <= 2.45): tmp = math.pow(a, 4.0) else: tmp = -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -6e-13) || !(a <= 2.45)) tmp = a ^ 4.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -6e-13) || ~((a <= 2.45))) tmp = a ^ 4.0; else tmp = -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -6e-13], N[Not[LessEqual[a, 2.45]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], -1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -6 \cdot 10^{-13} \lor \neg \left(a \leq 2.45\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if a < -5.99999999999999968e-13 or 2.4500000000000002 < a Initial program 47.6%
associate--l+47.6%
fma-def47.6%
distribute-rgt-in47.6%
sqr-neg47.6%
distribute-rgt-in47.6%
fma-def49.8%
sqr-neg49.8%
+-commutative49.8%
Simplified49.8%
Taylor expanded in a around inf 83.9%
if -5.99999999999999968e-13 < a < 2.4500000000000002Initial program 99.9%
associate--l+99.9%
fma-def99.9%
distribute-rgt-in99.9%
sqr-neg99.9%
distribute-rgt-in99.9%
fma-def99.9%
sqr-neg99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in b around 0 49.7%
associate--l+49.7%
associate-*r*49.7%
fma-def49.7%
sub-neg49.7%
metadata-eval49.7%
Simplified49.7%
Taylor expanded in a around 0 49.6%
Final simplification67.9%
(FPCore (a b) :precision binary64 (if (<= b 52000000000.0) (+ (pow a 4.0) -1.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if (b <= 52000000000.0) {
tmp = pow(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 <= 52000000000.0d0) then
tmp = (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 <= 52000000000.0) {
tmp = Math.pow(a, 4.0) + -1.0;
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 52000000000.0: tmp = math.pow(a, 4.0) + -1.0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 52000000000.0) tmp = 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 <= 52000000000.0) tmp = (a ^ 4.0) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 52000000000.0], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 52000000000:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 5.2e10Initial program 75.5%
associate--l+75.5%
fma-def75.5%
distribute-rgt-in75.5%
sqr-neg75.5%
distribute-rgt-in75.5%
fma-def76.5%
sqr-neg76.5%
+-commutative76.5%
Simplified76.5%
Taylor expanded in a around inf 83.1%
+-commutative83.1%
mul-1-neg83.1%
unsub-neg83.1%
Simplified83.1%
Taylor expanded in a around 0 78.4%
Taylor expanded in a around inf 77.2%
if 5.2e10 < b Initial program 62.5%
associate--l+62.5%
fma-def62.5%
distribute-rgt-in62.5%
sqr-neg62.5%
distribute-rgt-in62.5%
fma-def64.0%
sqr-neg64.0%
+-commutative64.0%
Simplified64.0%
Taylor expanded in b around inf 88.8%
Final simplification80.3%
(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 72.1%
associate--l+72.1%
fma-def72.1%
distribute-rgt-in72.1%
sqr-neg72.1%
distribute-rgt-in72.1%
fma-def73.3%
sqr-neg73.3%
+-commutative73.3%
Simplified73.3%
Taylor expanded in b around 0 52.8%
associate--l+52.8%
associate-*r*52.8%
fma-def55.5%
sub-neg55.5%
metadata-eval55.5%
Simplified55.5%
Taylor expanded in a around 0 23.7%
Final simplification23.7%
herbie shell --seed 2024033
(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))