Alternative 1 | |
---|---|
Error | 0.0 |
Cost | 6976 |
\[z \cdot z + \mathsf{fma}\left(x, x, y \cdot y\right)
\]
(FPCore (x y z) :precision binary64 (+ (+ (* x x) (* y y)) (* z z)))
(FPCore (x y z) :precision binary64 (fma x x (fma y y (* z z))))
double code(double x, double y, double z) { return ((x * x) + (y * y)) + (z * z); }
double code(double x, double y, double z) { return fma(x, x, fma(y, y, (z * z))); }
function code(x, y, z) return Float64(Float64(Float64(x * x) + Float64(y * y)) + Float64(z * z)) end
function code(x, y, z) return fma(x, x, fma(y, y, Float64(z * z))) end
code[x_, y_, z_] := N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(x * x + N[(y * y + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(x \cdot x + y \cdot y\right) + z \cdot z
\mathsf{fma}\left(x, x, \mathsf{fma}\left(y, y, z \cdot z\right)\right)
Initial program 0.0
Simplified0.0
[Start]0.0 | \[ \left(x \cdot x + y \cdot y\right) + z \cdot z
\] |
---|---|
associate-+l+ [=>]0.0 | \[ \color{blue}{x \cdot x + \left(y \cdot y + z \cdot z\right)}
\] |
fma-def [=>]0.0 | \[ \color{blue}{\mathsf{fma}\left(x, x, y \cdot y + z \cdot z\right)}
\] |
fma-def [=>]0.0 | \[ \mathsf{fma}\left(x, x, \color{blue}{\mathsf{fma}\left(y, y, z \cdot z\right)}\right)
\] |
Final simplification0.0
Alternative 1 | |
---|---|
Error | 0.0 |
Cost | 6976 |
Alternative 2 | |
---|---|
Error | 9.2 |
Cost | 845 |
Alternative 3 | |
---|---|
Error | 0.0 |
Cost | 704 |
Alternative 4 | |
---|---|
Error | 9.2 |
Cost | 580 |
Alternative 5 | |
---|---|
Error | 9.6 |
Cost | 324 |
Alternative 6 | |
---|---|
Error | 27.7 |
Cost | 192 |
herbie shell --seed 1
(FPCore (x y z)
:name "x*x+y*y+z*z"
:precision binary64
:pre (and (and (and (<= -1000.0 x) (<= x 1000.0)) (and (<= -1000.0 y) (<= y 1000.0))) (and (<= -1000.0 z) (<= z 1000.0)))
(+ (+ (* x x) (* y y)) (* z z)))