
(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 6 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 (<= a -1.02e+74)
(+ (pow a 4.0) -1.0)
(+
-1.0
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (+ a 1.0)) (pow (cbrt (pow b 2.0)) 3.0)))))))
double code(double a, double b) {
double tmp;
if (a <= -1.02e+74) {
tmp = pow(a, 4.0) + -1.0;
} else {
tmp = -1.0 + (pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + pow(cbrt(pow(b, 2.0)), 3.0))));
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (a <= -1.02e+74) {
tmp = Math.pow(a, 4.0) + -1.0;
} else {
tmp = -1.0 + (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + Math.pow(Math.cbrt(Math.pow(b, 2.0)), 3.0))));
}
return tmp;
}
function code(a, b) tmp = 0.0 if (a <= -1.02e+74) tmp = Float64((a ^ 4.0) + -1.0); else tmp = Float64(-1.0 + Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(a + 1.0)) + (cbrt((b ^ 2.0)) ^ 3.0))))); end return tmp end
code[a_, b_] := If[LessEqual[a, -1.02e+74], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[(-1.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[Power[N[Power[N[Power[b, 2.0], $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.02 \cdot 10^{+74}:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;-1 + \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right) + {\left(\sqrt[3]{{b}^{2}}\right)}^{3}\right)\right)\\
\end{array}
\end{array}
if a < -1.02000000000000005e74Initial program 6.1%
sub-neg6.1%
+-commutative6.1%
fma-define16.3%
+-commutative16.3%
associate-*l*16.3%
cancel-sign-sub-inv16.3%
metadata-eval16.3%
fma-define16.3%
metadata-eval16.3%
Simplified16.3%
Taylor expanded in a around inf 100.0%
if -1.02000000000000005e74 < a Initial program 85.9%
add-cube-cbrt85.9%
pow385.9%
pow285.9%
cancel-sign-sub-inv85.9%
metadata-eval85.9%
+-commutative85.9%
*-commutative85.9%
fma-undefine85.9%
Applied egg-rr85.9%
Taylor expanded in a around 0 99.9%
Final simplification99.9%
(FPCore (a b)
:precision binary64
(if (<= a -1.02e+74)
(+ (pow a 4.0) -1.0)
(+
-1.0
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* b b) (* (* a a) (+ a 1.0))))))))
double code(double a, double b) {
double tmp;
if (a <= -1.02e+74) {
tmp = pow(a, 4.0) + -1.0;
} else {
tmp = -1.0 + (pow(((a * a) + (b * b)), 2.0) + (4.0 * ((b * b) + ((a * a) * (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 <= (-1.02d+74)) then
tmp = (a ** 4.0d0) + (-1.0d0)
else
tmp = (-1.0d0) + ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * ((b * b) + ((a * a) * (a + 1.0d0)))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -1.02e+74) {
tmp = Math.pow(a, 4.0) + -1.0;
} else {
tmp = -1.0 + (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * ((b * b) + ((a * a) * (a + 1.0)))));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -1.02e+74: tmp = math.pow(a, 4.0) + -1.0 else: tmp = -1.0 + (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * ((b * b) + ((a * a) * (a + 1.0))))) return tmp
function code(a, b) tmp = 0.0 if (a <= -1.02e+74) tmp = Float64((a ^ 4.0) + -1.0); else tmp = Float64(-1.0 + Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(b * b) + Float64(Float64(a * a) * Float64(a + 1.0)))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -1.02e+74) tmp = (a ^ 4.0) + -1.0; else tmp = -1.0 + ((((a * a) + (b * b)) ^ 2.0) + (4.0 * ((b * b) + ((a * a) * (a + 1.0))))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -1.02e+74], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[(-1.0 + N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(b * b), $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * N[(a + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.02 \cdot 10^{+74}:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;-1 + \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b + \left(a \cdot a\right) \cdot \left(a + 1\right)\right)\right)\\
\end{array}
\end{array}
if a < -1.02000000000000005e74Initial program 6.1%
sub-neg6.1%
+-commutative6.1%
fma-define16.3%
+-commutative16.3%
associate-*l*16.3%
cancel-sign-sub-inv16.3%
metadata-eval16.3%
fma-define16.3%
metadata-eval16.3%
Simplified16.3%
Taylor expanded in a around inf 100.0%
if -1.02000000000000005e74 < a Initial program 85.9%
add-cube-cbrt85.9%
pow385.9%
pow285.9%
cancel-sign-sub-inv85.9%
metadata-eval85.9%
+-commutative85.9%
*-commutative85.9%
fma-undefine85.9%
Applied egg-rr85.9%
Taylor expanded in a around 0 99.9%
pow299.9%
rem-cube-cbrt99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (a b) :precision binary64 (if (or (<= b 7000000.0) (and (not (<= b 3e+39)) (<= b 3.2e+69))) (+ (pow a 4.0) -1.0) (+ -1.0 (pow b 4.0))))
double code(double a, double b) {
double tmp;
if ((b <= 7000000.0) || (!(b <= 3e+39) && (b <= 3.2e+69))) {
tmp = pow(a, 4.0) + -1.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 <= 7000000.0d0) .or. (.not. (b <= 3d+39)) .and. (b <= 3.2d+69)) then
tmp = (a ** 4.0d0) + (-1.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 <= 7000000.0) || (!(b <= 3e+39) && (b <= 3.2e+69))) {
tmp = Math.pow(a, 4.0) + -1.0;
} else {
tmp = -1.0 + Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b <= 7000000.0) or (not (b <= 3e+39) and (b <= 3.2e+69)): tmp = math.pow(a, 4.0) + -1.0 else: tmp = -1.0 + math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if ((b <= 7000000.0) || (!(b <= 3e+39) && (b <= 3.2e+69))) tmp = Float64((a ^ 4.0) + -1.0); else tmp = Float64(-1.0 + (b ^ 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b <= 7000000.0) || (~((b <= 3e+39)) && (b <= 3.2e+69))) tmp = (a ^ 4.0) + -1.0; else tmp = -1.0 + (b ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[b, 7000000.0], And[N[Not[LessEqual[b, 3e+39]], $MachinePrecision], LessEqual[b, 3.2e+69]]], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[(-1.0 + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7000000 \lor \neg \left(b \leq 3 \cdot 10^{+39}\right) \land b \leq 3.2 \cdot 10^{+69}:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;-1 + {b}^{4}\\
\end{array}
\end{array}
if b < 7e6 or 3e39 < b < 3.19999999999999985e69Initial program 75.0%
sub-neg75.0%
+-commutative75.0%
fma-define76.5%
+-commutative76.5%
associate-*l*76.5%
cancel-sign-sub-inv76.5%
metadata-eval76.5%
fma-define76.5%
metadata-eval76.5%
Simplified76.5%
Taylor expanded in a around inf 79.1%
if 7e6 < b < 3e39 or 3.19999999999999985e69 < b Initial program 55.8%
sub-neg55.8%
+-commutative55.8%
fma-define59.2%
+-commutative59.2%
associate-*l*59.2%
cancel-sign-sub-inv59.2%
metadata-eval59.2%
fma-define59.2%
metadata-eval59.2%
Simplified59.2%
Taylor expanded in b around inf 100.0%
Final simplification83.9%
(FPCore (a b)
:precision binary64
(if (<= b 10500000.0)
(+ -1.0 (* (pow a 3.0) (+ a 4.0)))
(if (or (<= b 3.3e+40) (not (<= b 9e+69)))
(+ -1.0 (pow b 4.0))
(+ (pow a 4.0) -1.0))))
double code(double a, double b) {
double tmp;
if (b <= 10500000.0) {
tmp = -1.0 + (pow(a, 3.0) * (a + 4.0));
} else if ((b <= 3.3e+40) || !(b <= 9e+69)) {
tmp = -1.0 + pow(b, 4.0);
} else {
tmp = pow(a, 4.0) + -1.0;
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 10500000.0d0) then
tmp = (-1.0d0) + ((a ** 3.0d0) * (a + 4.0d0))
else if ((b <= 3.3d+40) .or. (.not. (b <= 9d+69))) then
tmp = (-1.0d0) + (b ** 4.0d0)
else
tmp = (a ** 4.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 10500000.0) {
tmp = -1.0 + (Math.pow(a, 3.0) * (a + 4.0));
} else if ((b <= 3.3e+40) || !(b <= 9e+69)) {
tmp = -1.0 + Math.pow(b, 4.0);
} else {
tmp = Math.pow(a, 4.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 10500000.0: tmp = -1.0 + (math.pow(a, 3.0) * (a + 4.0)) elif (b <= 3.3e+40) or not (b <= 9e+69): tmp = -1.0 + math.pow(b, 4.0) else: tmp = math.pow(a, 4.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (b <= 10500000.0) tmp = Float64(-1.0 + Float64((a ^ 3.0) * Float64(a + 4.0))); elseif ((b <= 3.3e+40) || !(b <= 9e+69)) tmp = Float64(-1.0 + (b ^ 4.0)); else tmp = Float64((a ^ 4.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 10500000.0) tmp = -1.0 + ((a ^ 3.0) * (a + 4.0)); elseif ((b <= 3.3e+40) || ~((b <= 9e+69))) tmp = -1.0 + (b ^ 4.0); else tmp = (a ^ 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 10500000.0], N[(-1.0 + N[(N[Power[a, 3.0], $MachinePrecision] * N[(a + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[b, 3.3e+40], N[Not[LessEqual[b, 9e+69]], $MachinePrecision]], N[(-1.0 + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 10500000:\\
\;\;\;\;-1 + {a}^{3} \cdot \left(a + 4\right)\\
\mathbf{elif}\;b \leq 3.3 \cdot 10^{+40} \lor \neg \left(b \leq 9 \cdot 10^{+69}\right):\\
\;\;\;\;-1 + {b}^{4}\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} + -1\\
\end{array}
\end{array}
if b < 1.05e7Initial program 75.2%
sub-neg75.2%
+-commutative75.2%
fma-define76.7%
+-commutative76.7%
associate-*l*76.7%
cancel-sign-sub-inv76.7%
metadata-eval76.7%
fma-define76.7%
metadata-eval76.7%
Simplified76.7%
Taylor expanded in a around inf 79.4%
associate-*r/79.4%
metadata-eval79.4%
Simplified79.4%
Taylor expanded in a around 0 79.3%
if 1.05e7 < b < 3.2999999999999998e40 or 8.9999999999999999e69 < b Initial program 55.8%
sub-neg55.8%
+-commutative55.8%
fma-define59.2%
+-commutative59.2%
associate-*l*59.2%
cancel-sign-sub-inv59.2%
metadata-eval59.2%
fma-define59.2%
metadata-eval59.2%
Simplified59.2%
Taylor expanded in b around inf 100.0%
if 3.2999999999999998e40 < b < 8.9999999999999999e69Initial program 66.1%
sub-neg66.1%
+-commutative66.1%
fma-define66.1%
+-commutative66.1%
associate-*l*66.1%
cancel-sign-sub-inv66.1%
metadata-eval66.1%
fma-define66.1%
metadata-eval66.1%
Simplified66.1%
Taylor expanded in a around inf 66.9%
Final simplification83.9%
(FPCore (a b)
:precision binary64
(if (<= b 33000000.0)
(+ -1.0 (* (pow a 4.0) (+ 1.0 (/ 4.0 a))))
(if (or (<= b 2.8e+40) (not (<= b 8e+69)))
(+ -1.0 (pow b 4.0))
(+ (pow a 4.0) -1.0))))
double code(double a, double b) {
double tmp;
if (b <= 33000000.0) {
tmp = -1.0 + (pow(a, 4.0) * (1.0 + (4.0 / a)));
} else if ((b <= 2.8e+40) || !(b <= 8e+69)) {
tmp = -1.0 + pow(b, 4.0);
} else {
tmp = pow(a, 4.0) + -1.0;
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 33000000.0d0) then
tmp = (-1.0d0) + ((a ** 4.0d0) * (1.0d0 + (4.0d0 / a)))
else if ((b <= 2.8d+40) .or. (.not. (b <= 8d+69))) then
tmp = (-1.0d0) + (b ** 4.0d0)
else
tmp = (a ** 4.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 33000000.0) {
tmp = -1.0 + (Math.pow(a, 4.0) * (1.0 + (4.0 / a)));
} else if ((b <= 2.8e+40) || !(b <= 8e+69)) {
tmp = -1.0 + Math.pow(b, 4.0);
} else {
tmp = Math.pow(a, 4.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 33000000.0: tmp = -1.0 + (math.pow(a, 4.0) * (1.0 + (4.0 / a))) elif (b <= 2.8e+40) or not (b <= 8e+69): tmp = -1.0 + math.pow(b, 4.0) else: tmp = math.pow(a, 4.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (b <= 33000000.0) tmp = Float64(-1.0 + Float64((a ^ 4.0) * Float64(1.0 + Float64(4.0 / a)))); elseif ((b <= 2.8e+40) || !(b <= 8e+69)) tmp = Float64(-1.0 + (b ^ 4.0)); else tmp = Float64((a ^ 4.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 33000000.0) tmp = -1.0 + ((a ^ 4.0) * (1.0 + (4.0 / a))); elseif ((b <= 2.8e+40) || ~((b <= 8e+69))) tmp = -1.0 + (b ^ 4.0); else tmp = (a ^ 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 33000000.0], N[(-1.0 + N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 + N[(4.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[b, 2.8e+40], N[Not[LessEqual[b, 8e+69]], $MachinePrecision]], N[(-1.0 + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 33000000:\\
\;\;\;\;-1 + {a}^{4} \cdot \left(1 + \frac{4}{a}\right)\\
\mathbf{elif}\;b \leq 2.8 \cdot 10^{+40} \lor \neg \left(b \leq 8 \cdot 10^{+69}\right):\\
\;\;\;\;-1 + {b}^{4}\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} + -1\\
\end{array}
\end{array}
if b < 3.3e7Initial program 75.2%
sub-neg75.2%
+-commutative75.2%
fma-define76.7%
+-commutative76.7%
associate-*l*76.7%
cancel-sign-sub-inv76.7%
metadata-eval76.7%
fma-define76.7%
metadata-eval76.7%
Simplified76.7%
Taylor expanded in a around inf 79.4%
associate-*r/79.4%
metadata-eval79.4%
Simplified79.4%
if 3.3e7 < b < 2.8000000000000001e40 or 8.0000000000000006e69 < b Initial program 55.8%
sub-neg55.8%
+-commutative55.8%
fma-define59.2%
+-commutative59.2%
associate-*l*59.2%
cancel-sign-sub-inv59.2%
metadata-eval59.2%
fma-define59.2%
metadata-eval59.2%
Simplified59.2%
Taylor expanded in b around inf 100.0%
if 2.8000000000000001e40 < b < 8.0000000000000006e69Initial program 66.1%
sub-neg66.1%
+-commutative66.1%
fma-define66.1%
+-commutative66.1%
associate-*l*66.1%
cancel-sign-sub-inv66.1%
metadata-eval66.1%
fma-define66.1%
metadata-eval66.1%
Simplified66.1%
Taylor expanded in a around inf 66.9%
Final simplification84.0%
(FPCore (a b) :precision binary64 (+ (pow a 4.0) -1.0))
double code(double a, double b) {
return pow(a, 4.0) + -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (a ** 4.0d0) + (-1.0d0)
end function
public static double code(double a, double b) {
return Math.pow(a, 4.0) + -1.0;
}
def code(a, b): return math.pow(a, 4.0) + -1.0
function code(a, b) return Float64((a ^ 4.0) + -1.0) end
function tmp = code(a, b) tmp = (a ^ 4.0) + -1.0; end
code[a_, b_] := N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
{a}^{4} + -1
\end{array}
Initial program 70.6%
sub-neg70.6%
+-commutative70.6%
fma-define72.6%
+-commutative72.6%
associate-*l*72.6%
cancel-sign-sub-inv72.6%
metadata-eval72.6%
fma-define72.6%
metadata-eval72.6%
Simplified72.6%
Taylor expanded in a around inf 69.7%
Final simplification69.7%
herbie shell --seed 2024080
(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))