
(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)
(+
(* 4.0 (fma (pow b 2.0) (+ a 3.0) (* (- 1.0 a) (pow a 2.0))))
(+ (pow (hypot a b) 4.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 = (4.0 * fma(pow(b, 2.0), (a + 3.0), ((1.0 - a) * pow(a, 2.0)))) + (pow(hypot(a, b), 4.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(4.0 * fma((b ^ 2.0), Float64(a + 3.0), Float64(Float64(1.0 - a) * (a ^ 2.0)))) + Float64((hypot(a, b) ^ 4.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[(4.0 * N[(N[Power[b, 2.0], $MachinePrecision] * N[(a + 3.0), $MachinePrecision] + N[(N[(1.0 - a), $MachinePrecision] * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $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:\\
\;\;\;\;4 \cdot \mathsf{fma}\left({b}^{2}, a + 3, \left(1 - a\right) \cdot {a}^{2}\right) + \left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\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.7%
associate--l+99.7%
fma-define99.7%
sqr-neg99.7%
fma-define99.7%
distribute-rgt-in99.7%
sqr-neg99.7%
distribute-rgt-in99.7%
fma-define99.7%
sqr-neg99.7%
Simplified99.7%
+-commutative99.7%
fma-define99.7%
associate-+l-99.7%
Applied egg-rr99.7%
unpow299.7%
pow-sqr99.8%
metadata-eval99.8%
Simplified99.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%
Simplified9.9%
Taylor expanded in a around inf 98.7%
Final simplification99.5%
(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)) #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.7%
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%
Simplified9.9%
Taylor expanded in a around inf 98.7%
Final simplification99.4%
(FPCore (a b)
:precision binary64
(if (<= b 3.1e-156)
(pow a 4.0)
(if (<= b 2.9e-140)
-1.0
(if (<= b 1.3e-124)
(pow a 4.0)
(if (<= b 1e-69)
-1.0
(if (<= b 54000000000.0) (pow a 4.0) (pow b 4.0)))))))
double code(double a, double b) {
double tmp;
if (b <= 3.1e-156) {
tmp = pow(a, 4.0);
} else if (b <= 2.9e-140) {
tmp = -1.0;
} else if (b <= 1.3e-124) {
tmp = pow(a, 4.0);
} else if (b <= 1e-69) {
tmp = -1.0;
} else if (b <= 54000000000.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 <= 3.1d-156) then
tmp = a ** 4.0d0
else if (b <= 2.9d-140) then
tmp = -1.0d0
else if (b <= 1.3d-124) then
tmp = a ** 4.0d0
else if (b <= 1d-69) then
tmp = -1.0d0
else if (b <= 54000000000.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 <= 3.1e-156) {
tmp = Math.pow(a, 4.0);
} else if (b <= 2.9e-140) {
tmp = -1.0;
} else if (b <= 1.3e-124) {
tmp = Math.pow(a, 4.0);
} else if (b <= 1e-69) {
tmp = -1.0;
} else if (b <= 54000000000.0) {
tmp = Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 3.1e-156: tmp = math.pow(a, 4.0) elif b <= 2.9e-140: tmp = -1.0 elif b <= 1.3e-124: tmp = math.pow(a, 4.0) elif b <= 1e-69: tmp = -1.0 elif b <= 54000000000.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 <= 3.1e-156) tmp = a ^ 4.0; elseif (b <= 2.9e-140) tmp = -1.0; elseif (b <= 1.3e-124) tmp = a ^ 4.0; elseif (b <= 1e-69) tmp = -1.0; elseif (b <= 54000000000.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 <= 3.1e-156) tmp = a ^ 4.0; elseif (b <= 2.9e-140) tmp = -1.0; elseif (b <= 1.3e-124) tmp = a ^ 4.0; elseif (b <= 1e-69) tmp = -1.0; elseif (b <= 54000000000.0) tmp = a ^ 4.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 3.1e-156], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[b, 2.9e-140], -1.0, If[LessEqual[b, 1.3e-124], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[b, 1e-69], -1.0, If[LessEqual[b, 54000000000.0], N[Power[a, 4.0], $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.1 \cdot 10^{-156}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;b \leq 2.9 \cdot 10^{-140}:\\
\;\;\;\;-1\\
\mathbf{elif}\;b \leq 1.3 \cdot 10^{-124}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;b \leq 10^{-69}:\\
\;\;\;\;-1\\
\mathbf{elif}\;b \leq 54000000000:\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 3.0999999999999998e-156 or 2.89999999999999997e-140 < b < 1.3e-124 or 9.9999999999999996e-70 < b < 5.4e10Initial program 70.9%
associate--l+70.9%
fma-define70.9%
sqr-neg70.9%
fma-define70.9%
distribute-rgt-in70.9%
sqr-neg70.9%
distribute-rgt-in70.9%
fma-define70.9%
sqr-neg70.9%
Simplified73.0%
Taylor expanded in a around inf 53.1%
if 3.0999999999999998e-156 < b < 2.89999999999999997e-140 or 1.3e-124 < b < 9.9999999999999996e-70Initial program 92.9%
associate--l+92.9%
fma-define92.9%
sqr-neg92.9%
fma-define92.9%
distribute-rgt-in92.9%
sqr-neg92.9%
distribute-rgt-in92.9%
fma-define92.9%
sqr-neg92.9%
Simplified92.9%
Taylor expanded in b around 0 92.9%
associate--l+92.9%
associate-*r*92.9%
fma-define92.9%
sub-neg92.9%
metadata-eval92.9%
Simplified92.9%
Taylor expanded in a around 0 78.7%
if 5.4e10 < b Initial program 70.8%
associate--l+70.8%
fma-define70.8%
sqr-neg70.8%
fma-define70.8%
distribute-rgt-in70.8%
sqr-neg70.8%
distribute-rgt-in70.8%
fma-define70.8%
sqr-neg70.8%
Simplified76.3%
Taylor expanded in b around inf 93.1%
Final simplification63.1%
(FPCore (a b) :precision binary64 (if (<= b 44000000000.0) (+ (* (pow a 2.0) (+ 4.0 (* a (- a 4.0)))) -1.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if (b <= 44000000000.0) {
tmp = (pow(a, 2.0) * (4.0 + (a * (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 <= 44000000000.0d0) then
tmp = ((a ** 2.0d0) * (4.0d0 + (a * (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 <= 44000000000.0) {
tmp = (Math.pow(a, 2.0) * (4.0 + (a * (a - 4.0)))) + -1.0;
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 44000000000.0: tmp = (math.pow(a, 2.0) * (4.0 + (a * (a - 4.0)))) + -1.0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 44000000000.0) tmp = Float64(Float64((a ^ 2.0) * Float64(4.0 + Float64(a * 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 <= 44000000000.0) tmp = ((a ^ 2.0) * (4.0 + (a * (a - 4.0)))) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 44000000000.0], N[(N[(N[Power[a, 2.0], $MachinePrecision] * N[(4.0 + N[(a * N[(a - 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 44000000000:\\
\;\;\;\;{a}^{2} \cdot \left(4 + a \cdot \left(a - 4\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 4.4e10Initial program 72.4%
associate--l+72.4%
fma-define72.4%
sqr-neg72.4%
fma-define72.4%
distribute-rgt-in72.4%
sqr-neg72.4%
distribute-rgt-in72.4%
fma-define72.4%
sqr-neg72.4%
Simplified74.4%
Taylor expanded in b around 0 57.0%
associate--l+57.0%
associate-*r*57.0%
fma-define61.5%
sub-neg61.5%
metadata-eval61.5%
Simplified61.5%
Taylor expanded in a around 0 78.3%
if 4.4e10 < b Initial program 70.8%
associate--l+70.8%
fma-define70.8%
sqr-neg70.8%
fma-define70.8%
distribute-rgt-in70.8%
sqr-neg70.8%
distribute-rgt-in70.8%
fma-define70.8%
sqr-neg70.8%
Simplified76.3%
Taylor expanded in b around inf 93.1%
Final simplification81.5%
(FPCore (a b) :precision binary64 (if (or (<= a -1.82e-9) (not (<= a 2.4))) (pow a 4.0) -1.0))
double code(double a, double b) {
double tmp;
if ((a <= -1.82e-9) || !(a <= 2.4)) {
tmp = pow(a, 4.0);
} else {
tmp = -1.0;
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a <= (-1.82d-9)) .or. (.not. (a <= 2.4d0))) then
tmp = a ** 4.0d0
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -1.82e-9) || !(a <= 2.4)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -1.82e-9) or not (a <= 2.4): tmp = math.pow(a, 4.0) else: tmp = -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -1.82e-9) || !(a <= 2.4)) tmp = a ^ 4.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -1.82e-9) || ~((a <= 2.4))) tmp = a ^ 4.0; else tmp = -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -1.82e-9], N[Not[LessEqual[a, 2.4]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], -1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.82 \cdot 10^{-9} \lor \neg \left(a \leq 2.4\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if a < -1.8199999999999999e-9 or 2.39999999999999991 < a Initial program 47.3%
associate--l+47.3%
fma-define47.3%
sqr-neg47.3%
fma-define47.3%
distribute-rgt-in47.3%
sqr-neg47.3%
distribute-rgt-in47.3%
fma-define47.3%
sqr-neg47.3%
Simplified52.5%
Taylor expanded in a around inf 89.3%
if -1.8199999999999999e-9 < a < 2.39999999999999991Initial program 99.7%
associate--l+99.7%
fma-define99.7%
sqr-neg99.7%
fma-define99.7%
distribute-rgt-in99.7%
sqr-neg99.7%
distribute-rgt-in99.7%
fma-define99.7%
sqr-neg99.7%
Simplified99.7%
Taylor expanded in b around 0 46.6%
associate--l+46.6%
associate-*r*46.6%
fma-define46.6%
sub-neg46.6%
metadata-eval46.6%
Simplified46.6%
Taylor expanded in a around 0 45.6%
Final simplification68.7%
(FPCore (a b) :precision binary64 (if (<= b 38000000000.0) (+ (pow a 4.0) -1.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if (b <= 38000000000.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 <= 38000000000.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 <= 38000000000.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 <= 38000000000.0: tmp = math.pow(a, 4.0) + -1.0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 38000000000.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 <= 38000000000.0) tmp = (a ^ 4.0) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 38000000000.0], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 38000000000:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 3.8e10Initial program 72.4%
associate--l+72.4%
fma-define72.4%
sqr-neg72.4%
fma-define72.4%
distribute-rgt-in72.4%
sqr-neg72.4%
distribute-rgt-in72.4%
fma-define72.4%
sqr-neg72.4%
Simplified74.4%
Taylor expanded in b around 0 57.0%
associate--l+57.0%
associate-*r*57.0%
fma-define61.5%
sub-neg61.5%
metadata-eval61.5%
Simplified61.5%
Taylor expanded in a around 0 78.3%
Taylor expanded in a around inf 77.2%
if 3.8e10 < b Initial program 70.8%
associate--l+70.8%
fma-define70.8%
sqr-neg70.8%
fma-define70.8%
distribute-rgt-in70.8%
sqr-neg70.8%
distribute-rgt-in70.8%
fma-define70.8%
sqr-neg70.8%
Simplified76.3%
Taylor expanded in b around inf 93.1%
Final simplification80.6%
(FPCore (a b) :precision binary64 -1.0)
double code(double a, double b) {
return -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = -1.0d0
end function
public static double code(double a, double b) {
return -1.0;
}
def code(a, b): return -1.0
function code(a, b) return -1.0 end
function tmp = code(a, b) tmp = -1.0; end
code[a_, b_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 72.1%
associate--l+72.1%
fma-define72.1%
sqr-neg72.1%
fma-define72.1%
distribute-rgt-in72.1%
sqr-neg72.1%
distribute-rgt-in72.1%
fma-define72.1%
sqr-neg72.1%
Simplified74.8%
Taylor expanded in b around 0 50.4%
associate--l+50.4%
associate-*r*50.4%
fma-define55.1%
sub-neg55.1%
metadata-eval55.1%
Simplified55.1%
Taylor expanded in a around 0 21.9%
Final simplification21.9%
herbie shell --seed 2024077
(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))