
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 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) * (1.0 - (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) * (1.0d0 - (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) * (1.0 - (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) * (1.0 - (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(1.0 - 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) * (1.0 - (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[(1.0 - N[(3.0 * a), $MachinePrecision]), $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(1 - 3 \cdot 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) (- 1.0 (* 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) * (1.0 - (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) * (1.0d0 - (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) * (1.0 - (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) * (1.0 - (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(1.0 - 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) * (1.0 - (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[(1.0 - N[(3.0 * a), $MachinePrecision]), $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(1 - 3 \cdot a\right)\right)\right) - 1
\end{array}
(FPCore (a b)
:precision binary64
(if (<=
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (+ a 1.0)) (* (* b b) (- 1.0 (* a 3.0))))))
INFINITY)
(+
(fma
4.0
(fma a (fma a a a) (* b (* b (fma a -3.0 1.0))))
(pow (hypot a b) 4.0))
-1.0)
(pow a 4.0)))
double code(double a, double b) {
double tmp;
if ((pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))))) <= ((double) INFINITY)) {
tmp = fma(4.0, fma(a, fma(a, a, a), (b * (b * fma(a, -3.0, 1.0)))), pow(hypot(a, b), 4.0)) + -1.0;
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(a + 1.0)) + Float64(Float64(b * b) * Float64(1.0 - Float64(a * 3.0)))))) <= Inf) tmp = Float64(fma(4.0, fma(a, fma(a, a, a), Float64(b * Float64(b * fma(a, -3.0, 1.0)))), (hypot(a, b) ^ 4.0)) + -1.0); else tmp = a ^ 4.0; end return tmp end
code[a_, b_] := If[LessEqual[N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(a + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(4.0 * N[(a * N[(a * a + a), $MachinePrecision] + N[(b * N[(b * N[(a * -3.0 + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right) \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(4, \mathsf{fma}\left(a, \mathsf{fma}\left(a, a, a\right), b \cdot \left(b \cdot \mathsf{fma}\left(a, -3, 1\right)\right)\right), {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{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 1 (*.f64 3 a)))))) < +inf.0Initial program 99.8%
sub-neg99.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 1 (*.f64 3 a)))))) Initial program 0.0%
associate--l+0.0%
fma-def0.0%
Simplified3.0%
Taylor expanded in a around inf 95.7%
Final simplification98.9%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (+ a 1.0)) (* (* b b) (- 1.0 (* a 3.0))))))))
(if (<= t_0 INFINITY) (+ t_0 -1.0) (pow a 4.0))))
double code(double a, double b) {
double t_0 = pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0 + -1.0;
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 + -1.0;
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): t_0 = math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0))))) tmp = 0 if t_0 <= math.inf: tmp = t_0 + -1.0 else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) t_0 = Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(a + 1.0)) + Float64(Float64(b * b) * Float64(1.0 - Float64(a * 3.0)))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(t_0 + -1.0); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) t_0 = (((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0))))); tmp = 0.0; if (t_0 <= Inf) tmp = t_0 + -1.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(a + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(t$95$0 + -1.0), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right)\\
\mathbf{if}\;t_0 \leq \infty:\\
\;\;\;\;t_0 + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (+.f64 1 a)) (*.f64 (*.f64 b b) (-.f64 1 (*.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 1 (*.f64 3 a)))))) Initial program 0.0%
associate--l+0.0%
fma-def0.0%
Simplified3.0%
Taylor expanded in a around inf 95.7%
Final simplification98.7%
(FPCore (a b) :precision binary64 (if (<= (* b b) 0.005) (+ -1.0 (pow a 4.0)) (+ -1.0 (+ (* (* b b) 4.0) (pow b 4.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 0.005) {
tmp = -1.0 + pow(a, 4.0);
} else {
tmp = -1.0 + (((b * b) * 4.0) + 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) <= 0.005d0) then
tmp = (-1.0d0) + (a ** 4.0d0)
else
tmp = (-1.0d0) + (((b * b) * 4.0d0) + (b ** 4.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 0.005) {
tmp = -1.0 + Math.pow(a, 4.0);
} else {
tmp = -1.0 + (((b * b) * 4.0) + Math.pow(b, 4.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 0.005: tmp = -1.0 + math.pow(a, 4.0) else: tmp = -1.0 + (((b * b) * 4.0) + math.pow(b, 4.0)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 0.005) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = Float64(-1.0 + Float64(Float64(Float64(b * b) * 4.0) + (b ^ 4.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 0.005) tmp = -1.0 + (a ^ 4.0); else tmp = -1.0 + (((b * b) * 4.0) + (b ^ 4.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 0.005], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 0.005:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(\left(b \cdot b\right) \cdot 4 + {b}^{4}\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 0.0050000000000000001Initial program 80.3%
Applied egg-rr80.3%
Taylor expanded in a around inf 98.3%
if 0.0050000000000000001 < (*.f64 b b) Initial program 68.3%
associate--l+68.3%
fma-def68.3%
Simplified69.8%
Taylor expanded in a around 0 92.2%
associate--l+92.2%
fma-def92.2%
unpow292.2%
sub-neg92.2%
metadata-eval92.2%
Simplified92.2%
fma-udef92.2%
associate-+r+92.2%
Applied egg-rr92.2%
Final simplification95.1%
(FPCore (a b) :precision binary64 (if (<= (* b b) 0.005) (+ (pow a 4.0) (+ -1.0 (* (* a a) 4.0))) (+ -1.0 (+ (* (* b b) 4.0) (pow b 4.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 0.005) {
tmp = pow(a, 4.0) + (-1.0 + ((a * a) * 4.0));
} else {
tmp = -1.0 + (((b * b) * 4.0) + 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) <= 0.005d0) then
tmp = (a ** 4.0d0) + ((-1.0d0) + ((a * a) * 4.0d0))
else
tmp = (-1.0d0) + (((b * b) * 4.0d0) + (b ** 4.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 0.005) {
tmp = Math.pow(a, 4.0) + (-1.0 + ((a * a) * 4.0));
} else {
tmp = -1.0 + (((b * b) * 4.0) + Math.pow(b, 4.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 0.005: tmp = math.pow(a, 4.0) + (-1.0 + ((a * a) * 4.0)) else: tmp = -1.0 + (((b * b) * 4.0) + math.pow(b, 4.0)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 0.005) tmp = Float64((a ^ 4.0) + Float64(-1.0 + Float64(Float64(a * a) * 4.0))); else tmp = Float64(-1.0 + Float64(Float64(Float64(b * b) * 4.0) + (b ^ 4.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 0.005) tmp = (a ^ 4.0) + (-1.0 + ((a * a) * 4.0)); else tmp = -1.0 + (((b * b) * 4.0) + (b ^ 4.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 0.005], N[(N[Power[a, 4.0], $MachinePrecision] + N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 0.005:\\
\;\;\;\;{a}^{4} + \left(-1 + \left(a \cdot a\right) \cdot 4\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(\left(b \cdot b\right) \cdot 4 + {b}^{4}\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 0.0050000000000000001Initial program 80.3%
associate--l+80.3%
fma-def80.3%
Simplified80.3%
Taylor expanded in b around 0 80.4%
associate--l+80.4%
associate-*r*80.4%
unpow280.4%
Simplified80.4%
Taylor expanded in a around 0 98.4%
unpow298.4%
Simplified98.4%
if 0.0050000000000000001 < (*.f64 b b) Initial program 68.3%
associate--l+68.3%
fma-def68.3%
Simplified69.8%
Taylor expanded in a around 0 92.2%
associate--l+92.2%
fma-def92.2%
unpow292.2%
sub-neg92.2%
metadata-eval92.2%
Simplified92.2%
fma-udef92.2%
associate-+r+92.2%
Applied egg-rr92.2%
Final simplification95.2%
(FPCore (a b) :precision binary64 (if (<= (* b b) 0.005) (+ -1.0 (pow a 4.0)) (+ -1.0 (* b (* b (fma b b 4.0))))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 0.005) {
tmp = -1.0 + pow(a, 4.0);
} else {
tmp = -1.0 + (b * (b * fma(b, b, 4.0)));
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 0.005) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = Float64(-1.0 + Float64(b * Float64(b * fma(b, b, 4.0)))); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 0.005], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(b * N[(b * N[(b * b + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 0.005:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + b \cdot \left(b \cdot \mathsf{fma}\left(b, b, 4\right)\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 0.0050000000000000001Initial program 80.3%
Applied egg-rr80.3%
Taylor expanded in a around inf 98.3%
if 0.0050000000000000001 < (*.f64 b b) Initial program 68.3%
associate--l+68.3%
fma-def68.3%
Simplified69.8%
Taylor expanded in a around 0 92.2%
associate--l+92.2%
fma-def92.2%
unpow292.2%
sub-neg92.2%
metadata-eval92.2%
Simplified92.2%
fma-udef92.2%
associate-+r+92.2%
Applied egg-rr92.2%
Taylor expanded in b around 0 92.2%
unpow292.2%
metadata-eval92.2%
pow-sqr92.1%
unpow292.1%
unpow292.1%
distribute-rgt-in92.1%
fma-udef92.1%
associate-*l*92.1%
Simplified92.1%
Final simplification95.1%
(FPCore (a b) :precision binary64 (if (<= (* b b) 0.005) (+ -1.0 (pow a 4.0)) (+ -1.0 (* (* b b) (+ (* b b) 4.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 0.005) {
tmp = -1.0 + pow(a, 4.0);
} else {
tmp = -1.0 + ((b * b) * ((b * 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) <= 0.005d0) then
tmp = (-1.0d0) + (a ** 4.0d0)
else
tmp = (-1.0d0) + ((b * b) * ((b * b) + 4.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 0.005) {
tmp = -1.0 + Math.pow(a, 4.0);
} else {
tmp = -1.0 + ((b * b) * ((b * b) + 4.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 0.005: tmp = -1.0 + math.pow(a, 4.0) else: tmp = -1.0 + ((b * b) * ((b * b) + 4.0)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 0.005) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = Float64(-1.0 + Float64(Float64(b * b) * Float64(Float64(b * b) + 4.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 0.005) tmp = -1.0 + (a ^ 4.0); else tmp = -1.0 + ((b * b) * ((b * b) + 4.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 0.005], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 0.005:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 4\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 0.0050000000000000001Initial program 80.3%
Applied egg-rr80.3%
Taylor expanded in a around inf 98.3%
if 0.0050000000000000001 < (*.f64 b b) Initial program 68.3%
associate--l+68.3%
fma-def68.3%
Simplified69.8%
Taylor expanded in a around 0 92.2%
associate--l+92.2%
fma-def92.2%
unpow292.2%
sub-neg92.2%
metadata-eval92.2%
Simplified92.2%
fma-udef92.2%
associate-+r+92.2%
Applied egg-rr92.2%
sqr-pow92.1%
metadata-eval92.1%
pow292.1%
metadata-eval92.1%
pow292.1%
distribute-rgt-out92.1%
Applied egg-rr92.1%
Final simplification95.0%
(FPCore (a b) :precision binary64 (if (<= a -5e+23) (pow a 4.0) (if (<= a 7.5e+19) (+ -1.0 (* (* b b) (+ (* b b) 4.0))) (pow a 4.0))))
double code(double a, double b) {
double tmp;
if (a <= -5e+23) {
tmp = pow(a, 4.0);
} else if (a <= 7.5e+19) {
tmp = -1.0 + ((b * b) * ((b * b) + 4.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 <= (-5d+23)) then
tmp = a ** 4.0d0
else if (a <= 7.5d+19) then
tmp = (-1.0d0) + ((b * b) * ((b * b) + 4.0d0))
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -5e+23) {
tmp = Math.pow(a, 4.0);
} else if (a <= 7.5e+19) {
tmp = -1.0 + ((b * b) * ((b * b) + 4.0));
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -5e+23: tmp = math.pow(a, 4.0) elif a <= 7.5e+19: tmp = -1.0 + ((b * b) * ((b * b) + 4.0)) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -5e+23) tmp = a ^ 4.0; elseif (a <= 7.5e+19) tmp = Float64(-1.0 + Float64(Float64(b * b) * Float64(Float64(b * b) + 4.0))); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -5e+23) tmp = a ^ 4.0; elseif (a <= 7.5e+19) tmp = -1.0 + ((b * b) * ((b * b) + 4.0)); else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -5e+23], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 7.5e+19], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5 \cdot 10^{+23}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 7.5 \cdot 10^{+19}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 4\right)\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -4.9999999999999999e23 or 7.5e19 < a Initial program 47.0%
associate--l+47.0%
fma-def47.0%
Simplified48.6%
Taylor expanded in a around inf 92.4%
if -4.9999999999999999e23 < a < 7.5e19Initial program 99.1%
associate--l+99.1%
fma-def99.1%
Simplified99.1%
Taylor expanded in a around 0 97.3%
associate--l+97.3%
fma-def97.3%
unpow297.3%
sub-neg97.3%
metadata-eval97.3%
Simplified97.3%
fma-udef97.3%
associate-+r+97.3%
Applied egg-rr97.3%
sqr-pow97.2%
metadata-eval97.2%
pow297.2%
metadata-eval97.2%
pow297.2%
distribute-rgt-out97.2%
Applied egg-rr97.2%
Final simplification94.9%
(FPCore (a b) :precision binary64 (if (or (<= a -6.3e+153) (not (<= a 6.8e+153))) (* (* a a) 4.0) (+ -1.0 (* (* b b) (+ (* b b) 4.0)))))
double code(double a, double b) {
double tmp;
if ((a <= -6.3e+153) || !(a <= 6.8e+153)) {
tmp = (a * a) * 4.0;
} else {
tmp = -1.0 + ((b * b) * ((b * 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 ((a <= (-6.3d+153)) .or. (.not. (a <= 6.8d+153))) then
tmp = (a * a) * 4.0d0
else
tmp = (-1.0d0) + ((b * b) * ((b * b) + 4.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -6.3e+153) || !(a <= 6.8e+153)) {
tmp = (a * a) * 4.0;
} else {
tmp = -1.0 + ((b * b) * ((b * b) + 4.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -6.3e+153) or not (a <= 6.8e+153): tmp = (a * a) * 4.0 else: tmp = -1.0 + ((b * b) * ((b * b) + 4.0)) return tmp
function code(a, b) tmp = 0.0 if ((a <= -6.3e+153) || !(a <= 6.8e+153)) tmp = Float64(Float64(a * a) * 4.0); else tmp = Float64(-1.0 + Float64(Float64(b * b) * Float64(Float64(b * b) + 4.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -6.3e+153) || ~((a <= 6.8e+153))) tmp = (a * a) * 4.0; else tmp = -1.0 + ((b * b) * ((b * b) + 4.0)); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -6.3e+153], N[Not[LessEqual[a, 6.8e+153]], $MachinePrecision]], N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -6.3 \cdot 10^{+153} \lor \neg \left(a \leq 6.8 \cdot 10^{+153}\right):\\
\;\;\;\;\left(a \cdot a\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 4\right)\\
\end{array}
\end{array}
if a < -6.3000000000000001e153 or 6.7999999999999995e153 < a Initial program 24.6%
associate--l+24.6%
fma-def24.6%
Simplified24.6%
Taylor expanded in b around 0 44.6%
associate--l+44.6%
associate-*r*44.6%
unpow244.6%
Simplified44.6%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in a around inf 100.0%
+-commutative100.0%
metadata-eval100.0%
pow-sqr100.0%
unpow2100.0%
unpow2100.0%
unpow2100.0%
distribute-rgt-in100.0%
fma-udef100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Simplified100.0%
if -6.3000000000000001e153 < a < 6.7999999999999995e153Initial program 90.9%
associate--l+90.9%
fma-def90.9%
Simplified91.9%
Taylor expanded in a around 0 78.0%
associate--l+78.0%
fma-def78.0%
unpow278.0%
sub-neg78.0%
metadata-eval78.0%
Simplified78.0%
fma-udef78.0%
associate-+r+78.0%
Applied egg-rr78.0%
sqr-pow77.9%
metadata-eval77.9%
pow277.9%
metadata-eval77.9%
pow277.9%
distribute-rgt-out77.9%
Applied egg-rr77.9%
Final simplification83.5%
(FPCore (a b) :precision binary64 (if (or (<= a -1.35e+152) (not (<= a 6.8e+153))) (* (* a a) 4.0) (+ -1.0 (* b (* b 4.0)))))
double code(double a, double b) {
double tmp;
if ((a <= -1.35e+152) || !(a <= 6.8e+153)) {
tmp = (a * a) * 4.0;
} else {
tmp = -1.0 + (b * (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 ((a <= (-1.35d+152)) .or. (.not. (a <= 6.8d+153))) then
tmp = (a * a) * 4.0d0
else
tmp = (-1.0d0) + (b * (b * 4.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -1.35e+152) || !(a <= 6.8e+153)) {
tmp = (a * a) * 4.0;
} else {
tmp = -1.0 + (b * (b * 4.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -1.35e+152) or not (a <= 6.8e+153): tmp = (a * a) * 4.0 else: tmp = -1.0 + (b * (b * 4.0)) return tmp
function code(a, b) tmp = 0.0 if ((a <= -1.35e+152) || !(a <= 6.8e+153)) tmp = Float64(Float64(a * a) * 4.0); else tmp = Float64(-1.0 + Float64(b * Float64(b * 4.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -1.35e+152) || ~((a <= 6.8e+153))) tmp = (a * a) * 4.0; else tmp = -1.0 + (b * (b * 4.0)); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -1.35e+152], N[Not[LessEqual[a, 6.8e+153]], $MachinePrecision]], N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision], N[(-1.0 + N[(b * N[(b * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.35 \cdot 10^{+152} \lor \neg \left(a \leq 6.8 \cdot 10^{+153}\right):\\
\;\;\;\;\left(a \cdot a\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;-1 + b \cdot \left(b \cdot 4\right)\\
\end{array}
\end{array}
if a < -1.35000000000000007e152 or 6.7999999999999995e153 < a Initial program 23.9%
associate--l+23.9%
fma-def23.9%
Simplified25.4%
Taylor expanded in b around 0 43.3%
associate--l+43.3%
associate-*r*43.3%
unpow243.3%
Simplified43.3%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in a around inf 100.0%
+-commutative100.0%
metadata-eval100.0%
pow-sqr100.0%
unpow2100.0%
unpow2100.0%
unpow2100.0%
distribute-rgt-in100.0%
fma-udef100.0%
Simplified100.0%
Taylor expanded in a around 0 97.4%
unpow297.4%
Simplified97.4%
if -1.35000000000000007e152 < a < 6.7999999999999995e153Initial program 91.9%
associate--l+91.9%
fma-def91.9%
Simplified92.4%
Taylor expanded in a around 0 78.3%
associate--l+78.3%
fma-def78.3%
unpow278.3%
sub-neg78.3%
metadata-eval78.3%
Simplified78.3%
fma-udef78.3%
associate-+r+78.3%
Applied egg-rr78.3%
Taylor expanded in b around 0 78.3%
unpow278.3%
metadata-eval78.3%
pow-sqr78.2%
unpow278.2%
unpow278.2%
distribute-rgt-in78.2%
fma-udef78.2%
associate-*l*78.2%
Simplified78.2%
Taylor expanded in b around 0 52.7%
Final simplification64.4%
(FPCore (a b) :precision binary64 (if (or (<= a -0.00045) (not (<= a 0.09))) (* (* a a) 4.0) -1.0))
double code(double a, double b) {
double tmp;
if ((a <= -0.00045) || !(a <= 0.09)) {
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.00045d0)) .or. (.not. (a <= 0.09d0))) 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.00045) || !(a <= 0.09)) {
tmp = (a * a) * 4.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -0.00045) or not (a <= 0.09): tmp = (a * a) * 4.0 else: tmp = -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -0.00045) || !(a <= 0.09)) 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.00045) || ~((a <= 0.09))) tmp = (a * a) * 4.0; else tmp = -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -0.00045], N[Not[LessEqual[a, 0.09]], $MachinePrecision]], N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision], -1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.00045 \lor \neg \left(a \leq 0.09\right):\\
\;\;\;\;\left(a \cdot a\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if a < -4.4999999999999999e-4 or 0.089999999999999997 < a Initial program 50.2%
associate--l+50.2%
fma-def50.2%
Simplified51.7%
Taylor expanded in b around 0 53.3%
associate--l+53.3%
associate-*r*53.3%
unpow253.3%
Simplified53.3%
Taylor expanded in a around 0 86.7%
unpow286.7%
Simplified86.7%
Taylor expanded in a around inf 86.8%
+-commutative86.8%
metadata-eval86.8%
pow-sqr86.6%
unpow286.6%
unpow286.6%
unpow286.6%
distribute-rgt-in86.6%
fma-udef86.6%
Simplified86.6%
Taylor expanded in a around 0 52.2%
unpow252.2%
Simplified52.2%
if -4.4999999999999999e-4 < a < 0.089999999999999997Initial program 99.9%
associate--l+99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in b around 0 43.5%
associate--l+43.5%
associate-*r*43.5%
unpow243.5%
Simplified43.5%
Taylor expanded in a around 0 43.0%
Final simplification47.8%
(FPCore (a b) :precision binary64 -1.0)
double code(double a, double b) {
return -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = -1.0d0
end function
public static double code(double a, double b) {
return -1.0;
}
def code(a, b): return -1.0
function code(a, b) return -1.0 end
function tmp = code(a, b) tmp = -1.0; end
code[a_, b_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 74.1%
associate--l+74.1%
fma-def74.1%
Simplified74.8%
Taylor expanded in b around 0 48.6%
associate--l+48.6%
associate-*r*48.6%
unpow248.6%
Simplified48.6%
Taylor expanded in a around 0 21.0%
Final simplification21.0%
herbie shell --seed 2023227
(FPCore (a b)
:name "Bouland and Aaronson, Equation (25)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 3.0 a)))))) 1.0))