| Alternative 1 | |
|---|---|
| Accuracy | 39.0% |
| Cost | 19776 |
\[{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(b, b \cdot 4, -1\right)
\]
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))
(FPCore (a b) :precision binary64 (if (<= (* b b) 4e+15) (+ (+ (* 4.0 (* b b)) (pow a 4.0)) -1.0) (+ (pow b 4.0) -1.0)))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0;
}
double code(double a, double b) {
double tmp;
if ((b * b) <= 4e+15) {
tmp = ((4.0 * (b * b)) + pow(a, 4.0)) + -1.0;
} else {
tmp = pow(b, 4.0) + -1.0;
}
return tmp;
}
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 * (b * b))) - 1.0d0
end function
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 4d+15) then
tmp = ((4.0d0 * (b * b)) + (a ** 4.0d0)) + (-1.0d0)
else
tmp = (b ** 4.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0;
}
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 4e+15) {
tmp = ((4.0 * (b * b)) + Math.pow(a, 4.0)) + -1.0;
} else {
tmp = Math.pow(b, 4.0) + -1.0;
}
return tmp;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0
def code(a, b): tmp = 0 if (b * b) <= 4e+15: tmp = ((4.0 * (b * b)) + math.pow(a, 4.0)) + -1.0 else: tmp = math.pow(b, 4.0) + -1.0 return tmp
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(b * b))) - 1.0) end
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 4e+15) tmp = Float64(Float64(Float64(4.0 * Float64(b * b)) + (a ^ 4.0)) + -1.0); else tmp = Float64((b ^ 4.0) + -1.0); end return tmp end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (b * b))) - 1.0; end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 4e+15) tmp = ((4.0 * (b * b)) + (a ^ 4.0)) + -1.0; else tmp = (b ^ 4.0) + -1.0; end tmp_2 = tmp; 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[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 4e+15], N[(N[(N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision] + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 4 \cdot 10^{+15}:\\
\;\;\;\;\left(4 \cdot \left(b \cdot b\right) + {a}^{4}\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4} + -1\\
\end{array}
Results
if (*.f64 b b) < 4e15Initial program 66.1%
Taylor expanded in a around inf 65.8%
if 4e15 < (*.f64 b b) Initial program 11.9%
Taylor expanded in a around 0 12.5%
Taylor expanded in b around inf 12.5%
Final simplification41.4%
| Alternative 1 | |
|---|---|
| Accuracy | 39.0% |
| Cost | 19776 |
| Alternative 2 | |
|---|---|
| Accuracy | 38.9% |
| Cost | 7424 |
| Alternative 3 | |
|---|---|
| Accuracy | 32.2% |
| Cost | 6976 |
| Alternative 4 | |
|---|---|
| Accuracy | 32.2% |
| Cost | 704 |
| Alternative 5 | |
|---|---|
| Accuracy | 26.0% |
| Cost | 448 |
herbie shell --seed 2023157
(FPCore (a b)
:name "Bouland and Aaronson, Equation (26)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))