
(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)
(fma 4.0 (fma a (- a (* a a)) t_0) (+ (pow (hypot a b) 4.0) -1.0))
(+ -1.0 (+ (pow a 4.0) (* (* b b) (* a (* a 2.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 = fma(4.0, fma(a, (a - (a * a)), t_0), (pow(hypot(a, b), 4.0) + -1.0));
} else {
tmp = -1.0 + (pow(a, 4.0) + ((b * b) * (a * (a * 2.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 = fma(4.0, fma(a, Float64(a - Float64(a * a)), t_0), Float64((hypot(a, b) ^ 4.0) + -1.0)); else tmp = Float64(-1.0 + Float64((a ^ 4.0) + Float64(Float64(b * b) * Float64(a * Float64(a * 2.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[(4.0 * N[(a * N[(a - N[(a * a), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision] + N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[Power[a, 4.0], $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(a * N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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:\\
\;\;\;\;\mathsf{fma}\left(4, \mathsf{fma}\left(a, a - a \cdot a, t_0\right), {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left({a}^{4} + \left(b \cdot b\right) \cdot \left(a \cdot \left(a \cdot 2\right)\right)\right)\\
\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%
+-commutative99.8%
associate-+l+99.8%
fma-def99.8%
associate-*l*99.8%
fma-def99.8%
distribute-lft-out--99.8%
*-rgt-identity99.8%
+-commutative99.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-pow0.0%
sqr-pow0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
Simplified8.3%
Taylor expanded in b around 0 36.1%
fma-def36.1%
fma-def36.1%
unpow236.1%
distribute-rgt-in36.1%
metadata-eval36.1%
unpow236.1%
unpow236.1%
associate-*r*36.1%
Simplified36.1%
Taylor expanded in a around inf 88.9%
Taylor expanded in a around inf 52.8%
+-commutative52.8%
+-commutative52.8%
associate-+l+52.8%
unpow252.8%
associate-*r*52.8%
unpow252.8%
unpow252.8%
associate-*r*52.8%
unpow252.8%
distribute-rgt-in88.9%
*-commutative88.9%
+-commutative88.9%
unpow288.9%
associate-*r*88.9%
*-commutative88.9%
distribute-rgt-out88.9%
Simplified88.9%
Taylor expanded in a around inf 88.9%
unpow288.9%
*-commutative88.9%
associate-*r*88.9%
*-commutative88.9%
Simplified88.9%
Final simplification96.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)
(+ -1.0 (+ (pow a 4.0) (* (* b b) (* a (* a 2.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 = -1.0 + (pow(a, 4.0) + ((b * b) * (a * (a * 2.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 = -1.0 + (Math.pow(a, 4.0) + ((b * b) * (a * (a * 2.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 = -1.0 + (math.pow(a, 4.0) + ((b * b) * (a * (a * 2.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(-1.0 + Float64((a ^ 4.0) + Float64(Float64(b * b) * Float64(a * Float64(a * 2.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 = -1.0 + ((a ^ 4.0) + ((b * b) * (a * (a * 2.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[(-1.0 + N[(N[Power[a, 4.0], $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(a * N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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}:\\
\;\;\;\;-1 + \left({a}^{4} + \left(b \cdot b\right) \cdot \left(a \cdot \left(a \cdot 2\right)\right)\right)\\
\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-pow0.0%
sqr-pow0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
Simplified8.3%
Taylor expanded in b around 0 36.1%
fma-def36.1%
fma-def36.1%
unpow236.1%
distribute-rgt-in36.1%
metadata-eval36.1%
unpow236.1%
unpow236.1%
associate-*r*36.1%
Simplified36.1%
Taylor expanded in a around inf 88.9%
Taylor expanded in a around inf 52.8%
+-commutative52.8%
+-commutative52.8%
associate-+l+52.8%
unpow252.8%
associate-*r*52.8%
unpow252.8%
unpow252.8%
associate-*r*52.8%
unpow252.8%
distribute-rgt-in88.9%
*-commutative88.9%
+-commutative88.9%
unpow288.9%
associate-*r*88.9%
*-commutative88.9%
distribute-rgt-out88.9%
Simplified88.9%
Taylor expanded in a around inf 88.9%
unpow288.9%
*-commutative88.9%
associate-*r*88.9%
*-commutative88.9%
Simplified88.9%
Final simplification96.8%
(FPCore (a b)
:precision binary64
(if (<= a -3.3e+59)
(+ -1.0 (* (* a a) (+ (* a a) 4.0)))
(if (<= a 7.4e+19)
(+ -1.0 (+ (pow b 4.0) (* (* b b) 12.0)))
(+ -1.0 (pow a 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= -3.3e+59) {
tmp = -1.0 + ((a * a) * ((a * a) + 4.0));
} else if (a <= 7.4e+19) {
tmp = -1.0 + (pow(b, 4.0) + ((b * b) * 12.0));
} else {
tmp = -1.0 + 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 <= (-3.3d+59)) then
tmp = (-1.0d0) + ((a * a) * ((a * a) + 4.0d0))
else if (a <= 7.4d+19) then
tmp = (-1.0d0) + ((b ** 4.0d0) + ((b * b) * 12.0d0))
else
tmp = (-1.0d0) + (a ** 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -3.3e+59) {
tmp = -1.0 + ((a * a) * ((a * a) + 4.0));
} else if (a <= 7.4e+19) {
tmp = -1.0 + (Math.pow(b, 4.0) + ((b * b) * 12.0));
} else {
tmp = -1.0 + Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -3.3e+59: tmp = -1.0 + ((a * a) * ((a * a) + 4.0)) elif a <= 7.4e+19: tmp = -1.0 + (math.pow(b, 4.0) + ((b * b) * 12.0)) else: tmp = -1.0 + math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -3.3e+59) tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(Float64(a * a) + 4.0))); elseif (a <= 7.4e+19) tmp = Float64(-1.0 + Float64((b ^ 4.0) + Float64(Float64(b * b) * 12.0))); else tmp = Float64(-1.0 + (a ^ 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -3.3e+59) tmp = -1.0 + ((a * a) * ((a * a) + 4.0)); elseif (a <= 7.4e+19) tmp = -1.0 + ((b ^ 4.0) + ((b * b) * 12.0)); else tmp = -1.0 + (a ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -3.3e+59], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 7.4e+19], N[(-1.0 + N[(N[Power[b, 4.0], $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.3 \cdot 10^{+59}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a + 4\right)\\
\mathbf{elif}\;a \leq 7.4 \cdot 10^{+19}:\\
\;\;\;\;-1 + \left({b}^{4} + \left(b \cdot b\right) \cdot 12\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + {a}^{4}\\
\end{array}
\end{array}
if a < -3.2999999999999999e59Initial program 61.7%
sub-neg61.7%
sqr-pow61.7%
sqr-pow61.7%
sqr-neg61.7%
distribute-rgt-in61.7%
sqr-neg61.7%
distribute-rgt-in61.7%
Simplified61.7%
Taylor expanded in b around 0 98.1%
unpow298.1%
associate-*r*98.1%
Simplified98.1%
Taylor expanded in a around 0 98.1%
unpow298.1%
Simplified98.1%
+-commutative98.1%
metadata-eval98.1%
pow-sqr98.1%
pow-prod-down98.1%
pow298.1%
distribute-rgt-out98.1%
Applied egg-rr98.1%
if -3.2999999999999999e59 < a < 7.4e19Initial program 94.2%
sub-neg94.2%
sqr-pow94.2%
sqr-pow94.2%
sqr-neg94.2%
distribute-rgt-in94.2%
sqr-neg94.2%
distribute-rgt-in94.2%
Simplified94.2%
Taylor expanded in a around 0 77.5%
associate-+r+77.5%
associate-*r*77.5%
distribute-rgt-out91.0%
metadata-eval91.0%
distribute-lft-in91.0%
+-commutative91.0%
unpow291.0%
distribute-lft-in91.0%
metadata-eval91.0%
Simplified91.0%
Taylor expanded in a around 0 96.7%
unpow296.7%
Simplified96.7%
if 7.4e19 < a Initial program 32.2%
sub-neg32.2%
sqr-pow32.2%
sqr-pow32.2%
sqr-neg32.2%
distribute-rgt-in32.2%
sqr-neg32.2%
distribute-rgt-in32.2%
Simplified41.1%
Taylor expanded in a around inf 93.1%
Final simplification96.0%
(FPCore (a b)
:precision binary64
(if (<= a -3.8e+60)
(+ -1.0 (* (* a a) (+ (* a a) 4.0)))
(if (<= a 3.3e+21)
(+ -1.0 (* b (* b (fma b b 12.0))))
(+ -1.0 (pow a 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= -3.8e+60) {
tmp = -1.0 + ((a * a) * ((a * a) + 4.0));
} else if (a <= 3.3e+21) {
tmp = -1.0 + (b * (b * fma(b, b, 12.0)));
} else {
tmp = -1.0 + pow(a, 4.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (a <= -3.8e+60) tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(Float64(a * a) + 4.0))); elseif (a <= 3.3e+21) tmp = Float64(-1.0 + Float64(b * Float64(b * fma(b, b, 12.0)))); else tmp = Float64(-1.0 + (a ^ 4.0)); end return tmp end
code[a_, b_] := If[LessEqual[a, -3.8e+60], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 3.3e+21], N[(-1.0 + N[(b * N[(b * N[(b * b + 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.8 \cdot 10^{+60}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a + 4\right)\\
\mathbf{elif}\;a \leq 3.3 \cdot 10^{+21}:\\
\;\;\;\;-1 + b \cdot \left(b \cdot \mathsf{fma}\left(b, b, 12\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + {a}^{4}\\
\end{array}
\end{array}
if a < -3.80000000000000009e60Initial program 61.7%
sub-neg61.7%
sqr-pow61.7%
sqr-pow61.7%
sqr-neg61.7%
distribute-rgt-in61.7%
sqr-neg61.7%
distribute-rgt-in61.7%
Simplified61.7%
Taylor expanded in b around 0 98.1%
unpow298.1%
associate-*r*98.1%
Simplified98.1%
Taylor expanded in a around 0 98.1%
unpow298.1%
Simplified98.1%
+-commutative98.1%
metadata-eval98.1%
pow-sqr98.1%
pow-prod-down98.1%
pow298.1%
distribute-rgt-out98.1%
Applied egg-rr98.1%
if -3.80000000000000009e60 < a < 3.3e21Initial program 94.2%
sub-neg94.2%
sqr-pow94.2%
sqr-pow94.2%
sqr-neg94.2%
distribute-rgt-in94.2%
sqr-neg94.2%
distribute-rgt-in94.2%
Simplified94.2%
Taylor expanded in a around 0 77.5%
associate-+r+77.5%
associate-*r*77.5%
distribute-rgt-out91.0%
metadata-eval91.0%
distribute-lft-in91.0%
+-commutative91.0%
unpow291.0%
distribute-lft-in91.0%
metadata-eval91.0%
Simplified91.0%
Taylor expanded in a around 0 96.7%
unpow296.7%
Simplified96.7%
Taylor expanded in b around 0 96.7%
unpow296.7%
metadata-eval96.7%
pow-plus96.6%
unpow396.6%
associate-*r*96.6%
distribute-rgt-in96.5%
associate-*l*96.6%
+-commutative96.6%
fma-udef96.6%
Simplified96.6%
if 3.3e21 < a Initial program 32.2%
sub-neg32.2%
sqr-pow32.2%
sqr-pow32.2%
sqr-neg32.2%
distribute-rgt-in32.2%
sqr-neg32.2%
distribute-rgt-in32.2%
Simplified41.1%
Taylor expanded in a around inf 93.1%
Final simplification96.0%
(FPCore (a b)
:precision binary64
(if (<= a -7e+60)
(+ -1.0 (* (* a a) (+ (* a a) 4.0)))
(if (<= a 122000000000.0)
(+ -1.0 (* (* b b) (+ (* b b) 12.0)))
(+ -1.0 (pow a 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= -7e+60) {
tmp = -1.0 + ((a * a) * ((a * a) + 4.0));
} else if (a <= 122000000000.0) {
tmp = -1.0 + ((b * b) * ((b * b) + 12.0));
} else {
tmp = -1.0 + 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 <= (-7d+60)) then
tmp = (-1.0d0) + ((a * a) * ((a * a) + 4.0d0))
else if (a <= 122000000000.0d0) then
tmp = (-1.0d0) + ((b * b) * ((b * b) + 12.0d0))
else
tmp = (-1.0d0) + (a ** 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -7e+60) {
tmp = -1.0 + ((a * a) * ((a * a) + 4.0));
} else if (a <= 122000000000.0) {
tmp = -1.0 + ((b * b) * ((b * b) + 12.0));
} else {
tmp = -1.0 + Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -7e+60: tmp = -1.0 + ((a * a) * ((a * a) + 4.0)) elif a <= 122000000000.0: tmp = -1.0 + ((b * b) * ((b * b) + 12.0)) else: tmp = -1.0 + math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -7e+60) tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(Float64(a * a) + 4.0))); elseif (a <= 122000000000.0) tmp = Float64(-1.0 + Float64(Float64(b * b) * Float64(Float64(b * b) + 12.0))); else tmp = Float64(-1.0 + (a ^ 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -7e+60) tmp = -1.0 + ((a * a) * ((a * a) + 4.0)); elseif (a <= 122000000000.0) tmp = -1.0 + ((b * b) * ((b * b) + 12.0)); else tmp = -1.0 + (a ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -7e+60], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 122000000000.0], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -7 \cdot 10^{+60}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a + 4\right)\\
\mathbf{elif}\;a \leq 122000000000:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 12\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + {a}^{4}\\
\end{array}
\end{array}
if a < -7.0000000000000004e60Initial program 61.7%
sub-neg61.7%
sqr-pow61.7%
sqr-pow61.7%
sqr-neg61.7%
distribute-rgt-in61.7%
sqr-neg61.7%
distribute-rgt-in61.7%
Simplified61.7%
Taylor expanded in b around 0 98.1%
unpow298.1%
associate-*r*98.1%
Simplified98.1%
Taylor expanded in a around 0 98.1%
unpow298.1%
Simplified98.1%
+-commutative98.1%
metadata-eval98.1%
pow-sqr98.1%
pow-prod-down98.1%
pow298.1%
distribute-rgt-out98.1%
Applied egg-rr98.1%
if -7.0000000000000004e60 < a < 1.22e11Initial program 94.2%
sub-neg94.2%
sqr-pow94.2%
sqr-pow94.2%
sqr-neg94.2%
distribute-rgt-in94.2%
sqr-neg94.2%
distribute-rgt-in94.2%
Simplified94.2%
Taylor expanded in a around 0 77.5%
associate-+r+77.5%
associate-*r*77.5%
distribute-rgt-out91.0%
metadata-eval91.0%
distribute-lft-in91.0%
+-commutative91.0%
unpow291.0%
distribute-lft-in91.0%
metadata-eval91.0%
Simplified91.0%
Taylor expanded in a around 0 96.7%
unpow296.7%
Simplified96.7%
+-commutative96.7%
metadata-eval96.7%
pow-prod-up96.6%
pow296.6%
pow296.6%
distribute-rgt-out96.5%
Applied egg-rr96.5%
if 1.22e11 < a Initial program 32.2%
sub-neg32.2%
sqr-pow32.2%
sqr-pow32.2%
sqr-neg32.2%
distribute-rgt-in32.2%
sqr-neg32.2%
distribute-rgt-in32.2%
Simplified41.1%
Taylor expanded in a around inf 93.1%
Final simplification95.9%
(FPCore (a b) :precision binary64 (if (or (<= a -4.6e+58) (not (<= a 1.7e+17))) (+ -1.0 (* (* a a) (+ (* a a) 4.0))) (+ -1.0 (* (* b b) (+ (* b b) 12.0)))))
double code(double a, double b) {
double tmp;
if ((a <= -4.6e+58) || !(a <= 1.7e+17)) {
tmp = -1.0 + ((a * a) * ((a * a) + 4.0));
} else {
tmp = -1.0 + ((b * b) * ((b * b) + 12.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.6d+58)) .or. (.not. (a <= 1.7d+17))) then
tmp = (-1.0d0) + ((a * a) * ((a * a) + 4.0d0))
else
tmp = (-1.0d0) + ((b * b) * ((b * b) + 12.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -4.6e+58) || !(a <= 1.7e+17)) {
tmp = -1.0 + ((a * a) * ((a * a) + 4.0));
} else {
tmp = -1.0 + ((b * b) * ((b * b) + 12.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -4.6e+58) or not (a <= 1.7e+17): tmp = -1.0 + ((a * a) * ((a * a) + 4.0)) else: tmp = -1.0 + ((b * b) * ((b * b) + 12.0)) return tmp
function code(a, b) tmp = 0.0 if ((a <= -4.6e+58) || !(a <= 1.7e+17)) tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(Float64(a * a) + 4.0))); else tmp = Float64(-1.0 + Float64(Float64(b * b) * Float64(Float64(b * b) + 12.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -4.6e+58) || ~((a <= 1.7e+17))) tmp = -1.0 + ((a * a) * ((a * a) + 4.0)); else tmp = -1.0 + ((b * b) * ((b * b) + 12.0)); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -4.6e+58], N[Not[LessEqual[a, 1.7e+17]], $MachinePrecision]], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.6 \cdot 10^{+58} \lor \neg \left(a \leq 1.7 \cdot 10^{+17}\right):\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a + 4\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 12\right)\\
\end{array}
\end{array}
if a < -4.60000000000000005e58 or 1.7e17 < a Initial program 44.3%
sub-neg44.3%
sqr-pow44.3%
sqr-pow44.3%
sqr-neg44.3%
distribute-rgt-in44.3%
sqr-neg44.3%
distribute-rgt-in44.3%
Simplified49.5%
Taylor expanded in b around 0 55.1%
unpow255.1%
associate-*r*55.1%
Simplified55.1%
Taylor expanded in a around 0 95.1%
unpow295.1%
Simplified95.1%
+-commutative95.1%
metadata-eval95.1%
pow-sqr95.1%
pow-prod-down95.1%
pow295.1%
distribute-rgt-out95.1%
Applied egg-rr95.1%
if -4.60000000000000005e58 < a < 1.7e17Initial program 94.2%
sub-neg94.2%
sqr-pow94.2%
sqr-pow94.2%
sqr-neg94.2%
distribute-rgt-in94.2%
sqr-neg94.2%
distribute-rgt-in94.2%
Simplified94.2%
Taylor expanded in a around 0 77.5%
associate-+r+77.5%
associate-*r*77.5%
distribute-rgt-out91.0%
metadata-eval91.0%
distribute-lft-in91.0%
+-commutative91.0%
unpow291.0%
distribute-lft-in91.0%
metadata-eval91.0%
Simplified91.0%
Taylor expanded in a around 0 96.7%
unpow296.7%
Simplified96.7%
+-commutative96.7%
metadata-eval96.7%
pow-prod-up96.6%
pow296.6%
pow296.6%
distribute-rgt-out96.5%
Applied egg-rr96.5%
Final simplification95.9%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e+254) (+ -1.0 (* (* a a) (+ (* a a) 4.0))) (+ -1.0 (* (* b b) 12.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e+254) {
tmp = -1.0 + ((a * a) * ((a * a) + 4.0));
} else {
tmp = -1.0 + ((b * b) * 12.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+254) then
tmp = (-1.0d0) + ((a * a) * ((a * a) + 4.0d0))
else
tmp = (-1.0d0) + ((b * b) * 12.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 1e+254) {
tmp = -1.0 + ((a * a) * ((a * a) + 4.0));
} else {
tmp = -1.0 + ((b * b) * 12.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 1e+254: tmp = -1.0 + ((a * a) * ((a * a) + 4.0)) else: tmp = -1.0 + ((b * b) * 12.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1e+254) tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(Float64(a * a) + 4.0))); else tmp = Float64(-1.0 + Float64(Float64(b * b) * 12.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 1e+254) tmp = -1.0 + ((a * a) * ((a * a) + 4.0)); else tmp = -1.0 + ((b * b) * 12.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e+254], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{+254}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a + 4\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\end{array}
\end{array}
if (*.f64 b b) < 9.9999999999999994e253Initial program 78.9%
sub-neg78.9%
sqr-pow78.9%
sqr-pow78.9%
sqr-neg78.9%
distribute-rgt-in78.9%
sqr-neg78.9%
distribute-rgt-in78.9%
Simplified79.5%
Taylor expanded in b around 0 57.8%
unpow257.8%
associate-*r*57.8%
Simplified57.8%
Taylor expanded in a around 0 76.1%
unpow276.1%
Simplified76.1%
+-commutative76.1%
metadata-eval76.1%
pow-sqr76.1%
pow-prod-down76.1%
pow276.1%
distribute-rgt-out76.1%
Applied egg-rr76.1%
if 9.9999999999999994e253 < (*.f64 b b) Initial program 58.4%
sub-neg58.4%
sqr-pow58.4%
sqr-pow58.4%
sqr-neg58.4%
distribute-rgt-in58.4%
sqr-neg58.4%
distribute-rgt-in58.4%
Simplified64.0%
Taylor expanded in a around 0 52.8%
associate-+r+52.8%
associate-*r*52.8%
distribute-rgt-out74.2%
metadata-eval74.2%
distribute-lft-in74.2%
+-commutative74.2%
unpow274.2%
distribute-lft-in74.2%
metadata-eval74.2%
Simplified74.2%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in b around 0 100.0%
unpow2100.0%
metadata-eval100.0%
pow-plus100.0%
unpow3100.0%
associate-*r*100.0%
distribute-rgt-in100.0%
associate-*l*100.0%
+-commutative100.0%
fma-udef100.0%
Simplified100.0%
Taylor expanded in b around 0 92.8%
unpow292.8%
Simplified92.8%
Final simplification81.9%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e+204) (+ -1.0 (* (* a a) 4.0)) (+ -1.0 (* (* b b) 12.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e+204) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = -1.0 + ((b * b) * 12.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+204) then
tmp = (-1.0d0) + ((a * a) * 4.0d0)
else
tmp = (-1.0d0) + ((b * b) * 12.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 1e+204) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = -1.0 + ((b * b) * 12.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 1e+204: tmp = -1.0 + ((a * a) * 4.0) else: tmp = -1.0 + ((b * b) * 12.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1e+204) tmp = Float64(-1.0 + Float64(Float64(a * a) * 4.0)); else tmp = Float64(-1.0 + Float64(Float64(b * b) * 12.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 1e+204) tmp = -1.0 + ((a * a) * 4.0); else tmp = -1.0 + ((b * b) * 12.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e+204], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{+204}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\end{array}
\end{array}
if (*.f64 b b) < 9.99999999999999989e203Initial program 78.8%
sub-neg78.8%
sqr-pow78.8%
sqr-pow78.8%
sqr-neg78.8%
distribute-rgt-in78.8%
sqr-neg78.8%
distribute-rgt-in78.8%
Simplified78.8%
Taylor expanded in b around 0 60.8%
unpow260.8%
associate-*r*60.8%
Simplified60.8%
Taylor expanded in a around 0 57.7%
unpow257.7%
Simplified57.7%
if 9.99999999999999989e203 < (*.f64 b b) Initial program 60.6%
sub-neg60.6%
sqr-pow60.6%
sqr-pow60.6%
sqr-neg60.6%
distribute-rgt-in60.6%
sqr-neg60.6%
distribute-rgt-in60.6%
Simplified66.7%
Taylor expanded in a around 0 56.6%
associate-+r+56.6%
associate-*r*56.6%
distribute-rgt-out75.8%
metadata-eval75.8%
distribute-lft-in75.8%
+-commutative75.8%
unpow275.8%
distribute-lft-in75.8%
metadata-eval75.8%
Simplified75.8%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in b around 0 100.0%
unpow2100.0%
metadata-eval100.0%
pow-plus100.0%
unpow3100.0%
associate-*r*100.0%
distribute-rgt-in100.0%
associate-*l*100.0%
+-commutative100.0%
fma-udef100.0%
Simplified100.0%
Taylor expanded in b around 0 84.0%
unpow284.0%
Simplified84.0%
Final simplification67.9%
(FPCore (a b) :precision binary64 (+ -1.0 (* (* a a) 4.0)))
double code(double a, double b) {
return -1.0 + ((a * a) * 4.0);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (-1.0d0) + ((a * a) * 4.0d0)
end function
public static double code(double a, double b) {
return -1.0 + ((a * a) * 4.0);
}
def code(a, b): return -1.0 + ((a * a) * 4.0)
function code(a, b) return Float64(-1.0 + Float64(Float64(a * a) * 4.0)) end
function tmp = code(a, b) tmp = -1.0 + ((a * a) * 4.0); end
code[a_, b_] := N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 + \left(a \cdot a\right) \cdot 4
\end{array}
Initial program 71.8%
sub-neg71.8%
sqr-pow71.8%
sqr-pow71.8%
sqr-neg71.8%
distribute-rgt-in71.8%
sqr-neg71.8%
distribute-rgt-in71.8%
Simplified74.1%
Taylor expanded in b around 0 44.7%
unpow244.7%
associate-*r*44.7%
Simplified44.7%
Taylor expanded in a around 0 41.7%
unpow241.7%
Simplified41.7%
Final simplification41.7%
herbie shell --seed 2023263
(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))