
(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 (<= a 3.5e+64)
(+
(* (hypot a b) (pow (hypot a b) 3.0))
(+ (* 4.0 (* (pow a 2.0) (- 1.0 a))) -1.0))
(pow a 4.0)))
double code(double a, double b) {
double tmp;
if (a <= 3.5e+64) {
tmp = (hypot(a, b) * pow(hypot(a, b), 3.0)) + ((4.0 * (pow(a, 2.0) * (1.0 - a))) + -1.0);
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (a <= 3.5e+64) {
tmp = (Math.hypot(a, b) * Math.pow(Math.hypot(a, b), 3.0)) + ((4.0 * (Math.pow(a, 2.0) * (1.0 - a))) + -1.0);
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= 3.5e+64: tmp = (math.hypot(a, b) * math.pow(math.hypot(a, b), 3.0)) + ((4.0 * (math.pow(a, 2.0) * (1.0 - a))) + -1.0) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= 3.5e+64) tmp = Float64(Float64(hypot(a, b) * (hypot(a, b) ^ 3.0)) + Float64(Float64(4.0 * Float64((a ^ 2.0) * Float64(1.0 - a))) + -1.0)); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= 3.5e+64) tmp = (hypot(a, b) * (hypot(a, b) ^ 3.0)) + ((4.0 * ((a ^ 2.0) * (1.0 - a))) + -1.0); else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, 3.5e+64], N[(N[(N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision] * N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(4.0 * N[(N[Power[a, 2.0], $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 3.5 \cdot 10^{+64}:\\
\;\;\;\;\mathsf{hypot}\left(a, b\right) \cdot {\left(\mathsf{hypot}\left(a, b\right)\right)}^{3} + \left(4 \cdot \left({a}^{2} \cdot \left(1 - a\right)\right) + -1\right)\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < 3.4999999999999999e64Initial program 89.0%
associate--l+89.0%
fma-def89.0%
distribute-rgt-in89.0%
sqr-neg89.0%
distribute-rgt-in89.0%
fma-def89.0%
sqr-neg89.0%
+-commutative89.0%
Simplified89.0%
fma-def89.0%
add-cbrt-cube80.1%
pow380.1%
pow-pow80.2%
fma-def80.2%
add-sqr-sqrt80.2%
pow280.2%
fma-def80.2%
hypot-def80.2%
metadata-eval80.2%
Applied egg-rr80.2%
pow1/379.8%
pow-pow89.0%
metadata-eval89.0%
pow289.0%
unpow289.0%
associate-*r*89.0%
pow-plus89.0%
metadata-eval89.0%
Applied egg-rr89.0%
Taylor expanded in b around 0 98.7%
if 3.4999999999999999e64 < a Initial program 13.3%
associate--l+13.3%
fma-def13.3%
distribute-rgt-in13.3%
sqr-neg13.3%
distribute-rgt-in13.3%
fma-def20.0%
sqr-neg20.0%
+-commutative20.0%
Simplified20.0%
Taylor expanded in a around inf 100.0%
Final simplification98.9%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (- 1.0 a) (* a 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 * (((1.0 - a) * (a * 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 * (((1.0 - a) * (a * 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 * (((1.0 - a) * (a * 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(1.0 - a) * Float64(a * 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 * (((1.0 - a) * (a * 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[(1.0 - a), $MachinePrecision] * N[(a * 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(1 - a\right) \cdot \left(a \cdot 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)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) < +inf.0Initial program 99.9%
if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) Initial program 0.0%
associate--l+0.0%
fma-def0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
fma-def4.8%
sqr-neg4.8%
+-commutative4.8%
Simplified4.8%
Taylor expanded in a around inf 92.4%
Final simplification98.1%
(FPCore (a b)
:precision binary64
(if (<= b 9.2e-257)
(pow a 4.0)
(if (<= b 1.6e-179)
-1.0
(if (<= b 5.5e-17) (pow a 4.0) (if (<= b 0.28) -1.0 (pow b 4.0))))))
double code(double a, double b) {
double tmp;
if (b <= 9.2e-257) {
tmp = pow(a, 4.0);
} else if (b <= 1.6e-179) {
tmp = -1.0;
} else if (b <= 5.5e-17) {
tmp = pow(a, 4.0);
} else if (b <= 0.28) {
tmp = -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 <= 9.2d-257) then
tmp = a ** 4.0d0
else if (b <= 1.6d-179) then
tmp = -1.0d0
else if (b <= 5.5d-17) then
tmp = a ** 4.0d0
else if (b <= 0.28d0) then
tmp = -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 <= 9.2e-257) {
tmp = Math.pow(a, 4.0);
} else if (b <= 1.6e-179) {
tmp = -1.0;
} else if (b <= 5.5e-17) {
tmp = Math.pow(a, 4.0);
} else if (b <= 0.28) {
tmp = -1.0;
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 9.2e-257: tmp = math.pow(a, 4.0) elif b <= 1.6e-179: tmp = -1.0 elif b <= 5.5e-17: tmp = math.pow(a, 4.0) elif b <= 0.28: tmp = -1.0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 9.2e-257) tmp = a ^ 4.0; elseif (b <= 1.6e-179) tmp = -1.0; elseif (b <= 5.5e-17) tmp = a ^ 4.0; elseif (b <= 0.28) tmp = -1.0; else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 9.2e-257) tmp = a ^ 4.0; elseif (b <= 1.6e-179) tmp = -1.0; elseif (b <= 5.5e-17) tmp = a ^ 4.0; elseif (b <= 0.28) tmp = -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 9.2e-257], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[b, 1.6e-179], -1.0, If[LessEqual[b, 5.5e-17], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[b, 0.28], -1.0, N[Power[b, 4.0], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 9.2 \cdot 10^{-257}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;b \leq 1.6 \cdot 10^{-179}:\\
\;\;\;\;-1\\
\mathbf{elif}\;b \leq 5.5 \cdot 10^{-17}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;b \leq 0.28:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 9.2000000000000001e-257 or 1.6e-179 < b < 5.50000000000000001e-17Initial program 77.2%
associate--l+77.2%
fma-def77.2%
distribute-rgt-in77.2%
sqr-neg77.2%
distribute-rgt-in77.2%
fma-def78.5%
sqr-neg78.5%
+-commutative78.5%
Simplified78.5%
Taylor expanded in a around inf 50.1%
if 9.2000000000000001e-257 < b < 1.6e-179 or 5.50000000000000001e-17 < b < 0.28000000000000003Initial program 95.7%
associate--l+95.7%
fma-def95.7%
distribute-rgt-in95.7%
sqr-neg95.7%
distribute-rgt-in95.7%
fma-def95.7%
sqr-neg95.7%
+-commutative95.7%
Simplified95.7%
Taylor expanded in a around 0 74.0%
Taylor expanded in b around 0 72.7%
if 0.28000000000000003 < b Initial program 66.5%
associate--l+66.5%
fma-def66.5%
distribute-rgt-in66.5%
sqr-neg66.5%
distribute-rgt-in66.5%
fma-def67.8%
sqr-neg67.8%
+-commutative67.8%
Simplified67.8%
Taylor expanded in b around inf 87.3%
Final simplification63.5%
(FPCore (a b) :precision binary64 (if (<= b 610.0) (+ (pow a 4.0) -1.0) (if (or (<= b 1.6e+40) (not (<= b 1.2e+50))) (pow b 4.0) (pow a 4.0))))
double code(double a, double b) {
double tmp;
if (b <= 610.0) {
tmp = pow(a, 4.0) + -1.0;
} else if ((b <= 1.6e+40) || !(b <= 1.2e+50)) {
tmp = pow(b, 4.0);
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 610.0d0) then
tmp = (a ** 4.0d0) + (-1.0d0)
else if ((b <= 1.6d+40) .or. (.not. (b <= 1.2d+50))) then
tmp = b ** 4.0d0
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 610.0) {
tmp = Math.pow(a, 4.0) + -1.0;
} else if ((b <= 1.6e+40) || !(b <= 1.2e+50)) {
tmp = Math.pow(b, 4.0);
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 610.0: tmp = math.pow(a, 4.0) + -1.0 elif (b <= 1.6e+40) or not (b <= 1.2e+50): tmp = math.pow(b, 4.0) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 610.0) tmp = Float64((a ^ 4.0) + -1.0); elseif ((b <= 1.6e+40) || !(b <= 1.2e+50)) tmp = b ^ 4.0; else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 610.0) tmp = (a ^ 4.0) + -1.0; elseif ((b <= 1.6e+40) || ~((b <= 1.2e+50))) tmp = b ^ 4.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 610.0], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], If[Or[LessEqual[b, 1.6e+40], N[Not[LessEqual[b, 1.2e+50]], $MachinePrecision]], N[Power[b, 4.0], $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 610:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{elif}\;b \leq 1.6 \cdot 10^{+40} \lor \neg \left(b \leq 1.2 \cdot 10^{+50}\right):\\
\;\;\;\;{b}^{4}\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if b < 610Initial program 79.9%
Taylor expanded in b around 0 63.0%
fma-def63.0%
sub-neg63.0%
distribute-lft-in63.0%
distribute-rgt-neg-in63.0%
unpow263.0%
unpow363.1%
unsub-neg63.1%
*-rgt-identity63.1%
Simplified63.1%
fma-udef63.1%
+-commutative63.1%
Applied egg-rr63.1%
Taylor expanded in a around inf 77.5%
if 610 < b < 1.5999999999999999e40 or 1.2000000000000001e50 < b Initial program 66.1%
associate--l+66.1%
fma-def66.1%
distribute-rgt-in66.1%
sqr-neg66.1%
distribute-rgt-in66.1%
fma-def67.5%
sqr-neg67.5%
+-commutative67.5%
Simplified67.5%
Taylor expanded in b around inf 95.2%
if 1.5999999999999999e40 < b < 1.2000000000000001e50Initial program 60.0%
associate--l+60.0%
fma-def60.0%
distribute-rgt-in60.0%
sqr-neg60.0%
distribute-rgt-in60.0%
fma-def60.0%
sqr-neg60.0%
+-commutative60.0%
Simplified60.0%
Taylor expanded in a around inf 100.0%
Final simplification82.9%
(FPCore (a b) :precision binary64 (if (<= b 610.0) (+ (+ (pow a 4.0) (* 4.0 (* a a))) -1.0) (if (or (<= b 1.25e+38) (not (<= b 3.8e+49))) (pow b 4.0) (pow a 4.0))))
double code(double a, double b) {
double tmp;
if (b <= 610.0) {
tmp = (pow(a, 4.0) + (4.0 * (a * a))) + -1.0;
} else if ((b <= 1.25e+38) || !(b <= 3.8e+49)) {
tmp = pow(b, 4.0);
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 610.0d0) then
tmp = ((a ** 4.0d0) + (4.0d0 * (a * a))) + (-1.0d0)
else if ((b <= 1.25d+38) .or. (.not. (b <= 3.8d+49))) then
tmp = b ** 4.0d0
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 610.0) {
tmp = (Math.pow(a, 4.0) + (4.0 * (a * a))) + -1.0;
} else if ((b <= 1.25e+38) || !(b <= 3.8e+49)) {
tmp = Math.pow(b, 4.0);
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 610.0: tmp = (math.pow(a, 4.0) + (4.0 * (a * a))) + -1.0 elif (b <= 1.25e+38) or not (b <= 3.8e+49): tmp = math.pow(b, 4.0) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 610.0) tmp = Float64(Float64((a ^ 4.0) + Float64(4.0 * Float64(a * a))) + -1.0); elseif ((b <= 1.25e+38) || !(b <= 3.8e+49)) tmp = b ^ 4.0; else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 610.0) tmp = ((a ^ 4.0) + (4.0 * (a * a))) + -1.0; elseif ((b <= 1.25e+38) || ~((b <= 3.8e+49))) tmp = b ^ 4.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 610.0], N[(N[(N[Power[a, 4.0], $MachinePrecision] + N[(4.0 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[Or[LessEqual[b, 1.25e+38], N[Not[LessEqual[b, 3.8e+49]], $MachinePrecision]], N[Power[b, 4.0], $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 610:\\
\;\;\;\;\left({a}^{4} + 4 \cdot \left(a \cdot a\right)\right) + -1\\
\mathbf{elif}\;b \leq 1.25 \cdot 10^{+38} \lor \neg \left(b \leq 3.8 \cdot 10^{+49}\right):\\
\;\;\;\;{b}^{4}\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if b < 610Initial program 79.9%
Taylor expanded in b around 0 63.0%
fma-def63.0%
sub-neg63.0%
distribute-lft-in63.0%
distribute-rgt-neg-in63.0%
unpow263.0%
unpow363.1%
unsub-neg63.1%
*-rgt-identity63.1%
Simplified63.1%
fma-udef63.1%
+-commutative63.1%
Applied egg-rr63.1%
cube-mult63.0%
unpow263.0%
*-un-lft-identity63.0%
distribute-rgt-out--63.0%
*-commutative63.0%
unpow263.0%
associate-*r*63.0%
Applied egg-rr63.0%
Taylor expanded in a around 0 77.7%
if 610 < b < 1.24999999999999992e38 or 3.7999999999999999e49 < b Initial program 66.1%
associate--l+66.1%
fma-def66.1%
distribute-rgt-in66.1%
sqr-neg66.1%
distribute-rgt-in66.1%
fma-def67.5%
sqr-neg67.5%
+-commutative67.5%
Simplified67.5%
Taylor expanded in b around inf 95.2%
if 1.24999999999999992e38 < b < 3.7999999999999999e49Initial program 60.0%
associate--l+60.0%
fma-def60.0%
distribute-rgt-in60.0%
sqr-neg60.0%
distribute-rgt-in60.0%
fma-def60.0%
sqr-neg60.0%
+-commutative60.0%
Simplified60.0%
Taylor expanded in a around inf 100.0%
Final simplification83.0%
(FPCore (a b) :precision binary64 (if (or (<= a -0.0065) (not (<= a 3.9e-7))) (pow a 4.0) -1.0))
double code(double a, double b) {
double tmp;
if ((a <= -0.0065) || !(a <= 3.9e-7)) {
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 <= (-0.0065d0)) .or. (.not. (a <= 3.9d-7))) 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 <= -0.0065) || !(a <= 3.9e-7)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -0.0065) or not (a <= 3.9e-7): tmp = math.pow(a, 4.0) else: tmp = -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -0.0065) || !(a <= 3.9e-7)) tmp = a ^ 4.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -0.0065) || ~((a <= 3.9e-7))) tmp = a ^ 4.0; else tmp = -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -0.0065], N[Not[LessEqual[a, 3.9e-7]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], -1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.0065 \lor \neg \left(a \leq 3.9 \cdot 10^{-7}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if a < -0.0064999999999999997 or 3.90000000000000025e-7 < a Initial program 53.6%
associate--l+53.6%
fma-def53.6%
distribute-rgt-in53.6%
sqr-neg53.6%
distribute-rgt-in53.6%
fma-def55.9%
sqr-neg55.9%
+-commutative55.9%
Simplified55.9%
Taylor expanded in a around inf 83.1%
if -0.0064999999999999997 < a < 3.90000000000000025e-7Initial program 99.9%
associate--l+99.9%
fma-def99.9%
distribute-rgt-in99.9%
sqr-neg99.9%
distribute-rgt-in99.9%
fma-def99.9%
sqr-neg99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in a around 0 99.7%
Taylor expanded in b around 0 47.6%
Final simplification66.2%
(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 75.7%
associate--l+75.7%
fma-def75.7%
distribute-rgt-in75.7%
sqr-neg75.7%
distribute-rgt-in75.7%
fma-def76.9%
sqr-neg76.9%
+-commutative76.9%
Simplified76.9%
Taylor expanded in a around 0 69.8%
Taylor expanded in b around 0 23.1%
Final simplification23.1%
herbie shell --seed 2024018
(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))