
(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 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) (+ 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 (+ (* 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.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%
Simplified7.8%
Taylor expanded in a around inf 95.7%
Final simplification98.8%
(FPCore (a b)
:precision binary64
(if (<= (* b b) 2e+149)
(+
(+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* a a) (* (* b b) (+ a 3.0)))))
-1.0)
(pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+149) {
tmp = (pow(((a * a) + (b * b)), 2.0) + (4.0 * ((a * a) + ((b * b) * (a + 3.0))))) + -1.0;
} else {
tmp = pow(b, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 2d+149) then
tmp = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * ((a * a) + ((b * b) * (a + 3.0d0))))) + (-1.0d0)
else
tmp = b ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+149) {
tmp = (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * ((a * a) + ((b * b) * (a + 3.0))))) + -1.0;
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2e+149: tmp = (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * ((a * a) + ((b * b) * (a + 3.0))))) + -1.0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e+149) tmp = Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(a * a) + Float64(Float64(b * b) * Float64(a + 3.0))))) + -1.0); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2e+149) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * ((a * a) + ((b * b) * (a + 3.0))))) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e+149], N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(a * a), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+149}:\\
\;\;\;\;\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(a \cdot a + \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 2.0000000000000001e149Initial program 83.0%
Taylor expanded in a around 0 98.0%
if 2.0000000000000001e149 < (*.f64 b b) Initial program 59.6%
associate--l+59.6%
fma-define59.6%
sqr-neg59.6%
fma-define59.6%
distribute-rgt-in59.6%
sqr-neg59.6%
distribute-rgt-in59.6%
fma-define59.6%
sqr-neg59.6%
Simplified65.2%
Taylor expanded in b around inf 100.0%
Final simplification98.7%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e+149) (+ (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* a a) (* a (* b b))))) -1.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+149) {
tmp = (pow(((a * a) + (b * b)), 2.0) + (4.0 * ((a * a) + (a * (b * b))))) + -1.0;
} else {
tmp = pow(b, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 2d+149) then
tmp = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * ((a * a) + (a * (b * b))))) + (-1.0d0)
else
tmp = b ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+149) {
tmp = (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * ((a * a) + (a * (b * b))))) + -1.0;
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2e+149: tmp = (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * ((a * a) + (a * (b * b))))) + -1.0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e+149) tmp = Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(a * a) + Float64(a * Float64(b * b))))) + -1.0); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2e+149) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * ((a * a) + (a * (b * b))))) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e+149], N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(a * a), $MachinePrecision] + N[(a * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+149}:\\
\;\;\;\;\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(a \cdot a + a \cdot \left(b \cdot b\right)\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 2.0000000000000001e149Initial program 83.0%
Taylor expanded in a around 0 98.0%
Taylor expanded in a around inf 97.5%
if 2.0000000000000001e149 < (*.f64 b b) Initial program 59.6%
associate--l+59.6%
fma-define59.6%
sqr-neg59.6%
fma-define59.6%
distribute-rgt-in59.6%
sqr-neg59.6%
distribute-rgt-in59.6%
fma-define59.6%
sqr-neg59.6%
Simplified65.2%
Taylor expanded in b around inf 100.0%
Final simplification98.4%
(FPCore (a b) :precision binary64 (if (<= (* b b) 0.005) (+ (* (* a a) (+ 4.0 (* a (- a 4.0)))) -1.0) (+ (+ (pow b 4.0) (* (* b b) 12.0)) -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 0.005) {
tmp = ((a * a) * (4.0 + (a * (a - 4.0)))) + -1.0;
} else {
tmp = (pow(b, 4.0) + ((b * b) * 12.0)) + -1.0;
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 0.005d0) then
tmp = ((a * a) * (4.0d0 + (a * (a - 4.0d0)))) + (-1.0d0)
else
tmp = ((b ** 4.0d0) + ((b * b) * 12.0d0)) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 0.005) {
tmp = ((a * a) * (4.0 + (a * (a - 4.0)))) + -1.0;
} else {
tmp = (Math.pow(b, 4.0) + ((b * b) * 12.0)) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 0.005: tmp = ((a * a) * (4.0 + (a * (a - 4.0)))) + -1.0 else: tmp = (math.pow(b, 4.0) + ((b * b) * 12.0)) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 0.005) tmp = Float64(Float64(Float64(a * a) * Float64(4.0 + Float64(a * Float64(a - 4.0)))) + -1.0); else tmp = Float64(Float64((b ^ 4.0) + Float64(Float64(b * b) * 12.0)) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 0.005) tmp = ((a * a) * (4.0 + (a * (a - 4.0)))) + -1.0; else tmp = ((b ^ 4.0) + ((b * b) * 12.0)) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 0.005], N[(N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * N[(a - 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[Power[b, 4.0], $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 0.005:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a - 4\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left({b}^{4} + \left(b \cdot b\right) \cdot 12\right) + -1\\
\end{array}
\end{array}
if (*.f64 b b) < 0.0050000000000000001Initial program 84.4%
associate--l+84.4%
fma-define84.4%
sqr-neg84.4%
fma-define84.4%
distribute-rgt-in84.4%
sqr-neg84.4%
distribute-rgt-in84.4%
fma-define84.4%
sqr-neg84.4%
Simplified84.4%
Taylor expanded in b around 0 84.4%
Taylor expanded in a around 0 99.7%
pow299.7%
Applied egg-rr99.7%
if 0.0050000000000000001 < (*.f64 b b) Initial program 64.0%
associate--l+64.0%
fma-define64.0%
sqr-neg64.0%
fma-define64.0%
distribute-rgt-in64.0%
sqr-neg64.0%
distribute-rgt-in64.0%
fma-define64.0%
sqr-neg64.0%
Simplified68.2%
Taylor expanded in a around 0 90.5%
pow290.5%
Applied egg-rr90.5%
Final simplification95.4%
(FPCore (a b) :precision binary64 (if (<= (* b b) 20000000000000.0) (+ (* (* a a) (+ 4.0 (* a (- a 4.0)))) -1.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 20000000000000.0) {
tmp = ((a * a) * (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 * b) <= 20000000000000.0d0) then
tmp = ((a * a) * (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 * b) <= 20000000000000.0) {
tmp = ((a * a) * (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 * b) <= 20000000000000.0: tmp = ((a * a) * (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 (Float64(b * b) <= 20000000000000.0) tmp = Float64(Float64(Float64(a * a) * 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 * b) <= 20000000000000.0) tmp = ((a * a) * (4.0 + (a * (a - 4.0)))) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 20000000000000.0], N[(N[(N[(a * a), $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 \cdot b \leq 20000000000000:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a - 4\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 2e13Initial program 84.6%
associate--l+84.6%
fma-define84.6%
sqr-neg84.6%
fma-define84.6%
distribute-rgt-in84.6%
sqr-neg84.6%
distribute-rgt-in84.6%
fma-define84.6%
sqr-neg84.6%
Simplified84.6%
Taylor expanded in b around 0 83.9%
Taylor expanded in a around 0 99.0%
pow299.0%
Applied egg-rr99.0%
if 2e13 < (*.f64 b b) Initial program 63.4%
associate--l+63.4%
fma-define63.4%
sqr-neg63.4%
fma-define63.4%
distribute-rgt-in63.4%
sqr-neg63.4%
distribute-rgt-in63.4%
fma-define63.4%
sqr-neg63.4%
Simplified67.7%
Taylor expanded in b around inf 91.0%
Final simplification95.3%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1.28e+306) (+ (* (* a a) (+ 4.0 (* a (- a 4.0)))) -1.0) (+ (* (* b b) 12.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1.28e+306) {
tmp = ((a * a) * (4.0 + (a * (a - 4.0)))) + -1.0;
} else {
tmp = ((b * b) * 12.0) + -1.0;
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 1.28d+306) then
tmp = ((a * a) * (4.0d0 + (a * (a - 4.0d0)))) + (-1.0d0)
else
tmp = ((b * b) * 12.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 1.28e+306) {
tmp = ((a * a) * (4.0 + (a * (a - 4.0)))) + -1.0;
} else {
tmp = ((b * b) * 12.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 1.28e+306: tmp = ((a * a) * (4.0 + (a * (a - 4.0)))) + -1.0 else: tmp = ((b * b) * 12.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1.28e+306) tmp = Float64(Float64(Float64(a * a) * Float64(4.0 + Float64(a * Float64(a - 4.0)))) + -1.0); else tmp = Float64(Float64(Float64(b * b) * 12.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 1.28e+306) tmp = ((a * a) * (4.0 + (a * (a - 4.0)))) + -1.0; else tmp = ((b * b) * 12.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1.28e+306], N[(N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * N[(a - 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 1.28 \cdot 10^{+306}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a - 4\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 12 + -1\\
\end{array}
\end{array}
if (*.f64 b b) < 1.2799999999999999e306Initial program 81.1%
associate--l+81.1%
fma-define81.1%
sqr-neg81.1%
fma-define81.1%
distribute-rgt-in81.1%
sqr-neg81.1%
distribute-rgt-in81.1%
fma-define81.1%
sqr-neg81.1%
Simplified82.1%
Taylor expanded in b around 0 66.3%
Taylor expanded in a around 0 81.8%
pow281.8%
Applied egg-rr81.8%
if 1.2799999999999999e306 < (*.f64 b b) Initial program 56.3%
associate--l+56.3%
fma-define56.3%
sqr-neg56.3%
fma-define56.3%
distribute-rgt-in56.3%
sqr-neg56.3%
distribute-rgt-in56.3%
fma-define56.3%
sqr-neg56.3%
Simplified60.9%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 98.7%
*-commutative98.7%
Simplified98.7%
pow2100.0%
Applied egg-rr98.7%
Final simplification86.1%
(FPCore (a b) :precision binary64 (if (<= a -3.1e+89) (+ (* (* a a) (+ 4.0 (* a -4.0))) -1.0) (+ (* (* b b) 12.0) -1.0)))
double code(double a, double b) {
double tmp;
if (a <= -3.1e+89) {
tmp = ((a * a) * (4.0 + (a * -4.0))) + -1.0;
} else {
tmp = ((b * b) * 12.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 <= (-3.1d+89)) then
tmp = ((a * a) * (4.0d0 + (a * (-4.0d0)))) + (-1.0d0)
else
tmp = ((b * b) * 12.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -3.1e+89) {
tmp = ((a * a) * (4.0 + (a * -4.0))) + -1.0;
} else {
tmp = ((b * b) * 12.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -3.1e+89: tmp = ((a * a) * (4.0 + (a * -4.0))) + -1.0 else: tmp = ((b * b) * 12.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (a <= -3.1e+89) tmp = Float64(Float64(Float64(a * a) * Float64(4.0 + Float64(a * -4.0))) + -1.0); else tmp = Float64(Float64(Float64(b * b) * 12.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -3.1e+89) tmp = ((a * a) * (4.0 + (a * -4.0))) + -1.0; else tmp = ((b * b) * 12.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -3.1e+89], N[(N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.1 \cdot 10^{+89}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot -4\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 12 + -1\\
\end{array}
\end{array}
if a < -3.1e89Initial program 60.4%
associate--l+60.4%
fma-define60.4%
sqr-neg60.4%
fma-define60.4%
distribute-rgt-in60.4%
sqr-neg60.4%
distribute-rgt-in60.4%
fma-define60.4%
sqr-neg60.4%
Simplified60.4%
Taylor expanded in b around 0 100.0%
Taylor expanded in a around 0 94.3%
*-commutative94.3%
Simplified94.3%
pow2100.0%
Applied egg-rr94.3%
if -3.1e89 < a Initial program 78.2%
associate--l+78.2%
fma-define78.2%
sqr-neg78.2%
fma-define78.2%
distribute-rgt-in78.2%
sqr-neg78.2%
distribute-rgt-in78.2%
fma-define78.2%
sqr-neg78.2%
Simplified80.6%
Taylor expanded in a around 0 76.9%
Taylor expanded in b around 0 59.0%
*-commutative59.0%
Simplified59.0%
pow276.9%
Applied egg-rr59.0%
Final simplification65.6%
(FPCore (a b) :precision binary64 (+ (* (* b b) 12.0) -1.0))
double code(double a, double b) {
return ((b * b) * 12.0) + -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((b * b) * 12.0d0) + (-1.0d0)
end function
public static double code(double a, double b) {
return ((b * b) * 12.0) + -1.0;
}
def code(a, b): return ((b * b) * 12.0) + -1.0
function code(a, b) return Float64(Float64(Float64(b * b) * 12.0) + -1.0) end
function tmp = code(a, b) tmp = ((b * b) * 12.0) + -1.0; end
code[a_, b_] := N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\left(b \cdot b\right) \cdot 12 + -1
\end{array}
Initial program 74.9%
associate--l+74.9%
fma-define74.9%
sqr-neg74.9%
fma-define74.9%
distribute-rgt-in74.9%
sqr-neg74.9%
distribute-rgt-in74.9%
fma-define74.9%
sqr-neg74.9%
Simplified76.8%
Taylor expanded in a around 0 69.6%
Taylor expanded in b around 0 53.3%
*-commutative53.3%
Simplified53.3%
pow269.6%
Applied egg-rr53.3%
Final simplification53.3%
(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 74.9%
associate--l+74.9%
fma-define74.9%
sqr-neg74.9%
fma-define74.9%
distribute-rgt-in74.9%
sqr-neg74.9%
distribute-rgt-in74.9%
fma-define74.9%
sqr-neg74.9%
Simplified76.8%
Taylor expanded in a around 0 69.6%
Taylor expanded in b around 0 27.5%
herbie shell --seed 2024116
(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))