\[{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(4, \mathsf{fma}\left(a, a - a \cdot a, b \cdot \left(b \cdot \left(a + 3\right)\right)\right), -1\right)
\]
(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))
↓
(FPCore (a b)
:precision binary64
(+
(pow (hypot a b) 4.0)
(fma 4.0 (fma a (- a (* a a)) (* b (* b (+ a 3.0)))) -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;
}
↓
double code(double a, double b) {
return pow(hypot(a, b), 4.0) + fma(4.0, fma(a, (a - (a * a)), (b * (b * (a + 3.0)))), -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 code(a, b)
return Float64((hypot(a, b) ^ 4.0) + fma(4.0, fma(a, Float64(a - Float64(a * a)), Float64(b * Float64(b * Float64(a + 3.0)))), -1.0))
end
{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(4, \mathsf{fma}\left(a, a - a \cdot a, b \cdot \left(b \cdot \left(a + 3\right)\right)\right), -1\right)
\[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(4, \mathsf{fma}\left(a, a - a \cdot a, b \cdot \left(b \cdot \left(a + 3\right)\right)\right), -1\right)}
\]
Final simplification0.0
\[\leadsto {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(4, \mathsf{fma}\left(a, a - a \cdot a, b \cdot \left(b \cdot \left(a + 3\right)\right)\right), -1\right)
\]
\[-1 + a \cdot \left(a \cdot \left(4 + a \cdot \left(a + -4\right)\right)\right)
\]
Alternative 14
Error
22.6
Cost
448
\[-1 + 4 \cdot \left(a \cdot a\right)
\]
Alternative 15
Error
22.5
Cost
448
\[-1 + \left(b \cdot b\right) \cdot 12
\]
Alternative 16
Error
23.5
Cost
64
\[-1
\]
Error
Reproduce
herbie shell --seed 2022216
(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))