
(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 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) (+ 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 4.6e+60)
(+
(fma
(* b b)
(fma 2.0 (* a a) (+ 12.0 (* a 4.0)))
(+ (* (pow a 4.0) 0.5) (fma 4.0 (- (* a a) (pow a 3.0)) (pow b 4.0))))
(fma (pow a 4.0) 0.5 -1.0))
(pow a 4.0)))
double code(double a, double b) {
double tmp;
if (a <= 4.6e+60) {
tmp = fma((b * b), fma(2.0, (a * a), (12.0 + (a * 4.0))), ((pow(a, 4.0) * 0.5) + fma(4.0, ((a * a) - pow(a, 3.0)), pow(b, 4.0)))) + fma(pow(a, 4.0), 0.5, -1.0);
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (a <= 4.6e+60) tmp = Float64(fma(Float64(b * b), fma(2.0, Float64(a * a), Float64(12.0 + Float64(a * 4.0))), Float64(Float64((a ^ 4.0) * 0.5) + fma(4.0, Float64(Float64(a * a) - (a ^ 3.0)), (b ^ 4.0)))) + fma((a ^ 4.0), 0.5, -1.0)); else tmp = a ^ 4.0; end return tmp end
code[a_, b_] := If[LessEqual[a, 4.6e+60], N[(N[(N[(b * b), $MachinePrecision] * N[(2.0 * N[(a * a), $MachinePrecision] + N[(12.0 + N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[a, 4.0], $MachinePrecision] * 0.5), $MachinePrecision] + N[(4.0 * N[(N[(a * a), $MachinePrecision] - N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[a, 4.0], $MachinePrecision] * 0.5 + -1.0), $MachinePrecision]), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 4.6 \cdot 10^{+60}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(2, a \cdot a, 12 + a \cdot 4\right), {a}^{4} \cdot 0.5 + \mathsf{fma}\left(4, a \cdot a - {a}^{3}, {b}^{4}\right)\right) + \mathsf{fma}\left({a}^{4}, 0.5, -1\right)\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < 4.60000000000000034e60Initial program 89.4%
associate--l+89.4%
Simplified91.8%
Taylor expanded in b around inf 80.8%
+-commutative80.8%
associate--l+80.8%
Simplified99.0%
if 4.60000000000000034e60 < a Initial program 4.2%
associate--l+4.2%
fma-def4.2%
fma-neg4.2%
associate-*l*4.2%
fma-def19.1%
+-commutative19.1%
metadata-eval19.1%
Simplified19.1%
Taylor expanded in b around 0 4.3%
associate--l+4.3%
unpow24.3%
Simplified4.3%
Taylor expanded in a around inf 100.0%
Final simplification99.2%
(FPCore (a b)
:precision binary64
(if (<=
(+
(pow (+ (* b b) (* a a)) 2.0)
(* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))
INFINITY)
(+
(pow (hypot a b) 4.0)
(fma 4.0 (- (fma (* b b) (+ a 3.0) (* a a)) (pow a 3.0)) -1.0))
(+ (pow a 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((pow(((b * b) + (a * a)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))))) <= ((double) INFINITY)) {
tmp = pow(hypot(a, b), 4.0) + fma(4.0, (fma((b * b), (a + 3.0), (a * a)) - pow(a, 3.0)), -1.0);
} else {
tmp = pow(a, 4.0) + -1.0;
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64((Float64(Float64(b * b) + Float64(a * a)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + Float64(Float64(b * b) * Float64(a + 3.0))))) <= Inf) tmp = Float64((hypot(a, b) ^ 4.0) + fma(4.0, Float64(fma(Float64(b * b), Float64(a + 3.0), Float64(a * a)) - (a ^ 3.0)), -1.0)); else tmp = Float64((a ^ 4.0) + -1.0); end return tmp end
code[a_, b_] := If[LessEqual[N[(N[Power[N[(N[(b * b), $MachinePrecision] + N[(a * a), $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], Infinity], N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision] - N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{\left(b \cdot b + a \cdot a\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) \leq \infty:\\
\;\;\;\;{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(4, \mathsf{fma}\left(b \cdot b, a + 3, a \cdot a\right) - {a}^{3}, -1\right)\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} + -1\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) < +inf.0Initial program 99.9%
associate--l+99.9%
Simplified100.0%
if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) Initial program 0.0%
sub-neg0.0%
fma-def0.0%
fma-def10.4%
+-commutative10.4%
metadata-eval10.4%
Simplified10.4%
Taylor expanded in a around inf 93.0%
Final simplification98.1%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* (* b b) (+ a 3.0))))
(if (<=
(+ (pow (+ (* b b) (* a a)) 2.0) (* 4.0 (+ (* (* a a) (- 1.0 a)) t_0)))
INFINITY)
(+ (pow (fma a a (* b b)) 2.0) (fma 4.0 (fma a (* a (- 1.0 a)) t_0) -1.0))
(+ (pow a 4.0) -1.0))))
double code(double a, double b) {
double t_0 = (b * b) * (a + 3.0);
double tmp;
if ((pow(((b * b) + (a * a)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + t_0))) <= ((double) INFINITY)) {
tmp = pow(fma(a, a, (b * b)), 2.0) + fma(4.0, fma(a, (a * (1.0 - a)), t_0), -1.0);
} else {
tmp = pow(a, 4.0) + -1.0;
}
return tmp;
}
function code(a, b) t_0 = Float64(Float64(b * b) * Float64(a + 3.0)) tmp = 0.0 if (Float64((Float64(Float64(b * b) + Float64(a * a)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + t_0))) <= Inf) tmp = Float64((fma(a, a, Float64(b * b)) ^ 2.0) + fma(4.0, fma(a, Float64(a * Float64(1.0 - a)), t_0), -1.0)); else tmp = Float64((a ^ 4.0) + -1.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[(b * b), $MachinePrecision] + N[(a * a), $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[(N[Power[N[(a * a + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(a * N[(a * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(b \cdot b\right) \cdot \left(a + 3\right)\\
\mathbf{if}\;{\left(b \cdot b + a \cdot a\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + t_0\right) \leq \infty:\\
\;\;\;\;{\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + \mathsf{fma}\left(4, \mathsf{fma}\left(a, a \cdot \left(1 - a\right), t_0\right), -1\right)\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} + -1\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) < +inf.0Initial program 99.9%
associate--l+99.9%
fma-def99.9%
fma-neg99.9%
associate-*l*99.9%
fma-def99.9%
+-commutative99.9%
metadata-eval99.9%
Simplified99.9%
if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) Initial program 0.0%
sub-neg0.0%
fma-def0.0%
fma-def10.4%
+-commutative10.4%
metadata-eval10.4%
Simplified10.4%
Taylor expanded in a around inf 93.0%
Final simplification98.1%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* b b) (* a a)) 2.0)
(* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))))
(if (<= t_0 INFINITY) (+ -1.0 t_0) (+ (pow a 4.0) -1.0))))
double code(double a, double b) {
double t_0 = pow(((b * b) + (a * a)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = -1.0 + t_0;
} else {
tmp = pow(a, 4.0) + -1.0;
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = Math.pow(((b * b) + (a * a)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = -1.0 + t_0;
} else {
tmp = Math.pow(a, 4.0) + -1.0;
}
return tmp;
}
def code(a, b): t_0 = math.pow(((b * b) + (a * a)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0)))) tmp = 0 if t_0 <= math.inf: tmp = -1.0 + t_0 else: tmp = math.pow(a, 4.0) + -1.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(a * a) * Float64(1.0 - a)) + Float64(Float64(b * b) * Float64(a + 3.0))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(-1.0 + t_0); else tmp = Float64((a ^ 4.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) t_0 = (((b * b) + (a * a)) ^ 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0)))); tmp = 0.0; if (t_0 <= Inf) tmp = -1.0 + t_0; else tmp = (a ^ 4.0) + -1.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[(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[(-1.0 + t$95$0), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(b \cdot b + a \cdot a\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:\\
\;\;\;\;-1 + t_0\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} + -1\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) < +inf.0Initial program 99.9%
if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) Initial program 0.0%
sub-neg0.0%
fma-def0.0%
fma-def10.4%
+-commutative10.4%
metadata-eval10.4%
Simplified10.4%
Taylor expanded in a around inf 93.0%
Final simplification98.1%
(FPCore (a b)
:precision binary64
(if (<= (* b b) 4e-251)
-1.0
(if (<= (* b b) 4e-156)
(pow a 4.0)
(if (<= (* b b) 0.001) -1.0 (pow b 4.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 4e-251) {
tmp = -1.0;
} else if ((b * b) <= 4e-156) {
tmp = pow(a, 4.0);
} else if ((b * b) <= 0.001) {
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 * b) <= 4d-251) then
tmp = -1.0d0
else if ((b * b) <= 4d-156) then
tmp = a ** 4.0d0
else if ((b * b) <= 0.001d0) 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 * b) <= 4e-251) {
tmp = -1.0;
} else if ((b * b) <= 4e-156) {
tmp = Math.pow(a, 4.0);
} else if ((b * b) <= 0.001) {
tmp = -1.0;
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 4e-251: tmp = -1.0 elif (b * b) <= 4e-156: tmp = math.pow(a, 4.0) elif (b * b) <= 0.001: tmp = -1.0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 4e-251) tmp = -1.0; elseif (Float64(b * b) <= 4e-156) tmp = a ^ 4.0; elseif (Float64(b * b) <= 0.001) tmp = -1.0; else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 4e-251) tmp = -1.0; elseif ((b * b) <= 4e-156) tmp = a ^ 4.0; elseif ((b * b) <= 0.001) tmp = -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 4e-251], -1.0, If[LessEqual[N[(b * b), $MachinePrecision], 4e-156], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[N[(b * b), $MachinePrecision], 0.001], -1.0, N[Power[b, 4.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 4 \cdot 10^{-251}:\\
\;\;\;\;-1\\
\mathbf{elif}\;b \cdot b \leq 4 \cdot 10^{-156}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;b \cdot b \leq 0.001:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 4.00000000000000006e-251 or 4.00000000000000016e-156 < (*.f64 b b) < 1e-3Initial program 82.3%
associate--l+82.3%
Simplified82.4%
Taylor expanded in a around 0 62.6%
associate-+r+62.6%
associate-*r*62.6%
distribute-rgt-out62.6%
metadata-eval62.6%
distribute-lft-in62.6%
associate--l+62.6%
sub-neg62.6%
metadata-eval62.6%
unpow262.6%
distribute-lft-in62.6%
metadata-eval62.6%
Simplified62.6%
Taylor expanded in b around 0 60.6%
if 4.00000000000000006e-251 < (*.f64 b b) < 4.00000000000000016e-156Initial program 87.4%
associate--l+87.4%
fma-def87.4%
fma-neg87.4%
associate-*l*87.4%
fma-def87.4%
+-commutative87.4%
metadata-eval87.4%
Simplified87.4%
Taylor expanded in b around 0 87.5%
associate--l+87.5%
unpow287.5%
Simplified87.5%
Taylor expanded in a around inf 63.7%
if 1e-3 < (*.f64 b b) Initial program 65.1%
associate--l+65.1%
fma-def65.1%
fma-neg65.1%
associate-*l*65.1%
fma-def70.4%
+-commutative70.4%
metadata-eval70.4%
Simplified70.4%
fma-def70.4%
add-sqr-sqrt70.4%
hypot-udef70.4%
hypot-udef70.4%
pow-prod-down70.4%
pow-prod-up70.4%
metadata-eval70.4%
add-log-exp58.2%
Applied egg-rr58.2%
Taylor expanded in b around 0 68.8%
unpow268.8%
associate-*r*68.8%
*-commutative68.8%
sub-neg68.8%
+-commutative68.8%
distribute-rgt1-in68.8%
distribute-lft-neg-out68.8%
unsub-neg68.8%
Simplified68.8%
Taylor expanded in b around inf 90.8%
Final simplification76.4%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e-32) (+ (pow a 4.0) -1.0) (+ (* (* b b) 12.0) (+ (pow b 4.0) -1.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e-32) {
tmp = pow(a, 4.0) + -1.0;
} else {
tmp = ((b * b) * 12.0) + (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 ((b * b) <= 5d-32) then
tmp = (a ** 4.0d0) + (-1.0d0)
else
tmp = ((b * b) * 12.0d0) + ((b ** 4.0d0) + (-1.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 5e-32) {
tmp = Math.pow(a, 4.0) + -1.0;
} else {
tmp = ((b * b) * 12.0) + (Math.pow(b, 4.0) + -1.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e-32: tmp = math.pow(a, 4.0) + -1.0 else: tmp = ((b * b) * 12.0) + (math.pow(b, 4.0) + -1.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e-32) tmp = Float64((a ^ 4.0) + -1.0); else tmp = Float64(Float64(Float64(b * b) * 12.0) + Float64((b ^ 4.0) + -1.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5e-32) tmp = (a ^ 4.0) + -1.0; else tmp = ((b * b) * 12.0) + ((b ^ 4.0) + -1.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e-32], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{-32}:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 12 + \left({b}^{4} + -1\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 5e-32Initial program 82.5%
sub-neg82.5%
fma-def82.5%
fma-def82.5%
+-commutative82.5%
metadata-eval82.5%
Simplified82.5%
Taylor expanded in a around inf 98.3%
if 5e-32 < (*.f64 b b) Initial program 65.8%
associate--l+65.9%
Simplified69.6%
Taylor expanded in a around 0 62.2%
associate-+r+62.2%
associate-*r*62.2%
distribute-rgt-out79.2%
metadata-eval79.2%
distribute-lft-in79.2%
associate--l+79.2%
sub-neg79.2%
metadata-eval79.2%
unpow279.2%
distribute-lft-in79.2%
metadata-eval79.2%
Simplified79.2%
Taylor expanded in a around 0 92.1%
*-commutative92.1%
unpow292.1%
associate-*l*92.1%
Simplified92.1%
Taylor expanded in b around 0 92.1%
unpow292.1%
Simplified92.1%
Final simplification95.1%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e-32) (+ (pow a 4.0) (+ -1.0 (* a (* a 4.0)))) (+ (* (* b b) 12.0) (+ (pow b 4.0) -1.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e-32) {
tmp = pow(a, 4.0) + (-1.0 + (a * (a * 4.0)));
} else {
tmp = ((b * b) * 12.0) + (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 ((b * b) <= 5d-32) then
tmp = (a ** 4.0d0) + ((-1.0d0) + (a * (a * 4.0d0)))
else
tmp = ((b * b) * 12.0d0) + ((b ** 4.0d0) + (-1.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 5e-32) {
tmp = Math.pow(a, 4.0) + (-1.0 + (a * (a * 4.0)));
} else {
tmp = ((b * b) * 12.0) + (Math.pow(b, 4.0) + -1.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e-32: tmp = math.pow(a, 4.0) + (-1.0 + (a * (a * 4.0))) else: tmp = ((b * b) * 12.0) + (math.pow(b, 4.0) + -1.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e-32) tmp = Float64((a ^ 4.0) + Float64(-1.0 + Float64(a * Float64(a * 4.0)))); else tmp = Float64(Float64(Float64(b * b) * 12.0) + Float64((b ^ 4.0) + -1.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5e-32) tmp = (a ^ 4.0) + (-1.0 + (a * (a * 4.0))); else tmp = ((b * b) * 12.0) + ((b ^ 4.0) + -1.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e-32], N[(N[Power[a, 4.0], $MachinePrecision] + N[(-1.0 + N[(a * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{-32}:\\
\;\;\;\;{a}^{4} + \left(-1 + a \cdot \left(a \cdot 4\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 12 + \left({b}^{4} + -1\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 5e-32Initial program 82.5%
associate--l+82.6%
fma-def82.6%
fma-neg82.6%
associate-*l*82.6%
fma-def82.6%
+-commutative82.6%
metadata-eval82.6%
Simplified82.6%
Taylor expanded in b around 0 82.6%
associate--l+82.6%
unpow282.6%
Simplified82.6%
Taylor expanded in a around 0 98.5%
unpow298.5%
*-commutative98.5%
associate-*l*98.5%
Simplified98.5%
if 5e-32 < (*.f64 b b) Initial program 65.8%
associate--l+65.9%
Simplified69.6%
Taylor expanded in a around 0 62.2%
associate-+r+62.2%
associate-*r*62.2%
distribute-rgt-out79.2%
metadata-eval79.2%
distribute-lft-in79.2%
associate--l+79.2%
sub-neg79.2%
metadata-eval79.2%
unpow279.2%
distribute-lft-in79.2%
metadata-eval79.2%
Simplified79.2%
Taylor expanded in a around 0 92.1%
*-commutative92.1%
unpow292.1%
associate-*l*92.1%
Simplified92.1%
Taylor expanded in b around 0 92.1%
unpow292.1%
Simplified92.1%
Final simplification95.1%
(FPCore (a b) :precision binary64 (if (<= (* b b) 500.0) (+ (pow a 4.0) -1.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 500.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 * b) <= 500.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 * b) <= 500.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 * b) <= 500.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 (Float64(b * b) <= 500.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 * b) <= 500.0) tmp = (a ^ 4.0) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 500.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 \cdot b \leq 500:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 500Initial program 83.2%
sub-neg83.2%
fma-def83.2%
fma-def83.2%
+-commutative83.2%
metadata-eval83.2%
Simplified83.2%
Taylor expanded in a around inf 96.1%
if 500 < (*.f64 b b) Initial program 64.5%
associate--l+64.5%
fma-def64.5%
fma-neg64.5%
associate-*l*64.5%
fma-def69.9%
+-commutative69.9%
metadata-eval69.9%
Simplified69.9%
fma-def69.9%
add-sqr-sqrt69.9%
hypot-udef69.9%
hypot-udef69.9%
pow-prod-down69.9%
pow-prod-up70.0%
metadata-eval70.0%
add-log-exp57.6%
Applied egg-rr57.6%
Taylor expanded in b around 0 69.1%
unpow269.1%
associate-*r*69.1%
*-commutative69.1%
sub-neg69.1%
+-commutative69.1%
distribute-rgt1-in69.1%
distribute-lft-neg-out69.1%
unsub-neg69.1%
Simplified69.1%
Taylor expanded in b around inf 92.1%
Final simplification94.1%
(FPCore (a b) :precision binary64 (if (<= a -0.42) (pow a 4.0) (if (<= a 2.4) -1.0 (pow a 4.0))))
double code(double a, double b) {
double tmp;
if (a <= -0.42) {
tmp = pow(a, 4.0);
} else if (a <= 2.4) {
tmp = -1.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 <= (-0.42d0)) then
tmp = a ** 4.0d0
else if (a <= 2.4d0) then
tmp = -1.0d0
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -0.42) {
tmp = Math.pow(a, 4.0);
} else if (a <= 2.4) {
tmp = -1.0;
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -0.42: tmp = math.pow(a, 4.0) elif a <= 2.4: tmp = -1.0 else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -0.42) tmp = a ^ 4.0; elseif (a <= 2.4) tmp = -1.0; else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -0.42) tmp = a ^ 4.0; elseif (a <= 2.4) tmp = -1.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -0.42], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 2.4], -1.0, N[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.42:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 2.4:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -0.419999999999999984 or 2.39999999999999991 < a Initial program 41.6%
associate--l+41.6%
fma-def41.6%
fma-neg41.6%
associate-*l*41.6%
fma-def47.7%
+-commutative47.7%
metadata-eval47.7%
Simplified47.7%
Taylor expanded in b around 0 47.7%
associate--l+47.7%
unpow247.7%
Simplified47.7%
Taylor expanded in a around inf 86.0%
if -0.419999999999999984 < a < 2.39999999999999991Initial program 99.9%
associate--l+99.9%
Simplified100.0%
Taylor expanded in a around 0 83.0%
associate-+r+83.0%
associate-*r*83.0%
distribute-rgt-out99.3%
metadata-eval99.3%
distribute-lft-in99.3%
associate--l+99.3%
sub-neg99.3%
metadata-eval99.3%
unpow299.3%
distribute-lft-in99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in b around 0 50.8%
Final simplification66.6%
(FPCore (a b) :precision binary64 (if (<= (* b b) 0.001) -1.0 (* a (* (* b b) 4.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 0.001) {
tmp = -1.0;
} else {
tmp = a * ((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) <= 0.001d0) then
tmp = -1.0d0
else
tmp = a * ((b * b) * 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 0.001) {
tmp = -1.0;
} else {
tmp = a * ((b * b) * 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 0.001: tmp = -1.0 else: tmp = a * ((b * b) * 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 0.001) tmp = -1.0; else tmp = Float64(a * Float64(Float64(b * b) * 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 0.001) tmp = -1.0; else tmp = a * ((b * b) * 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 0.001], -1.0, N[(a * N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 0.001:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(\left(b \cdot b\right) \cdot 4\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 1e-3Initial program 83.0%
associate--l+83.0%
Simplified83.0%
Taylor expanded in a around 0 59.4%
associate-+r+59.4%
associate-*r*59.4%
distribute-rgt-out59.4%
metadata-eval59.4%
distribute-lft-in59.4%
associate--l+59.4%
sub-neg59.4%
metadata-eval59.4%
unpow259.4%
distribute-lft-in59.4%
metadata-eval59.4%
Simplified59.4%
Taylor expanded in b around 0 57.7%
if 1e-3 < (*.f64 b b) Initial program 65.1%
associate--l+65.1%
Simplified68.9%
Taylor expanded in a around 0 61.3%
associate-+r+61.3%
associate-*r*61.3%
distribute-rgt-out78.7%
metadata-eval78.7%
distribute-lft-in78.7%
associate--l+78.8%
sub-neg78.8%
metadata-eval78.8%
unpow278.8%
distribute-lft-in78.8%
metadata-eval78.8%
Simplified78.8%
Taylor expanded in a around inf 36.3%
*-commutative36.3%
associate-*l*36.3%
*-commutative36.3%
unpow236.3%
Simplified36.3%
Final simplification46.7%
(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 73.7%
associate--l+73.8%
Simplified75.8%
Taylor expanded in a around 0 60.4%
associate-+r+60.4%
associate-*r*60.4%
distribute-rgt-out69.4%
metadata-eval69.4%
distribute-lft-in69.4%
associate--l+69.4%
sub-neg69.4%
metadata-eval69.4%
unpow269.4%
distribute-lft-in69.4%
metadata-eval69.4%
Simplified69.4%
Taylor expanded in b around 0 28.3%
Final simplification28.3%
herbie shell --seed 2023214
(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))