
(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 11 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 (<=
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))
INFINITY)
(+
(+ (pow b 4.0) (+ (* 2.0 (* (* a b) (* a b))) (pow a 4.0)))
(+ (* 4.0 (fma (* a a) (- 1.0 a) (* b (* b (+ a 3.0))))) -1.0))
(pow a 4.0)))
double code(double a, double b) {
double tmp;
if ((pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))))) <= ((double) INFINITY)) {
tmp = (pow(b, 4.0) + ((2.0 * ((a * b) * (a * b))) + pow(a, 4.0))) + ((4.0 * fma((a * a), (1.0 - a), (b * (b * (a + 3.0))))) + -1.0);
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
function code(a, b) 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)) + Float64(Float64(b * b) * Float64(a + 3.0))))) <= Inf) tmp = Float64(Float64((b ^ 4.0) + Float64(Float64(2.0 * Float64(Float64(a * b) * Float64(a * b))) + (a ^ 4.0))) + Float64(Float64(4.0 * fma(Float64(a * a), Float64(1.0 - a), Float64(b * Float64(b * Float64(a + 3.0))))) + -1.0)); else tmp = a ^ 4.0; end return tmp end
code[a_, b_] := 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] + N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[Power[b, 4.0], $MachinePrecision] + N[(N[(2.0 * N[(N[(a * b), $MachinePrecision] * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(4.0 * N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision] + N[(b * N[(b * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{\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) \leq \infty:\\
\;\;\;\;\left({b}^{4} + \left(2 \cdot \left(\left(a \cdot b\right) \cdot \left(a \cdot b\right)\right) + {a}^{4}\right)\right) + \left(4 \cdot \mathsf{fma}\left(a \cdot a, 1 - a, b \cdot \left(b \cdot \left(a + 3\right)\right)\right) + -1\right)\\
\mathbf{else}:\\
\;\;\;\;{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 3 binary64) a))))) < +inf.0Initial program 99.9%
associate--l+99.9%
fma-define99.9%
distribute-rgt-in99.9%
sqr-neg99.9%
distribute-rgt-in99.9%
Simplified99.9%
Taylor expanded in a around 0 91.5%
+-commutative91.5%
distribute-rgt-in87.0%
pow-sqr87.0%
metadata-eval87.0%
associate-*r*87.0%
*-commutative87.0%
fma-define87.0%
unpow287.0%
unpow287.0%
swap-sqr100.0%
unpow2100.0%
*-commutative100.0%
Simplified100.0%
fma-undefine100.0%
*-commutative100.0%
Applied egg-rr100.0%
unpow2100.0%
Applied egg-rr100.0%
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 3 binary64) a))))) Initial program 0.0%
associate--l+0.0%
fma-define0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
Simplified7.1%
Taylor expanded in a around inf 98.5%
associate-*r/98.5%
metadata-eval98.5%
Simplified98.5%
Taylor expanded in a around inf 98.5%
Final simplification99.6%
(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))))
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);
}
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);
}
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) 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 = a ^ 4.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; 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[Power[a, 4.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}\\
\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 3 binary64) a))))) < +inf.0Initial program 99.9%
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 3 binary64) a))))) Initial program 0.0%
associate--l+0.0%
fma-define0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
Simplified7.1%
Taylor expanded in a around inf 98.5%
associate-*r/98.5%
metadata-eval98.5%
Simplified98.5%
Taylor expanded in a around inf 98.5%
Final simplification99.6%
(FPCore (a b)
:precision binary64
(if (<= a -5e+71)
(pow a 4.0)
(+
(+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* a a) (* (* b b) (+ a 3.0)))))
-1.0)))
double code(double a, double b) {
double tmp;
if (a <= -5e+71) {
tmp = pow(a, 4.0);
} else {
tmp = (pow(((a * a) + (b * b)), 2.0) + (4.0 * ((a * a) + ((b * b) * (a + 3.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 <= (-5d+71)) then
tmp = a ** 4.0d0
else
tmp = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * ((a * a) + ((b * b) * (a + 3.0d0))))) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -5e+71) {
tmp = Math.pow(a, 4.0);
} else {
tmp = (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * ((a * a) + ((b * b) * (a + 3.0))))) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -5e+71: tmp = math.pow(a, 4.0) else: tmp = (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * ((a * a) + ((b * b) * (a + 3.0))))) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (a <= -5e+71) tmp = a ^ 4.0; else tmp = Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(a * a) + Float64(Float64(b * b) * Float64(a + 3.0))))) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -5e+71) tmp = a ^ 4.0; else tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * ((a * a) + ((b * b) * (a + 3.0))))) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -5e+71], N[Power[a, 4.0], $MachinePrecision], N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $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]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5 \cdot 10^{+71}:\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(a \cdot a + \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\right) + -1\\
\end{array}
\end{array}
if a < -4.99999999999999972e71Initial program 66.7%
associate--l+66.7%
fma-define66.7%
distribute-rgt-in66.7%
sqr-neg66.7%
distribute-rgt-in66.7%
Simplified66.7%
Taylor expanded in a around inf 98.1%
associate-*r/98.1%
metadata-eval98.1%
Simplified98.1%
Taylor expanded in a around inf 98.1%
if -4.99999999999999972e71 < a Initial program 80.5%
Taylor expanded in a around 0 99.3%
Final simplification99.1%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+143) (+ (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* a a) (* a (* b b))))) -1.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+143) {
tmp = (pow(((a * a) + (b * b)), 2.0) + (4.0 * ((a * a) + (a * (b * b))))) + -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+143) then
tmp = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * ((a * a) + (a * (b * b))))) + (-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+143) {
tmp = (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * ((a * a) + (a * (b * b))))) + -1.0;
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e+143: tmp = (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * ((a * a) + (a * (b * b))))) + -1.0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e+143) tmp = Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(a * a) + Float64(a * Float64(b * b))))) + -1.0); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5e+143) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * ((a * a) + (a * (b * b))))) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e+143], N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(a * a), $MachinePrecision] + N[(a * N[(b * b), $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^{+143}:\\
\;\;\;\;\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(a \cdot a + a \cdot \left(b \cdot b\right)\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 5.00000000000000012e143Initial program 81.8%
Taylor expanded in a around 0 98.6%
Taylor expanded in a around inf 97.7%
if 5.00000000000000012e143 < (*.f64 b b) Initial program 70.2%
associate--l+70.2%
fma-define70.2%
distribute-rgt-in70.2%
sqr-neg70.2%
distribute-rgt-in70.2%
Simplified75.0%
Taylor expanded in a around 0 54.8%
+-commutative54.8%
distribute-rgt-in54.8%
pow-sqr54.8%
metadata-eval54.8%
associate-*r*54.8%
*-commutative54.8%
fma-define54.8%
unpow254.8%
unpow254.8%
swap-sqr75.0%
unpow275.0%
*-commutative75.0%
Simplified75.0%
fma-undefine75.0%
*-commutative75.0%
Applied egg-rr75.0%
unpow275.0%
Applied egg-rr75.0%
Taylor expanded in b around inf 100.0%
Final simplification98.4%
(FPCore (a b) :precision binary64 (if (<= a -1850000.0) (* (pow a 4.0) (- 1.0 (/ 4.0 a))) (if (<= a 1.5e+31) (+ (+ (pow b 4.0) (* (* b b) 12.0)) -1.0) (pow a 4.0))))
double code(double a, double b) {
double tmp;
if (a <= -1850000.0) {
tmp = pow(a, 4.0) * (1.0 - (4.0 / a));
} else if (a <= 1.5e+31) {
tmp = (pow(b, 4.0) + ((b * b) * 12.0)) + -1.0;
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-1850000.0d0)) then
tmp = (a ** 4.0d0) * (1.0d0 - (4.0d0 / a))
else if (a <= 1.5d+31) then
tmp = ((b ** 4.0d0) + ((b * b) * 12.0d0)) + (-1.0d0)
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -1850000.0) {
tmp = Math.pow(a, 4.0) * (1.0 - (4.0 / a));
} else if (a <= 1.5e+31) {
tmp = (Math.pow(b, 4.0) + ((b * b) * 12.0)) + -1.0;
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -1850000.0: tmp = math.pow(a, 4.0) * (1.0 - (4.0 / a)) elif a <= 1.5e+31: tmp = (math.pow(b, 4.0) + ((b * b) * 12.0)) + -1.0 else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -1850000.0) tmp = Float64((a ^ 4.0) * Float64(1.0 - Float64(4.0 / a))); elseif (a <= 1.5e+31) tmp = Float64(Float64((b ^ 4.0) + Float64(Float64(b * b) * 12.0)) + -1.0); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -1850000.0) tmp = (a ^ 4.0) * (1.0 - (4.0 / a)); elseif (a <= 1.5e+31) tmp = ((b ^ 4.0) + ((b * b) * 12.0)) + -1.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -1850000.0], N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 - N[(4.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.5e+31], N[(N[(N[Power[b, 4.0], $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1850000:\\
\;\;\;\;{a}^{4} \cdot \left(1 - \frac{4}{a}\right)\\
\mathbf{elif}\;a \leq 1.5 \cdot 10^{+31}:\\
\;\;\;\;\left({b}^{4} + \left(b \cdot b\right) \cdot 12\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -1.85e6Initial program 72.7%
associate--l+72.7%
fma-define72.7%
distribute-rgt-in72.7%
sqr-neg72.7%
distribute-rgt-in72.7%
Simplified72.7%
Taylor expanded in a around inf 95.9%
associate-*r/95.9%
metadata-eval95.9%
Simplified95.9%
if -1.85e6 < a < 1.49999999999999995e31Initial program 99.9%
associate--l+99.9%
fma-define99.9%
distribute-rgt-in99.9%
sqr-neg99.9%
distribute-rgt-in99.9%
Simplified99.9%
Taylor expanded in a around 0 98.9%
pow298.9%
Applied egg-rr98.9%
if 1.49999999999999995e31 < a Initial program 22.5%
associate--l+22.5%
fma-define22.5%
distribute-rgt-in22.5%
sqr-neg22.5%
distribute-rgt-in22.5%
Simplified30.1%
Taylor expanded in a around inf 98.2%
associate-*r/98.2%
metadata-eval98.2%
Simplified98.2%
Taylor expanded in a around inf 98.2%
Final simplification98.1%
(FPCore (a b) :precision binary64 (if (or (<= a -60000000000.0) (not (<= a 1.9e+32))) (pow a 4.0) (+ (pow b 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -60000000000.0) || !(a <= 1.9e+32)) {
tmp = pow(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 ((a <= (-60000000000.0d0)) .or. (.not. (a <= 1.9d+32))) then
tmp = 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 ((a <= -60000000000.0) || !(a <= 1.9e+32)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -60000000000.0) or not (a <= 1.9e+32): tmp = math.pow(a, 4.0) else: tmp = math.pow(b, 4.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -60000000000.0) || !(a <= 1.9e+32)) tmp = 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 ((a <= -60000000000.0) || ~((a <= 1.9e+32))) tmp = a ^ 4.0; else tmp = (b ^ 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -60000000000.0], N[Not[LessEqual[a, 1.9e+32]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -60000000000 \lor \neg \left(a \leq 1.9 \cdot 10^{+32}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4} + -1\\
\end{array}
\end{array}
if a < -6e10 or 1.9000000000000002e32 < a Initial program 48.1%
associate--l+48.1%
fma-define48.1%
distribute-rgt-in48.1%
sqr-neg48.1%
distribute-rgt-in48.1%
Simplified51.8%
Taylor expanded in a around inf 97.1%
associate-*r/97.1%
metadata-eval97.1%
Simplified97.1%
Taylor expanded in a around inf 97.0%
if -6e10 < a < 1.9000000000000002e32Initial program 99.9%
Taylor expanded in a around 0 99.1%
Taylor expanded in a around inf 88.0%
Taylor expanded in a around 0 98.0%
Final simplification97.6%
(FPCore (a b) :precision binary64 (if (<= a -11500000.0) (* (pow a 4.0) (- 1.0 (/ 4.0 a))) (if (<= a 2.5e+32) (+ (pow b 4.0) -1.0) (pow a 4.0))))
double code(double a, double b) {
double tmp;
if (a <= -11500000.0) {
tmp = pow(a, 4.0) * (1.0 - (4.0 / a));
} else if (a <= 2.5e+32) {
tmp = pow(b, 4.0) + -1.0;
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-11500000.0d0)) then
tmp = (a ** 4.0d0) * (1.0d0 - (4.0d0 / a))
else if (a <= 2.5d+32) then
tmp = (b ** 4.0d0) + (-1.0d0)
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -11500000.0) {
tmp = Math.pow(a, 4.0) * (1.0 - (4.0 / a));
} else if (a <= 2.5e+32) {
tmp = Math.pow(b, 4.0) + -1.0;
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -11500000.0: tmp = math.pow(a, 4.0) * (1.0 - (4.0 / a)) elif a <= 2.5e+32: tmp = math.pow(b, 4.0) + -1.0 else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -11500000.0) tmp = Float64((a ^ 4.0) * Float64(1.0 - Float64(4.0 / a))); elseif (a <= 2.5e+32) tmp = Float64((b ^ 4.0) + -1.0); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -11500000.0) tmp = (a ^ 4.0) * (1.0 - (4.0 / a)); elseif (a <= 2.5e+32) tmp = (b ^ 4.0) + -1.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -11500000.0], N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 - N[(4.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 2.5e+32], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -11500000:\\
\;\;\;\;{a}^{4} \cdot \left(1 - \frac{4}{a}\right)\\
\mathbf{elif}\;a \leq 2.5 \cdot 10^{+32}:\\
\;\;\;\;{b}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -1.15e7Initial program 72.7%
associate--l+72.7%
fma-define72.7%
distribute-rgt-in72.7%
sqr-neg72.7%
distribute-rgt-in72.7%
Simplified72.7%
Taylor expanded in a around inf 95.9%
associate-*r/95.9%
metadata-eval95.9%
Simplified95.9%
if -1.15e7 < a < 2.4999999999999999e32Initial program 99.9%
Taylor expanded in a around 0 99.1%
Taylor expanded in a around inf 88.0%
Taylor expanded in a around 0 98.0%
if 2.4999999999999999e32 < a Initial program 22.5%
associate--l+22.5%
fma-define22.5%
distribute-rgt-in22.5%
sqr-neg22.5%
distribute-rgt-in22.5%
Simplified30.1%
Taylor expanded in a around inf 98.2%
associate-*r/98.2%
metadata-eval98.2%
Simplified98.2%
Taylor expanded in a around inf 98.2%
Final simplification97.6%
(FPCore (a b) :precision binary64 (if (<= a -28000000.0) (* (pow a 3.0) (- a 4.0)) (if (<= a 1.25e+31) (+ (pow b 4.0) -1.0) (pow a 4.0))))
double code(double a, double b) {
double tmp;
if (a <= -28000000.0) {
tmp = pow(a, 3.0) * (a - 4.0);
} else if (a <= 1.25e+31) {
tmp = pow(b, 4.0) + -1.0;
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-28000000.0d0)) then
tmp = (a ** 3.0d0) * (a - 4.0d0)
else if (a <= 1.25d+31) then
tmp = (b ** 4.0d0) + (-1.0d0)
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -28000000.0) {
tmp = Math.pow(a, 3.0) * (a - 4.0);
} else if (a <= 1.25e+31) {
tmp = Math.pow(b, 4.0) + -1.0;
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -28000000.0: tmp = math.pow(a, 3.0) * (a - 4.0) elif a <= 1.25e+31: tmp = math.pow(b, 4.0) + -1.0 else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -28000000.0) tmp = Float64((a ^ 3.0) * Float64(a - 4.0)); elseif (a <= 1.25e+31) tmp = Float64((b ^ 4.0) + -1.0); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -28000000.0) tmp = (a ^ 3.0) * (a - 4.0); elseif (a <= 1.25e+31) tmp = (b ^ 4.0) + -1.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -28000000.0], N[(N[Power[a, 3.0], $MachinePrecision] * N[(a - 4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.25e+31], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -28000000:\\
\;\;\;\;{a}^{3} \cdot \left(a - 4\right)\\
\mathbf{elif}\;a \leq 1.25 \cdot 10^{+31}:\\
\;\;\;\;{b}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -2.8e7Initial program 72.7%
associate--l+72.7%
fma-define72.7%
distribute-rgt-in72.7%
sqr-neg72.7%
distribute-rgt-in72.7%
Simplified72.7%
Taylor expanded in a around inf 95.9%
associate-*r/95.9%
metadata-eval95.9%
Simplified95.9%
Taylor expanded in a around 0 95.8%
if -2.8e7 < a < 1.25000000000000007e31Initial program 99.9%
Taylor expanded in a around 0 99.1%
Taylor expanded in a around inf 88.0%
Taylor expanded in a around 0 98.0%
if 1.25000000000000007e31 < a Initial program 22.5%
associate--l+22.5%
fma-define22.5%
distribute-rgt-in22.5%
sqr-neg22.5%
distribute-rgt-in22.5%
Simplified30.1%
Taylor expanded in a around inf 98.2%
associate-*r/98.2%
metadata-eval98.2%
Simplified98.2%
Taylor expanded in a around inf 98.2%
Final simplification97.6%
(FPCore (a b) :precision binary64 (if (or (<= a -12.6) (not (<= a 1.25e+31))) (pow a 4.0) (+ (* (* b b) 12.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -12.6) || !(a <= 1.25e+31)) {
tmp = pow(a, 4.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 ((a <= (-12.6d0)) .or. (.not. (a <= 1.25d+31))) then
tmp = a ** 4.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 ((a <= -12.6) || !(a <= 1.25e+31)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = ((b * b) * 12.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -12.6) or not (a <= 1.25e+31): tmp = math.pow(a, 4.0) else: tmp = ((b * b) * 12.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -12.6) || !(a <= 1.25e+31)) tmp = a ^ 4.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 ((a <= -12.6) || ~((a <= 1.25e+31))) tmp = a ^ 4.0; else tmp = ((b * b) * 12.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -12.6], N[Not[LessEqual[a, 1.25e+31]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -12.6 \lor \neg \left(a \leq 1.25 \cdot 10^{+31}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 12 + -1\\
\end{array}
\end{array}
if a < -12.5999999999999996 or 1.25000000000000007e31 < a Initial program 49.0%
associate--l+49.0%
fma-define49.0%
distribute-rgt-in49.0%
sqr-neg49.0%
distribute-rgt-in49.0%
Simplified52.7%
Taylor expanded in a around inf 95.7%
associate-*r/95.7%
metadata-eval95.7%
Simplified95.7%
Taylor expanded in a around inf 95.5%
if -12.5999999999999996 < a < 1.25000000000000007e31Initial program 99.9%
associate--l+99.9%
fma-define99.9%
distribute-rgt-in99.9%
sqr-neg99.9%
distribute-rgt-in99.9%
Simplified99.9%
Taylor expanded in a around 0 99.6%
Taylor expanded in b around 0 76.1%
*-commutative76.1%
Simplified76.1%
pow299.6%
Applied egg-rr76.1%
Final simplification84.4%
(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 78.0%
associate--l+78.0%
fma-define78.0%
distribute-rgt-in78.0%
sqr-neg78.0%
distribute-rgt-in78.0%
Simplified79.6%
Taylor expanded in a around 0 68.6%
Taylor expanded in b around 0 50.8%
*-commutative50.8%
Simplified50.8%
pow268.6%
Applied egg-rr50.8%
Final simplification50.8%
(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%
fma-define78.0%
distribute-rgt-in78.0%
sqr-neg78.0%
distribute-rgt-in78.0%
Simplified79.6%
Taylor expanded in a around 0 68.6%
Taylor expanded in b around 0 29.5%
herbie shell --seed 2024160
(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))