Average Error: 3.0 → 3.0
Time: 7.4s
Precision: binary64
\[[y, z, t] = \mathsf{sort}([y, z, t]) \[a, b] = \mathsf{sort}([a, b]) \\]
\[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
\[\mathsf{fma}\left(y, \left(z \cdot t\right) \cdot -9, 2 \cdot x + \left(a \cdot 27\right) \cdot b\right) \]
\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b
\mathsf{fma}\left(y, \left(z \cdot t\right) \cdot -9, 2 \cdot x + \left(a \cdot 27\right) \cdot b\right)
(FPCore (x y z t a b)
 :precision binary64
 (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* (* a 27.0) b)))
(FPCore (x y z t a b)
 :precision binary64
 (fma y (* (* z t) -9.0) (+ (* 2.0 x) (* (* a 27.0) b))))
double code(double x, double y, double z, double t, double a, double b) {
	return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
}
double code(double x, double y, double z, double t, double a, double b) {
	return fma(y, ((z * t) * -9.0), ((2.0 * x) + ((a * 27.0) * b)));
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Bits error versus b

Target

Original3.0
Target3.3
Herbie3.0
\[\begin{array}{l} \mathbf{if}\;y < 7.590524218811189 \cdot 10^{-161}:\\ \;\;\;\;\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + a \cdot \left(27 \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - 9 \cdot \left(y \cdot \left(t \cdot z\right)\right)\right) + \left(a \cdot 27\right) \cdot b\\ \end{array} \]

Derivation

  1. Initial program 3.0

    \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
  2. Simplified3.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, \left(z \cdot t\right) \cdot -9, \mathsf{fma}\left(x, 2, \left(a \cdot 27\right) \cdot b\right)\right)} \]
  3. Applied fma-udef_binary643.0

    \[\leadsto \mathsf{fma}\left(y, \left(z \cdot t\right) \cdot -9, \color{blue}{x \cdot 2 + \left(a \cdot 27\right) \cdot b}\right) \]
  4. Simplified3.0

    \[\leadsto \mathsf{fma}\left(y, \left(z \cdot t\right) \cdot -9, \color{blue}{2 \cdot x} + \left(a \cdot 27\right) \cdot b\right) \]
  5. Final simplification3.0

    \[\leadsto \mathsf{fma}\left(y, \left(z \cdot t\right) \cdot -9, 2 \cdot x + \left(a \cdot 27\right) \cdot b\right) \]

Reproduce

herbie shell --seed 2022087 
(FPCore (x y z t a b)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, A"
  :precision binary64

  :herbie-target
  (if (< y 7.590524218811189e-161) (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* a (* 27.0 b))) (+ (- (* x 2.0) (* 9.0 (* y (* t z)))) (* (* a 27.0) b)))

  (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* (* a 27.0) b)))