
(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 7 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 (<=
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))
INFINITY)
(+
(* (hypot a b) (* (hypot a b) (pow (hypot a b) 2.0)))
(+ (* 4.0 (fma (* a a) (- 1.0 a) (* b (* b (+ a 3.0))))) -1.0))
(pow a 4.0)))
double code(double a, double b) {
double tmp;
if ((pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))))) <= ((double) INFINITY)) {
tmp = (hypot(a, b) * (hypot(a, b) * pow(hypot(a, b), 2.0))) + ((4.0 * fma((a * a), (1.0 - a), (b * (b * (a + 3.0))))) + -1.0);
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + Float64(Float64(b * b) * Float64(a + 3.0))))) <= Inf) tmp = Float64(Float64(hypot(a, b) * Float64(hypot(a, b) * (hypot(a, b) ^ 2.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 = a ^ 4.0; end return tmp end
code[a_, b_] := If[LessEqual[N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision] * N[(N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision] * N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 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[Power[a, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(a + 3\right)\right) \leq \infty:\\
\;\;\;\;\mathsf{hypot}\left(a, b\right) \cdot \left(\mathsf{hypot}\left(a, b\right) \cdot {\left(\mathsf{hypot}\left(a, b\right)\right)}^{2}\right) + \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}:\\
\;\;\;\;{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.8%
associate--l+99.8%
fma-define99.8%
sqr-neg99.8%
fma-define99.8%
distribute-rgt-in99.3%
sqr-neg99.3%
distribute-rgt-in99.8%
fma-define99.8%
sqr-neg99.8%
Simplified99.8%
fma-define99.8%
unpow299.8%
fma-define99.8%
add-sqr-sqrt99.8%
associate-*l*99.9%
fma-define99.9%
hypot-define99.9%
fma-define99.9%
hypot-define99.9%
fma-define99.9%
add-sqr-sqrt99.9%
pow299.9%
fma-define99.9%
hypot-define99.9%
Applied egg-rr99.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%
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%
Simplified4.8%
Taylor expanded in a around inf 94.1%
Final simplification98.4%
(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 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, 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, 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, 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 = 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 ^ 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[Power[a, 4.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(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}^{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.8%
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-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%
Simplified4.8%
Taylor expanded in a around inf 94.1%
Final simplification98.4%
(FPCore (a b) :precision binary64 (if (or (<= a -69000000000000.0) (not (<= a 7.6e+18))) (pow a 4.0) (+ (pow b 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -69000000000000.0) || !(a <= 7.6e+18)) {
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 <= (-69000000000000.0d0)) .or. (.not. (a <= 7.6d+18))) 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 <= -69000000000000.0) || !(a <= 7.6e+18)) {
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 <= -69000000000000.0) or not (a <= 7.6e+18): 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 <= -69000000000000.0) || !(a <= 7.6e+18)) 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 <= -69000000000000.0) || ~((a <= 7.6e+18))) tmp = a ^ 4.0; else tmp = (b ^ 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -69000000000000.0], N[Not[LessEqual[a, 7.6e+18]], $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 -69000000000000 \lor \neg \left(a \leq 7.6 \cdot 10^{+18}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4} + -1\\
\end{array}
\end{array}
if a < -6.9e13 or 7.6e18 < a Initial program 48.6%
associate--l+48.6%
fma-define48.6%
sqr-neg48.6%
fma-define48.6%
distribute-rgt-in47.8%
sqr-neg47.8%
distribute-rgt-in48.6%
fma-define48.6%
sqr-neg48.6%
Simplified51.1%
Taylor expanded in a around inf 92.0%
if -6.9e13 < a < 7.6e18Initial program 99.2%
associate--l+99.2%
fma-define99.2%
sqr-neg99.2%
fma-define99.2%
distribute-rgt-in99.2%
sqr-neg99.2%
distribute-rgt-in99.2%
fma-define99.2%
sqr-neg99.2%
Simplified99.2%
Taylor expanded in a around 0 99.2%
+-commutative99.2%
flip-+32.5%
pow-prod-up32.4%
metadata-eval32.4%
*-commutative32.4%
*-commutative32.4%
swap-sqr32.4%
pow-prod-up32.4%
metadata-eval32.4%
metadata-eval32.4%
Applied egg-rr32.4%
Taylor expanded in b around inf 97.9%
Final simplification95.1%
(FPCore (a b) :precision binary64 (if (<= a -68000000000000.0) (* (pow a 3.0) (- a 4.0)) (if (<= a 2.9e+19) (+ (pow b 4.0) -1.0) (pow a 4.0))))
double code(double a, double b) {
double tmp;
if (a <= -68000000000000.0) {
tmp = pow(a, 3.0) * (a - 4.0);
} else if (a <= 2.9e+19) {
tmp = pow(b, 4.0) + -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 <= (-68000000000000.0d0)) then
tmp = (a ** 3.0d0) * (a - 4.0d0)
else if (a <= 2.9d+19) then
tmp = (b ** 4.0d0) + (-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 <= -68000000000000.0) {
tmp = Math.pow(a, 3.0) * (a - 4.0);
} else if (a <= 2.9e+19) {
tmp = Math.pow(b, 4.0) + -1.0;
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -68000000000000.0: tmp = math.pow(a, 3.0) * (a - 4.0) elif a <= 2.9e+19: tmp = math.pow(b, 4.0) + -1.0 else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -68000000000000.0) tmp = Float64((a ^ 3.0) * Float64(a - 4.0)); elseif (a <= 2.9e+19) tmp = Float64((b ^ 4.0) + -1.0); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -68000000000000.0) tmp = (a ^ 3.0) * (a - 4.0); elseif (a <= 2.9e+19) tmp = (b ^ 4.0) + -1.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -68000000000000.0], N[(N[Power[a, 3.0], $MachinePrecision] * N[(a - 4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 2.9e+19], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -68000000000000:\\
\;\;\;\;{a}^{3} \cdot \left(a - 4\right)\\
\mathbf{elif}\;a \leq 2.9 \cdot 10^{+19}:\\
\;\;\;\;{b}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -6.8e13Initial program 62.7%
associate--l+62.7%
fma-define62.7%
sqr-neg62.7%
fma-define62.7%
distribute-rgt-in62.7%
sqr-neg62.7%
distribute-rgt-in62.7%
fma-define62.7%
sqr-neg62.7%
Simplified62.7%
Taylor expanded in a around inf 90.6%
associate-*r/90.6%
metadata-eval90.6%
Simplified90.6%
Taylor expanded in a around 0 90.4%
if -6.8e13 < a < 2.9e19Initial program 99.2%
associate--l+99.2%
fma-define99.2%
sqr-neg99.2%
fma-define99.2%
distribute-rgt-in99.2%
sqr-neg99.2%
distribute-rgt-in99.2%
fma-define99.2%
sqr-neg99.2%
Simplified99.2%
Taylor expanded in a around 0 99.2%
+-commutative99.2%
flip-+32.5%
pow-prod-up32.4%
metadata-eval32.4%
*-commutative32.4%
*-commutative32.4%
swap-sqr32.4%
pow-prod-up32.4%
metadata-eval32.4%
metadata-eval32.4%
Applied egg-rr32.4%
Taylor expanded in b around inf 97.9%
if 2.9e19 < a Initial program 29.4%
associate--l+29.4%
fma-define29.4%
sqr-neg29.4%
fma-define29.4%
distribute-rgt-in27.4%
sqr-neg27.4%
distribute-rgt-in29.4%
fma-define29.4%
sqr-neg29.4%
Simplified35.2%
Taylor expanded in a around inf 94.5%
Final simplification95.2%
(FPCore (a b) :precision binary64 (if (<= a -86000000000000.0) (* (pow a 4.0) (- 1.0 (/ 4.0 a))) (if (<= a 2.6e+22) (+ (pow b 4.0) -1.0) (pow a 4.0))))
double code(double a, double b) {
double tmp;
if (a <= -86000000000000.0) {
tmp = pow(a, 4.0) * (1.0 - (4.0 / a));
} else if (a <= 2.6e+22) {
tmp = pow(b, 4.0) + -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 <= (-86000000000000.0d0)) then
tmp = (a ** 4.0d0) * (1.0d0 - (4.0d0 / a))
else if (a <= 2.6d+22) then
tmp = (b ** 4.0d0) + (-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 <= -86000000000000.0) {
tmp = Math.pow(a, 4.0) * (1.0 - (4.0 / a));
} else if (a <= 2.6e+22) {
tmp = Math.pow(b, 4.0) + -1.0;
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -86000000000000.0: tmp = math.pow(a, 4.0) * (1.0 - (4.0 / a)) elif a <= 2.6e+22: tmp = math.pow(b, 4.0) + -1.0 else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -86000000000000.0) tmp = Float64((a ^ 4.0) * Float64(1.0 - Float64(4.0 / a))); elseif (a <= 2.6e+22) tmp = Float64((b ^ 4.0) + -1.0); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -86000000000000.0) tmp = (a ^ 4.0) * (1.0 - (4.0 / a)); elseif (a <= 2.6e+22) tmp = (b ^ 4.0) + -1.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -86000000000000.0], N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 - N[(4.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 2.6e+22], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -86000000000000:\\
\;\;\;\;{a}^{4} \cdot \left(1 - \frac{4}{a}\right)\\
\mathbf{elif}\;a \leq 2.6 \cdot 10^{+22}:\\
\;\;\;\;{b}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -8.6e13Initial program 62.7%
associate--l+62.7%
fma-define62.7%
sqr-neg62.7%
fma-define62.7%
distribute-rgt-in62.7%
sqr-neg62.7%
distribute-rgt-in62.7%
fma-define62.7%
sqr-neg62.7%
Simplified62.7%
Taylor expanded in a around inf 90.6%
associate-*r/90.6%
metadata-eval90.6%
Simplified90.6%
if -8.6e13 < a < 2.6e22Initial program 99.2%
associate--l+99.2%
fma-define99.2%
sqr-neg99.2%
fma-define99.2%
distribute-rgt-in99.2%
sqr-neg99.2%
distribute-rgt-in99.2%
fma-define99.2%
sqr-neg99.2%
Simplified99.2%
Taylor expanded in a around 0 99.2%
+-commutative99.2%
flip-+32.5%
pow-prod-up32.4%
metadata-eval32.4%
*-commutative32.4%
*-commutative32.4%
swap-sqr32.4%
pow-prod-up32.4%
metadata-eval32.4%
metadata-eval32.4%
Applied egg-rr32.4%
Taylor expanded in b around inf 97.9%
if 2.6e22 < a Initial program 29.4%
associate--l+29.4%
fma-define29.4%
sqr-neg29.4%
fma-define29.4%
distribute-rgt-in27.4%
sqr-neg27.4%
distribute-rgt-in29.4%
fma-define29.4%
sqr-neg29.4%
Simplified35.2%
Taylor expanded in a around inf 94.5%
Final simplification95.2%
(FPCore (a b) :precision binary64 (if (<= b 31000000000000.0) (pow a 4.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if (b <= 31000000000000.0) {
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 (b <= 31000000000000.0d0) 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 (b <= 31000000000000.0) {
tmp = Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 31000000000000.0: tmp = math.pow(a, 4.0) else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 31000000000000.0) tmp = a ^ 4.0; else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 31000000000000.0) tmp = a ^ 4.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 31000000000000.0], N[Power[a, 4.0], $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 31000000000000:\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 3.1e13Initial program 78.3%
associate--l+78.3%
fma-define78.3%
sqr-neg78.3%
fma-define78.3%
distribute-rgt-in78.3%
sqr-neg78.3%
distribute-rgt-in78.3%
fma-define78.3%
sqr-neg78.3%
Simplified79.3%
Taylor expanded in a around inf 47.6%
if 3.1e13 < b Initial program 65.5%
associate--l+65.5%
fma-define65.5%
sqr-neg65.5%
fma-define65.5%
distribute-rgt-in63.9%
sqr-neg63.9%
distribute-rgt-in65.5%
fma-define65.5%
sqr-neg65.5%
Simplified67.2%
Taylor expanded in b around inf 95.4%
Final simplification59.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 75.3%
associate--l+75.3%
fma-define75.3%
sqr-neg75.3%
fma-define75.3%
distribute-rgt-in74.9%
sqr-neg74.9%
distribute-rgt-in75.3%
fma-define75.3%
sqr-neg75.3%
Simplified76.4%
Taylor expanded in a around inf 44.8%
Final simplification44.8%
herbie shell --seed 2024056
(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))