Average Error: 8.0 → 8.0
Time: 7.6s
Precision: 64
\[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
\[\frac{\mathsf{fma}\left(x, y, -t \cdot \left(z \cdot 9\right)\right)}{a \cdot 2}\]
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
\frac{\mathsf{fma}\left(x, y, -t \cdot \left(z \cdot 9\right)\right)}{a \cdot 2}
double f(double x, double y, double z, double t, double a) {
        double r648257 = x;
        double r648258 = y;
        double r648259 = r648257 * r648258;
        double r648260 = z;
        double r648261 = 9.0;
        double r648262 = r648260 * r648261;
        double r648263 = t;
        double r648264 = r648262 * r648263;
        double r648265 = r648259 - r648264;
        double r648266 = a;
        double r648267 = 2.0;
        double r648268 = r648266 * r648267;
        double r648269 = r648265 / r648268;
        return r648269;
}

double f(double x, double y, double z, double t, double a) {
        double r648270 = x;
        double r648271 = y;
        double r648272 = t;
        double r648273 = z;
        double r648274 = 9.0;
        double r648275 = r648273 * r648274;
        double r648276 = r648272 * r648275;
        double r648277 = -r648276;
        double r648278 = fma(r648270, r648271, r648277);
        double r648279 = a;
        double r648280 = 2.0;
        double r648281 = r648279 * r648280;
        double r648282 = r648278 / r648281;
        return r648282;
}

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 *-un-lft-identity8.0

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

    \[\leadsto \color{blue}{\frac{1}{a} \cdot \frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{2}}\]
  5. Using strategy rm
  6. 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 t}{2}\]
  7. 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 t}{2}\right)}\]
  8. Simplified8.0

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

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

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)))