
(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 8 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 -5e+103)
(pow a 4.0)
(+
(+ (* 4.0 (* (pow a 3.0) (+ 1.0 (/ 1.0 a)))) -1.0)
(pow (hypot a b) 4.0))))
double code(double a, double b) {
double tmp;
if (a <= -5e+103) {
tmp = pow(a, 4.0);
} else {
tmp = ((4.0 * (pow(a, 3.0) * (1.0 + (1.0 / a)))) + -1.0) + pow(hypot(a, b), 4.0);
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (a <= -5e+103) {
tmp = Math.pow(a, 4.0);
} else {
tmp = ((4.0 * (Math.pow(a, 3.0) * (1.0 + (1.0 / a)))) + -1.0) + Math.pow(Math.hypot(a, b), 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -5e+103: tmp = math.pow(a, 4.0) else: tmp = ((4.0 * (math.pow(a, 3.0) * (1.0 + (1.0 / a)))) + -1.0) + math.pow(math.hypot(a, b), 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -5e+103) tmp = a ^ 4.0; else tmp = Float64(Float64(Float64(4.0 * Float64((a ^ 3.0) * Float64(1.0 + Float64(1.0 / a)))) + -1.0) + (hypot(a, b) ^ 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -5e+103) tmp = a ^ 4.0; else tmp = ((4.0 * ((a ^ 3.0) * (1.0 + (1.0 / a)))) + -1.0) + (hypot(a, b) ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -5e+103], N[Power[a, 4.0], $MachinePrecision], N[(N[(N[(4.0 * N[(N[Power[a, 3.0], $MachinePrecision] * N[(1.0 + N[(1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision] + N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5 \cdot 10^{+103}:\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;\left(4 \cdot \left({a}^{3} \cdot \left(1 + \frac{1}{a}\right)\right) + -1\right) + {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}\\
\end{array}
\end{array}
if a < -5e103Initial program 0.0%
associate--l+0.0%
+-commutative0.0%
+-commutative0.0%
sub-neg0.0%
associate-+l+0.0%
+-commutative0.0%
fma-define0.0%
Simplified0.0%
Applied egg-rr0.0%
Taylor expanded in a around inf 100.0%
if -5e103 < a Initial program 89.6%
associate--l+89.7%
+-commutative89.7%
+-commutative89.7%
sub-neg89.7%
associate-+l+89.6%
+-commutative89.6%
fma-define89.6%
Simplified91.6%
Applied egg-rr91.6%
Taylor expanded in a around inf 99.3%
*-un-lft-identity99.3%
pow-pow99.4%
metadata-eval99.4%
Applied egg-rr99.4%
*-lft-identity99.4%
Simplified99.4%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (+ a 1.0)) (* (* b b) (- 1.0 (* a 3.0))))))))
(if (<= t_0 INFINITY)
(+ -1.0 t_0)
(+ -1.0 (* (pow a 2.0) (+ 4.0 (* a (+ a 4.0))))))))
double code(double a, double b) {
double t_0 = pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = -1.0 + t_0;
} else {
tmp = -1.0 + (pow(a, 2.0) * (4.0 + (a * (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) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = -1.0 + t_0;
} else {
tmp = -1.0 + (Math.pow(a, 2.0) * (4.0 + (a * (a + 4.0))));
}
return tmp;
}
def code(a, b): t_0 = math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0))))) tmp = 0 if t_0 <= math.inf: tmp = -1.0 + t_0 else: tmp = -1.0 + (math.pow(a, 2.0) * (4.0 + (a * (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(a + 1.0)) + Float64(Float64(b * b) * Float64(1.0 - Float64(a * 3.0)))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(-1.0 + t_0); else tmp = Float64(-1.0 + Float64((a ^ 2.0) * Float64(4.0 + Float64(a * Float64(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) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0))))); tmp = 0.0; if (t_0 <= Inf) tmp = -1.0 + t_0; else tmp = -1.0 + ((a ^ 2.0) * (4.0 + (a * (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[(a + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(-1.0 + t$95$0), $MachinePrecision], N[(-1.0 + N[(N[Power[a, 2.0], $MachinePrecision] * N[(4.0 + N[(a * N[(a + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right)\\
\mathbf{if}\;t\_0 \leq \infty:\\
\;\;\;\;-1 + t\_0\\
\mathbf{else}:\\
\;\;\;\;-1 + {a}^{2} \cdot \left(4 + a \cdot \left(a + 4\right)\right)\\
\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 1 binary64) (*.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 1 binary64) (*.f64 #s(literal 3 binary64) a)))))) Initial program 0.0%
sub-neg0.0%
+-commutative0.0%
fma-define2.8%
+-commutative2.8%
associate-*l*2.8%
cancel-sign-sub-inv2.8%
metadata-eval2.8%
fma-define2.8%
metadata-eval2.8%
Simplified2.8%
Taylor expanded in b around 0 24.2%
Taylor expanded in a around 0 94.6%
Final simplification98.4%
(FPCore (a b) :precision binary64 (if (<= b 8000.0) (+ (pow a 4.0) -1.0) (if (or (<= b 2.1e+34) (not (<= b 4.9e+64))) (pow b 4.0) (pow a 4.0))))
double code(double a, double b) {
double tmp;
if (b <= 8000.0) {
tmp = pow(a, 4.0) + -1.0;
} else if ((b <= 2.1e+34) || !(b <= 4.9e+64)) {
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 <= 8000.0d0) then
tmp = (a ** 4.0d0) + (-1.0d0)
else if ((b <= 2.1d+34) .or. (.not. (b <= 4.9d+64))) 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 <= 8000.0) {
tmp = Math.pow(a, 4.0) + -1.0;
} else if ((b <= 2.1e+34) || !(b <= 4.9e+64)) {
tmp = Math.pow(b, 4.0);
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 8000.0: tmp = math.pow(a, 4.0) + -1.0 elif (b <= 2.1e+34) or not (b <= 4.9e+64): tmp = math.pow(b, 4.0) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 8000.0) tmp = Float64((a ^ 4.0) + -1.0); elseif ((b <= 2.1e+34) || !(b <= 4.9e+64)) tmp = b ^ 4.0; else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 8000.0) tmp = (a ^ 4.0) + -1.0; elseif ((b <= 2.1e+34) || ~((b <= 4.9e+64))) tmp = b ^ 4.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 8000.0], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], If[Or[LessEqual[b, 2.1e+34], N[Not[LessEqual[b, 4.9e+64]], $MachinePrecision]], N[Power[b, 4.0], $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 8000:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{elif}\;b \leq 2.1 \cdot 10^{+34} \lor \neg \left(b \leq 4.9 \cdot 10^{+64}\right):\\
\;\;\;\;{b}^{4}\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if b < 8e3Initial program 74.7%
sub-neg74.7%
+-commutative74.7%
fma-define75.2%
+-commutative75.2%
associate-*l*75.2%
cancel-sign-sub-inv75.2%
metadata-eval75.2%
fma-define75.2%
metadata-eval75.2%
Simplified75.2%
Taylor expanded in a around inf 79.3%
if 8e3 < b < 2.10000000000000017e34 or 4.9000000000000003e64 < b Initial program 64.1%
associate--l+64.1%
+-commutative64.1%
+-commutative64.1%
sub-neg64.1%
associate-+l+64.1%
+-commutative64.1%
fma-define64.1%
Simplified67.9%
Applied egg-rr67.9%
Taylor expanded in b around inf 99.3%
if 2.10000000000000017e34 < b < 4.9000000000000003e64Initial program 50.0%
associate--l+50.0%
+-commutative50.0%
+-commutative50.0%
sub-neg50.0%
associate-+l+50.0%
+-commutative50.0%
fma-define50.0%
Simplified50.0%
Applied egg-rr50.0%
Taylor expanded in a around inf 75.6%
Final simplification83.4%
(FPCore (a b) :precision binary64 (if (or (<= a -1.6e+57) (not (<= a 3.2e+40))) (pow a 4.0) (+ -1.0 (pow b 4.0))))
double code(double a, double b) {
double tmp;
if ((a <= -1.6e+57) || !(a <= 3.2e+40)) {
tmp = pow(a, 4.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 ((a <= (-1.6d+57)) .or. (.not. (a <= 3.2d+40))) then
tmp = a ** 4.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 ((a <= -1.6e+57) || !(a <= 3.2e+40)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = -1.0 + Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -1.6e+57) or not (a <= 3.2e+40): tmp = math.pow(a, 4.0) else: tmp = -1.0 + math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if ((a <= -1.6e+57) || !(a <= 3.2e+40)) tmp = a ^ 4.0; else tmp = Float64(-1.0 + (b ^ 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -1.6e+57) || ~((a <= 3.2e+40))) tmp = a ^ 4.0; else tmp = -1.0 + (b ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -1.6e+57], N[Not[LessEqual[a, 3.2e+40]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[(-1.0 + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.6 \cdot 10^{+57} \lor \neg \left(a \leq 3.2 \cdot 10^{+40}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + {b}^{4}\\
\end{array}
\end{array}
if a < -1.60000000000000015e57 or 3.19999999999999981e40 < a Initial program 41.1%
associate--l+41.1%
+-commutative41.1%
+-commutative41.1%
sub-neg41.1%
associate-+l+41.1%
+-commutative41.1%
fma-define41.1%
Simplified44.7%
Applied egg-rr44.7%
Taylor expanded in a around inf 99.2%
if -1.60000000000000015e57 < a < 3.19999999999999981e40Initial program 97.0%
sub-neg97.0%
+-commutative97.0%
fma-define97.0%
+-commutative97.0%
associate-*l*97.0%
cancel-sign-sub-inv97.0%
metadata-eval97.0%
fma-define97.0%
metadata-eval97.0%
Simplified97.0%
Taylor expanded in b around inf 93.0%
Final simplification95.8%
(FPCore (a b) :precision binary64 (if (or (<= a -9.8e-8) (not (<= a 1.95))) (pow a 4.0) (* (+ 1.0 (* a 2.0)) (+ -1.0 (* a 2.0)))))
double code(double a, double b) {
double tmp;
if ((a <= -9.8e-8) || !(a <= 1.95)) {
tmp = pow(a, 4.0);
} else {
tmp = (1.0 + (a * 2.0)) * (-1.0 + (a * 2.0));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a <= (-9.8d-8)) .or. (.not. (a <= 1.95d0))) then
tmp = a ** 4.0d0
else
tmp = (1.0d0 + (a * 2.0d0)) * ((-1.0d0) + (a * 2.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -9.8e-8) || !(a <= 1.95)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = (1.0 + (a * 2.0)) * (-1.0 + (a * 2.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -9.8e-8) or not (a <= 1.95): tmp = math.pow(a, 4.0) else: tmp = (1.0 + (a * 2.0)) * (-1.0 + (a * 2.0)) return tmp
function code(a, b) tmp = 0.0 if ((a <= -9.8e-8) || !(a <= 1.95)) tmp = a ^ 4.0; else tmp = Float64(Float64(1.0 + Float64(a * 2.0)) * Float64(-1.0 + Float64(a * 2.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -9.8e-8) || ~((a <= 1.95))) tmp = a ^ 4.0; else tmp = (1.0 + (a * 2.0)) * (-1.0 + (a * 2.0)); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -9.8e-8], N[Not[LessEqual[a, 1.95]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[(N[(1.0 + N[(a * 2.0), $MachinePrecision]), $MachinePrecision] * N[(-1.0 + N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -9.8 \cdot 10^{-8} \lor \neg \left(a \leq 1.95\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + a \cdot 2\right) \cdot \left(-1 + a \cdot 2\right)\\
\end{array}
\end{array}
if a < -9.8000000000000004e-8 or 1.94999999999999996 < a Initial program 47.6%
associate--l+47.6%
+-commutative47.6%
+-commutative47.6%
sub-neg47.6%
associate-+l+47.6%
+-commutative47.6%
fma-define47.6%
Simplified50.5%
Applied egg-rr50.5%
Taylor expanded in a around inf 88.0%
if -9.8000000000000004e-8 < a < 1.94999999999999996Initial program 99.9%
sub-neg99.9%
+-commutative99.9%
fma-define99.9%
+-commutative99.9%
associate-*l*99.9%
cancel-sign-sub-inv99.9%
metadata-eval99.9%
fma-define99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in b around 0 52.7%
Taylor expanded in a around 0 51.9%
add-sqr-sqrt51.9%
difference-of-sqr-151.9%
*-commutative51.9%
sqrt-prod51.9%
sqrt-pow151.8%
metadata-eval51.8%
pow151.8%
metadata-eval51.8%
*-commutative51.8%
sqrt-prod51.8%
sqrt-pow151.9%
metadata-eval51.9%
pow151.9%
metadata-eval51.9%
Applied egg-rr51.9%
Final simplification71.1%
(FPCore (a b) :precision binary64 (if (<= b 7000.0) (* (+ 1.0 (* a 2.0)) (+ -1.0 (* a 2.0))) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if (b <= 7000.0) {
tmp = (1.0 + (a * 2.0)) * (-1.0 + (a * 2.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 <= 7000.0d0) then
tmp = (1.0d0 + (a * 2.0d0)) * ((-1.0d0) + (a * 2.0d0))
else
tmp = b ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 7000.0) {
tmp = (1.0 + (a * 2.0)) * (-1.0 + (a * 2.0));
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 7000.0: tmp = (1.0 + (a * 2.0)) * (-1.0 + (a * 2.0)) else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 7000.0) tmp = Float64(Float64(1.0 + Float64(a * 2.0)) * Float64(-1.0 + Float64(a * 2.0))); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 7000.0) tmp = (1.0 + (a * 2.0)) * (-1.0 + (a * 2.0)); else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 7000.0], N[(N[(1.0 + N[(a * 2.0), $MachinePrecision]), $MachinePrecision] * N[(-1.0 + N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7000:\\
\;\;\;\;\left(1 + a \cdot 2\right) \cdot \left(-1 + a \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 7e3Initial program 74.7%
sub-neg74.7%
+-commutative74.7%
fma-define75.2%
+-commutative75.2%
associate-*l*75.2%
cancel-sign-sub-inv75.2%
metadata-eval75.2%
fma-define75.2%
metadata-eval75.2%
Simplified75.2%
Taylor expanded in b around 0 61.4%
Taylor expanded in a around 0 58.6%
add-sqr-sqrt58.6%
difference-of-sqr-158.6%
*-commutative58.6%
sqrt-prod58.6%
sqrt-pow142.4%
metadata-eval42.4%
pow142.4%
metadata-eval42.4%
*-commutative42.4%
sqrt-prod42.4%
sqrt-pow158.6%
metadata-eval58.6%
pow158.6%
metadata-eval58.6%
Applied egg-rr58.6%
if 7e3 < b Initial program 63.1%
associate--l+63.1%
+-commutative63.1%
+-commutative63.1%
sub-neg63.1%
associate-+l+63.1%
+-commutative63.1%
fma-define63.1%
Simplified66.6%
Applied egg-rr66.6%
Taylor expanded in b around inf 94.4%
Final simplification66.5%
(FPCore (a b) :precision binary64 (* (+ 1.0 (* a 2.0)) (+ -1.0 (* a 2.0))))
double code(double a, double b) {
return (1.0 + (a * 2.0)) * (-1.0 + (a * 2.0));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (1.0d0 + (a * 2.0d0)) * ((-1.0d0) + (a * 2.0d0))
end function
public static double code(double a, double b) {
return (1.0 + (a * 2.0)) * (-1.0 + (a * 2.0));
}
def code(a, b): return (1.0 + (a * 2.0)) * (-1.0 + (a * 2.0))
function code(a, b) return Float64(Float64(1.0 + Float64(a * 2.0)) * Float64(-1.0 + Float64(a * 2.0))) end
function tmp = code(a, b) tmp = (1.0 + (a * 2.0)) * (-1.0 + (a * 2.0)); end
code[a_, b_] := N[(N[(1.0 + N[(a * 2.0), $MachinePrecision]), $MachinePrecision] * N[(-1.0 + N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 + a \cdot 2\right) \cdot \left(-1 + a \cdot 2\right)
\end{array}
Initial program 72.1%
sub-neg72.1%
+-commutative72.1%
fma-define72.9%
+-commutative72.9%
associate-*l*72.9%
cancel-sign-sub-inv72.9%
metadata-eval72.9%
fma-define72.9%
metadata-eval72.9%
Simplified72.9%
Taylor expanded in b around 0 52.6%
Taylor expanded in a around 0 51.4%
add-sqr-sqrt51.4%
difference-of-sqr-151.4%
*-commutative51.4%
sqrt-prod51.4%
sqrt-pow134.8%
metadata-eval34.8%
pow134.8%
metadata-eval34.8%
*-commutative34.8%
sqrt-prod34.8%
sqrt-pow151.4%
metadata-eval51.4%
pow151.4%
metadata-eval51.4%
Applied egg-rr51.4%
Final simplification51.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 72.1%
sub-neg72.1%
+-commutative72.1%
fma-define72.9%
+-commutative72.9%
associate-*l*72.9%
cancel-sign-sub-inv72.9%
metadata-eval72.9%
fma-define72.9%
metadata-eval72.9%
Simplified72.9%
Taylor expanded in a around inf 70.9%
Taylor expanded in a around 0 24.6%
herbie shell --seed 2024083
(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))