
(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 10 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.9%
sub-neg99.9%
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%
Simplified5.9%
Taylor expanded in a around inf 97.2%
Final simplification99.2%
(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)
(+
(pow (fma a a (* b b)) 2.0)
(+ -1.0 (* 4.0 (fma (* a a) (+ a 1.0) (* (* b b) (+ 1.0 (* a -3.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 = pow(fma(a, a, (b * b)), 2.0) + (-1.0 + (4.0 * fma((a * a), (a + 1.0), ((b * b) * (1.0 + (a * -3.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(a, a, Float64(b * b)) ^ 2.0) + Float64(-1.0 + Float64(4.0 * fma(Float64(a * a), Float64(a + 1.0), Float64(Float64(b * b) * Float64(1.0 + Float64(a * -3.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[Power[N[(a * a + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(-1.0 + N[(4.0 * N[(N[(a * a), $MachinePrecision] * N[(a + 1.0), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 + N[(a * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right) \leq \infty:\\
\;\;\;\;{\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + \left(-1 + 4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, \left(b \cdot b\right) \cdot \left(1 + a \cdot -3\right)\right)\right)\\
\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.9%
associate--l+99.9%
fma-def99.9%
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 1 (*.f64 3 a)))))) Initial program 0.0%
associate--l+0.0%
fma-def0.0%
Simplified5.9%
Taylor expanded in a around inf 97.2%
Final simplification99.1%
(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.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 1 (*.f64 3 a)))))) Initial program 0.0%
associate--l+0.0%
fma-def0.0%
Simplified5.9%
Taylor expanded in a around inf 97.2%
Final simplification99.1%
(FPCore (a b)
:precision binary64
(if (<= a -88.0)
(pow a 4.0)
(if (<= a 960000000000.0)
(+ (+ -1.0 (pow b 4.0)) (* (* b b) 4.0))
(+ (pow a 4.0) (+ -1.0 (* (+ a 1.0) (* (* a a) 4.0)))))))
double code(double a, double b) {
double tmp;
if (a <= -88.0) {
tmp = pow(a, 4.0);
} else if (a <= 960000000000.0) {
tmp = (-1.0 + pow(b, 4.0)) + ((b * b) * 4.0);
} else {
tmp = pow(a, 4.0) + (-1.0 + ((a + 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 <= (-88.0d0)) then
tmp = a ** 4.0d0
else if (a <= 960000000000.0d0) then
tmp = ((-1.0d0) + (b ** 4.0d0)) + ((b * b) * 4.0d0)
else
tmp = (a ** 4.0d0) + ((-1.0d0) + ((a + 1.0d0) * ((a * a) * 4.0d0)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -88.0) {
tmp = Math.pow(a, 4.0);
} else if (a <= 960000000000.0) {
tmp = (-1.0 + Math.pow(b, 4.0)) + ((b * b) * 4.0);
} else {
tmp = Math.pow(a, 4.0) + (-1.0 + ((a + 1.0) * ((a * a) * 4.0)));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -88.0: tmp = math.pow(a, 4.0) elif a <= 960000000000.0: tmp = (-1.0 + math.pow(b, 4.0)) + ((b * b) * 4.0) else: tmp = math.pow(a, 4.0) + (-1.0 + ((a + 1.0) * ((a * a) * 4.0))) return tmp
function code(a, b) tmp = 0.0 if (a <= -88.0) tmp = a ^ 4.0; elseif (a <= 960000000000.0) tmp = Float64(Float64(-1.0 + (b ^ 4.0)) + Float64(Float64(b * b) * 4.0)); else tmp = Float64((a ^ 4.0) + Float64(-1.0 + Float64(Float64(a + 1.0) * Float64(Float64(a * a) * 4.0)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -88.0) tmp = a ^ 4.0; elseif (a <= 960000000000.0) tmp = (-1.0 + (b ^ 4.0)) + ((b * b) * 4.0); else tmp = (a ^ 4.0) + (-1.0 + ((a + 1.0) * ((a * a) * 4.0))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -88.0], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 960000000000.0], N[(N[(-1.0 + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] + N[(-1.0 + N[(N[(a + 1.0), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -88:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 960000000000:\\
\;\;\;\;\left(-1 + {b}^{4}\right) + \left(b \cdot b\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} + \left(-1 + \left(a + 1\right) \cdot \left(\left(a \cdot a\right) \cdot 4\right)\right)\\
\end{array}
\end{array}
if a < -88Initial program 35.1%
associate--l+35.1%
fma-def35.1%
Simplified40.7%
Taylor expanded in a around inf 89.7%
if -88 < a < 9.6e11Initial program 99.1%
associate--l+99.1%
fma-def99.1%
Simplified99.1%
Taylor expanded in a around 0 100.0%
associate--l+100.0%
fma-def100.0%
unpow2100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
fma-udef100.0%
+-commutative100.0%
Applied egg-rr100.0%
if 9.6e11 < a Initial program 66.5%
associate--l+66.5%
fma-def66.5%
Simplified66.5%
Taylor expanded in b around 0 96.4%
associate--l+96.4%
associate-*r*96.4%
unpow296.4%
Simplified96.4%
Final simplification96.3%
(FPCore (a b)
:precision binary64
(if (<= (* b b) 5e-61)
(pow a 4.0)
(if (<= (* b b) 1e-25)
-1.0
(if (<= (* b b) 1e+80) (pow a 4.0) (pow b 4.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e-61) {
tmp = pow(a, 4.0);
} else if ((b * b) <= 1e-25) {
tmp = -1.0;
} else if ((b * b) <= 1e+80) {
tmp = 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) <= 5d-61) then
tmp = a ** 4.0d0
else if ((b * b) <= 1d-25) then
tmp = -1.0d0
else if ((b * b) <= 1d+80) then
tmp = 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) <= 5e-61) {
tmp = Math.pow(a, 4.0);
} else if ((b * b) <= 1e-25) {
tmp = -1.0;
} else if ((b * b) <= 1e+80) {
tmp = Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e-61: tmp = math.pow(a, 4.0) elif (b * b) <= 1e-25: tmp = -1.0 elif (b * b) <= 1e+80: tmp = 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) <= 5e-61) tmp = a ^ 4.0; elseif (Float64(b * b) <= 1e-25) tmp = -1.0; elseif (Float64(b * b) <= 1e+80) tmp = a ^ 4.0; else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5e-61) tmp = a ^ 4.0; elseif ((b * b) <= 1e-25) tmp = -1.0; elseif ((b * b) <= 1e+80) tmp = a ^ 4.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e-61], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[N[(b * b), $MachinePrecision], 1e-25], -1.0, If[LessEqual[N[(b * b), $MachinePrecision], 1e+80], N[Power[a, 4.0], $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{-61}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;b \cdot b \leq 10^{-25}:\\
\;\;\;\;-1\\
\mathbf{elif}\;b \cdot b \leq 10^{+80}:\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 4.9999999999999999e-61 or 1.00000000000000004e-25 < (*.f64 b b) < 1e80Initial program 79.0%
associate--l+79.0%
fma-def79.0%
Simplified79.0%
Taylor expanded in a around inf 57.9%
if 4.9999999999999999e-61 < (*.f64 b b) < 1.00000000000000004e-25Initial program 88.9%
associate--l+88.9%
fma-def88.9%
Simplified88.9%
Taylor expanded in b around 0 88.9%
associate--l+88.9%
associate-*r*88.9%
unpow288.9%
Simplified88.9%
Taylor expanded in a around 0 77.9%
if 1e80 < (*.f64 b b) Initial program 64.7%
associate--l+64.7%
fma-def64.7%
Simplified68.4%
Taylor expanded in b around inf 95.7%
Final simplification74.6%
(FPCore (a b)
:precision binary64
(if (<= a -210.0)
(pow a 4.0)
(if (<= a 3450000000000.0)
(+ (+ -1.0 (pow b 4.0)) (* (* b b) 4.0))
(pow a 4.0))))
double code(double a, double b) {
double tmp;
if (a <= -210.0) {
tmp = pow(a, 4.0);
} else if (a <= 3450000000000.0) {
tmp = (-1.0 + pow(b, 4.0)) + ((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 <= (-210.0d0)) then
tmp = a ** 4.0d0
else if (a <= 3450000000000.0d0) then
tmp = ((-1.0d0) + (b ** 4.0d0)) + ((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 <= -210.0) {
tmp = Math.pow(a, 4.0);
} else if (a <= 3450000000000.0) {
tmp = (-1.0 + Math.pow(b, 4.0)) + ((b * b) * 4.0);
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -210.0: tmp = math.pow(a, 4.0) elif a <= 3450000000000.0: tmp = (-1.0 + math.pow(b, 4.0)) + ((b * b) * 4.0) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -210.0) tmp = a ^ 4.0; elseif (a <= 3450000000000.0) tmp = Float64(Float64(-1.0 + (b ^ 4.0)) + 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 <= -210.0) tmp = a ^ 4.0; elseif (a <= 3450000000000.0) tmp = (-1.0 + (b ^ 4.0)) + ((b * b) * 4.0); else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -210.0], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 3450000000000.0], N[(N[(-1.0 + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -210:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 3450000000000:\\
\;\;\;\;\left(-1 + {b}^{4}\right) + \left(b \cdot b\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -210 or 3.45e12 < a Initial program 49.9%
associate--l+49.9%
fma-def49.9%
Simplified52.9%
Taylor expanded in a around inf 92.8%
if -210 < a < 3.45e12Initial program 99.1%
associate--l+99.1%
fma-def99.1%
Simplified99.1%
Taylor expanded in a around 0 100.0%
associate--l+100.0%
fma-def100.0%
unpow2100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
fma-udef100.0%
+-commutative100.0%
Applied egg-rr100.0%
Final simplification96.2%
(FPCore (a b)
:precision binary64
(if (<= a -1.45e-23)
(pow a 4.0)
(if (<= a -6e-110)
-1.0
(if (<= a -2.15e-197)
(* (* b b) 4.0)
(if (<= a 0.41) -1.0 (pow a 4.0))))))
double code(double a, double b) {
double tmp;
if (a <= -1.45e-23) {
tmp = pow(a, 4.0);
} else if (a <= -6e-110) {
tmp = -1.0;
} else if (a <= -2.15e-197) {
tmp = (b * b) * 4.0;
} else if (a <= 0.41) {
tmp = -1.0;
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-1.45d-23)) then
tmp = a ** 4.0d0
else if (a <= (-6d-110)) then
tmp = -1.0d0
else if (a <= (-2.15d-197)) then
tmp = (b * b) * 4.0d0
else if (a <= 0.41d0) then
tmp = -1.0d0
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -1.45e-23) {
tmp = Math.pow(a, 4.0);
} else if (a <= -6e-110) {
tmp = -1.0;
} else if (a <= -2.15e-197) {
tmp = (b * b) * 4.0;
} else if (a <= 0.41) {
tmp = -1.0;
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -1.45e-23: tmp = math.pow(a, 4.0) elif a <= -6e-110: tmp = -1.0 elif a <= -2.15e-197: tmp = (b * b) * 4.0 elif a <= 0.41: tmp = -1.0 else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -1.45e-23) tmp = a ^ 4.0; elseif (a <= -6e-110) tmp = -1.0; elseif (a <= -2.15e-197) tmp = Float64(Float64(b * b) * 4.0); elseif (a <= 0.41) tmp = -1.0; else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -1.45e-23) tmp = a ^ 4.0; elseif (a <= -6e-110) tmp = -1.0; elseif (a <= -2.15e-197) tmp = (b * b) * 4.0; elseif (a <= 0.41) tmp = -1.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -1.45e-23], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, -6e-110], -1.0, If[LessEqual[a, -2.15e-197], N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision], If[LessEqual[a, 0.41], -1.0, N[Power[a, 4.0], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.45 \cdot 10^{-23}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq -6 \cdot 10^{-110}:\\
\;\;\;\;-1\\
\mathbf{elif}\;a \leq -2.15 \cdot 10^{-197}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 4\\
\mathbf{elif}\;a \leq 0.41:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -1.4500000000000001e-23 or 0.409999999999999976 < a Initial program 51.3%
associate--l+51.3%
fma-def51.3%
Simplified54.2%
Taylor expanded in a around inf 88.9%
if -1.4500000000000001e-23 < a < -5.99999999999999972e-110 or -2.15e-197 < a < 0.409999999999999976Initial program 99.9%
associate--l+99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in b around 0 55.2%
associate--l+55.2%
associate-*r*55.2%
unpow255.2%
Simplified55.2%
Taylor expanded in a around 0 55.2%
if -5.99999999999999972e-110 < a < -2.15e-197Initial program 100.0%
associate--l+100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
associate--l+100.0%
fma-def100.0%
unpow2100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in b around 0 80.2%
fma-neg80.2%
unpow280.2%
metadata-eval80.2%
Simplified80.2%
Taylor expanded in b around inf 59.4%
unpow259.4%
Simplified59.4%
Final simplification73.9%
(FPCore (a b) :precision binary64 (if (<= a -108.0) (pow a 4.0) (if (<= a 3400000000000.0) (fma 4.0 (* b b) -1.0) (pow a 4.0))))
double code(double a, double b) {
double tmp;
if (a <= -108.0) {
tmp = pow(a, 4.0);
} else if (a <= 3400000000000.0) {
tmp = fma(4.0, (b * b), -1.0);
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (a <= -108.0) tmp = a ^ 4.0; elseif (a <= 3400000000000.0) tmp = fma(4.0, Float64(b * b), -1.0); else tmp = a ^ 4.0; end return tmp end
code[a_, b_] := If[LessEqual[a, -108.0], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 3400000000000.0], N[(4.0 * N[(b * b), $MachinePrecision] + -1.0), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -108:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 3400000000000:\\
\;\;\;\;\mathsf{fma}\left(4, b \cdot b, -1\right)\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -108 or 3.4e12 < a Initial program 49.9%
associate--l+49.9%
fma-def49.9%
Simplified52.9%
Taylor expanded in a around inf 92.8%
if -108 < a < 3.4e12Initial program 99.1%
associate--l+99.1%
fma-def99.1%
Simplified99.1%
Taylor expanded in a around 0 100.0%
associate--l+100.0%
fma-def100.0%
unpow2100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in b around 0 77.9%
fma-neg77.9%
unpow277.9%
metadata-eval77.9%
Simplified77.9%
Final simplification85.7%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e-16) -1.0 (* (* b b) 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e-16) {
tmp = -1.0;
} else {
tmp = (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) <= 5d-16) then
tmp = -1.0d0
else
tmp = (b * b) * 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 5e-16) {
tmp = -1.0;
} else {
tmp = (b * b) * 4.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e-16: tmp = -1.0 else: tmp = (b * b) * 4.0 return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e-16) tmp = -1.0; else tmp = Float64(Float64(b * b) * 4.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5e-16) tmp = -1.0; else tmp = (b * b) * 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e-16], -1.0, N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{-16}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 4\\
\end{array}
\end{array}
if (*.f64 b b) < 5.0000000000000004e-16Initial program 80.4%
associate--l+80.4%
fma-def80.4%
Simplified80.4%
Taylor expanded in b around 0 80.5%
associate--l+80.5%
associate-*r*80.5%
unpow280.5%
Simplified80.5%
Taylor expanded in a around 0 46.5%
if 5.0000000000000004e-16 < (*.f64 b b) Initial program 66.3%
associate--l+66.3%
fma-def66.3%
Simplified69.4%
Taylor expanded in a around 0 85.8%
associate--l+85.8%
fma-def85.8%
unpow285.8%
sub-neg85.8%
metadata-eval85.8%
Simplified85.8%
Taylor expanded in b around 0 52.2%
fma-neg52.2%
unpow252.2%
metadata-eval52.2%
Simplified52.2%
Taylor expanded in b around inf 52.3%
unpow252.3%
Simplified52.3%
Final simplification49.4%
(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 73.3%
associate--l+73.3%
fma-def73.3%
Simplified74.9%
Taylor expanded in b around 0 54.6%
associate--l+54.6%
associate-*r*54.6%
unpow254.6%
Simplified54.6%
Taylor expanded in a around 0 23.6%
Final simplification23.6%
herbie shell --seed 2023213
(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))