
(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
(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)
(+ t_0 -1.0)
(+ (* (* a a) (+ 4.0 (* a (+ 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) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0 + -1.0;
} else {
tmp = ((a * a) * (4.0 + (a * (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) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 + -1.0;
} else {
tmp = ((a * a) * (4.0 + (a * (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) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0))))) tmp = 0 if t_0 <= math.inf: tmp = t_0 + -1.0 else: tmp = ((a * a) * (4.0 + (a * (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(a + 1.0)) + Float64(Float64(b * b) * Float64(1.0 - Float64(a * 3.0)))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(t_0 + -1.0); else tmp = Float64(Float64(Float64(a * a) * Float64(4.0 + Float64(a * 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) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0))))); tmp = 0.0; if (t_0 <= Inf) tmp = t_0 + -1.0; else tmp = ((a * a) * (4.0 + (a * (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[(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[(t$95$0 + -1.0), $MachinePrecision], N[(N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * N[(a + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right)\\
\mathbf{if}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0 + -1\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + 4\right)\right) + -1\\
\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%
Simplified8.9%
Taylor expanded in b around 0 23.7%
Taylor expanded in a around 0 91.6%
+-commutative91.6%
Simplified91.6%
unpow291.6%
Applied egg-rr91.6%
Final simplification98.0%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e-5) (+ (* (* a a) (+ 4.0 (* a (+ a 4.0)))) -1.0) (+ (+ (* (* b b) 4.0) (pow b 4.0)) -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e-5) {
tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0;
} else {
tmp = (((b * b) * 4.0) + 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 * b) <= 1d-5) then
tmp = ((a * a) * (4.0d0 + (a * (a + 4.0d0)))) + (-1.0d0)
else
tmp = (((b * b) * 4.0d0) + (b ** 4.0d0)) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 1e-5) {
tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0;
} else {
tmp = (((b * b) * 4.0) + Math.pow(b, 4.0)) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 1e-5: tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0 else: tmp = (((b * b) * 4.0) + math.pow(b, 4.0)) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1e-5) tmp = Float64(Float64(Float64(a * a) * Float64(4.0 + Float64(a * Float64(a + 4.0)))) + -1.0); else tmp = Float64(Float64(Float64(Float64(b * b) * 4.0) + (b ^ 4.0)) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 1e-5) tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0; else tmp = (((b * b) * 4.0) + (b ^ 4.0)) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e-5], N[(N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * N[(a + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{-5}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + 4\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left(\left(b \cdot b\right) \cdot 4 + {b}^{4}\right) + -1\\
\end{array}
\end{array}
if (*.f64 b b) < 1.00000000000000008e-5Initial program 86.4%
sub-neg86.4%
Simplified86.4%
Taylor expanded in b around 0 86.3%
Taylor expanded in a around 0 99.7%
+-commutative99.7%
Simplified99.7%
unpow299.7%
Applied egg-rr99.7%
if 1.00000000000000008e-5 < (*.f64 b b) Initial program 67.7%
associate--l+67.7%
+-commutative67.7%
+-commutative67.7%
sub-neg67.7%
associate-+l+67.7%
+-commutative67.7%
associate-+l+67.7%
Simplified74.7%
Taylor expanded in a around 0 95.2%
pow295.2%
Applied egg-rr95.2%
Final simplification97.6%
(FPCore (a b) :precision binary64 (if (<= (* b b) 0.0005) (+ (* (* a a) (+ 4.0 (* a (+ a 4.0)))) -1.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 0.0005) {
tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -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 * b) <= 0.0005d0) then
tmp = ((a * a) * (4.0d0 + (a * (a + 4.0d0)))) + (-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 * b) <= 0.0005) {
tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0;
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 0.0005: tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 0.0005) tmp = Float64(Float64(Float64(a * a) * Float64(4.0 + Float64(a * Float64(a + 4.0)))) + -1.0); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 0.0005) tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 0.0005], N[(N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * N[(a + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 0.0005:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + 4\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 5.0000000000000001e-4Initial program 86.5%
sub-neg86.5%
Simplified86.5%
Taylor expanded in b around 0 85.9%
Taylor expanded in a around 0 99.2%
+-commutative99.2%
Simplified99.2%
unpow299.2%
Applied egg-rr99.2%
if 5.0000000000000001e-4 < (*.f64 b b) Initial program 67.4%
associate--l+67.4%
+-commutative67.4%
+-commutative67.4%
sub-neg67.4%
associate-+l+67.4%
+-commutative67.4%
associate-+l+67.4%
Simplified74.5%
Taylor expanded in a around 0 95.1%
Taylor expanded in b around inf 94.9%
(FPCore (a b) :precision binary64 (if (<= (* b b) 4e+307) (+ (* (* a a) (+ 4.0 (* a (+ a 4.0)))) -1.0) (+ (* (* b b) 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 4e+307) {
tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0;
} else {
tmp = ((b * 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 * b) <= 4d+307) then
tmp = ((a * a) * (4.0d0 + (a * (a + 4.0d0)))) + (-1.0d0)
else
tmp = ((b * b) * 4.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 4e+307) {
tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0;
} else {
tmp = ((b * b) * 4.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 4e+307: tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0 else: tmp = ((b * b) * 4.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 4e+307) tmp = Float64(Float64(Float64(a * a) * Float64(4.0 + Float64(a * Float64(a + 4.0)))) + -1.0); else tmp = Float64(Float64(Float64(b * b) * 4.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 4e+307) tmp = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.0; else tmp = ((b * b) * 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 4e+307], N[(N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * N[(a + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 4 \cdot 10^{+307}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + 4\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 4 + -1\\
\end{array}
\end{array}
if (*.f64 b b) < 3.99999999999999994e307Initial program 81.9%
sub-neg81.9%
Simplified82.9%
Taylor expanded in b around 0 64.4%
Taylor expanded in a around 0 77.9%
+-commutative77.9%
Simplified77.9%
unpow277.9%
Applied egg-rr77.9%
if 3.99999999999999994e307 < (*.f64 b b) Initial program 62.0%
associate--l+62.0%
+-commutative62.0%
+-commutative62.0%
sub-neg62.0%
associate-+l+62.0%
+-commutative62.0%
associate-+l+62.0%
Simplified62.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 100.0%
pow2100.0%
Applied egg-rr100.0%
Final simplification82.2%
(FPCore (a b) :precision binary64 (* (+ 1.0 (* b 2.0)) (+ (* b 2.0) -1.0)))
double code(double a, double b) {
return (1.0 + (b * 2.0)) * ((b * 2.0) + -1.0);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (1.0d0 + (b * 2.0d0)) * ((b * 2.0d0) + (-1.0d0))
end function
public static double code(double a, double b) {
return (1.0 + (b * 2.0)) * ((b * 2.0) + -1.0);
}
def code(a, b): return (1.0 + (b * 2.0)) * ((b * 2.0) + -1.0)
function code(a, b) return Float64(Float64(1.0 + Float64(b * 2.0)) * Float64(Float64(b * 2.0) + -1.0)) end
function tmp = code(a, b) tmp = (1.0 + (b * 2.0)) * ((b * 2.0) + -1.0); end
code[a_, b_] := N[(N[(1.0 + N[(b * 2.0), $MachinePrecision]), $MachinePrecision] * N[(N[(b * 2.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 + b \cdot 2\right) \cdot \left(b \cdot 2 + -1\right)
\end{array}
Initial program 78.0%
associate--l+78.0%
+-commutative78.0%
+-commutative78.0%
sub-neg78.0%
associate-+l+78.0%
+-commutative78.0%
associate-+l+78.0%
Simplified81.1%
Taylor expanded in a around 0 69.6%
Taylor expanded in b around 0 48.2%
add-sqr-sqrt48.2%
difference-of-sqr-148.2%
*-commutative48.2%
sqrt-prod48.2%
sqrt-pow136.5%
metadata-eval36.5%
pow136.5%
metadata-eval36.5%
*-commutative36.5%
sqrt-prod36.5%
sqrt-pow148.2%
metadata-eval48.2%
pow148.2%
metadata-eval48.2%
Applied egg-rr48.2%
Final simplification48.2%
(FPCore (a b) :precision binary64 (+ (* (* b b) 4.0) -1.0))
double code(double a, double b) {
return ((b * b) * 4.0) + -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((b * b) * 4.0d0) + (-1.0d0)
end function
public static double code(double a, double b) {
return ((b * b) * 4.0) + -1.0;
}
def code(a, b): return ((b * b) * 4.0) + -1.0
function code(a, b) return Float64(Float64(Float64(b * b) * 4.0) + -1.0) end
function tmp = code(a, b) tmp = ((b * b) * 4.0) + -1.0; end
code[a_, b_] := N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\left(b \cdot b\right) \cdot 4 + -1
\end{array}
Initial program 78.0%
associate--l+78.0%
+-commutative78.0%
+-commutative78.0%
sub-neg78.0%
associate-+l+78.0%
+-commutative78.0%
associate-+l+78.0%
Simplified81.1%
Taylor expanded in a around 0 69.6%
Taylor expanded in b around 0 48.2%
pow269.6%
Applied egg-rr48.2%
Final simplification48.2%
(FPCore (a b) :precision binary64 (+ (* b 2.0) -1.0))
double code(double a, double b) {
return (b * 2.0) + -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (b * 2.0d0) + (-1.0d0)
end function
public static double code(double a, double b) {
return (b * 2.0) + -1.0;
}
def code(a, b): return (b * 2.0) + -1.0
function code(a, b) return Float64(Float64(b * 2.0) + -1.0) end
function tmp = code(a, b) tmp = (b * 2.0) + -1.0; end
code[a_, b_] := N[(N[(b * 2.0), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
b \cdot 2 + -1
\end{array}
Initial program 78.0%
associate--l+78.0%
+-commutative78.0%
+-commutative78.0%
sub-neg78.0%
associate-+l+78.0%
+-commutative78.0%
associate-+l+78.0%
Simplified81.1%
Taylor expanded in a around 0 69.6%
Taylor expanded in b around 0 48.2%
add-sqr-sqrt48.2%
difference-of-sqr-148.2%
*-commutative48.2%
sqrt-prod48.2%
sqrt-pow136.5%
metadata-eval36.5%
pow136.5%
metadata-eval36.5%
*-commutative36.5%
sqrt-prod36.5%
sqrt-pow148.2%
metadata-eval48.2%
pow148.2%
metadata-eval48.2%
Applied egg-rr48.2%
Taylor expanded in b around 0 28.0%
Final simplification28.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 78.0%
associate--l+78.0%
+-commutative78.0%
+-commutative78.0%
sub-neg78.0%
associate-+l+78.0%
+-commutative78.0%
associate-+l+78.0%
Simplified81.1%
Taylor expanded in a around 0 69.6%
Taylor expanded in b around 0 27.3%
herbie shell --seed 2024180
(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))