
(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 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) (+ 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 (<= (* b b) 5e+110)
(+
(+ (pow (+ (* b b) (* a a)) 2.0) (* 4.0 (+ (* a a) (* (* b b) (+ a 3.0)))))
-1.0)
(pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+110) {
tmp = (pow(((b * b) + (a * a)), 2.0) + (4.0 * ((a * a) + ((b * b) * (a + 3.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) <= 5d+110) then
tmp = ((((b * b) + (a * a)) ** 2.0d0) + (4.0d0 * ((a * a) + ((b * b) * (a + 3.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) <= 5e+110) {
tmp = (Math.pow(((b * b) + (a * a)), 2.0) + (4.0 * ((a * a) + ((b * b) * (a + 3.0))))) + -1.0;
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e+110: tmp = (math.pow(((b * b) + (a * a)), 2.0) + (4.0 * ((a * a) + ((b * b) * (a + 3.0))))) + -1.0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e+110) tmp = Float64(Float64((Float64(Float64(b * b) + Float64(a * a)) ^ 2.0) + Float64(4.0 * Float64(Float64(a * a) + Float64(Float64(b * b) * Float64(a + 3.0))))) + -1.0); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5e+110) tmp = ((((b * b) + (a * a)) ^ 2.0) + (4.0 * ((a * a) + ((b * b) * (a + 3.0))))) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e+110], N[(N[(N[Power[N[(N[(b * b), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(a * a), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $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 5 \cdot 10^{+110}:\\
\;\;\;\;\left({\left(b \cdot b + a \cdot a\right)}^{2} + 4 \cdot \left(a \cdot a + \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 4.99999999999999978e110Initial program 83.8%
Taylor expanded in a around 0 98.2%
if 4.99999999999999978e110 < (*.f64 b b) Initial program 61.2%
associate--l+61.2%
fma-define61.2%
sqr-neg61.2%
fma-define61.2%
distribute-rgt-in61.2%
sqr-neg61.2%
distribute-rgt-in61.2%
fma-define61.2%
sqr-neg61.2%
Simplified64.1%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around inf 100.0%
Final simplification98.9%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2000000000000.0) (+ (* (* a a) (+ 4.0 (* a (- a 4.0)))) -1.0) (+ (+ (pow b 4.0) (* (* b b) 12.0)) -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2000000000000.0) {
tmp = ((a * a) * (4.0 + (a * (a - 4.0)))) + -1.0;
} else {
tmp = (pow(b, 4.0) + ((b * b) * 12.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) <= 2000000000000.0d0) then
tmp = ((a * a) * (4.0d0 + (a * (a - 4.0d0)))) + (-1.0d0)
else
tmp = ((b ** 4.0d0) + ((b * b) * 12.0d0)) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2000000000000.0) {
tmp = ((a * a) * (4.0 + (a * (a - 4.0)))) + -1.0;
} else {
tmp = (Math.pow(b, 4.0) + ((b * b) * 12.0)) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2000000000000.0: tmp = ((a * a) * (4.0 + (a * (a - 4.0)))) + -1.0 else: tmp = (math.pow(b, 4.0) + ((b * b) * 12.0)) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2000000000000.0) tmp = Float64(Float64(Float64(a * a) * Float64(4.0 + Float64(a * Float64(a - 4.0)))) + -1.0); else tmp = Float64(Float64((b ^ 4.0) + Float64(Float64(b * b) * 12.0)) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2000000000000.0) tmp = ((a * a) * (4.0 + (a * (a - 4.0)))) + -1.0; else tmp = ((b ^ 4.0) + ((b * b) * 12.0)) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2000000000000.0], 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[Power[b, 4.0], $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2000000000000:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a - 4\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left({b}^{4} + \left(b \cdot b\right) \cdot 12\right) + -1\\
\end{array}
\end{array}
if (*.f64 b b) < 2e12Initial program 84.1%
associate--l+84.1%
fma-define84.1%
sqr-neg84.1%
fma-define84.1%
distribute-rgt-in84.1%
sqr-neg84.1%
distribute-rgt-in84.1%
fma-define84.1%
sqr-neg84.1%
Simplified84.1%
Taylor expanded in b around 0 83.8%
Taylor expanded in a around 0 99.5%
pow299.5%
Applied egg-rr99.5%
if 2e12 < (*.f64 b b) Initial program 65.0%
associate--l+65.0%
fma-define65.0%
sqr-neg65.0%
fma-define65.0%
distribute-rgt-in65.0%
sqr-neg65.0%
distribute-rgt-in65.0%
fma-define65.0%
sqr-neg65.0%
Simplified67.3%
Taylor expanded in a around 0 94.1%
pow294.1%
Applied egg-rr94.1%
Final simplification96.8%
(FPCore (a b) :precision binary64 (if (<= (* b b) 4e+21) (+ (* (* 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) <= 4e+21) {
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) <= 4d+21) 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) <= 4e+21) {
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) <= 4e+21: 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) <= 4e+21) 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) <= 4e+21) 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], 4e+21], 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 4 \cdot 10^{+21}:\\
\;\;\;\;\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) < 4e21Initial program 83.6%
associate--l+83.6%
fma-define83.6%
sqr-neg83.6%
fma-define83.6%
distribute-rgt-in83.6%
sqr-neg83.6%
distribute-rgt-in83.6%
fma-define83.6%
sqr-neg83.6%
Simplified83.6%
Taylor expanded in b around 0 82.5%
Taylor expanded in a around 0 98.7%
pow298.7%
Applied egg-rr98.7%
if 4e21 < (*.f64 b b) Initial program 65.2%
associate--l+65.2%
fma-define65.2%
sqr-neg65.2%
fma-define65.2%
distribute-rgt-in65.2%
sqr-neg65.2%
distribute-rgt-in65.2%
fma-define65.2%
sqr-neg65.2%
Simplified67.6%
Taylor expanded in a around 0 94.8%
Taylor expanded in b around inf 94.8%
Final simplification96.7%
(FPCore (a b) :precision binary64 (if (<= (* b b) 3.2e+279) (+ (* (* a a) (+ 4.0 (* a (- a 4.0)))) -1.0) (+ (* (* b b) 12.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 3.2e+279) {
tmp = ((a * a) * (4.0 + (a * (a - 4.0)))) + -1.0;
} else {
tmp = ((b * b) * 12.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) <= 3.2d+279) then
tmp = ((a * a) * (4.0d0 + (a * (a - 4.0d0)))) + (-1.0d0)
else
tmp = ((b * b) * 12.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 3.2e+279) {
tmp = ((a * a) * (4.0 + (a * (a - 4.0)))) + -1.0;
} else {
tmp = ((b * b) * 12.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 3.2e+279: tmp = ((a * a) * (4.0 + (a * (a - 4.0)))) + -1.0 else: tmp = ((b * b) * 12.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 3.2e+279) tmp = Float64(Float64(Float64(a * a) * Float64(4.0 + Float64(a * Float64(a - 4.0)))) + -1.0); else tmp = Float64(Float64(Float64(b * b) * 12.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 3.2e+279) tmp = ((a * a) * (4.0 + (a * (a - 4.0)))) + -1.0; else tmp = ((b * b) * 12.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 3.2e+279], 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] * 12.0), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 3.2 \cdot 10^{+279}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a - 4\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 12 + -1\\
\end{array}
\end{array}
if (*.f64 b b) < 3.19999999999999988e279Initial program 80.8%
associate--l+80.8%
fma-define80.8%
sqr-neg80.8%
fma-define80.8%
distribute-rgt-in80.8%
sqr-neg80.8%
distribute-rgt-in80.8%
fma-define80.8%
sqr-neg80.8%
Simplified81.3%
Taylor expanded in b around 0 63.1%
Taylor expanded in a around 0 77.8%
pow277.8%
Applied egg-rr77.8%
if 3.19999999999999988e279 < (*.f64 b b) Initial program 56.7%
associate--l+56.7%
fma-define56.7%
sqr-neg56.7%
fma-define56.7%
distribute-rgt-in56.7%
sqr-neg56.7%
distribute-rgt-in56.7%
fma-define56.7%
sqr-neg56.7%
Simplified59.7%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 97.3%
pow2100.0%
Applied egg-rr97.3%
Final simplification82.9%
(FPCore (a b) :precision binary64 (if (<= a -2.4e+99) (+ (* (* a a) (+ 4.0 (* a -4.0))) -1.0) (if (<= a 1.08e+129) (+ (* (* b b) 12.0) -1.0) (+ (* (* a a) 4.0) -1.0))))
double code(double a, double b) {
double tmp;
if (a <= -2.4e+99) {
tmp = ((a * a) * (4.0 + (a * -4.0))) + -1.0;
} else if (a <= 1.08e+129) {
tmp = ((b * b) * 12.0) + -1.0;
} else {
tmp = ((a * a) * 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 (a <= (-2.4d+99)) then
tmp = ((a * a) * (4.0d0 + (a * (-4.0d0)))) + (-1.0d0)
else if (a <= 1.08d+129) then
tmp = ((b * b) * 12.0d0) + (-1.0d0)
else
tmp = ((a * a) * 4.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -2.4e+99) {
tmp = ((a * a) * (4.0 + (a * -4.0))) + -1.0;
} else if (a <= 1.08e+129) {
tmp = ((b * b) * 12.0) + -1.0;
} else {
tmp = ((a * a) * 4.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -2.4e+99: tmp = ((a * a) * (4.0 + (a * -4.0))) + -1.0 elif a <= 1.08e+129: tmp = ((b * b) * 12.0) + -1.0 else: tmp = ((a * a) * 4.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (a <= -2.4e+99) tmp = Float64(Float64(Float64(a * a) * Float64(4.0 + Float64(a * -4.0))) + -1.0); elseif (a <= 1.08e+129) tmp = Float64(Float64(Float64(b * b) * 12.0) + -1.0); else tmp = Float64(Float64(Float64(a * a) * 4.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -2.4e+99) tmp = ((a * a) * (4.0 + (a * -4.0))) + -1.0; elseif (a <= 1.08e+129) tmp = ((b * b) * 12.0) + -1.0; else tmp = ((a * a) * 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -2.4e+99], N[(N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[a, 1.08e+129], N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.4 \cdot 10^{+99}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot -4\right) + -1\\
\mathbf{elif}\;a \leq 1.08 \cdot 10^{+129}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 12 + -1\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot a\right) \cdot 4 + -1\\
\end{array}
\end{array}
if a < -2.4000000000000001e99Initial program 62.5%
associate--l+62.5%
fma-define62.5%
sqr-neg62.5%
fma-define62.5%
distribute-rgt-in62.5%
sqr-neg62.5%
distribute-rgt-in62.5%
fma-define62.5%
sqr-neg62.5%
Simplified62.5%
Taylor expanded in b around 0 100.0%
Taylor expanded in a around 0 98.3%
*-commutative98.3%
Simplified98.3%
pow2100.0%
Applied egg-rr98.3%
if -2.4000000000000001e99 < a < 1.08e129Initial program 92.3%
associate--l+92.3%
fma-define92.3%
sqr-neg92.3%
fma-define92.3%
distribute-rgt-in92.3%
sqr-neg92.3%
distribute-rgt-in92.3%
fma-define92.3%
sqr-neg92.3%
Simplified93.5%
Taylor expanded in a around 0 87.9%
Taylor expanded in b around 0 63.1%
pow287.9%
Applied egg-rr63.1%
if 1.08e129 < a Initial program 0.0%
associate--l+0.0%
fma-define0.0%
sqr-neg0.0%
fma-define0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
fma-define0.0%
sqr-neg0.0%
Simplified2.9%
Taylor expanded in b around 0 0.0%
Taylor expanded in a around 0 0.0%
*-commutative0.0%
Simplified0.0%
pow2100.0%
Applied egg-rr0.0%
Taylor expanded in a around 0 92.1%
Final simplification73.6%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2.6e+266) (+ (* (* a a) 4.0) -1.0) (+ (* (* b b) 12.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2.6e+266) {
tmp = ((a * a) * 4.0) + -1.0;
} else {
tmp = ((b * b) * 12.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) <= 2.6d+266) then
tmp = ((a * a) * 4.0d0) + (-1.0d0)
else
tmp = ((b * b) * 12.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2.6e+266) {
tmp = ((a * a) * 4.0) + -1.0;
} else {
tmp = ((b * b) * 12.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2.6e+266: tmp = ((a * a) * 4.0) + -1.0 else: tmp = ((b * b) * 12.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2.6e+266) tmp = Float64(Float64(Float64(a * a) * 4.0) + -1.0); else tmp = Float64(Float64(Float64(b * b) * 12.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2.6e+266) tmp = ((a * a) * 4.0) + -1.0; else tmp = ((b * b) * 12.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2.6e+266], N[(N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2.6 \cdot 10^{+266}:\\
\;\;\;\;\left(a \cdot a\right) \cdot 4 + -1\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 12 + -1\\
\end{array}
\end{array}
if (*.f64 b b) < 2.60000000000000014e266Initial program 82.0%
associate--l+82.0%
fma-define82.0%
sqr-neg82.0%
fma-define82.0%
distribute-rgt-in82.0%
sqr-neg82.0%
distribute-rgt-in82.0%
fma-define82.0%
sqr-neg82.0%
Simplified82.5%
Taylor expanded in b around 0 63.3%
Taylor expanded in a around 0 53.0%
*-commutative53.0%
Simplified53.0%
pow278.4%
Applied egg-rr53.0%
Taylor expanded in a around 0 62.4%
if 2.60000000000000014e266 < (*.f64 b b) Initial program 54.9%
associate--l+54.9%
fma-define54.9%
sqr-neg54.9%
fma-define54.9%
distribute-rgt-in54.9%
sqr-neg54.9%
distribute-rgt-in54.9%
fma-define54.9%
sqr-neg54.9%
Simplified57.7%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 92.3%
pow2100.0%
Applied egg-rr92.3%
Final simplification70.7%
(FPCore (a b) :precision binary64 (+ (* (* b b) 12.0) -1.0))
double code(double a, double b) {
return ((b * b) * 12.0) + -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((b * b) * 12.0d0) + (-1.0d0)
end function
public static double code(double a, double b) {
return ((b * b) * 12.0) + -1.0;
}
def code(a, b): return ((b * b) * 12.0) + -1.0
function code(a, b) return Float64(Float64(Float64(b * b) * 12.0) + -1.0) end
function tmp = code(a, b) tmp = ((b * b) * 12.0) + -1.0; end
code[a_, b_] := N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\left(b \cdot b\right) \cdot 12 + -1
\end{array}
Initial program 74.5%
associate--l+74.5%
fma-define74.5%
sqr-neg74.5%
fma-define74.5%
distribute-rgt-in74.5%
sqr-neg74.5%
distribute-rgt-in74.5%
fma-define74.5%
sqr-neg74.5%
Simplified75.7%
Taylor expanded in a around 0 72.1%
Taylor expanded in b around 0 51.6%
pow272.1%
Applied egg-rr51.6%
Final simplification51.6%
(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.5%
associate--l+74.5%
fma-define74.5%
sqr-neg74.5%
fma-define74.5%
distribute-rgt-in74.5%
sqr-neg74.5%
distribute-rgt-in74.5%
fma-define74.5%
sqr-neg74.5%
Simplified75.7%
Taylor expanded in a around 0 72.1%
Taylor expanded in b around 0 24.8%
herbie shell --seed 2024132
(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))