
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 3.0 a)))))) 1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * (((a * a) * (1.0d0 + a)) + ((b * b) * (1.0d0 - (3.0d0 * a)))))) - 1.0d0
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 + a)) + Float64(Float64(b * b) * Float64(1.0 - Float64(3.0 * a)))))) - 1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0; end
code[a_, b_] := N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 + a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 3.0 a)))))) 1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * (((a * a) * (1.0d0 + a)) + ((b * b) * (1.0d0 - (3.0d0 * a)))))) - 1.0d0
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 + a)) + Float64(Float64(b * b) * Float64(1.0 - Float64(3.0 * a)))))) - 1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0; end
code[a_, b_] := N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 + a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1
\end{array}
(FPCore (a b)
:precision binary64
(if (<=
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (+ a 1.0)) (* (* b b) (- 1.0 (* a 3.0))))))
INFINITY)
(+
(fma
4.0
(fma a (fma a a a) (* b (* b (fma a -3.0 1.0))))
(pow (hypot a b) 4.0))
-1.0)
(+ (pow a 4.0) (+ -1.0 (* (* a a) 4.0)))))
double code(double a, double b) {
double tmp;
if ((pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))))) <= ((double) INFINITY)) {
tmp = fma(4.0, fma(a, fma(a, a, a), (b * (b * fma(a, -3.0, 1.0)))), pow(hypot(a, b), 4.0)) + -1.0;
} else {
tmp = pow(a, 4.0) + (-1.0 + ((a * 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(a + 1.0)) + Float64(Float64(b * b) * Float64(1.0 - Float64(a * 3.0)))))) <= Inf) tmp = Float64(fma(4.0, fma(a, fma(a, a, a), Float64(b * Float64(b * fma(a, -3.0, 1.0)))), (hypot(a, b) ^ 4.0)) + -1.0); else tmp = Float64((a ^ 4.0) + Float64(-1.0 + Float64(Float64(a * 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[(a + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(4.0 * N[(a * N[(a * a + a), $MachinePrecision] + N[(b * N[(b * N[(a * -3.0 + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] + N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $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(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right) \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(4, \mathsf{fma}\left(a, \mathsf{fma}\left(a, a, a\right), b \cdot \left(b \cdot \mathsf{fma}\left(a, -3, 1\right)\right)\right), {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} + \left(-1 + \left(a \cdot a\right) \cdot 4\right)\\
\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 1 (*.f64 3 a)))))) < +inf.0Initial program 99.8%
sub-neg99.8%
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 1 (*.f64 3 a)))))) Initial program 0.0%
associate--l+0.0%
fma-def0.0%
Simplified3.6%
Taylor expanded in b around 0 24.3%
associate--l+24.3%
associate-*r*24.3%
unpow224.3%
Simplified24.3%
Taylor expanded in a around 0 91.6%
unpow291.6%
Simplified91.6%
Final simplification98.2%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (+ a 1.0)) (* (* b b) (- 1.0 (* a 3.0))))))))
(if (<= t_0 INFINITY)
(+ t_0 -1.0)
(+ (pow a 4.0) (+ -1.0 (* (* a a) 4.0))))))
double code(double a, double b) {
double t_0 = pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0 + -1.0;
} else {
tmp = pow(a, 4.0) + (-1.0 + ((a * 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) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 + -1.0;
} else {
tmp = Math.pow(a, 4.0) + (-1.0 + ((a * a) * 4.0));
}
return tmp;
}
def code(a, b): t_0 = math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0))))) tmp = 0 if t_0 <= math.inf: tmp = t_0 + -1.0 else: tmp = math.pow(a, 4.0) + (-1.0 + ((a * 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(a + 1.0)) + Float64(Float64(b * b) * Float64(1.0 - Float64(a * 3.0)))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(t_0 + -1.0); else tmp = Float64((a ^ 4.0) + Float64(-1.0 + Float64(Float64(a * 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) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0))))); tmp = 0.0; if (t_0 <= Inf) tmp = t_0 + -1.0; else tmp = (a ^ 4.0) + (-1.0 + ((a * 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[(a + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(t$95$0 + -1.0), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] + N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $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(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right)\\
\mathbf{if}\;t_0 \leq \infty:\\
\;\;\;\;t_0 + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} + \left(-1 + \left(a \cdot a\right) \cdot 4\right)\\
\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 1 (*.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 1 (*.f64 3 a)))))) Initial program 0.0%
associate--l+0.0%
fma-def0.0%
Simplified3.6%
Taylor expanded in b around 0 24.3%
associate--l+24.3%
associate-*r*24.3%
unpow224.3%
Simplified24.3%
Taylor expanded in a around 0 91.6%
unpow291.6%
Simplified91.6%
Final simplification98.0%
(FPCore (a b)
:precision binary64
(if (<= a -680000000000.0)
(pow a 4.0)
(if (<= a 2100000000000.0)
(+ -1.0 (+ (pow b 4.0) (* (* b b) 4.0)))
(pow a 4.0))))
double code(double a, double b) {
double tmp;
if (a <= -680000000000.0) {
tmp = pow(a, 4.0);
} else if (a <= 2100000000000.0) {
tmp = -1.0 + (pow(b, 4.0) + ((b * b) * 4.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 <= (-680000000000.0d0)) then
tmp = a ** 4.0d0
else if (a <= 2100000000000.0d0) then
tmp = (-1.0d0) + ((b ** 4.0d0) + ((b * b) * 4.0d0))
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -680000000000.0) {
tmp = Math.pow(a, 4.0);
} else if (a <= 2100000000000.0) {
tmp = -1.0 + (Math.pow(b, 4.0) + ((b * b) * 4.0));
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -680000000000.0: tmp = math.pow(a, 4.0) elif a <= 2100000000000.0: tmp = -1.0 + (math.pow(b, 4.0) + ((b * b) * 4.0)) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -680000000000.0) tmp = a ^ 4.0; elseif (a <= 2100000000000.0) tmp = Float64(-1.0 + Float64((b ^ 4.0) + Float64(Float64(b * b) * 4.0))); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -680000000000.0) tmp = a ^ 4.0; elseif (a <= 2100000000000.0) tmp = -1.0 + ((b ^ 4.0) + ((b * b) * 4.0)); else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -680000000000.0], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 2100000000000.0], N[(-1.0 + N[(N[Power[b, 4.0], $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -680000000000:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 2100000000000:\\
\;\;\;\;-1 + \left({b}^{4} + \left(b \cdot b\right) \cdot 4\right)\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -6.8e11 or 2.1e12 < a Initial program 54.8%
associate--l+54.8%
fma-def54.8%
Simplified56.5%
Taylor expanded in a around inf 89.1%
if -6.8e11 < a < 2.1e12Initial program 99.1%
associate--l+99.1%
fma-def99.1%
Simplified99.1%
fma-def99.1%
add-cbrt-cube84.0%
cbrt-prod87.5%
pow-prod-up87.5%
add-sqr-sqrt87.5%
hypot-udef87.5%
hypot-udef87.5%
metadata-eval87.5%
pow-prod-down87.5%
pow-prod-up87.5%
metadata-eval87.5%
fma-def87.5%
Applied egg-rr87.5%
Taylor expanded in a around 0 89.3%
sub-neg89.3%
associate-+r+89.3%
+-commutative89.3%
associate-*r*89.3%
distribute-rgt-out98.1%
unpow298.1%
+-commutative98.1%
metadata-eval98.1%
associate-*r*98.1%
*-commutative98.1%
*-commutative98.1%
associate-*l*98.1%
metadata-eval98.1%
metadata-eval98.1%
Simplified98.1%
Taylor expanded in a around 0 98.8%
Final simplification94.2%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e+48) (+ (pow a 4.0) (+ -1.0 (* (* a a) 4.0))) (+ -1.0 (pow b 4.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+48) {
tmp = pow(a, 4.0) + (-1.0 + ((a * a) * 4.0));
} else {
tmp = -1.0 + pow(b, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 2d+48) then
tmp = (a ** 4.0d0) + ((-1.0d0) + ((a * a) * 4.0d0))
else
tmp = (-1.0d0) + (b ** 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+48) {
tmp = Math.pow(a, 4.0) + (-1.0 + ((a * a) * 4.0));
} else {
tmp = -1.0 + Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2e+48: tmp = math.pow(a, 4.0) + (-1.0 + ((a * a) * 4.0)) else: tmp = -1.0 + math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e+48) tmp = Float64((a ^ 4.0) + Float64(-1.0 + Float64(Float64(a * a) * 4.0))); else tmp = Float64(-1.0 + (b ^ 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2e+48) tmp = (a ^ 4.0) + (-1.0 + ((a * a) * 4.0)); else tmp = -1.0 + (b ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e+48], N[(N[Power[a, 4.0], $MachinePrecision] + N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+48}:\\
\;\;\;\;{a}^{4} + \left(-1 + \left(a \cdot a\right) \cdot 4\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + {b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 2.00000000000000009e48Initial program 82.2%
associate--l+82.2%
fma-def82.2%
Simplified82.2%
Taylor expanded in b around 0 79.4%
associate--l+79.4%
associate-*r*79.4%
unpow279.4%
Simplified79.4%
Taylor expanded in a around 0 96.1%
unpow296.1%
Simplified96.1%
if 2.00000000000000009e48 < (*.f64 b b) Initial program 74.5%
associate--l+74.5%
fma-def74.5%
Simplified76.1%
fma-def76.1%
add-cbrt-cube59.0%
cbrt-prod62.8%
pow-prod-up62.8%
add-sqr-sqrt62.8%
hypot-udef62.8%
hypot-udef62.8%
metadata-eval62.8%
pow-prod-down62.8%
pow-prod-up62.8%
metadata-eval62.8%
fma-def62.8%
Applied egg-rr62.8%
Taylor expanded in a around 0 72.5%
sub-neg72.5%
associate-+r+72.5%
+-commutative72.5%
associate-*r*72.5%
distribute-rgt-out82.0%
unpow282.0%
+-commutative82.0%
metadata-eval82.0%
associate-*r*82.0%
*-commutative82.0%
*-commutative82.0%
associate-*l*82.0%
metadata-eval82.0%
metadata-eval82.0%
Simplified82.0%
Taylor expanded in b around inf 94.0%
Final simplification95.1%
(FPCore (a b)
:precision binary64
(if (<= a -1.05e+15)
(pow a 4.0)
(if (<= a 400000000000.0)
(+ -1.0 (* (* b b) (+ (* b b) 4.0)))
(pow a 4.0))))
double code(double a, double b) {
double tmp;
if (a <= -1.05e+15) {
tmp = pow(a, 4.0);
} else if (a <= 400000000000.0) {
tmp = -1.0 + ((b * b) * ((b * b) + 4.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 <= (-1.05d+15)) then
tmp = a ** 4.0d0
else if (a <= 400000000000.0d0) then
tmp = (-1.0d0) + ((b * b) * ((b * b) + 4.0d0))
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -1.05e+15) {
tmp = Math.pow(a, 4.0);
} else if (a <= 400000000000.0) {
tmp = -1.0 + ((b * b) * ((b * b) + 4.0));
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -1.05e+15: tmp = math.pow(a, 4.0) elif a <= 400000000000.0: tmp = -1.0 + ((b * b) * ((b * b) + 4.0)) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -1.05e+15) tmp = a ^ 4.0; elseif (a <= 400000000000.0) tmp = Float64(-1.0 + Float64(Float64(b * b) * Float64(Float64(b * b) + 4.0))); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -1.05e+15) tmp = a ^ 4.0; elseif (a <= 400000000000.0) tmp = -1.0 + ((b * b) * ((b * b) + 4.0)); else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -1.05e+15], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 400000000000.0], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.05 \cdot 10^{+15}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 400000000000:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 4\right)\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -1.05e15 or 4e11 < a Initial program 54.8%
associate--l+54.8%
fma-def54.8%
Simplified56.5%
Taylor expanded in a around inf 89.1%
if -1.05e15 < a < 4e11Initial program 99.1%
associate--l+99.1%
fma-def99.1%
Simplified99.1%
fma-def99.1%
add-cbrt-cube84.0%
cbrt-prod87.5%
pow-prod-up87.5%
add-sqr-sqrt87.5%
hypot-udef87.5%
hypot-udef87.5%
metadata-eval87.5%
pow-prod-down87.5%
pow-prod-up87.5%
metadata-eval87.5%
fma-def87.5%
Applied egg-rr87.5%
Taylor expanded in a around 0 89.3%
sub-neg89.3%
associate-+r+89.3%
+-commutative89.3%
associate-*r*89.3%
distribute-rgt-out98.1%
unpow298.1%
+-commutative98.1%
metadata-eval98.1%
associate-*r*98.1%
*-commutative98.1%
*-commutative98.1%
associate-*l*98.1%
metadata-eval98.1%
metadata-eval98.1%
Simplified98.1%
+-commutative98.1%
metadata-eval98.1%
pow-sqr98.0%
pow298.0%
pow298.0%
distribute-lft-out98.7%
+-commutative98.7%
fma-def98.7%
Applied egg-rr98.7%
Taylor expanded in a around 0 98.7%
unpow298.7%
unpow298.7%
Simplified98.7%
Final simplification94.2%
(FPCore (a b) :precision binary64 (if (or (<= a -1.6e+138) (not (<= a 6.6e+153))) (+ -1.0 (* (* a a) 4.0)) (+ -1.0 (* (* b b) (+ (* b b) 4.0)))))
double code(double a, double b) {
double tmp;
if ((a <= -1.6e+138) || !(a <= 6.6e+153)) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = -1.0 + ((b * b) * ((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 ((a <= (-1.6d+138)) .or. (.not. (a <= 6.6d+153))) then
tmp = (-1.0d0) + ((a * a) * 4.0d0)
else
tmp = (-1.0d0) + ((b * b) * ((b * b) + 4.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -1.6e+138) || !(a <= 6.6e+153)) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = -1.0 + ((b * b) * ((b * b) + 4.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -1.6e+138) or not (a <= 6.6e+153): tmp = -1.0 + ((a * a) * 4.0) else: tmp = -1.0 + ((b * b) * ((b * b) + 4.0)) return tmp
function code(a, b) tmp = 0.0 if ((a <= -1.6e+138) || !(a <= 6.6e+153)) tmp = Float64(-1.0 + Float64(Float64(a * a) * 4.0)); else tmp = Float64(-1.0 + Float64(Float64(b * b) * Float64(Float64(b * b) + 4.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -1.6e+138) || ~((a <= 6.6e+153))) tmp = -1.0 + ((a * a) * 4.0); else tmp = -1.0 + ((b * b) * ((b * b) + 4.0)); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -1.6e+138], N[Not[LessEqual[a, 6.6e+153]], $MachinePrecision]], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.6 \cdot 10^{+138} \lor \neg \left(a \leq 6.6 \cdot 10^{+153}\right):\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 4\right)\\
\end{array}
\end{array}
if a < -1.6000000000000001e138 or 6.59999999999999989e153 < a Initial program 32.8%
associate--l+32.8%
fma-def32.8%
Simplified32.8%
Taylor expanded in b around 0 48.3%
associate--l+48.3%
associate-*r*48.3%
unpow248.3%
Simplified48.3%
Taylor expanded in a around 0 48.3%
Taylor expanded in a around 0 96.8%
unpow296.8%
Simplified96.8%
if -1.6000000000000001e138 < a < 6.59999999999999989e153Initial program 91.7%
associate--l+91.7%
fma-def91.7%
Simplified92.7%
fma-def92.7%
add-cbrt-cube73.4%
cbrt-prod78.7%
pow-prod-up78.7%
add-sqr-sqrt78.7%
hypot-udef78.7%
hypot-udef78.7%
metadata-eval78.7%
pow-prod-down78.7%
pow-prod-up78.7%
metadata-eval78.7%
fma-def78.7%
Applied egg-rr78.7%
Taylor expanded in a around 0 70.7%
sub-neg70.7%
associate-+r+70.7%
+-commutative70.7%
associate-*r*70.7%
distribute-rgt-out76.7%
unpow276.7%
+-commutative76.7%
metadata-eval76.7%
associate-*r*76.7%
*-commutative76.7%
*-commutative76.7%
associate-*l*76.7%
metadata-eval76.7%
metadata-eval76.7%
Simplified76.7%
+-commutative76.7%
metadata-eval76.7%
pow-sqr76.6%
pow276.6%
pow276.6%
distribute-lft-out81.2%
+-commutative81.2%
fma-def81.2%
Applied egg-rr81.2%
Taylor expanded in a around 0 81.2%
unpow281.2%
unpow281.2%
Simplified81.2%
Final simplification84.7%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e+228) (+ -1.0 (* (* a a) 4.0)) (+ -1.0 (* b (* b 4.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e+228) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = -1.0 + (b * (b * 4.0));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 1d+228) then
tmp = (-1.0d0) + ((a * a) * 4.0d0)
else
tmp = (-1.0d0) + (b * (b * 4.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 1e+228) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = -1.0 + (b * (b * 4.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 1e+228: tmp = -1.0 + ((a * a) * 4.0) else: tmp = -1.0 + (b * (b * 4.0)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1e+228) tmp = Float64(-1.0 + Float64(Float64(a * a) * 4.0)); else tmp = Float64(-1.0 + Float64(b * Float64(b * 4.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 1e+228) tmp = -1.0 + ((a * a) * 4.0); else tmp = -1.0 + (b * (b * 4.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e+228], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(b * N[(b * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{+228}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;-1 + b \cdot \left(b \cdot 4\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 9.9999999999999992e227Initial program 80.8%
associate--l+80.8%
fma-def80.8%
Simplified80.8%
Taylor expanded in b around 0 61.9%
associate--l+61.9%
associate-*r*61.9%
unpow261.9%
Simplified61.9%
Taylor expanded in a around 0 61.9%
Taylor expanded in a around 0 58.0%
unpow258.0%
Simplified58.0%
if 9.9999999999999992e227 < (*.f64 b b) Initial program 72.7%
associate--l+72.7%
fma-def72.7%
Simplified75.3%
fma-def75.3%
add-cbrt-cube75.3%
cbrt-prod75.3%
pow-prod-up75.3%
add-sqr-sqrt75.3%
hypot-udef75.3%
hypot-udef75.3%
metadata-eval75.3%
pow-prod-down75.3%
pow-prod-up75.3%
metadata-eval75.3%
fma-def75.3%
Applied egg-rr75.3%
Taylor expanded in a around 0 64.9%
sub-neg64.9%
associate-+r+64.9%
+-commutative64.9%
associate-*r*64.9%
distribute-rgt-out80.5%
unpow280.5%
+-commutative80.5%
metadata-eval80.5%
associate-*r*80.5%
*-commutative80.5%
*-commutative80.5%
associate-*l*80.5%
metadata-eval80.5%
metadata-eval80.5%
Simplified80.5%
Taylor expanded in b around 0 58.8%
+-commutative58.8%
*-commutative58.8%
fma-udef58.8%
unpow258.8%
*-commutative58.8%
associate-*l*58.8%
fma-udef58.8%
*-commutative58.8%
fma-udef58.8%
Simplified58.8%
Taylor expanded in a around 0 72.4%
Final simplification62.3%
(FPCore (a b) :precision binary64 (+ -1.0 (* b (* b 4.0))))
double code(double a, double b) {
return -1.0 + (b * (b * 4.0));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (-1.0d0) + (b * (b * 4.0d0))
end function
public static double code(double a, double b) {
return -1.0 + (b * (b * 4.0));
}
def code(a, b): return -1.0 + (b * (b * 4.0))
function code(a, b) return Float64(-1.0 + Float64(b * Float64(b * 4.0))) end
function tmp = code(a, b) tmp = -1.0 + (b * (b * 4.0)); end
code[a_, b_] := N[(-1.0 + N[(b * N[(b * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 + b \cdot \left(b \cdot 4\right)
\end{array}
Initial program 78.4%
associate--l+78.4%
fma-def78.4%
Simplified79.2%
fma-def79.2%
add-cbrt-cube64.2%
cbrt-prod68.3%
pow-prod-up68.3%
add-sqr-sqrt68.3%
hypot-udef68.3%
hypot-udef68.3%
metadata-eval68.3%
pow-prod-down68.3%
pow-prod-up68.3%
metadata-eval68.3%
fma-def68.3%
Applied egg-rr68.3%
Taylor expanded in a around 0 58.9%
sub-neg58.9%
associate-+r+58.9%
+-commutative58.9%
associate-*r*58.9%
distribute-rgt-out63.6%
unpow263.6%
+-commutative63.6%
metadata-eval63.6%
associate-*r*63.6%
*-commutative63.6%
*-commutative63.6%
associate-*l*63.6%
metadata-eval63.6%
metadata-eval63.6%
Simplified63.6%
Taylor expanded in b around 0 42.9%
+-commutative42.9%
*-commutative42.9%
fma-udef42.9%
unpow242.9%
*-commutative42.9%
associate-*l*42.9%
fma-udef42.9%
*-commutative42.9%
fma-udef42.9%
Simplified42.9%
Taylor expanded in a around 0 44.7%
Final simplification44.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 78.4%
associate--l+78.4%
fma-def78.4%
Simplified79.2%
Taylor expanded in b around 0 49.6%
associate--l+49.6%
associate-*r*49.6%
unpow249.6%
Simplified49.6%
Taylor expanded in a around 0 21.9%
Final simplification21.9%
herbie shell --seed 2023255
(FPCore (a b)
:name "Bouland and Aaronson, Equation (25)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 3.0 a)))))) 1.0))