
(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) 4e+132)
(+
(+ (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) <= 4e+132) {
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) <= 4d+132) 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) <= 4e+132) {
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) <= 4e+132: 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) <= 4e+132) 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) <= 4e+132) 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], 4e+132], 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 4 \cdot 10^{+132}:\\
\;\;\;\;\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) < 3.99999999999999996e132Initial program 79.2%
Taylor expanded in a around 0 98.8%
if 3.99999999999999996e132 < (*.f64 b b) Initial program 59.4%
associate--l+59.4%
fma-define59.4%
distribute-rgt-in59.4%
sqr-neg59.4%
distribute-rgt-in59.4%
Simplified62.3%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around inf 100.0%
Final simplification99.3%
(FPCore (a b) :precision binary64 (if (or (<= a -4.3e+37) (not (<= a 1.25e+31))) (pow a 4.0) (+ (+ (pow b 4.0) (* (* b b) 12.0)) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -4.3e+37) || !(a <= 1.25e+31)) {
tmp = pow(a, 4.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 ((a <= (-4.3d+37)) .or. (.not. (a <= 1.25d+31))) then
tmp = a ** 4.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 ((a <= -4.3e+37) || !(a <= 1.25e+31)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = (Math.pow(b, 4.0) + ((b * b) * 12.0)) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -4.3e+37) or not (a <= 1.25e+31): tmp = math.pow(a, 4.0) else: tmp = (math.pow(b, 4.0) + ((b * b) * 12.0)) + -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -4.3e+37) || !(a <= 1.25e+31)) tmp = a ^ 4.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 ((a <= -4.3e+37) || ~((a <= 1.25e+31))) tmp = a ^ 4.0; else tmp = ((b ^ 4.0) + ((b * b) * 12.0)) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -4.3e+37], N[Not[LessEqual[a, 1.25e+31]], $MachinePrecision]], N[Power[a, 4.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}\;a \leq -4.3 \cdot 10^{+37} \lor \neg \left(a \leq 1.25 \cdot 10^{+31}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;\left({b}^{4} + \left(b \cdot b\right) \cdot 12\right) + -1\\
\end{array}
\end{array}
if a < -4.2999999999999997e37 or 1.25000000000000007e31 < a Initial program 40.6%
associate--l+40.6%
fma-define40.6%
distribute-rgt-in40.6%
sqr-neg40.6%
distribute-rgt-in40.6%
Simplified43.1%
Taylor expanded in a around inf 98.4%
associate-*r/98.4%
metadata-eval98.4%
Simplified98.4%
Taylor expanded in a around inf 98.4%
if -4.2999999999999997e37 < a < 1.25000000000000007e31Initial program 97.7%
associate--l+97.7%
fma-define97.7%
distribute-rgt-in97.7%
sqr-neg97.7%
distribute-rgt-in97.7%
Simplified97.7%
Taylor expanded in a around 0 97.1%
pow297.1%
Applied egg-rr97.1%
Final simplification97.7%
(FPCore (a b) :precision binary64 (if (<= (* b b) 4e+132) (+ (* (* 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+132) {
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+132) 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+132) {
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+132: 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+132) 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+132) 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+132], 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^{+132}:\\
\;\;\;\;\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) < 3.99999999999999996e132Initial program 79.2%
associate--l+79.2%
fma-define79.2%
distribute-rgt-in79.2%
sqr-neg79.2%
distribute-rgt-in79.2%
Simplified79.2%
Taylor expanded in b around 0 71.0%
Taylor expanded in a around 0 90.9%
pow290.9%
Applied egg-rr90.9%
if 3.99999999999999996e132 < (*.f64 b b) Initial program 59.4%
associate--l+59.4%
fma-define59.4%
distribute-rgt-in59.4%
sqr-neg59.4%
distribute-rgt-in59.4%
Simplified62.3%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around inf 100.0%
Final simplification94.5%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1.05e+268) (+ (* (* 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) <= 1.05e+268) {
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) <= 1.05d+268) 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) <= 1.05e+268) {
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) <= 1.05e+268: 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) <= 1.05e+268) 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) <= 1.05e+268) 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], 1.05e+268], 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 1.05 \cdot 10^{+268}:\\
\;\;\;\;\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) < 1.0500000000000001e268Initial program 79.5%
associate--l+79.5%
fma-define79.5%
distribute-rgt-in79.5%
sqr-neg79.5%
distribute-rgt-in79.5%
Simplified80.0%
Taylor expanded in b around 0 63.3%
Taylor expanded in a around 0 81.4%
pow281.4%
Applied egg-rr81.4%
if 1.0500000000000001e268 < (*.f64 b b) Initial program 51.4%
associate--l+51.4%
fma-define51.4%
distribute-rgt-in51.4%
sqr-neg51.4%
distribute-rgt-in51.4%
Simplified54.1%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 92.7%
pow2100.0%
Applied egg-rr92.7%
Final simplification84.6%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1.05e+268) (+ (* (* a a) (+ (* a a) 4.0)) -1.0) (+ (* (* b b) 12.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1.05e+268) {
tmp = ((a * a) * ((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) <= 1.05d+268) then
tmp = ((a * a) * ((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) <= 1.05e+268) {
tmp = ((a * a) * ((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) <= 1.05e+268: tmp = ((a * a) * ((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) <= 1.05e+268) tmp = Float64(Float64(Float64(a * a) * 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) <= 1.05e+268) tmp = ((a * a) * ((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], 1.05e+268], N[(N[(N[(a * a), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + 4.0), $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 1.05 \cdot 10^{+268}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a + 4\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 12 + -1\\
\end{array}
\end{array}
if (*.f64 b b) < 1.0500000000000001e268Initial program 79.5%
associate--l+79.5%
fma-define79.5%
distribute-rgt-in79.5%
sqr-neg79.5%
distribute-rgt-in79.5%
Simplified80.0%
Taylor expanded in b around 0 63.3%
Taylor expanded in a around 0 81.4%
pow281.4%
Applied egg-rr81.4%
Taylor expanded in a around inf 81.1%
if 1.0500000000000001e268 < (*.f64 b b) Initial program 51.4%
associate--l+51.4%
fma-define51.4%
distribute-rgt-in51.4%
sqr-neg51.4%
distribute-rgt-in51.4%
Simplified54.1%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 92.7%
pow2100.0%
Applied egg-rr92.7%
Final simplification84.4%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5.3e+246) (+ (* (* a a) 4.0) -1.0) (+ (* (* b b) 12.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5.3e+246) {
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) <= 5.3d+246) 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) <= 5.3e+246) {
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) <= 5.3e+246: 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) <= 5.3e+246) 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) <= 5.3e+246) 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], 5.3e+246], 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 5.3 \cdot 10^{+246}:\\
\;\;\;\;\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) < 5.29999999999999976e246Initial program 79.1%
associate--l+79.1%
fma-define79.1%
distribute-rgt-in79.1%
sqr-neg79.1%
distribute-rgt-in79.1%
Simplified79.7%
Taylor expanded in b around 0 65.0%
Taylor expanded in a around 0 83.9%
pow283.9%
Applied egg-rr83.9%
Taylor expanded in a around 0 61.6%
if 5.29999999999999976e246 < (*.f64 b b) Initial program 54.9%
associate--l+54.9%
fma-define54.9%
distribute-rgt-in54.9%
sqr-neg54.9%
distribute-rgt-in54.9%
Simplified57.3%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 84.3%
pow2100.0%
Applied egg-rr84.3%
Final simplification68.9%
(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 71.4%
associate--l+71.4%
fma-define71.4%
distribute-rgt-in71.4%
sqr-neg71.4%
distribute-rgt-in71.4%
Simplified72.5%
Taylor expanded in a around 0 69.3%
Taylor expanded in b around 0 52.1%
pow269.3%
Applied egg-rr52.1%
Final simplification52.1%
(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 71.4%
associate--l+71.4%
fma-define71.4%
distribute-rgt-in71.4%
sqr-neg71.4%
distribute-rgt-in71.4%
Simplified72.5%
Taylor expanded in a around 0 69.3%
Taylor expanded in b around 0 24.3%
herbie shell --seed 2024154
(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))