
(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 (* (* b b) (+ a 3.0))))
(if (<=
(+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (- 1.0 a)) t_0)))
INFINITY)
(+
(+
(+ (pow b 4.0) (fma 2.0 (* b (* a (* a b))) (pow a 4.0)))
(* 4.0 (fma (* a a) (- 1.0 a) t_0)))
-1.0)
(+ (pow a 4.0) -1.0))))
double code(double a, double b) {
double t_0 = (b * b) * (a + 3.0);
double tmp;
if ((pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + t_0))) <= ((double) INFINITY)) {
tmp = ((pow(b, 4.0) + fma(2.0, (b * (a * (a * b))), pow(a, 4.0))) + (4.0 * fma((a * a), (1.0 - a), t_0))) + -1.0;
} else {
tmp = pow(a, 4.0) + -1.0;
}
return tmp;
}
function code(a, b) t_0 = Float64(Float64(b * b) * Float64(a + 3.0)) tmp = 0.0 if (Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + t_0))) <= Inf) tmp = Float64(Float64(Float64((b ^ 4.0) + fma(2.0, Float64(b * Float64(a * Float64(a * b))), (a ^ 4.0))) + Float64(4.0 * fma(Float64(a * a), Float64(1.0 - a), t_0))) + -1.0); else tmp = Float64((a ^ 4.0) + -1.0); end return tmp end
code[a_, b_] := Block[{t$95$0 = N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[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] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[(N[Power[b, 4.0], $MachinePrecision] + N[(2.0 * N[(b * N[(a * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(4.0 * N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(b \cdot b\right) \cdot \left(a + 3\right)\\
\mathbf{if}\;{\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + t_0\right) \leq \infty:\\
\;\;\;\;\left(\left({b}^{4} + \mathsf{fma}\left(2, b \cdot \left(a \cdot \left(a \cdot b\right)\right), {a}^{4}\right)\right) + 4 \cdot \mathsf{fma}\left(a \cdot a, 1 - a, t_0\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} + -1\\
\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.8%
sub-neg99.8%
sqr-neg99.8%
+-commutative99.8%
sqr-neg99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in a around 0 90.5%
associate-+r+90.5%
+-commutative90.5%
fma-def90.5%
unpow290.5%
unpow290.5%
swap-sqr100.0%
unpow2100.0%
*-commutative100.0%
Simplified100.0%
unpow2100.0%
*-commutative100.0%
associate-*r*100.0%
Applied egg-rr100.0%
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%
sub-neg0.0%
sqr-neg0.0%
+-commutative0.0%
sqr-neg0.0%
+-commutative0.0%
Simplified3.0%
Taylor expanded in a around inf 95.7%
Final simplification98.9%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* (* b b) (+ a 3.0))))
(if (<=
(+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (- 1.0 a)) t_0)))
INFINITY)
(+ (pow (hypot a b) 4.0) (fma 4.0 (fma a (* a (- 1.0 a)) t_0) -1.0))
(+ (pow a 4.0) -1.0))))
double code(double a, double b) {
double t_0 = (b * b) * (a + 3.0);
double tmp;
if ((pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + t_0))) <= ((double) INFINITY)) {
tmp = pow(hypot(a, b), 4.0) + fma(4.0, fma(a, (a * (1.0 - a)), t_0), -1.0);
} else {
tmp = pow(a, 4.0) + -1.0;
}
return tmp;
}
function code(a, b) t_0 = Float64(Float64(b * b) * Float64(a + 3.0)) tmp = 0.0 if (Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + t_0))) <= Inf) tmp = Float64((hypot(a, b) ^ 4.0) + fma(4.0, fma(a, Float64(a * Float64(1.0 - a)), t_0), -1.0)); else tmp = Float64((a ^ 4.0) + -1.0); end return tmp end
code[a_, b_] := Block[{t$95$0 = N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[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] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + N[(4.0 * N[(a * N[(a * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(b \cdot b\right) \cdot \left(a + 3\right)\\
\mathbf{if}\;{\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + t_0\right) \leq \infty:\\
\;\;\;\;{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(4, \mathsf{fma}\left(a, a \cdot \left(1 - a\right), t_0\right), -1\right)\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} + -1\\
\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.8%
associate--l+99.8%
sqr-pow99.8%
Simplified100.0%
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%
sub-neg0.0%
sqr-neg0.0%
+-commutative0.0%
sqr-neg0.0%
+-commutative0.0%
Simplified3.0%
Taylor expanded in a around inf 95.7%
Final simplification98.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) -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, 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, 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, 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((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 ^ 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[Power[a, 4.0], $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}^{4} + -1\\
\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.8%
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%
sub-neg0.0%
sqr-neg0.0%
+-commutative0.0%
sqr-neg0.0%
+-commutative0.0%
Simplified3.0%
Taylor expanded in a around inf 95.7%
Final simplification98.8%
(FPCore (a b) :precision binary64 (if (<= b 2.5e+18) (+ -1.0 (* (pow a 3.0) (+ a -4.0))) (+ (pow b 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if (b <= 2.5e+18) {
tmp = -1.0 + (pow(a, 3.0) * (a + -4.0));
} else {
tmp = pow(b, 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 <= 2.5d+18) then
tmp = (-1.0d0) + ((a ** 3.0d0) * (a + (-4.0d0)))
else
tmp = (b ** 4.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 2.5e+18) {
tmp = -1.0 + (Math.pow(a, 3.0) * (a + -4.0));
} else {
tmp = Math.pow(b, 4.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 2.5e+18: tmp = -1.0 + (math.pow(a, 3.0) * (a + -4.0)) else: tmp = math.pow(b, 4.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (b <= 2.5e+18) tmp = Float64(-1.0 + Float64((a ^ 3.0) * Float64(a + -4.0))); else tmp = Float64((b ^ 4.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 2.5e+18) tmp = -1.0 + ((a ^ 3.0) * (a + -4.0)); else tmp = (b ^ 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 2.5e+18], N[(-1.0 + N[(N[Power[a, 3.0], $MachinePrecision] * N[(a + -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.5 \cdot 10^{+18}:\\
\;\;\;\;-1 + {a}^{3} \cdot \left(a + -4\right)\\
\mathbf{else}:\\
\;\;\;\;{b}^{4} + -1\\
\end{array}
\end{array}
if b < 2.5e18Initial program 78.1%
sub-neg78.1%
sqr-neg78.1%
+-commutative78.1%
sqr-neg78.1%
+-commutative78.1%
Simplified79.0%
Taylor expanded in a around 0 72.0%
associate-+r+72.0%
+-commutative72.0%
fma-def72.0%
unpow272.0%
unpow272.0%
swap-sqr79.1%
unpow279.1%
*-commutative79.1%
Simplified79.1%
unpow279.1%
*-commutative79.1%
associate-*r*79.1%
Applied egg-rr79.1%
Taylor expanded in a around inf 59.0%
+-commutative59.0%
metadata-eval59.0%
pow-sqr58.9%
unpow258.9%
associate-*l*58.9%
unpow258.9%
cube-mult58.9%
distribute-rgt-out74.6%
Simplified74.6%
if 2.5e18 < b Initial program 55.4%
sub-neg55.4%
sqr-neg55.4%
+-commutative55.4%
sqr-neg55.4%
+-commutative55.4%
Simplified55.4%
Taylor expanded in b around inf 91.5%
Final simplification77.5%
(FPCore (a b) :precision binary64 (if (or (<= a -1.92) (not (<= a 0.09))) (pow a 4.0) (* (+ 1.0 (* a 2.0)) (+ -1.0 (* a 2.0)))))
double code(double a, double b) {
double tmp;
if ((a <= -1.92) || !(a <= 0.09)) {
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 <= (-1.92d0)) .or. (.not. (a <= 0.09d0))) 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 <= -1.92) || !(a <= 0.09)) {
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 <= -1.92) or not (a <= 0.09): 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 <= -1.92) || !(a <= 0.09)) 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 <= -1.92) || ~((a <= 0.09))) 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, -1.92], N[Not[LessEqual[a, 0.09]], $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 -1.92 \lor \neg \left(a \leq 0.09\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + a \cdot 2\right) \cdot \left(-1 + a \cdot 2\right)\\
\end{array}
\end{array}
if a < -1.9199999999999999 or 0.089999999999999997 < a Initial program 49.8%
sub-neg49.8%
sqr-neg49.8%
+-commutative49.8%
sqr-neg49.8%
+-commutative49.8%
Simplified51.3%
Taylor expanded in a around inf 86.9%
Taylor expanded in a around inf 86.9%
if -1.9199999999999999 < a < 0.089999999999999997Initial program 99.9%
associate--l+99.9%
sqr-pow99.9%
Simplified100.0%
Taylor expanded in b around 0 52.4%
Taylor expanded in a around 0 51.2%
add-sqr-sqrt51.2%
difference-of-sqr-151.2%
sqrt-prod51.2%
metadata-eval51.2%
pow251.2%
sqrt-prod22.4%
add-sqr-sqrt50.3%
sqrt-prod50.3%
metadata-eval50.3%
pow250.3%
sqrt-prod22.4%
add-sqr-sqrt51.2%
Applied egg-rr51.2%
Final simplification69.6%
(FPCore (a b) :precision binary64 (if (<= b 76000000000000.0) (+ (pow a 4.0) -1.0) (+ (pow b 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if (b <= 76000000000000.0) {
tmp = pow(a, 4.0) + -1.0;
} else {
tmp = pow(b, 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 <= 76000000000000.0d0) then
tmp = (a ** 4.0d0) + (-1.0d0)
else
tmp = (b ** 4.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 76000000000000.0) {
tmp = Math.pow(a, 4.0) + -1.0;
} else {
tmp = Math.pow(b, 4.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 76000000000000.0: tmp = math.pow(a, 4.0) + -1.0 else: tmp = math.pow(b, 4.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (b <= 76000000000000.0) tmp = Float64((a ^ 4.0) + -1.0); else tmp = Float64((b ^ 4.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 76000000000000.0) tmp = (a ^ 4.0) + -1.0; else tmp = (b ^ 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 76000000000000.0], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 76000000000000:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4} + -1\\
\end{array}
\end{array}
if b < 7.6e13Initial program 78.1%
sub-neg78.1%
sqr-neg78.1%
+-commutative78.1%
sqr-neg78.1%
+-commutative78.1%
Simplified79.0%
Taylor expanded in a around inf 73.8%
if 7.6e13 < b Initial program 55.4%
sub-neg55.4%
sqr-neg55.4%
+-commutative55.4%
sqr-neg55.4%
+-commutative55.4%
Simplified55.4%
Taylor expanded in b around inf 91.5%
Final simplification76.9%
(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 74.1%
sub-neg74.1%
sqr-neg74.1%
+-commutative74.1%
sqr-neg74.1%
+-commutative74.1%
Simplified74.9%
Taylor expanded in a around inf 69.4%
Final simplification69.4%
(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 74.1%
associate--l+74.1%
sqr-pow74.1%
Simplified75.0%
Taylor expanded in b around 0 55.9%
Taylor expanded in a around 0 50.0%
add-sqr-sqrt50.0%
difference-of-sqr-150.0%
sqrt-prod50.0%
metadata-eval50.0%
pow250.0%
sqrt-prod24.3%
add-sqr-sqrt37.9%
sqrt-prod37.9%
metadata-eval37.9%
pow237.9%
sqrt-prod24.3%
add-sqr-sqrt50.0%
Applied egg-rr50.0%
Final simplification50.0%
(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 74.1%
sub-neg74.1%
sqr-neg74.1%
+-commutative74.1%
sqr-neg74.1%
+-commutative74.1%
Simplified74.9%
Taylor expanded in a around inf 69.4%
Taylor expanded in a around 0 25.0%
Final simplification25.0%
herbie shell --seed 2023313
(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))