
(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 2.0) (+ (* 2.0 (pow b 2.0)) (* a (- a 4.0)))) -1.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, 2.0) * ((2.0 * pow(b, 2.0)) + (a * (a - 4.0)))) + -1.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, 2.0) * ((2.0 * Math.pow(b, 2.0)) + (a * (a - 4.0)))) + -1.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, 2.0) * ((2.0 * math.pow(b, 2.0)) + (a * (a - 4.0)))) + -1.0 return tmp
function code(a, b) t_0 = Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + Float64(Float64(b * b) * Float64(a + 3.0))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(t_0 + -1.0); else tmp = Float64(Float64((a ^ 2.0) * Float64(Float64(2.0 * (b ^ 2.0)) + Float64(a * Float64(a - 4.0)))) + -1.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 ^ 2.0) * ((2.0 * (b ^ 2.0)) + (a * (a - 4.0)))) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(t$95$0 + -1.0), $MachinePrecision], N[(N[(N[Power[a, 2.0], $MachinePrecision] * N[(N[(2.0 * N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] + N[(a * N[(a - 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.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}^{2} \cdot \left(2 \cdot {b}^{2} + a \cdot \left(a - 4\right)\right) + -1\\
\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%
Simplified6.6%
Taylor expanded in b around 0 6.6%
fma-define6.6%
unpow26.6%
unpow26.6%
swap-sqr6.6%
unpow26.6%
*-commutative6.6%
Simplified6.6%
unpow26.6%
associate-*r*6.6%
*-commutative6.6%
Applied egg-rr6.6%
Taylor expanded in a around inf 42.1%
mul-1-neg42.1%
Simplified42.1%
Taylor expanded in a around 0 100.0%
Final simplification99.9%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))))
(if (<= t_0 INFINITY) (+ t_0 -1.0) (pow a 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%
Simplified6.6%
Taylor expanded in a around inf 91.4%
Final simplification97.3%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* (- a 4.0) (pow a 3.0))))
(if (<= b 7.5e-148)
t_0
(if (<= b 5.9e-125)
-1.0
(if (<= b 1.4e-66)
t_0
(if (<= b 0.001) -1.0 (if (<= b 1.1e+27) t_0 (pow b 4.0))))))))
double code(double a, double b) {
double t_0 = (a - 4.0) * pow(a, 3.0);
double tmp;
if (b <= 7.5e-148) {
tmp = t_0;
} else if (b <= 5.9e-125) {
tmp = -1.0;
} else if (b <= 1.4e-66) {
tmp = t_0;
} else if (b <= 0.001) {
tmp = -1.0;
} else if (b <= 1.1e+27) {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = (a - 4.0d0) * (a ** 3.0d0)
if (b <= 7.5d-148) then
tmp = t_0
else if (b <= 5.9d-125) then
tmp = -1.0d0
else if (b <= 1.4d-66) then
tmp = t_0
else if (b <= 0.001d0) then
tmp = -1.0d0
else if (b <= 1.1d+27) then
tmp = t_0
else
tmp = b ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double t_0 = (a - 4.0) * Math.pow(a, 3.0);
double tmp;
if (b <= 7.5e-148) {
tmp = t_0;
} else if (b <= 5.9e-125) {
tmp = -1.0;
} else if (b <= 1.4e-66) {
tmp = t_0;
} else if (b <= 0.001) {
tmp = -1.0;
} else if (b <= 1.1e+27) {
tmp = t_0;
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): t_0 = (a - 4.0) * math.pow(a, 3.0) tmp = 0 if b <= 7.5e-148: tmp = t_0 elif b <= 5.9e-125: tmp = -1.0 elif b <= 1.4e-66: tmp = t_0 elif b <= 0.001: tmp = -1.0 elif b <= 1.1e+27: tmp = t_0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) t_0 = Float64(Float64(a - 4.0) * (a ^ 3.0)) tmp = 0.0 if (b <= 7.5e-148) tmp = t_0; elseif (b <= 5.9e-125) tmp = -1.0; elseif (b <= 1.4e-66) tmp = t_0; elseif (b <= 0.001) tmp = -1.0; elseif (b <= 1.1e+27) tmp = t_0; else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) t_0 = (a - 4.0) * (a ^ 3.0); tmp = 0.0; if (b <= 7.5e-148) tmp = t_0; elseif (b <= 5.9e-125) tmp = -1.0; elseif (b <= 1.4e-66) tmp = t_0; elseif (b <= 0.001) tmp = -1.0; elseif (b <= 1.1e+27) tmp = t_0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[(a - 4.0), $MachinePrecision] * N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 7.5e-148], t$95$0, If[LessEqual[b, 5.9e-125], -1.0, If[LessEqual[b, 1.4e-66], t$95$0, If[LessEqual[b, 0.001], -1.0, If[LessEqual[b, 1.1e+27], t$95$0, N[Power[b, 4.0], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(a - 4\right) \cdot {a}^{3}\\
\mathbf{if}\;b \leq 7.5 \cdot 10^{-148}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 5.9 \cdot 10^{-125}:\\
\;\;\;\;-1\\
\mathbf{elif}\;b \leq 1.4 \cdot 10^{-66}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 0.001:\\
\;\;\;\;-1\\
\mathbf{elif}\;b \leq 1.1 \cdot 10^{+27}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 7.5000000000000005e-148 or 5.89999999999999959e-125 < b < 1.4e-66 or 1e-3 < b < 1.0999999999999999e27Initial program 71.7%
associate--l+71.7%
fma-define71.7%
sqr-neg71.7%
fma-define71.7%
distribute-rgt-in71.7%
sqr-neg71.7%
distribute-rgt-in71.7%
fma-define71.7%
sqr-neg71.7%
Simplified72.8%
Taylor expanded in a around inf 50.4%
associate-*r/50.4%
metadata-eval50.4%
Simplified50.4%
Taylor expanded in a around 0 50.4%
if 7.5000000000000005e-148 < b < 5.89999999999999959e-125 or 1.4e-66 < b < 1e-3Initial program 87.2%
associate--l+87.2%
fma-define87.2%
sqr-neg87.2%
fma-define87.2%
distribute-rgt-in87.2%
sqr-neg87.2%
distribute-rgt-in87.2%
fma-define87.2%
sqr-neg87.2%
Simplified87.2%
Taylor expanded in b around 0 87.4%
fma-define87.4%
unpow287.4%
unpow287.4%
swap-sqr87.4%
unpow287.4%
*-commutative87.4%
Simplified87.4%
Taylor expanded in a around 0 62.9%
Taylor expanded in b around 0 62.9%
if 1.0999999999999999e27 < b Initial program 60.9%
associate--l+60.9%
fma-define60.9%
sqr-neg60.9%
fma-define60.9%
distribute-rgt-in60.9%
sqr-neg60.9%
distribute-rgt-in60.9%
fma-define60.9%
sqr-neg60.9%
Simplified66.0%
Taylor expanded in b around inf 95.2%
Final simplification61.5%
(FPCore (a b)
:precision binary64
(if (<= a -3450.0)
(* (pow a 4.0) (- 1.0 (/ 4.0 a)))
(if (<= a 12000000.0)
(+ (* (pow b 2.0) 12.0) -1.0)
(* (pow a 4.0) (+ (+ 2.0 (/ -4.0 a)) -1.0)))))
double code(double a, double b) {
double tmp;
if (a <= -3450.0) {
tmp = pow(a, 4.0) * (1.0 - (4.0 / a));
} else if (a <= 12000000.0) {
tmp = (pow(b, 2.0) * 12.0) + -1.0;
} else {
tmp = pow(a, 4.0) * ((2.0 + (-4.0 / a)) + -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 <= (-3450.0d0)) then
tmp = (a ** 4.0d0) * (1.0d0 - (4.0d0 / a))
else if (a <= 12000000.0d0) then
tmp = ((b ** 2.0d0) * 12.0d0) + (-1.0d0)
else
tmp = (a ** 4.0d0) * ((2.0d0 + ((-4.0d0) / a)) + (-1.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -3450.0) {
tmp = Math.pow(a, 4.0) * (1.0 - (4.0 / a));
} else if (a <= 12000000.0) {
tmp = (Math.pow(b, 2.0) * 12.0) + -1.0;
} else {
tmp = Math.pow(a, 4.0) * ((2.0 + (-4.0 / a)) + -1.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -3450.0: tmp = math.pow(a, 4.0) * (1.0 - (4.0 / a)) elif a <= 12000000.0: tmp = (math.pow(b, 2.0) * 12.0) + -1.0 else: tmp = math.pow(a, 4.0) * ((2.0 + (-4.0 / a)) + -1.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -3450.0) tmp = Float64((a ^ 4.0) * Float64(1.0 - Float64(4.0 / a))); elseif (a <= 12000000.0) tmp = Float64(Float64((b ^ 2.0) * 12.0) + -1.0); else tmp = Float64((a ^ 4.0) * Float64(Float64(2.0 + Float64(-4.0 / a)) + -1.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -3450.0) tmp = (a ^ 4.0) * (1.0 - (4.0 / a)); elseif (a <= 12000000.0) tmp = ((b ^ 2.0) * 12.0) + -1.0; else tmp = (a ^ 4.0) * ((2.0 + (-4.0 / a)) + -1.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -3450.0], N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 - N[(4.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 12000000.0], N[(N[(N[Power[b, 2.0], $MachinePrecision] * 12.0), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] * N[(N[(2.0 + N[(-4.0 / a), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3450:\\
\;\;\;\;{a}^{4} \cdot \left(1 - \frac{4}{a}\right)\\
\mathbf{elif}\;a \leq 12000000:\\
\;\;\;\;{b}^{2} \cdot 12 + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} \cdot \left(\left(2 + \frac{-4}{a}\right) + -1\right)\\
\end{array}
\end{array}
if a < -3450Initial program 52.8%
associate--l+52.8%
fma-define52.8%
sqr-neg52.8%
fma-define52.8%
distribute-rgt-in52.8%
sqr-neg52.8%
distribute-rgt-in52.8%
fma-define52.8%
sqr-neg52.8%
Simplified52.8%
Taylor expanded in a around inf 88.2%
associate-*r/88.2%
metadata-eval88.2%
Simplified88.2%
if -3450 < a < 1.2e7Initial program 99.9%
associate--l+99.9%
fma-define99.9%
sqr-neg99.9%
fma-define99.9%
distribute-rgt-in99.9%
sqr-neg99.9%
distribute-rgt-in99.9%
fma-define99.9%
sqr-neg99.9%
Simplified99.9%
Taylor expanded in b around 0 62.2%
fma-define62.2%
unpow262.2%
unpow262.2%
swap-sqr78.0%
unpow278.0%
*-commutative78.0%
Simplified78.0%
Taylor expanded in a around 0 78.0%
if 1.2e7 < a Initial program 35.2%
associate--l+35.2%
fma-define35.2%
sqr-neg35.2%
fma-define35.2%
distribute-rgt-in35.2%
sqr-neg35.2%
distribute-rgt-in35.2%
fma-define35.2%
sqr-neg35.2%
Simplified42.5%
Taylor expanded in a around inf 90.2%
associate-*r/90.2%
metadata-eval90.2%
Simplified90.2%
expm1-log1p-u90.2%
sub-neg90.2%
distribute-neg-frac90.2%
metadata-eval90.2%
Applied egg-rr90.2%
expm1-undefine90.2%
sub-neg90.2%
log1p-undefine90.2%
rem-exp-log90.2%
associate-+r+90.2%
metadata-eval90.2%
metadata-eval90.2%
Simplified90.2%
Final simplification84.0%
(FPCore (a b) :precision binary64 (if (or (<= a -80000.0) (not (<= a 2300000.0))) (* (pow a 4.0) (- 1.0 (/ 4.0 a))) (+ (* (pow b 2.0) 12.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -80000.0) || !(a <= 2300000.0)) {
tmp = pow(a, 4.0) * (1.0 - (4.0 / a));
} else {
tmp = (pow(b, 2.0) * 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 <= (-80000.0d0)) .or. (.not. (a <= 2300000.0d0))) then
tmp = (a ** 4.0d0) * (1.0d0 - (4.0d0 / a))
else
tmp = ((b ** 2.0d0) * 12.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -80000.0) || !(a <= 2300000.0)) {
tmp = Math.pow(a, 4.0) * (1.0 - (4.0 / a));
} else {
tmp = (Math.pow(b, 2.0) * 12.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -80000.0) or not (a <= 2300000.0): tmp = math.pow(a, 4.0) * (1.0 - (4.0 / a)) else: tmp = (math.pow(b, 2.0) * 12.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -80000.0) || !(a <= 2300000.0)) tmp = Float64((a ^ 4.0) * Float64(1.0 - Float64(4.0 / a))); else tmp = Float64(Float64((b ^ 2.0) * 12.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -80000.0) || ~((a <= 2300000.0))) tmp = (a ^ 4.0) * (1.0 - (4.0 / a)); else tmp = ((b ^ 2.0) * 12.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -80000.0], N[Not[LessEqual[a, 2300000.0]], $MachinePrecision]], N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 - N[(4.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[b, 2.0], $MachinePrecision] * 12.0), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -80000 \lor \neg \left(a \leq 2300000\right):\\
\;\;\;\;{a}^{4} \cdot \left(1 - \frac{4}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} \cdot 12 + -1\\
\end{array}
\end{array}
if a < -8e4 or 2.3e6 < a Initial program 44.0%
associate--l+44.0%
fma-define44.0%
sqr-neg44.0%
fma-define44.0%
distribute-rgt-in44.0%
sqr-neg44.0%
distribute-rgt-in44.0%
fma-define44.0%
sqr-neg44.0%
Simplified47.7%
Taylor expanded in a around inf 89.2%
associate-*r/89.2%
metadata-eval89.2%
Simplified89.2%
if -8e4 < a < 2.3e6Initial program 99.9%
associate--l+99.9%
fma-define99.9%
sqr-neg99.9%
fma-define99.9%
distribute-rgt-in99.9%
sqr-neg99.9%
distribute-rgt-in99.9%
fma-define99.9%
sqr-neg99.9%
Simplified99.9%
Taylor expanded in b around 0 62.2%
fma-define62.2%
unpow262.2%
unpow262.2%
swap-sqr78.0%
unpow278.0%
*-commutative78.0%
Simplified78.0%
Taylor expanded in a around 0 78.0%
Final simplification84.0%
(FPCore (a b) :precision binary64 (if (<= b 1.05e-147) (pow a 4.0) (if (<= b 2.25e-125) -1.0 (if (<= b 2e+27) (pow a 4.0) (pow b 4.0)))))
double code(double a, double b) {
double tmp;
if (b <= 1.05e-147) {
tmp = pow(a, 4.0);
} else if (b <= 2.25e-125) {
tmp = -1.0;
} else if (b <= 2e+27) {
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 <= 1.05d-147) then
tmp = a ** 4.0d0
else if (b <= 2.25d-125) then
tmp = -1.0d0
else if (b <= 2d+27) 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 <= 1.05e-147) {
tmp = Math.pow(a, 4.0);
} else if (b <= 2.25e-125) {
tmp = -1.0;
} else if (b <= 2e+27) {
tmp = Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 1.05e-147: tmp = math.pow(a, 4.0) elif b <= 2.25e-125: tmp = -1.0 elif b <= 2e+27: tmp = math.pow(a, 4.0) else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 1.05e-147) tmp = a ^ 4.0; elseif (b <= 2.25e-125) tmp = -1.0; elseif (b <= 2e+27) tmp = a ^ 4.0; else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 1.05e-147) tmp = a ^ 4.0; elseif (b <= 2.25e-125) tmp = -1.0; elseif (b <= 2e+27) tmp = a ^ 4.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 1.05e-147], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[b, 2.25e-125], -1.0, If[LessEqual[b, 2e+27], N[Power[a, 4.0], $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.05 \cdot 10^{-147}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;b \leq 2.25 \cdot 10^{-125}:\\
\;\;\;\;-1\\
\mathbf{elif}\;b \leq 2 \cdot 10^{+27}:\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 1.05e-147 or 2.25000000000000006e-125 < b < 2e27Initial program 72.5%
associate--l+72.5%
fma-define72.5%
sqr-neg72.5%
fma-define72.5%
distribute-rgt-in72.5%
sqr-neg72.5%
distribute-rgt-in72.5%
fma-define72.5%
sqr-neg72.5%
Simplified73.6%
Taylor expanded in a around inf 49.8%
if 1.05e-147 < b < 2.25000000000000006e-125Initial program 85.7%
associate--l+85.7%
fma-define85.7%
sqr-neg85.7%
fma-define85.7%
distribute-rgt-in85.7%
sqr-neg85.7%
distribute-rgt-in85.7%
fma-define85.7%
sqr-neg85.7%
Simplified85.7%
Taylor expanded in b around 0 85.5%
fma-define85.5%
unpow285.5%
unpow285.5%
swap-sqr85.5%
unpow285.5%
*-commutative85.5%
Simplified85.5%
Taylor expanded in a around 0 71.7%
Taylor expanded in b around 0 71.7%
if 2e27 < b Initial program 60.9%
associate--l+60.9%
fma-define60.9%
sqr-neg60.9%
fma-define60.9%
distribute-rgt-in60.9%
sqr-neg60.9%
distribute-rgt-in60.9%
fma-define60.9%
sqr-neg60.9%
Simplified66.0%
Taylor expanded in b around inf 95.2%
(FPCore (a b) :precision binary64 (if (or (<= a -790000.0) (not (<= a 650.0))) (* (- a 4.0) (pow a 3.0)) (+ (* (pow b 2.0) 12.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -790000.0) || !(a <= 650.0)) {
tmp = (a - 4.0) * pow(a, 3.0);
} else {
tmp = (pow(b, 2.0) * 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 <= (-790000.0d0)) .or. (.not. (a <= 650.0d0))) then
tmp = (a - 4.0d0) * (a ** 3.0d0)
else
tmp = ((b ** 2.0d0) * 12.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -790000.0) || !(a <= 650.0)) {
tmp = (a - 4.0) * Math.pow(a, 3.0);
} else {
tmp = (Math.pow(b, 2.0) * 12.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -790000.0) or not (a <= 650.0): tmp = (a - 4.0) * math.pow(a, 3.0) else: tmp = (math.pow(b, 2.0) * 12.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -790000.0) || !(a <= 650.0)) tmp = Float64(Float64(a - 4.0) * (a ^ 3.0)); else tmp = Float64(Float64((b ^ 2.0) * 12.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -790000.0) || ~((a <= 650.0))) tmp = (a - 4.0) * (a ^ 3.0); else tmp = ((b ^ 2.0) * 12.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -790000.0], N[Not[LessEqual[a, 650.0]], $MachinePrecision]], N[(N[(a - 4.0), $MachinePrecision] * N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[b, 2.0], $MachinePrecision] * 12.0), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -790000 \lor \neg \left(a \leq 650\right):\\
\;\;\;\;\left(a - 4\right) \cdot {a}^{3}\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} \cdot 12 + -1\\
\end{array}
\end{array}
if a < -7.9e5 or 650 < a Initial program 44.0%
associate--l+44.0%
fma-define44.0%
sqr-neg44.0%
fma-define44.0%
distribute-rgt-in44.0%
sqr-neg44.0%
distribute-rgt-in44.0%
fma-define44.0%
sqr-neg44.0%
Simplified47.7%
Taylor expanded in a around inf 89.2%
associate-*r/89.2%
metadata-eval89.2%
Simplified89.2%
Taylor expanded in a around 0 89.2%
if -7.9e5 < a < 650Initial program 99.9%
associate--l+99.9%
fma-define99.9%
sqr-neg99.9%
fma-define99.9%
distribute-rgt-in99.9%
sqr-neg99.9%
distribute-rgt-in99.9%
fma-define99.9%
sqr-neg99.9%
Simplified99.9%
Taylor expanded in b around 0 62.2%
fma-define62.2%
unpow262.2%
unpow262.2%
swap-sqr78.0%
unpow278.0%
*-commutative78.0%
Simplified78.0%
Taylor expanded in a around 0 78.0%
Final simplification84.0%
(FPCore (a b) :precision binary64 (if (or (<= a -7e-16) (not (<= a 3.4e-9))) (pow a 4.0) -1.0))
double code(double a, double b) {
double tmp;
if ((a <= -7e-16) || !(a <= 3.4e-9)) {
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 <= (-7d-16)) .or. (.not. (a <= 3.4d-9))) 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 <= -7e-16) || !(a <= 3.4e-9)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -7e-16) or not (a <= 3.4e-9): tmp = math.pow(a, 4.0) else: tmp = -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -7e-16) || !(a <= 3.4e-9)) tmp = a ^ 4.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -7e-16) || ~((a <= 3.4e-9))) tmp = a ^ 4.0; else tmp = -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -7e-16], N[Not[LessEqual[a, 3.4e-9]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], -1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -7 \cdot 10^{-16} \lor \neg \left(a \leq 3.4 \cdot 10^{-9}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if a < -7.00000000000000035e-16 or 3.3999999999999998e-9 < a Initial program 46.7%
associate--l+46.7%
fma-define46.7%
sqr-neg46.7%
fma-define46.7%
distribute-rgt-in46.7%
sqr-neg46.7%
distribute-rgt-in46.7%
fma-define46.7%
sqr-neg46.7%
Simplified50.2%
Taylor expanded in a around inf 84.2%
if -7.00000000000000035e-16 < a < 3.3999999999999998e-9Initial program 99.9%
associate--l+99.9%
fma-define99.9%
sqr-neg99.9%
fma-define99.9%
distribute-rgt-in99.9%
sqr-neg99.9%
distribute-rgt-in99.9%
fma-define99.9%
sqr-neg99.9%
Simplified99.9%
Taylor expanded in b around 0 63.2%
fma-define63.2%
unpow263.2%
unpow263.2%
swap-sqr80.0%
unpow280.0%
*-commutative80.0%
Simplified80.0%
Taylor expanded in a around 0 80.0%
Taylor expanded in b around 0 48.4%
Final simplification68.4%
(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 70.2%
associate--l+70.2%
fma-define70.2%
sqr-neg70.2%
fma-define70.2%
distribute-rgt-in70.2%
sqr-neg70.2%
distribute-rgt-in70.2%
fma-define70.2%
sqr-neg70.2%
Simplified72.2%
Taylor expanded in b around 0 49.5%
fma-define49.5%
unpow249.5%
unpow249.5%
swap-sqr61.6%
unpow261.6%
*-commutative61.6%
Simplified61.6%
Taylor expanded in a around 0 56.1%
Taylor expanded in b around 0 21.8%
herbie shell --seed 2024107
(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))