
(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 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) (- 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 (<= (* b b) 2e-233)
(+ (* (pow a 2.0) (fma a (+ a 4.0) 4.0)) -1.0)
(+
-1.0
(+
(* (* b b) 4.0)
(+ (pow b 4.0) (fma 2.0 (* (* b a) (* b a)) (pow a 4.0)))))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e-233) {
tmp = (pow(a, 2.0) * fma(a, (a + 4.0), 4.0)) + -1.0;
} else {
tmp = -1.0 + (((b * b) * 4.0) + (pow(b, 4.0) + fma(2.0, ((b * a) * (b * a)), pow(a, 4.0))));
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e-233) tmp = Float64(Float64((a ^ 2.0) * fma(a, Float64(a + 4.0), 4.0)) + -1.0); else tmp = Float64(-1.0 + Float64(Float64(Float64(b * b) * 4.0) + Float64((b ^ 4.0) + fma(2.0, Float64(Float64(b * a) * Float64(b * a)), (a ^ 4.0))))); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e-233], N[(N[(N[Power[a, 2.0], $MachinePrecision] * N[(a * N[(a + 4.0), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(-1.0 + N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + N[(N[Power[b, 4.0], $MachinePrecision] + N[(2.0 * N[(N[(b * a), $MachinePrecision] * N[(b * a), $MachinePrecision]), $MachinePrecision] + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{-233}:\\
\;\;\;\;{a}^{2} \cdot \mathsf{fma}\left(a, a + 4, 4\right) + -1\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(\left(b \cdot b\right) \cdot 4 + \left({b}^{4} + \mathsf{fma}\left(2, \left(b \cdot a\right) \cdot \left(b \cdot a\right), {a}^{4}\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 1.99999999999999992e-233Initial program 82.2%
sub-neg82.2%
+-commutative82.2%
fma-define82.2%
+-commutative82.2%
associate-*l*82.2%
cancel-sign-sub-inv82.2%
metadata-eval82.2%
fma-define82.2%
metadata-eval82.2%
Simplified82.2%
Applied egg-rr82.2%
Taylor expanded in b around 0 82.3%
distribute-lft-in82.3%
associate-+l+82.2%
*-commutative82.2%
*-commutative82.2%
metadata-eval82.2%
pow-plus82.2%
distribute-lft-in99.9%
unpow399.9%
unpow299.9%
associate-*r*99.8%
distribute-lft-in99.9%
+-commutative99.9%
fma-define99.9%
Simplified99.9%
if 1.99999999999999992e-233 < (*.f64 b b) Initial program 77.1%
sub-neg77.1%
+-commutative77.1%
fma-define78.2%
+-commutative78.2%
associate-*l*78.2%
cancel-sign-sub-inv78.2%
metadata-eval78.2%
fma-define78.2%
metadata-eval78.2%
Simplified78.2%
Taylor expanded in a around 0 68.4%
+-commutative68.4%
distribute-lft-in68.4%
associate-*r*68.4%
*-commutative68.4%
associate-*r*68.4%
pow-sqr68.4%
metadata-eval68.4%
fma-define68.4%
unpow268.4%
unpow268.4%
swap-sqr78.4%
unpow278.4%
*-commutative78.4%
Simplified78.4%
unpow278.4%
*-commutative78.4%
*-commutative78.4%
Applied egg-rr78.4%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* b b) (* a a)) 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 4.0)))))
double code(double a, double b) {
double t_0 = pow(((b * b) + (a * a)), 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, 4.0);
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = Math.pow(((b * b) + (a * a)), 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, 4.0);
}
return tmp;
}
def code(a, b): t_0 = math.pow(((b * b) + (a * a)), 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, 4.0) return tmp
function code(a, b) t_0 = Float64((Float64(Float64(b * b) + Float64(a * a)) ^ 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 + (a ^ 4.0)); end return tmp end
function tmp_2 = code(a, b) t_0 = (((b * b) + (a * a)) ^ 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 ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[Power[N[(N[(b * b), $MachinePrecision] + N[(a * a), $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[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(b \cdot b + a \cdot a\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}^{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 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-define3.7%
+-commutative3.7%
associate-*l*3.7%
cancel-sign-sub-inv3.7%
metadata-eval3.7%
fma-define3.7%
metadata-eval3.7%
Simplified3.7%
Taylor expanded in a around inf 98.2%
Final simplification99.5%
(FPCore (a b) :precision binary64 (if (<= b 3.8e+14) (+ -1.0 (* (pow a 2.0) (+ 4.0 (* a (+ a 4.0))))) (+ -1.0 (pow b 4.0))))
double code(double a, double b) {
double tmp;
if (b <= 3.8e+14) {
tmp = -1.0 + (pow(a, 2.0) * (4.0 + (a * (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 (b <= 3.8d+14) then
tmp = (-1.0d0) + ((a ** 2.0d0) * (4.0d0 + (a * (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 (b <= 3.8e+14) {
tmp = -1.0 + (Math.pow(a, 2.0) * (4.0 + (a * (a + 4.0))));
} else {
tmp = -1.0 + Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 3.8e+14: tmp = -1.0 + (math.pow(a, 2.0) * (4.0 + (a * (a + 4.0)))) else: tmp = -1.0 + math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 3.8e+14) tmp = Float64(-1.0 + Float64((a ^ 2.0) * Float64(4.0 + Float64(a * Float64(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 (b <= 3.8e+14) tmp = -1.0 + ((a ^ 2.0) * (4.0 + (a * (a + 4.0)))); else tmp = -1.0 + (b ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 3.8e+14], N[(-1.0 + N[(N[Power[a, 2.0], $MachinePrecision] * N[(4.0 + N[(a * N[(a + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.8 \cdot 10^{+14}:\\
\;\;\;\;-1 + {a}^{2} \cdot \left(4 + a \cdot \left(a + 4\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + {b}^{4}\\
\end{array}
\end{array}
if b < 3.8e14Initial program 78.4%
sub-neg78.4%
+-commutative78.4%
fma-define78.9%
+-commutative78.9%
associate-*l*78.9%
cancel-sign-sub-inv78.9%
metadata-eval78.9%
fma-define78.9%
metadata-eval78.9%
Simplified78.9%
Taylor expanded in b around 0 64.6%
Taylor expanded in a around 0 80.1%
if 3.8e14 < b Initial program 80.2%
sub-neg80.2%
+-commutative80.2%
fma-define82.0%
+-commutative82.0%
associate-*l*82.0%
cancel-sign-sub-inv82.0%
metadata-eval82.0%
fma-define82.0%
metadata-eval82.0%
Simplified82.0%
Taylor expanded in b around inf 92.5%
Final simplification82.8%
(FPCore (a b) :precision binary64 (if (<= b 7.2e+14) (+ -1.0 (* (pow a 4.0) (+ 1.0 (/ 4.0 a)))) (+ -1.0 (pow b 4.0))))
double code(double a, double b) {
double tmp;
if (b <= 7.2e+14) {
tmp = -1.0 + (pow(a, 4.0) * (1.0 + (4.0 / a)));
} 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 <= 7.2d+14) then
tmp = (-1.0d0) + ((a ** 4.0d0) * (1.0d0 + (4.0d0 / a)))
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 <= 7.2e+14) {
tmp = -1.0 + (Math.pow(a, 4.0) * (1.0 + (4.0 / a)));
} else {
tmp = -1.0 + Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 7.2e+14: tmp = -1.0 + (math.pow(a, 4.0) * (1.0 + (4.0 / a))) else: tmp = -1.0 + math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 7.2e+14) tmp = Float64(-1.0 + Float64((a ^ 4.0) * Float64(1.0 + Float64(4.0 / a)))); else tmp = Float64(-1.0 + (b ^ 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 7.2e+14) tmp = -1.0 + ((a ^ 4.0) * (1.0 + (4.0 / a))); else tmp = -1.0 + (b ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 7.2e+14], N[(-1.0 + N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 + N[(4.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7.2 \cdot 10^{+14}:\\
\;\;\;\;-1 + {a}^{4} \cdot \left(1 + \frac{4}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + {b}^{4}\\
\end{array}
\end{array}
if b < 7.2e14Initial program 78.4%
sub-neg78.4%
+-commutative78.4%
fma-define78.9%
+-commutative78.9%
associate-*l*78.9%
cancel-sign-sub-inv78.9%
metadata-eval78.9%
fma-define78.9%
metadata-eval78.9%
Simplified78.9%
Taylor expanded in a around inf 79.2%
associate-*r/79.2%
metadata-eval79.2%
Simplified79.2%
if 7.2e14 < b Initial program 80.2%
sub-neg80.2%
+-commutative80.2%
fma-define82.0%
+-commutative82.0%
associate-*l*82.0%
cancel-sign-sub-inv82.0%
metadata-eval82.0%
fma-define82.0%
metadata-eval82.0%
Simplified82.0%
Taylor expanded in b around inf 92.5%
Final simplification82.1%
(FPCore (a b) :precision binary64 (if (<= b 2.3e+14) (+ -1.0 (* (+ a 4.0) (pow a 3.0))) (+ -1.0 (pow b 4.0))))
double code(double a, double b) {
double tmp;
if (b <= 2.3e+14) {
tmp = -1.0 + ((a + 4.0) * pow(a, 3.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 <= 2.3d+14) then
tmp = (-1.0d0) + ((a + 4.0d0) * (a ** 3.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 <= 2.3e+14) {
tmp = -1.0 + ((a + 4.0) * Math.pow(a, 3.0));
} else {
tmp = -1.0 + Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 2.3e+14: tmp = -1.0 + ((a + 4.0) * math.pow(a, 3.0)) else: tmp = -1.0 + math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 2.3e+14) tmp = Float64(-1.0 + Float64(Float64(a + 4.0) * (a ^ 3.0))); else tmp = Float64(-1.0 + (b ^ 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 2.3e+14) tmp = -1.0 + ((a + 4.0) * (a ^ 3.0)); else tmp = -1.0 + (b ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 2.3e+14], N[(-1.0 + N[(N[(a + 4.0), $MachinePrecision] * N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.3 \cdot 10^{+14}:\\
\;\;\;\;-1 + \left(a + 4\right) \cdot {a}^{3}\\
\mathbf{else}:\\
\;\;\;\;-1 + {b}^{4}\\
\end{array}
\end{array}
if b < 2.3e14Initial program 78.4%
sub-neg78.4%
+-commutative78.4%
fma-define78.9%
+-commutative78.9%
associate-*l*78.9%
cancel-sign-sub-inv78.9%
metadata-eval78.9%
fma-define78.9%
metadata-eval78.9%
Simplified78.9%
Taylor expanded in a around inf 79.2%
associate-*r/79.2%
metadata-eval79.2%
Simplified79.2%
Taylor expanded in a around 0 79.2%
if 2.3e14 < b Initial program 80.2%
sub-neg80.2%
+-commutative80.2%
fma-define82.0%
+-commutative82.0%
associate-*l*82.0%
cancel-sign-sub-inv82.0%
metadata-eval82.0%
fma-define82.0%
metadata-eval82.0%
Simplified82.0%
Taylor expanded in b around inf 92.5%
Final simplification82.1%
(FPCore (a b) :precision binary64 (if (<= b 2.9e+14) (+ -1.0 (pow a 4.0)) (+ -1.0 (pow b 4.0))))
double code(double a, double b) {
double tmp;
if (b <= 2.9e+14) {
tmp = -1.0 + 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 (b <= 2.9d+14) then
tmp = (-1.0d0) + (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 (b <= 2.9e+14) {
tmp = -1.0 + Math.pow(a, 4.0);
} else {
tmp = -1.0 + Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 2.9e+14: tmp = -1.0 + math.pow(a, 4.0) else: tmp = -1.0 + math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 2.9e+14) tmp = Float64(-1.0 + (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 (b <= 2.9e+14) tmp = -1.0 + (a ^ 4.0); else tmp = -1.0 + (b ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 2.9e+14], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.9 \cdot 10^{+14}:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + {b}^{4}\\
\end{array}
\end{array}
if b < 2.9e14Initial program 78.4%
sub-neg78.4%
+-commutative78.4%
fma-define78.9%
+-commutative78.9%
associate-*l*78.9%
cancel-sign-sub-inv78.9%
metadata-eval78.9%
fma-define78.9%
metadata-eval78.9%
Simplified78.9%
Taylor expanded in a around inf 78.1%
if 2.9e14 < b Initial program 80.2%
sub-neg80.2%
+-commutative80.2%
fma-define82.0%
+-commutative82.0%
associate-*l*82.0%
cancel-sign-sub-inv82.0%
metadata-eval82.0%
fma-define82.0%
metadata-eval82.0%
Simplified82.0%
Taylor expanded in b around inf 92.5%
Final simplification81.3%
(FPCore (a b) :precision binary64 (+ -1.0 (pow a 4.0)))
double code(double a, double b) {
return -1.0 + pow(a, 4.0);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (-1.0d0) + (a ** 4.0d0)
end function
public static double code(double a, double b) {
return -1.0 + Math.pow(a, 4.0);
}
def code(a, b): return -1.0 + math.pow(a, 4.0)
function code(a, b) return Float64(-1.0 + (a ^ 4.0)) end
function tmp = code(a, b) tmp = -1.0 + (a ^ 4.0); end
code[a_, b_] := N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 + {a}^{4}
\end{array}
Initial program 78.8%
sub-neg78.8%
+-commutative78.8%
fma-define79.6%
+-commutative79.6%
associate-*l*79.6%
cancel-sign-sub-inv79.6%
metadata-eval79.6%
fma-define79.6%
metadata-eval79.6%
Simplified79.6%
Taylor expanded in a around inf 66.8%
Final simplification66.8%
herbie shell --seed 2024095
(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))