Average Error: 17.6 → 0.0
Time: 1.6s
Precision: 64
\[\left(\left(x \cdot y + y \cdot y\right) - y \cdot z\right) - y \cdot y\]
\[\mathsf{fma}\left(y, x, 0 - y \cdot z\right)\]
\left(\left(x \cdot y + y \cdot y\right) - y \cdot z\right) - y \cdot y
\mathsf{fma}\left(y, x, 0 - y \cdot z\right)
double code(double x, double y, double z) {
	return ((((x * y) + (y * y)) - (y * z)) - (y * y));
}
double code(double x, double y, double z) {
	return fma(y, x, (0.0 - (y * z)));
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original17.6
Target0.0
Herbie0.0
\[\left(x - z\right) \cdot y\]

Derivation

  1. Initial program 17.6

    \[\left(\left(x \cdot y + y \cdot y\right) - y \cdot z\right) - y \cdot y\]
  2. Using strategy rm
  3. Applied associate--l+17.6

    \[\leadsto \color{blue}{\left(x \cdot y + \left(y \cdot y - y \cdot z\right)\right)} - y \cdot y\]
  4. Applied associate--l+13.0

    \[\leadsto \color{blue}{x \cdot y + \left(\left(y \cdot y - y \cdot z\right) - y \cdot y\right)}\]
  5. Simplified0.0

    \[\leadsto x \cdot y + \color{blue}{\left(0 - y \cdot z\right)}\]
  6. Using strategy rm
  7. Applied *-commutative0.0

    \[\leadsto \color{blue}{y \cdot x} + \left(0 - y \cdot z\right)\]
  8. Applied fma-def0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, x, 0 - y \cdot z\right)}\]
  9. Final simplification0.0

    \[\leadsto \mathsf{fma}\left(y, x, 0 - y \cdot z\right)\]

Reproduce

herbie shell --seed 2020078 +o rules:numerics
(FPCore (x y z)
  :name "Linear.Quaternion:$c/ from linear-1.19.1.3, C"
  :precision binary64

  :herbie-target
  (* (- x z) y)

  (- (- (+ (* x y) (* y y)) (* y z)) (* y y)))