
(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 (hypot a b) 4.0)
(fma 4.0 (- (fma (* b b) (+ a 3.0) (* a a)) (pow a 3.0)) -1.0))
(* (+ (* a a) 1.0) (+ (* a a) -1.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(hypot(a, b), 4.0) + fma(4.0, (fma((b * b), (a + 3.0), (a * a)) - pow(a, 3.0)), -1.0);
} else {
tmp = ((a * a) + 1.0) * ((a * a) + -1.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((hypot(a, b) ^ 4.0) + fma(4.0, Float64(fma(Float64(b * b), Float64(a + 3.0), Float64(a * a)) - (a ^ 3.0)), -1.0)); else tmp = Float64(Float64(Float64(a * a) + 1.0) * Float64(Float64(a * a) + -1.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[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision] - N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a * a), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + -1.0), $MachinePrecision]), $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(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(4, \mathsf{fma}\left(b \cdot b, a + 3, a \cdot a\right) - {a}^{3}, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot a + 1\right) \cdot \left(a \cdot a + -1\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%
associate--l+99.8%
Simplified99.9%
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%
fma-def0.0%
fma-def9.7%
+-commutative9.7%
metadata-eval9.7%
Simplified9.7%
Taylor expanded in a around inf 96.9%
metadata-eval96.9%
pow-prod-up96.9%
pow296.9%
pow296.9%
difference-of-sqr--196.9%
Applied egg-rr96.9%
Final simplification99.2%
(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) (* (+ (* a a) 1.0) (+ (* a a) -1.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 = ((a * a) + 1.0) * ((a * a) + -1.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 = ((a * a) + 1.0) * ((a * a) + -1.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 = ((a * a) + 1.0) * ((a * a) + -1.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(Float64(Float64(a * a) + 1.0) * Float64(Float64(a * a) + -1.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 * a) + 1.0) * ((a * a) + -1.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[(N[(N[(a * a), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + -1.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}:\\
\;\;\;\;\left(a \cdot a + 1\right) \cdot \left(a \cdot a + -1\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%
fma-def0.0%
fma-def9.7%
+-commutative9.7%
metadata-eval9.7%
Simplified9.7%
Taylor expanded in a around inf 96.9%
metadata-eval96.9%
pow-prod-up96.9%
pow296.9%
pow296.9%
difference-of-sqr--196.9%
Applied egg-rr96.9%
Final simplification99.1%
(FPCore (a b) :precision binary64 (if (<= (* b b) 400000000.0) (+ -1.0 (pow a 4.0)) (+ -1.0 (* (* b b) (+ (* b b) (* (* a a) 2.0))))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 400000000.0) {
tmp = -1.0 + pow(a, 4.0);
} else {
tmp = -1.0 + ((b * b) * ((b * b) + ((a * a) * 2.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) <= 400000000.0d0) then
tmp = (-1.0d0) + (a ** 4.0d0)
else
tmp = (-1.0d0) + ((b * b) * ((b * b) + ((a * a) * 2.0d0)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 400000000.0) {
tmp = -1.0 + Math.pow(a, 4.0);
} else {
tmp = -1.0 + ((b * b) * ((b * b) + ((a * a) * 2.0)));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 400000000.0: tmp = -1.0 + math.pow(a, 4.0) else: tmp = -1.0 + ((b * b) * ((b * b) + ((a * a) * 2.0))) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 400000000.0) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = Float64(-1.0 + Float64(Float64(b * b) * Float64(Float64(b * b) + Float64(Float64(a * a) * 2.0)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 400000000.0) tmp = -1.0 + (a ^ 4.0); else tmp = -1.0 + ((b * b) * ((b * b) + ((a * a) * 2.0))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 400000000.0], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 400000000:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + \left(a \cdot a\right) \cdot 2\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 4e8Initial program 84.9%
sub-neg84.9%
fma-def84.9%
fma-def84.9%
+-commutative84.9%
metadata-eval84.9%
Simplified84.9%
Taylor expanded in a around inf 96.7%
if 4e8 < (*.f64 b b) Initial program 65.5%
sub-neg65.5%
fma-def65.5%
fma-def70.4%
+-commutative70.4%
metadata-eval70.4%
Simplified70.4%
Taylor expanded in b around inf 98.1%
fma-def98.1%
fma-def98.1%
unpow298.1%
distribute-lft-in98.1%
metadata-eval98.1%
unpow298.1%
Simplified98.1%
Taylor expanded in a around inf 86.5%
unpow286.5%
Simplified86.5%
fma-udef86.5%
metadata-eval86.5%
pow-prod-up86.4%
pow286.4%
pow286.4%
distribute-rgt-out97.9%
Applied egg-rr97.9%
Final simplification97.3%
(FPCore (a b) :precision binary64 (if (<= (* b b) 400000000.0) (* (+ (* a a) 1.0) (+ (* a a) -1.0)) (+ -1.0 (* (* b b) (+ (* b b) (* (* a a) 2.0))))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 400000000.0) {
tmp = ((a * a) + 1.0) * ((a * a) + -1.0);
} else {
tmp = -1.0 + ((b * b) * ((b * b) + ((a * a) * 2.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) <= 400000000.0d0) then
tmp = ((a * a) + 1.0d0) * ((a * a) + (-1.0d0))
else
tmp = (-1.0d0) + ((b * b) * ((b * b) + ((a * a) * 2.0d0)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 400000000.0) {
tmp = ((a * a) + 1.0) * ((a * a) + -1.0);
} else {
tmp = -1.0 + ((b * b) * ((b * b) + ((a * a) * 2.0)));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 400000000.0: tmp = ((a * a) + 1.0) * ((a * a) + -1.0) else: tmp = -1.0 + ((b * b) * ((b * b) + ((a * a) * 2.0))) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 400000000.0) tmp = Float64(Float64(Float64(a * a) + 1.0) * Float64(Float64(a * a) + -1.0)); else tmp = Float64(-1.0 + Float64(Float64(b * b) * Float64(Float64(b * b) + Float64(Float64(a * a) * 2.0)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 400000000.0) tmp = ((a * a) + 1.0) * ((a * a) + -1.0); else tmp = -1.0 + ((b * b) * ((b * b) + ((a * a) * 2.0))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 400000000.0], N[(N[(N[(a * a), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 400000000:\\
\;\;\;\;\left(a \cdot a + 1\right) \cdot \left(a \cdot a + -1\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + \left(a \cdot a\right) \cdot 2\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 4e8Initial program 84.9%
sub-neg84.9%
fma-def84.9%
fma-def84.9%
+-commutative84.9%
metadata-eval84.9%
Simplified84.9%
Taylor expanded in a around inf 96.7%
metadata-eval96.7%
pow-prod-up96.6%
pow296.6%
pow296.6%
difference-of-sqr--196.6%
Applied egg-rr96.6%
if 4e8 < (*.f64 b b) Initial program 65.5%
sub-neg65.5%
fma-def65.5%
fma-def70.4%
+-commutative70.4%
metadata-eval70.4%
Simplified70.4%
Taylor expanded in b around inf 98.1%
fma-def98.1%
fma-def98.1%
unpow298.1%
distribute-lft-in98.1%
metadata-eval98.1%
unpow298.1%
Simplified98.1%
Taylor expanded in a around inf 86.5%
unpow286.5%
Simplified86.5%
fma-udef86.5%
metadata-eval86.5%
pow-prod-up86.4%
pow286.4%
pow286.4%
distribute-rgt-out97.9%
Applied egg-rr97.9%
Final simplification97.2%
(FPCore (a b) :precision binary64 (if (or (<= a -1e-309) (not (<= a 580.0))) (* (+ (* a a) 1.0) (+ (* a a) -1.0)) (+ -1.0 (* b (* b (* a 4.0))))))
double code(double a, double b) {
double tmp;
if ((a <= -1e-309) || !(a <= 580.0)) {
tmp = ((a * a) + 1.0) * ((a * a) + -1.0);
} else {
tmp = -1.0 + (b * (b * (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 <= (-1d-309)) .or. (.not. (a <= 580.0d0))) then
tmp = ((a * a) + 1.0d0) * ((a * a) + (-1.0d0))
else
tmp = (-1.0d0) + (b * (b * (a * 4.0d0)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -1e-309) || !(a <= 580.0)) {
tmp = ((a * a) + 1.0) * ((a * a) + -1.0);
} else {
tmp = -1.0 + (b * (b * (a * 4.0)));
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -1e-309) or not (a <= 580.0): tmp = ((a * a) + 1.0) * ((a * a) + -1.0) else: tmp = -1.0 + (b * (b * (a * 4.0))) return tmp
function code(a, b) tmp = 0.0 if ((a <= -1e-309) || !(a <= 580.0)) tmp = Float64(Float64(Float64(a * a) + 1.0) * Float64(Float64(a * a) + -1.0)); else tmp = Float64(-1.0 + Float64(b * Float64(b * Float64(a * 4.0)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -1e-309) || ~((a <= 580.0))) tmp = ((a * a) + 1.0) * ((a * a) + -1.0); else tmp = -1.0 + (b * (b * (a * 4.0))); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -1e-309], N[Not[LessEqual[a, 580.0]], $MachinePrecision]], N[(N[(N[(a * a), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(b * N[(b * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1 \cdot 10^{-309} \lor \neg \left(a \leq 580\right):\\
\;\;\;\;\left(a \cdot a + 1\right) \cdot \left(a \cdot a + -1\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + b \cdot \left(b \cdot \left(a \cdot 4\right)\right)\\
\end{array}
\end{array}
if a < -1.000000000000002e-309 or 580 < a Initial program 68.0%
sub-neg68.0%
fma-def68.0%
fma-def71.1%
+-commutative71.1%
metadata-eval71.1%
Simplified71.1%
Taylor expanded in a around inf 76.4%
metadata-eval76.4%
pow-prod-up76.3%
pow276.3%
pow276.3%
difference-of-sqr--176.3%
Applied egg-rr76.3%
if -1.000000000000002e-309 < a < 580Initial program 100.0%
sub-neg100.0%
fma-def100.0%
fma-def100.0%
+-commutative100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in b around inf 99.3%
fma-def99.3%
fma-def99.3%
unpow299.3%
distribute-lft-in99.3%
metadata-eval99.3%
unpow299.3%
Simplified99.3%
Taylor expanded in a around inf 59.5%
unpow259.5%
unpow259.5%
associate-*r*59.5%
associate-*l*59.5%
unpow259.5%
associate-*r*59.5%
*-commutative59.5%
distribute-rgt-in70.9%
associate-*l*70.9%
unpow270.9%
*-commutative70.9%
+-commutative70.9%
associate-*l*57.0%
+-commutative57.0%
unpow257.0%
associate-*l*57.0%
distribute-rgt-out57.0%
Simplified57.0%
Taylor expanded in a around 0 57.0%
associate-*r*57.0%
*-commutative57.0%
*-commutative57.0%
*-commutative57.0%
Simplified57.0%
Final simplification71.7%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+61) (* (+ (* a a) 1.0) (+ (* a a) -1.0)) (+ -1.0 (* a (* a (* b (* b 2.0)))))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+61) {
tmp = ((a * a) + 1.0) * ((a * a) + -1.0);
} else {
tmp = -1.0 + (a * (a * (b * (b * 2.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+61) then
tmp = ((a * a) + 1.0d0) * ((a * a) + (-1.0d0))
else
tmp = (-1.0d0) + (a * (a * (b * (b * 2.0d0))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+61) {
tmp = ((a * a) + 1.0) * ((a * a) + -1.0);
} else {
tmp = -1.0 + (a * (a * (b * (b * 2.0))));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e+61: tmp = ((a * a) + 1.0) * ((a * a) + -1.0) else: tmp = -1.0 + (a * (a * (b * (b * 2.0)))) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e+61) tmp = Float64(Float64(Float64(a * a) + 1.0) * Float64(Float64(a * a) + -1.0)); else tmp = Float64(-1.0 + Float64(a * Float64(a * Float64(b * Float64(b * 2.0))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5e+61) tmp = ((a * a) + 1.0) * ((a * a) + -1.0); else tmp = -1.0 + (a * (a * (b * (b * 2.0)))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e+61], N[(N[(N[(a * a), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(a * N[(a * N[(b * N[(b * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{+61}:\\
\;\;\;\;\left(a \cdot a + 1\right) \cdot \left(a \cdot a + -1\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + a \cdot \left(a \cdot \left(b \cdot \left(b \cdot 2\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 5.00000000000000018e61Initial program 85.2%
sub-neg85.2%
fma-def85.2%
fma-def85.2%
+-commutative85.2%
metadata-eval85.2%
Simplified85.2%
Taylor expanded in a around inf 92.2%
metadata-eval92.2%
pow-prod-up92.0%
pow292.0%
pow292.0%
difference-of-sqr--192.0%
Applied egg-rr92.0%
if 5.00000000000000018e61 < (*.f64 b b) Initial program 63.3%
sub-neg63.3%
fma-def63.3%
fma-def68.7%
+-commutative68.7%
metadata-eval68.7%
Simplified68.7%
Taylor expanded in b around inf 100.0%
fma-def100.0%
fma-def100.0%
unpow2100.0%
distribute-lft-in100.0%
metadata-eval100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in a around inf 87.5%
unpow287.5%
Simplified87.5%
Taylor expanded in a around inf 60.5%
*-commutative60.5%
unpow260.5%
unpow260.5%
associate-*l*73.0%
associate-*l*73.0%
*-commutative73.0%
associate-*r*73.0%
*-commutative73.0%
*-commutative73.0%
*-commutative73.0%
associate-*l*73.0%
*-commutative73.0%
associate-*l*73.0%
Simplified73.0%
Final simplification83.7%
(FPCore (a b) :precision binary64 (if (<= a -5e-310) (+ -1.0 (* a (* a (* a -4.0)))) (if (<= a 6.8e+150) (+ -1.0 (* b (* b (* a 4.0)))) (* (* a a) 4.0))))
double code(double a, double b) {
double tmp;
if (a <= -5e-310) {
tmp = -1.0 + (a * (a * (a * -4.0)));
} else if (a <= 6.8e+150) {
tmp = -1.0 + (b * (b * (a * 4.0)));
} else {
tmp = (a * 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 <= (-5d-310)) then
tmp = (-1.0d0) + (a * (a * (a * (-4.0d0))))
else if (a <= 6.8d+150) then
tmp = (-1.0d0) + (b * (b * (a * 4.0d0)))
else
tmp = (a * a) * 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -5e-310) {
tmp = -1.0 + (a * (a * (a * -4.0)));
} else if (a <= 6.8e+150) {
tmp = -1.0 + (b * (b * (a * 4.0)));
} else {
tmp = (a * a) * 4.0;
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -5e-310: tmp = -1.0 + (a * (a * (a * -4.0))) elif a <= 6.8e+150: tmp = -1.0 + (b * (b * (a * 4.0))) else: tmp = (a * a) * 4.0 return tmp
function code(a, b) tmp = 0.0 if (a <= -5e-310) tmp = Float64(-1.0 + Float64(a * Float64(a * Float64(a * -4.0)))); elseif (a <= 6.8e+150) tmp = Float64(-1.0 + Float64(b * Float64(b * Float64(a * 4.0)))); else tmp = Float64(Float64(a * a) * 4.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -5e-310) tmp = -1.0 + (a * (a * (a * -4.0))); elseif (a <= 6.8e+150) tmp = -1.0 + (b * (b * (a * 4.0))); else tmp = (a * a) * 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -5e-310], N[(-1.0 + N[(a * N[(a * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 6.8e+150], N[(-1.0 + N[(b * N[(b * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-1 + a \cdot \left(a \cdot \left(a \cdot -4\right)\right)\\
\mathbf{elif}\;a \leq 6.8 \cdot 10^{+150}:\\
\;\;\;\;-1 + b \cdot \left(b \cdot \left(a \cdot 4\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot a\right) \cdot 4\\
\end{array}
\end{array}
if a < -4.999999999999985e-310Initial program 85.7%
sub-neg85.7%
fma-def85.7%
fma-def85.7%
+-commutative85.7%
metadata-eval85.7%
Simplified85.7%
Taylor expanded in b around 0 72.6%
associate-*r*72.6%
unpow272.6%
Simplified72.6%
Taylor expanded in a around 0 59.9%
unpow259.9%
*-commutative59.9%
associate-*r*59.9%
cube-mult59.9%
associate-*r*59.9%
metadata-eval59.9%
distribute-lft-neg-in59.9%
*-commutative59.9%
distribute-lft-neg-in59.9%
associate-*r*59.9%
*-commutative59.9%
associate-*r*59.9%
distribute-rgt1-in59.9%
+-commutative59.9%
sub-neg59.9%
*-commutative59.9%
associate-*l*59.9%
*-commutative59.9%
associate-*r*59.9%
Simplified59.9%
Taylor expanded in a around inf 59.3%
unpow259.3%
mul-1-neg59.3%
distribute-rgt-neg-out59.3%
Simplified59.3%
Taylor expanded in a around 0 59.3%
unpow259.3%
associate-*r*59.3%
Simplified59.3%
if -4.999999999999985e-310 < a < 6.79999999999999965e150Initial program 90.2%
sub-neg90.2%
fma-def90.2%
fma-def96.6%
+-commutative96.6%
metadata-eval96.6%
Simplified96.6%
Taylor expanded in b around inf 83.4%
fma-def83.4%
fma-def83.4%
unpow283.4%
distribute-lft-in83.4%
metadata-eval83.4%
unpow283.4%
Simplified83.4%
Taylor expanded in a around inf 55.2%
unpow255.2%
unpow255.2%
associate-*r*55.2%
associate-*l*55.2%
unpow255.2%
associate-*r*55.2%
*-commutative55.2%
distribute-rgt-in62.6%
associate-*l*62.6%
unpow262.6%
*-commutative62.6%
+-commutative62.6%
associate-*l*53.6%
+-commutative53.6%
unpow253.6%
associate-*l*53.6%
distribute-rgt-out53.6%
Simplified53.6%
Taylor expanded in a around 0 51.5%
associate-*r*51.5%
*-commutative51.5%
*-commutative51.5%
*-commutative51.5%
Simplified51.5%
if 6.79999999999999965e150 < a Initial program 0.0%
sub-neg0.0%
fma-def0.0%
fma-def0.0%
+-commutative0.0%
metadata-eval0.0%
Simplified0.0%
Taylor expanded in b around 0 0.0%
associate-*r*0.0%
unpow20.0%
Simplified0.0%
Taylor expanded in a around 0 97.5%
unpow297.5%
*-commutative97.5%
associate-*r*97.5%
*-commutative97.5%
Simplified97.5%
Taylor expanded in a around inf 97.5%
unpow297.5%
Simplified97.5%
Final simplification61.6%
(FPCore (a b) :precision binary64 (if (<= a -1.0) (+ -1.0 (* a (* a (* a -4.0)))) (+ -1.0 (* a (* a 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= -1.0) {
tmp = -1.0 + (a * (a * (a * -4.0)));
} else {
tmp = -1.0 + (a * (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 <= (-1.0d0)) then
tmp = (-1.0d0) + (a * (a * (a * (-4.0d0))))
else
tmp = (-1.0d0) + (a * (a * 4.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -1.0) {
tmp = -1.0 + (a * (a * (a * -4.0)));
} else {
tmp = -1.0 + (a * (a * 4.0));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -1.0: tmp = -1.0 + (a * (a * (a * -4.0))) else: tmp = -1.0 + (a * (a * 4.0)) return tmp
function code(a, b) tmp = 0.0 if (a <= -1.0) tmp = Float64(-1.0 + Float64(a * Float64(a * Float64(a * -4.0)))); else tmp = Float64(-1.0 + Float64(a * Float64(a * 4.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -1.0) tmp = -1.0 + (a * (a * (a * -4.0))); else tmp = -1.0 + (a * (a * 4.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -1.0], N[(-1.0 + N[(a * N[(a * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(a * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1:\\
\;\;\;\;-1 + a \cdot \left(a \cdot \left(a \cdot -4\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + a \cdot \left(a \cdot 4\right)\\
\end{array}
\end{array}
if a < -1Initial program 72.2%
sub-neg72.2%
fma-def72.2%
fma-def72.2%
+-commutative72.2%
metadata-eval72.2%
Simplified72.2%
Taylor expanded in b around 0 95.3%
associate-*r*95.3%
unpow295.3%
Simplified95.3%
Taylor expanded in a around 0 71.8%
unpow271.8%
*-commutative71.8%
associate-*r*71.8%
cube-mult71.8%
associate-*r*71.8%
metadata-eval71.8%
distribute-lft-neg-in71.8%
*-commutative71.8%
distribute-lft-neg-in71.8%
associate-*r*71.8%
*-commutative71.8%
associate-*r*71.8%
distribute-rgt1-in71.8%
+-commutative71.8%
sub-neg71.8%
*-commutative71.8%
associate-*l*71.8%
*-commutative71.8%
associate-*r*71.8%
Simplified71.8%
Taylor expanded in a around inf 71.8%
unpow271.8%
mul-1-neg71.8%
distribute-rgt-neg-out71.8%
Simplified71.8%
Taylor expanded in a around 0 71.8%
unpow271.8%
associate-*r*71.8%
Simplified71.8%
if -1 < a Initial program 76.8%
sub-neg76.8%
fma-def76.8%
fma-def80.0%
+-commutative80.0%
metadata-eval80.0%
Simplified80.0%
Taylor expanded in b around 0 39.3%
associate-*r*39.3%
unpow239.3%
Simplified39.3%
Taylor expanded in a around 0 48.8%
unpow248.8%
*-commutative48.8%
associate-*r*48.8%
*-commutative48.8%
Simplified48.8%
Final simplification54.6%
(FPCore (a b) :precision binary64 (if (or (<= a -0.42) (not (<= a 0.08))) (* (* a a) 4.0) -1.0))
double code(double a, double b) {
double tmp;
if ((a <= -0.42) || !(a <= 0.08)) {
tmp = (a * a) * 4.0;
} else {
tmp = -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 <= (-0.42d0)) .or. (.not. (a <= 0.08d0))) then
tmp = (a * a) * 4.0d0
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -0.42) || !(a <= 0.08)) {
tmp = (a * a) * 4.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -0.42) or not (a <= 0.08): tmp = (a * a) * 4.0 else: tmp = -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -0.42) || !(a <= 0.08)) tmp = Float64(Float64(a * a) * 4.0); else tmp = -1.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -0.42) || ~((a <= 0.08))) tmp = (a * a) * 4.0; else tmp = -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -0.42], N[Not[LessEqual[a, 0.08]], $MachinePrecision]], N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision], -1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.42 \lor \neg \left(a \leq 0.08\right):\\
\;\;\;\;\left(a \cdot a\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if a < -0.419999999999999984 or 0.0800000000000000017 < a Initial program 53.5%
sub-neg53.5%
fma-def53.5%
fma-def58.0%
+-commutative58.0%
metadata-eval58.0%
Simplified58.0%
Taylor expanded in b around 0 58.6%
associate-*r*58.6%
unpow258.6%
Simplified58.6%
Taylor expanded in a around 0 54.8%
unpow254.8%
*-commutative54.8%
associate-*r*54.8%
*-commutative54.8%
Simplified54.8%
Taylor expanded in a around inf 54.8%
unpow254.8%
Simplified54.8%
if -0.419999999999999984 < a < 0.0800000000000000017Initial program 99.9%
sub-neg99.9%
fma-def99.9%
fma-def99.9%
+-commutative99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in b around inf 98.3%
fma-def98.3%
fma-def98.3%
unpow298.3%
distribute-lft-in98.3%
metadata-eval98.3%
unpow298.3%
Simplified98.3%
Taylor expanded in b around 0 46.2%
Final simplification50.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(a * Float64(a * 4.0))) end
function tmp = code(a, b) tmp = -1.0 + (a * (a * 4.0)); end
code[a_, b_] := N[(-1.0 + N[(a * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 + a \cdot \left(a \cdot 4\right)
\end{array}
Initial program 75.6%
sub-neg75.6%
fma-def75.6%
fma-def78.0%
+-commutative78.0%
metadata-eval78.0%
Simplified78.0%
Taylor expanded in b around 0 53.5%
associate-*r*53.5%
unpow253.5%
Simplified53.5%
Taylor expanded in a around 0 50.9%
unpow250.9%
*-commutative50.9%
associate-*r*50.9%
*-commutative50.9%
Simplified50.9%
Final simplification50.9%
(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 75.6%
sub-neg75.6%
fma-def75.6%
fma-def78.0%
+-commutative78.0%
metadata-eval78.0%
Simplified78.0%
Taylor expanded in b around inf 76.7%
fma-def76.7%
fma-def76.7%
unpow276.7%
distribute-lft-in76.7%
metadata-eval76.7%
unpow276.7%
Simplified76.7%
Taylor expanded in b around 0 22.4%
Final simplification22.4%
herbie shell --seed 2023256
(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))