
(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
(let* ((t_0 (pow (hypot b a) 4.0)) (t_1 (* 4.0 (pow a 3.0))))
(if (<= a -45000.0)
(+ t_0 (- -1.0 t_1))
(if (<= a 2.1e+14)
(+ t_0 (+ (* 4.0 (fma (* a a) (- 1.0 a) (* b (* b (+ a 3.0))))) -1.0))
(+ (+ t_0 t_1) -1.0)))))
double code(double a, double b) {
double t_0 = pow(hypot(b, a), 4.0);
double t_1 = 4.0 * pow(a, 3.0);
double tmp;
if (a <= -45000.0) {
tmp = t_0 + (-1.0 - t_1);
} else if (a <= 2.1e+14) {
tmp = t_0 + ((4.0 * fma((a * a), (1.0 - a), (b * (b * (a + 3.0))))) + -1.0);
} else {
tmp = (t_0 + t_1) + -1.0;
}
return tmp;
}
function code(a, b) t_0 = hypot(b, a) ^ 4.0 t_1 = Float64(4.0 * (a ^ 3.0)) tmp = 0.0 if (a <= -45000.0) tmp = Float64(t_0 + Float64(-1.0 - t_1)); elseif (a <= 2.1e+14) tmp = Float64(t_0 + Float64(Float64(4.0 * fma(Float64(a * a), Float64(1.0 - a), Float64(b * Float64(b * Float64(a + 3.0))))) + -1.0)); else tmp = Float64(Float64(t_0 + t_1) + -1.0); end return tmp end
code[a_, b_] := Block[{t$95$0 = N[Power[N[Sqrt[b ^ 2 + a ^ 2], $MachinePrecision], 4.0], $MachinePrecision]}, Block[{t$95$1 = N[(4.0 * N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -45000.0], N[(t$95$0 + N[(-1.0 - t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 2.1e+14], N[(t$95$0 + N[(N[(4.0 * N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision] + N[(b * N[(b * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 + t$95$1), $MachinePrecision] + -1.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{hypot}\left(b, a\right)\right)}^{4}\\
t_1 := 4 \cdot {a}^{3}\\
\mathbf{if}\;a \leq -45000:\\
\;\;\;\;t\_0 + \left(-1 - t\_1\right)\\
\mathbf{elif}\;a \leq 2.1 \cdot 10^{+14}:\\
\;\;\;\;t\_0 + \left(4 \cdot \mathsf{fma}\left(a \cdot a, 1 - a, b \cdot \left(b \cdot \left(a + 3\right)\right)\right) + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t\_0 + t\_1\right) + -1\\
\end{array}
\end{array}
if a < -45000Initial program 56.6%
associate--l+56.6%
fma-define56.6%
sqr-neg56.6%
fma-define56.6%
distribute-rgt-in56.6%
sqr-neg56.6%
distribute-rgt-in56.6%
fma-define56.6%
sqr-neg56.6%
Simplified56.6%
fma-define56.6%
unpow256.6%
distribute-lft-in43.3%
fma-define43.3%
add-sqr-sqrt43.3%
pow243.3%
fma-define43.3%
hypot-define43.3%
pow243.3%
fma-define43.3%
add-sqr-sqrt43.3%
pow243.3%
fma-define43.3%
hypot-define43.3%
pow243.3%
Applied egg-rr43.3%
distribute-lft-out56.6%
rem-square-sqrt56.6%
unpow256.6%
unpow256.6%
hypot-undefine56.6%
unpow256.6%
unpow256.6%
hypot-undefine56.6%
unpow256.6%
pow-sqr56.7%
hypot-undefine56.7%
unpow256.7%
unpow256.7%
+-commutative56.7%
unpow256.7%
unpow256.7%
hypot-define56.7%
metadata-eval56.7%
Simplified56.7%
Taylor expanded in a around inf 100.0%
mul-1-neg100.0%
Simplified100.0%
if -45000 < a < 2.1e14Initial program 99.9%
associate--l+99.9%
fma-define99.9%
sqr-neg99.9%
fma-define99.9%
distribute-rgt-in99.9%
sqr-neg99.9%
distribute-rgt-in99.9%
fma-define99.9%
sqr-neg99.9%
Simplified99.9%
fma-define99.9%
unpow299.9%
distribute-lft-in88.6%
fma-define88.6%
add-sqr-sqrt88.6%
pow288.6%
fma-define88.6%
hypot-define88.6%
pow288.6%
fma-define88.6%
add-sqr-sqrt88.6%
pow288.6%
fma-define88.6%
hypot-define88.6%
pow288.6%
Applied egg-rr88.6%
distribute-lft-out99.9%
rem-square-sqrt99.9%
unpow299.9%
unpow299.9%
hypot-undefine99.9%
unpow299.9%
unpow299.9%
hypot-undefine99.9%
unpow299.9%
pow-sqr100.0%
hypot-undefine100.0%
unpow2100.0%
unpow2100.0%
+-commutative100.0%
unpow2100.0%
unpow2100.0%
hypot-define100.0%
metadata-eval100.0%
Simplified100.0%
if 2.1e14 < a Initial program 26.9%
associate--l+26.9%
fma-define26.9%
sqr-neg26.9%
fma-define26.9%
distribute-rgt-in26.9%
sqr-neg26.9%
distribute-rgt-in26.9%
fma-define26.9%
sqr-neg26.9%
Simplified33.2%
fma-define33.2%
unpow233.2%
distribute-lft-in33.2%
fma-define33.2%
add-sqr-sqrt33.2%
pow233.2%
fma-define33.2%
hypot-define33.2%
pow233.2%
fma-define33.2%
add-sqr-sqrt33.2%
pow233.2%
fma-define33.2%
hypot-define33.2%
pow233.2%
Applied egg-rr33.2%
distribute-lft-out33.2%
rem-square-sqrt33.2%
unpow233.2%
unpow233.2%
hypot-undefine33.2%
unpow233.2%
unpow233.2%
hypot-undefine33.2%
unpow233.2%
pow-sqr33.3%
hypot-undefine33.3%
unpow233.3%
unpow233.3%
+-commutative33.3%
unpow233.3%
unpow233.3%
hypot-define33.3%
metadata-eval33.3%
Simplified33.3%
Taylor expanded in a around inf 27.0%
mul-1-neg27.0%
Simplified27.0%
associate-+r-27.0%
add-sqr-sqrt0.0%
sqrt-unprod98.6%
sqr-neg98.6%
sqrt-unprod100.0%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (a b)
:precision binary64
(let* ((t_0 (pow (hypot b a) 4.0)) (t_1 (* 4.0 (pow a 3.0))))
(if (<= a -90000.0)
(+ t_0 (- -1.0 t_1))
(if (<= a 2.1e+14)
(+
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))
-1.0)
(+ (+ t_0 t_1) -1.0)))))
double code(double a, double b) {
double t_0 = pow(hypot(b, a), 4.0);
double t_1 = 4.0 * pow(a, 3.0);
double tmp;
if (a <= -90000.0) {
tmp = t_0 + (-1.0 - t_1);
} else if (a <= 2.1e+14) {
tmp = (pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))))) + -1.0;
} else {
tmp = (t_0 + t_1) + -1.0;
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = Math.pow(Math.hypot(b, a), 4.0);
double t_1 = 4.0 * Math.pow(a, 3.0);
double tmp;
if (a <= -90000.0) {
tmp = t_0 + (-1.0 - t_1);
} else if (a <= 2.1e+14) {
tmp = (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))))) + -1.0;
} else {
tmp = (t_0 + t_1) + -1.0;
}
return tmp;
}
def code(a, b): t_0 = math.pow(math.hypot(b, a), 4.0) t_1 = 4.0 * math.pow(a, 3.0) tmp = 0 if a <= -90000.0: tmp = t_0 + (-1.0 - t_1) elif a <= 2.1e+14: tmp = (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))))) + -1.0 else: tmp = (t_0 + t_1) + -1.0 return tmp
function code(a, b) t_0 = hypot(b, a) ^ 4.0 t_1 = Float64(4.0 * (a ^ 3.0)) tmp = 0.0 if (a <= -90000.0) tmp = Float64(t_0 + Float64(-1.0 - t_1)); elseif (a <= 2.1e+14) tmp = 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(a + 3.0))))) + -1.0); else tmp = Float64(Float64(t_0 + t_1) + -1.0); end return tmp end
function tmp_2 = code(a, b) t_0 = hypot(b, a) ^ 4.0; t_1 = 4.0 * (a ^ 3.0); tmp = 0.0; if (a <= -90000.0) tmp = t_0 + (-1.0 - t_1); elseif (a <= 2.1e+14) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))))) + -1.0; else tmp = (t_0 + t_1) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[Power[N[Sqrt[b ^ 2 + a ^ 2], $MachinePrecision], 4.0], $MachinePrecision]}, Block[{t$95$1 = N[(4.0 * N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -90000.0], N[(t$95$0 + N[(-1.0 - t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 2.1e+14], 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[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(t$95$0 + t$95$1), $MachinePrecision] + -1.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{hypot}\left(b, a\right)\right)}^{4}\\
t_1 := 4 \cdot {a}^{3}\\
\mathbf{if}\;a \leq -90000:\\
\;\;\;\;t\_0 + \left(-1 - t\_1\right)\\
\mathbf{elif}\;a \leq 2.1 \cdot 10^{+14}:\\
\;\;\;\;\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(a + 3\right)\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left(t\_0 + t\_1\right) + -1\\
\end{array}
\end{array}
if a < -9e4Initial program 56.6%
associate--l+56.6%
fma-define56.6%
sqr-neg56.6%
fma-define56.6%
distribute-rgt-in56.6%
sqr-neg56.6%
distribute-rgt-in56.6%
fma-define56.6%
sqr-neg56.6%
Simplified56.6%
fma-define56.6%
unpow256.6%
distribute-lft-in43.3%
fma-define43.3%
add-sqr-sqrt43.3%
pow243.3%
fma-define43.3%
hypot-define43.3%
pow243.3%
fma-define43.3%
add-sqr-sqrt43.3%
pow243.3%
fma-define43.3%
hypot-define43.3%
pow243.3%
Applied egg-rr43.3%
distribute-lft-out56.6%
rem-square-sqrt56.6%
unpow256.6%
unpow256.6%
hypot-undefine56.6%
unpow256.6%
unpow256.6%
hypot-undefine56.6%
unpow256.6%
pow-sqr56.7%
hypot-undefine56.7%
unpow256.7%
unpow256.7%
+-commutative56.7%
unpow256.7%
unpow256.7%
hypot-define56.7%
metadata-eval56.7%
Simplified56.7%
Taylor expanded in a around inf 100.0%
mul-1-neg100.0%
Simplified100.0%
if -9e4 < a < 2.1e14Initial program 99.9%
if 2.1e14 < a Initial program 26.9%
associate--l+26.9%
fma-define26.9%
sqr-neg26.9%
fma-define26.9%
distribute-rgt-in26.9%
sqr-neg26.9%
distribute-rgt-in26.9%
fma-define26.9%
sqr-neg26.9%
Simplified33.2%
fma-define33.2%
unpow233.2%
distribute-lft-in33.2%
fma-define33.2%
add-sqr-sqrt33.2%
pow233.2%
fma-define33.2%
hypot-define33.2%
pow233.2%
fma-define33.2%
add-sqr-sqrt33.2%
pow233.2%
fma-define33.2%
hypot-define33.2%
pow233.2%
Applied egg-rr33.2%
distribute-lft-out33.2%
rem-square-sqrt33.2%
unpow233.2%
unpow233.2%
hypot-undefine33.2%
unpow233.2%
unpow233.2%
hypot-undefine33.2%
unpow233.2%
pow-sqr33.3%
hypot-undefine33.3%
unpow233.3%
unpow233.3%
+-commutative33.3%
unpow233.3%
unpow233.3%
hypot-define33.3%
metadata-eval33.3%
Simplified33.3%
Taylor expanded in a around inf 27.0%
mul-1-neg27.0%
Simplified27.0%
associate-+r-27.0%
add-sqr-sqrt0.0%
sqrt-unprod98.6%
sqr-neg98.6%
sqrt-unprod100.0%
add-sqr-sqrt100.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)))))))
(if (<= t_0 INFINITY) (+ t_0 -1.0) (* (pow a 3.0) (- a 4.0)))))
double code(double a, double b) {
double t_0 = pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0 + -1.0;
} else {
tmp = pow(a, 3.0) * (a - 4.0);
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 + -1.0;
} else {
tmp = Math.pow(a, 3.0) * (a - 4.0);
}
return tmp;
}
def code(a, b): t_0 = math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0)))) tmp = 0 if t_0 <= math.inf: tmp = t_0 + -1.0 else: tmp = math.pow(a, 3.0) * (a - 4.0) return tmp
function code(a, b) t_0 = Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + Float64(Float64(b * b) * Float64(a + 3.0))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(t_0 + -1.0); else tmp = Float64((a ^ 3.0) * Float64(a - 4.0)); end return tmp end
function tmp_2 = code(a, b) t_0 = (((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0)))); tmp = 0.0; if (t_0 <= Inf) tmp = t_0 + -1.0; else tmp = (a ^ 3.0) * (a - 4.0); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(t$95$0 + -1.0), $MachinePrecision], N[(N[Power[a, 3.0], $MachinePrecision] * N[(a - 4.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\\
\mathbf{if}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0 + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{3} \cdot \left(a - 4\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 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 3 binary64) a))))) Initial program 0.0%
associate--l+0.0%
fma-define0.0%
sqr-neg0.0%
fma-define0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
fma-define0.0%
sqr-neg0.0%
Simplified5.6%
Taylor expanded in a around inf 92.2%
associate-*r/92.2%
metadata-eval92.2%
Simplified92.2%
Taylor expanded in a around 0 92.2%
Final simplification97.7%
(FPCore (a b)
:precision binary64
(if (<= a -1.05e+69)
(pow a 4.0)
(if (<= a 1200000000.0)
(+ (pow b 4.0) -1.0)
(* (pow a 4.0) (- 1.0 (/ 4.0 a))))))
double code(double a, double b) {
double tmp;
if (a <= -1.05e+69) {
tmp = pow(a, 4.0);
} else if (a <= 1200000000.0) {
tmp = pow(b, 4.0) + -1.0;
} else {
tmp = pow(a, 4.0) * (1.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.05d+69)) then
tmp = a ** 4.0d0
else if (a <= 1200000000.0d0) then
tmp = (b ** 4.0d0) + (-1.0d0)
else
tmp = (a ** 4.0d0) * (1.0d0 - (4.0d0 / a))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -1.05e+69) {
tmp = Math.pow(a, 4.0);
} else if (a <= 1200000000.0) {
tmp = Math.pow(b, 4.0) + -1.0;
} else {
tmp = Math.pow(a, 4.0) * (1.0 - (4.0 / a));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -1.05e+69: tmp = math.pow(a, 4.0) elif a <= 1200000000.0: tmp = math.pow(b, 4.0) + -1.0 else: tmp = math.pow(a, 4.0) * (1.0 - (4.0 / a)) return tmp
function code(a, b) tmp = 0.0 if (a <= -1.05e+69) tmp = a ^ 4.0; elseif (a <= 1200000000.0) tmp = Float64((b ^ 4.0) + -1.0); else tmp = Float64((a ^ 4.0) * Float64(1.0 - Float64(4.0 / a))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -1.05e+69) tmp = a ^ 4.0; elseif (a <= 1200000000.0) tmp = (b ^ 4.0) + -1.0; else tmp = (a ^ 4.0) * (1.0 - (4.0 / a)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -1.05e+69], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 1200000000.0], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 - N[(4.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.05 \cdot 10^{+69}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 1200000000:\\
\;\;\;\;{b}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} \cdot \left(1 - \frac{4}{a}\right)\\
\end{array}
\end{array}
if a < -1.05000000000000008e69Initial program 54.5%
associate--l+54.5%
fma-define54.5%
sqr-neg54.5%
fma-define54.5%
distribute-rgt-in54.5%
sqr-neg54.5%
distribute-rgt-in54.5%
fma-define54.5%
sqr-neg54.5%
Simplified54.5%
Taylor expanded in a around inf 100.0%
if -1.05000000000000008e69 < a < 1.2e9Initial program 95.7%
associate--l+95.7%
fma-define95.7%
sqr-neg95.7%
fma-define95.7%
distribute-rgt-in95.7%
sqr-neg95.7%
distribute-rgt-in95.7%
fma-define95.7%
sqr-neg95.7%
Simplified95.7%
fma-define95.7%
unpow295.7%
distribute-lft-in85.4%
fma-define85.4%
add-sqr-sqrt85.4%
pow285.4%
fma-define85.4%
hypot-define85.4%
pow285.4%
fma-define85.4%
add-sqr-sqrt85.4%
pow285.4%
fma-define85.4%
hypot-define85.4%
pow285.4%
Applied egg-rr85.4%
distribute-lft-out95.8%
rem-square-sqrt95.7%
unpow295.7%
unpow295.7%
hypot-undefine95.7%
unpow295.7%
unpow295.7%
hypot-undefine95.7%
unpow295.7%
pow-sqr95.9%
hypot-undefine95.9%
unpow295.9%
unpow295.9%
+-commutative95.9%
unpow295.9%
unpow295.9%
hypot-define95.9%
metadata-eval95.9%
Simplified95.9%
Taylor expanded in a around inf 96.3%
mul-1-neg96.3%
Simplified96.3%
Taylor expanded in a around 0 90.9%
if 1.2e9 < a Initial program 31.2%
associate--l+31.2%
fma-define31.2%
sqr-neg31.2%
fma-define31.2%
distribute-rgt-in31.2%
sqr-neg31.2%
distribute-rgt-in31.2%
fma-define31.2%
sqr-neg31.2%
Simplified37.1%
Taylor expanded in a around inf 91.6%
associate-*r/91.6%
metadata-eval91.6%
Simplified91.6%
Final simplification92.6%
(FPCore (a b) :precision binary64 (if (<= a -9e+69) (pow a 4.0) (if (<= a 440000000.0) (+ (pow b 4.0) -1.0) (* (pow a 3.0) (- a 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= -9e+69) {
tmp = pow(a, 4.0);
} else if (a <= 440000000.0) {
tmp = pow(b, 4.0) + -1.0;
} else {
tmp = pow(a, 3.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 <= (-9d+69)) then
tmp = a ** 4.0d0
else if (a <= 440000000.0d0) then
tmp = (b ** 4.0d0) + (-1.0d0)
else
tmp = (a ** 3.0d0) * (a - 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -9e+69) {
tmp = Math.pow(a, 4.0);
} else if (a <= 440000000.0) {
tmp = Math.pow(b, 4.0) + -1.0;
} else {
tmp = Math.pow(a, 3.0) * (a - 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -9e+69: tmp = math.pow(a, 4.0) elif a <= 440000000.0: tmp = math.pow(b, 4.0) + -1.0 else: tmp = math.pow(a, 3.0) * (a - 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -9e+69) tmp = a ^ 4.0; elseif (a <= 440000000.0) tmp = Float64((b ^ 4.0) + -1.0); else tmp = Float64((a ^ 3.0) * Float64(a - 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -9e+69) tmp = a ^ 4.0; elseif (a <= 440000000.0) tmp = (b ^ 4.0) + -1.0; else tmp = (a ^ 3.0) * (a - 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -9e+69], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 440000000.0], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[a, 3.0], $MachinePrecision] * N[(a - 4.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -9 \cdot 10^{+69}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 440000000:\\
\;\;\;\;{b}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{3} \cdot \left(a - 4\right)\\
\end{array}
\end{array}
if a < -8.9999999999999999e69Initial program 54.5%
associate--l+54.5%
fma-define54.5%
sqr-neg54.5%
fma-define54.5%
distribute-rgt-in54.5%
sqr-neg54.5%
distribute-rgt-in54.5%
fma-define54.5%
sqr-neg54.5%
Simplified54.5%
Taylor expanded in a around inf 100.0%
if -8.9999999999999999e69 < a < 4.4e8Initial program 95.7%
associate--l+95.7%
fma-define95.7%
sqr-neg95.7%
fma-define95.7%
distribute-rgt-in95.7%
sqr-neg95.7%
distribute-rgt-in95.7%
fma-define95.7%
sqr-neg95.7%
Simplified95.7%
fma-define95.7%
unpow295.7%
distribute-lft-in85.4%
fma-define85.4%
add-sqr-sqrt85.4%
pow285.4%
fma-define85.4%
hypot-define85.4%
pow285.4%
fma-define85.4%
add-sqr-sqrt85.4%
pow285.4%
fma-define85.4%
hypot-define85.4%
pow285.4%
Applied egg-rr85.4%
distribute-lft-out95.8%
rem-square-sqrt95.7%
unpow295.7%
unpow295.7%
hypot-undefine95.7%
unpow295.7%
unpow295.7%
hypot-undefine95.7%
unpow295.7%
pow-sqr95.9%
hypot-undefine95.9%
unpow295.9%
unpow295.9%
+-commutative95.9%
unpow295.9%
unpow295.9%
hypot-define95.9%
metadata-eval95.9%
Simplified95.9%
Taylor expanded in a around inf 96.3%
mul-1-neg96.3%
Simplified96.3%
Taylor expanded in a around 0 90.9%
if 4.4e8 < a Initial program 31.2%
associate--l+31.2%
fma-define31.2%
sqr-neg31.2%
fma-define31.2%
distribute-rgt-in31.2%
sqr-neg31.2%
distribute-rgt-in31.2%
fma-define31.2%
sqr-neg31.2%
Simplified37.1%
Taylor expanded in a around inf 91.6%
associate-*r/91.6%
metadata-eval91.6%
Simplified91.6%
Taylor expanded in a around 0 91.5%
Final simplification92.6%
(FPCore (a b) :precision binary64 (if (or (<= a -2.25e+71) (not (<= a 6e+20))) (pow a 4.0) (+ (pow b 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -2.25e+71) || !(a <= 6e+20)) {
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.25d+71)) .or. (.not. (a <= 6d+20))) 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.25e+71) || !(a <= 6e+20)) {
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.25e+71) or not (a <= 6e+20): 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.25e+71) || !(a <= 6e+20)) 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.25e+71) || ~((a <= 6e+20))) tmp = a ^ 4.0; else tmp = (b ^ 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -2.25e+71], N[Not[LessEqual[a, 6e+20]], $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.25 \cdot 10^{+71} \lor \neg \left(a \leq 6 \cdot 10^{+20}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4} + -1\\
\end{array}
\end{array}
if a < -2.25000000000000022e71 or 6e20 < a Initial program 37.1%
associate--l+37.1%
fma-define37.1%
sqr-neg37.1%
fma-define37.1%
distribute-rgt-in37.1%
sqr-neg37.1%
distribute-rgt-in37.1%
fma-define37.1%
sqr-neg37.1%
Simplified40.9%
Taylor expanded in a around inf 97.3%
if -2.25000000000000022e71 < a < 6e20Initial program 95.9%
associate--l+95.9%
fma-define95.9%
sqr-neg95.9%
fma-define95.9%
distribute-rgt-in95.9%
sqr-neg95.9%
distribute-rgt-in95.9%
fma-define95.9%
sqr-neg95.9%
Simplified95.9%
fma-define95.9%
unpow295.9%
distribute-lft-in85.9%
fma-define85.9%
add-sqr-sqrt85.9%
pow285.9%
fma-define85.9%
hypot-define85.9%
pow285.9%
fma-define85.9%
add-sqr-sqrt85.9%
pow285.9%
fma-define85.9%
hypot-define85.9%
pow285.9%
Applied egg-rr85.9%
distribute-lft-out95.9%
rem-square-sqrt95.9%
unpow295.9%
unpow295.9%
hypot-undefine95.9%
unpow295.9%
unpow295.9%
hypot-undefine95.9%
unpow295.9%
pow-sqr96.0%
hypot-undefine96.0%
unpow296.0%
unpow296.0%
+-commutative96.0%
unpow296.0%
unpow296.0%
hypot-define96.0%
metadata-eval96.0%
Simplified96.0%
Taylor expanded in a around inf 96.5%
mul-1-neg96.5%
Simplified96.5%
Taylor expanded in a around 0 89.3%
Final simplification92.6%
(FPCore (a b) :precision binary64 (if (or (<= a -1.15e+69) (not (<= a 5e+20))) (pow a 4.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((a <= -1.15e+69) || !(a <= 5e+20)) {
tmp = 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 ((a <= (-1.15d+69)) .or. (.not. (a <= 5d+20))) then
tmp = 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 ((a <= -1.15e+69) || !(a <= 5e+20)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -1.15e+69) or not (a <= 5e+20): tmp = math.pow(a, 4.0) else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if ((a <= -1.15e+69) || !(a <= 5e+20)) tmp = a ^ 4.0; else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -1.15e+69) || ~((a <= 5e+20))) tmp = a ^ 4.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -1.15e+69], N[Not[LessEqual[a, 5e+20]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.15 \cdot 10^{+69} \lor \neg \left(a \leq 5 \cdot 10^{+20}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if a < -1.15000000000000008e69 or 5e20 < a Initial program 37.1%
associate--l+37.1%
fma-define37.1%
sqr-neg37.1%
fma-define37.1%
distribute-rgt-in37.1%
sqr-neg37.1%
distribute-rgt-in37.1%
fma-define37.1%
sqr-neg37.1%
Simplified40.9%
Taylor expanded in a around inf 97.3%
if -1.15000000000000008e69 < a < 5e20Initial program 95.9%
associate--l+95.9%
fma-define95.9%
sqr-neg95.9%
fma-define95.9%
distribute-rgt-in95.9%
sqr-neg95.9%
distribute-rgt-in95.9%
fma-define95.9%
sqr-neg95.9%
Simplified95.9%
Taylor expanded in b around inf 49.3%
Final simplification69.0%
(FPCore (a b) :precision binary64 (pow a 4.0))
double code(double a, double b) {
return pow(a, 4.0);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = a ** 4.0d0
end function
public static double code(double a, double b) {
return Math.pow(a, 4.0);
}
def code(a, b): return math.pow(a, 4.0)
function code(a, b) return a ^ 4.0 end
function tmp = code(a, b) tmp = a ^ 4.0; end
code[a_, b_] := N[Power[a, 4.0], $MachinePrecision]
\begin{array}{l}
\\
{a}^{4}
\end{array}
Initial program 71.8%
associate--l+71.8%
fma-define71.8%
sqr-neg71.8%
fma-define71.8%
distribute-rgt-in71.8%
sqr-neg71.8%
distribute-rgt-in71.8%
fma-define71.8%
sqr-neg71.8%
Simplified73.3%
Taylor expanded in a around inf 45.1%
Final simplification45.1%
herbie shell --seed 2024071
(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))