Average Error: 8.0 → 8.0
Time: 13.4s
Precision: 64
\[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
\[\frac{\frac{\mathsf{fma}\left(x, y, -t \cdot \left(z \cdot 9\right)\right)}{2}}{a}\]
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
\frac{\frac{\mathsf{fma}\left(x, y, -t \cdot \left(z \cdot 9\right)\right)}{2}}{a}
double f(double x, double y, double z, double t, double a) {
        double r854311 = x;
        double r854312 = y;
        double r854313 = r854311 * r854312;
        double r854314 = z;
        double r854315 = 9.0;
        double r854316 = r854314 * r854315;
        double r854317 = t;
        double r854318 = r854316 * r854317;
        double r854319 = r854313 - r854318;
        double r854320 = a;
        double r854321 = 2.0;
        double r854322 = r854320 * r854321;
        double r854323 = r854319 / r854322;
        return r854323;
}

double f(double x, double y, double z, double t, double a) {
        double r854324 = x;
        double r854325 = y;
        double r854326 = t;
        double r854327 = z;
        double r854328 = 9.0;
        double r854329 = r854327 * r854328;
        double r854330 = r854326 * r854329;
        double r854331 = -r854330;
        double r854332 = fma(r854324, r854325, r854331);
        double r854333 = 2.0;
        double r854334 = r854332 / r854333;
        double r854335 = a;
        double r854336 = r854334 / r854335;
        return r854336;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original8.0
Target5.9
Herbie8.0
\[\begin{array}{l} \mathbf{if}\;a \lt -2.090464557976709 \cdot 10^{86}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot x}{a} - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;a \lt 2.14403070783397609 \cdot 10^{99}:\\ \;\;\;\;\frac{x \cdot y - z \cdot \left(9 \cdot t\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a} \cdot \left(x \cdot 0.5\right) - \frac{t}{a} \cdot \left(z \cdot 4.5\right)\\ \end{array}\]

Derivation

  1. Initial program 8.0

    \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
  2. Using strategy rm
  3. Applied prod-diff8.0

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

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

    \[\leadsto \frac{\left(x \cdot y - 9 \cdot \left(t \cdot z\right)\right) + \color{blue}{\left(z \cdot 9\right) \cdot \left(\left(-t\right) + t\right)}}{a \cdot 2}\]
  6. Using strategy rm
  7. Applied *-un-lft-identity8.0

    \[\leadsto \frac{\color{blue}{1 \cdot \left(\left(x \cdot y - 9 \cdot \left(t \cdot z\right)\right) + \left(z \cdot 9\right) \cdot \left(\left(-t\right) + t\right)\right)}}{a \cdot 2}\]
  8. Applied times-frac8.1

    \[\leadsto \color{blue}{\frac{1}{a} \cdot \frac{\left(x \cdot y - 9 \cdot \left(t \cdot z\right)\right) + \left(z \cdot 9\right) \cdot \left(\left(-t\right) + t\right)}{2}}\]
  9. Simplified8.1

    \[\leadsto \frac{1}{a} \cdot \color{blue}{\frac{x \cdot y - \left(z \cdot 9\right) \cdot \left(t - \left(t - t\right)\right)}{2}}\]
  10. Using strategy rm
  11. Applied *-un-lft-identity8.1

    \[\leadsto \color{blue}{\left(1 \cdot \frac{1}{a}\right)} \cdot \frac{x \cdot y - \left(z \cdot 9\right) \cdot \left(t - \left(t - t\right)\right)}{2}\]
  12. Applied associate-*l*8.1

    \[\leadsto \color{blue}{1 \cdot \left(\frac{1}{a} \cdot \frac{x \cdot y - \left(z \cdot 9\right) \cdot \left(t - \left(t - t\right)\right)}{2}\right)}\]
  13. Simplified8.0

    \[\leadsto 1 \cdot \color{blue}{\frac{\frac{\mathsf{fma}\left(x, y, -t \cdot \left(z \cdot 9\right)\right)}{2}}{a}}\]
  14. Final simplification8.0

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

Reproduce

herbie shell --seed 2020047 +o rules:numerics
(FPCore (x y z t a)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, I"
  :precision binary64

  :herbie-target
  (if (< a -2.090464557976709e+86) (- (* 0.5 (/ (* y x) a)) (* 4.5 (/ t (/ a z)))) (if (< a 2.144030707833976e+99) (/ (- (* x y) (* z (* 9 t))) (* a 2)) (- (* (/ y a) (* x 0.5)) (* (/ t a) (* z 4.5)))))

  (/ (- (* x y) (* (* z 9) t)) (* a 2)))