
(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
(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)))
5e+295)
(fma 4.0 (fma a (* a (- 1.0 a)) t_0) (+ (pow (hypot a b) 4.0) -1.0))
(fma 4.0 (* a a) (+ -1.0 (pow (sqrt (hypot a b)) 8.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))) <= 5e+295) {
tmp = fma(4.0, fma(a, (a * (1.0 - a)), t_0), (pow(hypot(a, b), 4.0) + -1.0));
} else {
tmp = fma(4.0, (a * a), (-1.0 + pow(sqrt(hypot(a, b)), 8.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))) <= 5e+295) tmp = fma(4.0, fma(a, Float64(a * Float64(1.0 - a)), t_0), Float64((hypot(a, b) ^ 4.0) + -1.0)); else tmp = fma(4.0, Float64(a * a), Float64(-1.0 + (sqrt(hypot(a, b)) ^ 8.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], 5e+295], N[(4.0 * N[(a * N[(a * N[(1.0 - 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[(4.0 * N[(a * a), $MachinePrecision] + N[(-1.0 + N[Power[N[Sqrt[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision]], $MachinePrecision], 8.0], $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 5 \cdot 10^{+295}:\\
\;\;\;\;\mathsf{fma}\left(4, \mathsf{fma}\left(a, a \cdot \left(1 - a\right), t_0\right), {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(4, a \cdot a, -1 + {\left(\sqrt{\mathsf{hypot}\left(a, b\right)}\right)}^{8}\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))))) < 4.99999999999999991e295Initial program 99.6%
sub-neg99.6%
+-commutative99.6%
associate-+l+99.6%
fma-def99.6%
associate-*l*99.6%
fma-def99.6%
distribute-lft-out--99.6%
*-rgt-identity99.6%
+-commutative99.6%
Simplified99.8%
Taylor expanded in a around 0 99.8%
mul-1-neg99.8%
*-rgt-identity99.8%
unpow299.8%
distribute-rgt-neg-out99.8%
distribute-lft-in99.9%
sub-neg99.9%
Simplified99.9%
if 4.99999999999999991e295 < (+.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 57.4%
sub-neg57.4%
+-commutative57.4%
associate-+l+57.4%
fma-def57.4%
associate-*l*57.4%
fma-def60.5%
distribute-lft-out--60.5%
*-rgt-identity60.5%
+-commutative60.5%
Simplified60.5%
Taylor expanded in a around 0 60.5%
mul-1-neg60.5%
*-rgt-identity60.5%
unpow260.5%
distribute-rgt-neg-out60.5%
distribute-lft-in60.5%
sub-neg60.5%
Simplified60.5%
Taylor expanded in a around inf 73.5%
+-commutative73.5%
*-rgt-identity73.5%
mul-1-neg73.5%
unpow373.5%
unpow273.5%
distribute-rgt-neg-out73.5%
distribute-lft-out73.5%
sub-neg73.5%
unpow273.5%
associate-*l*73.5%
Simplified73.5%
add-sqr-sqrt73.5%
unpow-prod-down73.4%
Applied egg-rr73.4%
pow-sqr73.5%
metadata-eval73.5%
Simplified73.5%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Simplified100.0%
Final simplification100.0%
(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 5e+279)
(+ t_0 -1.0)
(fma 4.0 (* a a) (+ -1.0 (pow (sqrt (hypot a b)) 8.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 <= 5e+279) {
tmp = t_0 + -1.0;
} else {
tmp = fma(4.0, (a * a), (-1.0 + pow(sqrt(hypot(a, b)), 8.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 <= 5e+279) tmp = Float64(t_0 + -1.0); else tmp = fma(4.0, Float64(a * a), Float64(-1.0 + (sqrt(hypot(a, b)) ^ 8.0))); end return 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, 5e+279], N[(t$95$0 + -1.0), $MachinePrecision], N[(4.0 * N[(a * a), $MachinePrecision] + N[(-1.0 + N[Power[N[Sqrt[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision]], $MachinePrecision], 8.0], $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 5 \cdot 10^{+279}:\\
\;\;\;\;t_0 + -1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(4, a \cdot a, -1 + {\left(\sqrt{\mathsf{hypot}\left(a, b\right)}\right)}^{8}\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))))) < 5.0000000000000002e279Initial program 99.6%
if 5.0000000000000002e279 < (+.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 57.9%
sub-neg57.9%
+-commutative57.9%
associate-+l+57.9%
fma-def57.9%
associate-*l*57.9%
fma-def60.9%
distribute-lft-out--60.9%
*-rgt-identity60.9%
+-commutative60.9%
Simplified61.0%
Taylor expanded in a around 0 61.0%
mul-1-neg61.0%
*-rgt-identity61.0%
unpow261.0%
distribute-rgt-neg-out61.0%
distribute-lft-in61.0%
sub-neg61.0%
Simplified61.0%
Taylor expanded in a around inf 73.8%
+-commutative73.8%
*-rgt-identity73.8%
mul-1-neg73.8%
unpow373.8%
unpow273.8%
distribute-rgt-neg-out73.8%
distribute-lft-out73.8%
sub-neg73.8%
unpow273.8%
associate-*l*73.8%
Simplified73.8%
add-sqr-sqrt73.8%
unpow-prod-down73.8%
Applied egg-rr73.8%
pow-sqr73.8%
metadata-eval73.8%
Simplified73.8%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (a b) :precision binary64 (if (<= a 8e+73) (fma 4.0 (* a (* a (- 1.0 a))) (+ (pow (hypot a b) 4.0) -1.0)) (pow a 4.0)))
double code(double a, double b) {
double tmp;
if (a <= 8e+73) {
tmp = fma(4.0, (a * (a * (1.0 - a))), (pow(hypot(a, b), 4.0) + -1.0));
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (a <= 8e+73) tmp = fma(4.0, Float64(a * Float64(a * Float64(1.0 - a))), Float64((hypot(a, b) ^ 4.0) + -1.0)); else tmp = a ^ 4.0; end return tmp end
code[a_, b_] := If[LessEqual[a, 8e+73], N[(4.0 * N[(a * N[(a * N[(1.0 - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 8 \cdot 10^{+73}:\\
\;\;\;\;\mathsf{fma}\left(4, a \cdot \left(a \cdot \left(1 - a\right)\right), {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < 7.99999999999999986e73Initial program 87.1%
sub-neg87.1%
+-commutative87.1%
associate-+l+87.1%
fma-def87.1%
associate-*l*87.1%
fma-def87.1%
distribute-lft-out--87.1%
*-rgt-identity87.1%
+-commutative87.1%
Simplified87.2%
Taylor expanded in a around 0 87.2%
mul-1-neg87.2%
*-rgt-identity87.2%
unpow287.2%
distribute-rgt-neg-out87.2%
distribute-lft-in87.2%
sub-neg87.2%
Simplified87.2%
Taylor expanded in a around inf 99.0%
+-commutative99.0%
*-rgt-identity99.0%
mul-1-neg99.0%
unpow399.1%
unpow299.1%
distribute-rgt-neg-out99.1%
distribute-lft-out99.1%
sub-neg99.1%
unpow299.1%
associate-*l*99.1%
Simplified99.1%
if 7.99999999999999986e73 < a Initial program 17.3%
sub-neg17.3%
+-commutative17.3%
associate-+l+17.3%
fma-def17.3%
associate-*l*17.3%
fma-def26.9%
distribute-lft-out--26.9%
*-rgt-identity26.9%
+-commutative26.9%
Simplified26.9%
Taylor expanded in a around 0 26.9%
mul-1-neg26.9%
*-rgt-identity26.9%
unpow226.9%
distribute-rgt-neg-out26.9%
distribute-lft-in26.9%
sub-neg26.9%
Simplified26.9%
Taylor expanded in a around inf 100.0%
Final simplification99.3%
(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)))))
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);
}
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);
}
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) 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 + (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 = -1.0 + (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[(-1.0 + N[Power[a, 4.0], $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 + {a}^{4}\\
\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%
Simplified7.2%
Taylor expanded in a around inf 94.5%
Final simplification98.4%
(FPCore (a b) :precision binary64 (if (<= (* b b) 4e-32) (+ -1.0 (pow a 4.0)) (+ -1.0 (+ (pow b 4.0) (* (* b b) 12.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 4e-32) {
tmp = -1.0 + pow(a, 4.0);
} else {
tmp = -1.0 + (pow(b, 4.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) <= 4d-32) then
tmp = (-1.0d0) + (a ** 4.0d0)
else
tmp = (-1.0d0) + ((b ** 4.0d0) + ((b * b) * 12.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 4e-32) {
tmp = -1.0 + Math.pow(a, 4.0);
} else {
tmp = -1.0 + (Math.pow(b, 4.0) + ((b * b) * 12.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 4e-32: tmp = -1.0 + math.pow(a, 4.0) else: tmp = -1.0 + (math.pow(b, 4.0) + ((b * b) * 12.0)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 4e-32) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = Float64(-1.0 + Float64((b ^ 4.0) + Float64(Float64(b * b) * 12.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 4e-32) tmp = -1.0 + (a ^ 4.0); else tmp = -1.0 + ((b ^ 4.0) + ((b * b) * 12.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 4e-32], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[Power[b, 4.0], $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 4 \cdot 10^{-32}:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + \left({b}^{4} + \left(b \cdot b\right) \cdot 12\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 4.00000000000000022e-32Initial program 82.5%
sub-neg82.5%
sqr-pow82.5%
sqr-pow82.5%
sqr-neg82.5%
distribute-rgt-in82.5%
sqr-neg82.5%
distribute-rgt-in82.5%
Simplified82.5%
Taylor expanded in a around inf 97.6%
if 4.00000000000000022e-32 < (*.f64 b b) Initial program 63.4%
sub-neg63.4%
sqr-pow63.4%
sqr-pow63.4%
sqr-neg63.4%
distribute-rgt-in63.4%
sqr-neg63.4%
distribute-rgt-in63.4%
Simplified67.3%
Taylor expanded in a around 0 62.2%
+-commutative62.2%
+-commutative62.2%
associate-+l+62.2%
unpow262.2%
unpow262.2%
associate-*r*62.2%
distribute-rgt-in73.8%
metadata-eval73.8%
distribute-lft-in73.8%
*-commutative73.8%
distribute-lft-in73.8%
metadata-eval73.8%
Simplified73.8%
Taylor expanded in a around 0 92.5%
unpow292.5%
Simplified92.5%
Final simplification95.0%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5000.0) (+ -1.0 (pow a 4.0)) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5000.0) {
tmp = -1.0 + pow(a, 4.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) <= 5000.0d0) then
tmp = (-1.0d0) + (a ** 4.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) <= 5000.0) {
tmp = -1.0 + Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5000.0: tmp = -1.0 + math.pow(a, 4.0) else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5000.0) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5000.0) tmp = -1.0 + (a ^ 4.0); else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5000.0], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5000:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 5e3Initial program 83.1%
sub-neg83.1%
sqr-pow83.1%
sqr-pow83.1%
sqr-neg83.1%
distribute-rgt-in83.1%
sqr-neg83.1%
distribute-rgt-in83.1%
Simplified83.1%
Taylor expanded in a around inf 96.2%
if 5e3 < (*.f64 b b) Initial program 62.0%
sub-neg62.0%
+-commutative62.0%
associate-+l+62.0%
fma-def62.0%
associate-*l*62.0%
fma-def66.0%
distribute-lft-out--66.0%
*-rgt-identity66.0%
+-commutative66.0%
Simplified66.1%
Taylor expanded in a around 0 66.1%
mul-1-neg66.1%
*-rgt-identity66.1%
unpow266.1%
distribute-rgt-neg-out66.1%
distribute-lft-in66.1%
sub-neg66.1%
Simplified66.1%
Taylor expanded in b around inf 93.0%
Final simplification94.6%
(FPCore (a b) :precision binary64 (if (<= a -2.5e+20) (pow a 4.0) (if (<= a 1.5e+37) (+ -1.0 (* (* b b) 12.0)) (pow a 4.0))))
double code(double a, double b) {
double tmp;
if (a <= -2.5e+20) {
tmp = pow(a, 4.0);
} else if (a <= 1.5e+37) {
tmp = -1.0 + ((b * b) * 12.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 <= (-2.5d+20)) then
tmp = a ** 4.0d0
else if (a <= 1.5d+37) then
tmp = (-1.0d0) + ((b * b) * 12.0d0)
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -2.5e+20) {
tmp = Math.pow(a, 4.0);
} else if (a <= 1.5e+37) {
tmp = -1.0 + ((b * b) * 12.0);
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -2.5e+20: tmp = math.pow(a, 4.0) elif a <= 1.5e+37: tmp = -1.0 + ((b * b) * 12.0) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -2.5e+20) tmp = a ^ 4.0; elseif (a <= 1.5e+37) tmp = Float64(-1.0 + Float64(Float64(b * b) * 12.0)); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -2.5e+20) tmp = a ^ 4.0; elseif (a <= 1.5e+37) tmp = -1.0 + ((b * b) * 12.0); else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -2.5e+20], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 1.5e+37], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.5 \cdot 10^{+20}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 1.5 \cdot 10^{+37}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -2.5e20 or 1.50000000000000011e37 < a Initial program 43.7%
sub-neg43.7%
+-commutative43.7%
associate-+l+43.7%
fma-def43.7%
associate-*l*43.7%
fma-def47.8%
distribute-lft-out--47.8%
*-rgt-identity47.8%
+-commutative47.8%
Simplified47.9%
Taylor expanded in a around 0 47.9%
mul-1-neg47.9%
*-rgt-identity47.9%
unpow247.9%
distribute-rgt-neg-out47.9%
distribute-lft-in47.9%
sub-neg47.9%
Simplified47.9%
Taylor expanded in a around inf 93.0%
if -2.5e20 < a < 1.50000000000000011e37Initial program 99.0%
sub-neg99.0%
sqr-pow99.0%
sqr-pow99.0%
sqr-neg99.0%
distribute-rgt-in99.0%
sqr-neg99.0%
distribute-rgt-in99.0%
Simplified99.0%
Taylor expanded in a around 0 84.8%
+-commutative84.8%
+-commutative84.8%
associate-+l+84.8%
unpow284.8%
unpow284.8%
associate-*r*84.8%
distribute-rgt-in95.9%
metadata-eval95.9%
distribute-lft-in95.9%
*-commutative95.9%
distribute-lft-in95.9%
metadata-eval95.9%
Simplified95.9%
Taylor expanded in b around 0 74.4%
unpow274.4%
+-commutative74.4%
fma-udef74.4%
Simplified74.4%
Taylor expanded in a around 0 75.2%
*-commutative75.2%
unpow275.2%
associate-*l*75.2%
Simplified75.2%
Taylor expanded in b around 0 75.2%
unpow275.2%
Simplified75.2%
Final simplification83.6%
(FPCore (a b) :precision binary64 (if (<= b 102.0) (+ -1.0 (* (* a a) 4.0)) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if (b <= 102.0) {
tmp = -1.0 + ((a * a) * 4.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 <= 102.0d0) then
tmp = (-1.0d0) + ((a * a) * 4.0d0)
else
tmp = b ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 102.0) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 102.0: tmp = -1.0 + ((a * a) * 4.0) else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 102.0) tmp = Float64(-1.0 + Float64(Float64(a * a) * 4.0)); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 102.0) tmp = -1.0 + ((a * a) * 4.0); else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 102.0], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 102:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 102Initial program 76.6%
sub-neg76.6%
sqr-pow76.6%
sqr-pow76.6%
sqr-neg76.6%
distribute-rgt-in76.6%
sqr-neg76.6%
distribute-rgt-in76.6%
Simplified77.6%
Taylor expanded in b around 0 64.3%
fma-def64.3%
unpow264.3%
associate-*r*64.3%
Simplified64.3%
Taylor expanded in a around 0 63.8%
unpow263.8%
Simplified63.8%
if 102 < b Initial program 62.5%
sub-neg62.5%
+-commutative62.5%
associate-+l+62.5%
fma-def62.5%
associate-*l*62.5%
fma-def67.0%
distribute-lft-out--67.0%
*-rgt-identity67.0%
+-commutative67.0%
Simplified67.2%
Taylor expanded in a around 0 67.2%
mul-1-neg67.2%
*-rgt-identity67.2%
unpow267.2%
distribute-rgt-neg-out67.2%
distribute-lft-in67.2%
sub-neg67.2%
Simplified67.2%
Taylor expanded in b around inf 91.5%
Final simplification71.0%
(FPCore (a b) :precision binary64 (if (<= b 7e+152) (+ -1.0 (* (* a a) 4.0)) (+ -1.0 (* (* b b) 12.0))))
double code(double a, double b) {
double tmp;
if (b <= 7e+152) {
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 <= 7d+152) 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 <= 7e+152) {
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 <= 7e+152: 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 (b <= 7e+152) 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 <= 7e+152) 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[b, 7e+152], 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 \leq 7 \cdot 10^{+152}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\end{array}
\end{array}
if b < 6.99999999999999963e152Initial program 77.2%
sub-neg77.2%
sqr-pow77.2%
sqr-pow77.2%
sqr-neg77.2%
distribute-rgt-in77.2%
sqr-neg77.2%
distribute-rgt-in77.2%
Simplified78.1%
Taylor expanded in b around 0 59.2%
fma-def59.2%
unpow259.2%
associate-*r*59.2%
Simplified59.2%
Taylor expanded in a around 0 58.0%
unpow258.0%
Simplified58.0%
if 6.99999999999999963e152 < b Initial program 45.7%
sub-neg45.7%
sqr-pow45.7%
sqr-pow45.7%
sqr-neg45.7%
distribute-rgt-in45.7%
sqr-neg45.7%
distribute-rgt-in45.7%
Simplified54.3%
Taylor expanded in a around 0 51.4%
+-commutative51.4%
+-commutative51.4%
associate-+l+51.4%
unpow251.4%
unpow251.4%
associate-*r*51.4%
distribute-rgt-in74.3%
metadata-eval74.3%
distribute-lft-in74.3%
*-commutative74.3%
distribute-lft-in74.3%
metadata-eval74.3%
Simplified74.3%
Taylor expanded in b around 0 74.3%
unpow274.3%
+-commutative74.3%
fma-udef74.3%
Simplified74.3%
Taylor expanded in a around 0 100.0%
*-commutative100.0%
unpow2100.0%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in b around 0 100.0%
unpow2100.0%
Simplified100.0%
Final simplification63.7%
(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 72.9%
sub-neg72.9%
sqr-pow72.9%
sqr-pow72.9%
sqr-neg72.9%
distribute-rgt-in72.9%
sqr-neg72.9%
distribute-rgt-in72.9%
Simplified74.8%
Taylor expanded in b around 0 55.1%
fma-def55.1%
unpow255.1%
associate-*r*55.1%
Simplified55.1%
Taylor expanded in a around 0 55.1%
unpow255.1%
Simplified55.1%
Final simplification55.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 72.9%
sub-neg72.9%
sqr-pow72.9%
sqr-pow72.9%
sqr-neg72.9%
distribute-rgt-in72.9%
sqr-neg72.9%
distribute-rgt-in72.9%
Simplified74.8%
Taylor expanded in b around 0 55.1%
fma-def55.1%
unpow255.1%
associate-*r*55.1%
Simplified55.1%
Taylor expanded in a around 0 26.6%
Final simplification26.6%
herbie shell --seed 2023287
(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))