Average Error: 8.0 → 4.9
Time: 3.9s
Precision: 64
\[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} = -\infty \lor \neg \left(\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \le 2.9483588165168357 \cdot 10^{293}\right):\\ \;\;\;\;\frac{x \cdot y}{a \cdot 2} - \frac{z \cdot 9}{2} \cdot \frac{t - \left(\left(-t\right) + t\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;\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)}{a \cdot 2}\\ \end{array}\]
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} = -\infty \lor \neg \left(\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \le 2.9483588165168357 \cdot 10^{293}\right):\\
\;\;\;\;\frac{x \cdot y}{a \cdot 2} - \frac{z \cdot 9}{2} \cdot \frac{t - \left(\left(-t\right) + t\right)}{a}\\

\mathbf{else}:\\
\;\;\;\;\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)}{a \cdot 2}\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r653485 = x;
        double r653486 = y;
        double r653487 = r653485 * r653486;
        double r653488 = z;
        double r653489 = 9.0;
        double r653490 = r653488 * r653489;
        double r653491 = t;
        double r653492 = r653490 * r653491;
        double r653493 = r653487 - r653492;
        double r653494 = a;
        double r653495 = 2.0;
        double r653496 = r653494 * r653495;
        double r653497 = r653493 / r653496;
        return r653497;
}

double f(double x, double y, double z, double t, double a) {
        double r653498 = x;
        double r653499 = y;
        double r653500 = r653498 * r653499;
        double r653501 = z;
        double r653502 = 9.0;
        double r653503 = r653501 * r653502;
        double r653504 = t;
        double r653505 = r653503 * r653504;
        double r653506 = r653500 - r653505;
        double r653507 = a;
        double r653508 = 2.0;
        double r653509 = r653507 * r653508;
        double r653510 = r653506 / r653509;
        double r653511 = -inf.0;
        bool r653512 = r653510 <= r653511;
        double r653513 = 2.9483588165168357e+293;
        bool r653514 = r653510 <= r653513;
        double r653515 = !r653514;
        bool r653516 = r653512 || r653515;
        double r653517 = r653500 / r653509;
        double r653518 = r653503 / r653508;
        double r653519 = -r653504;
        double r653520 = r653519 + r653504;
        double r653521 = r653504 - r653520;
        double r653522 = r653521 / r653507;
        double r653523 = r653518 * r653522;
        double r653524 = r653517 - r653523;
        double r653525 = r653504 * r653501;
        double r653526 = r653502 * r653525;
        double r653527 = r653500 - r653526;
        double r653528 = r653503 * r653520;
        double r653529 = r653527 + r653528;
        double r653530 = r653529 / r653509;
        double r653531 = r653516 ? r653524 : r653530;
        return r653531;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original8.0
Target5.6
Herbie4.9
\[\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. Split input into 2 regimes
  2. if (/ (- (* x y) (* (* z 9.0) t)) (* a 2.0)) < -inf.0 or 2.9483588165168357e+293 < (/ (- (* x y) (* (* z 9.0) t)) (* a 2.0))

    1. Initial program 59.6

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

      \[\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. Simplified59.6

      \[\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. Simplified59.6

      \[\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 associate-+l-59.6

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

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

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

    if -inf.0 < (/ (- (* x y) (* (* z 9.0) t)) (* a 2.0)) < 2.9483588165168357e+293

    1. Initial program 0.8

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

      \[\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. Simplified0.8

      \[\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. Simplified0.8

      \[\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}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification4.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} = -\infty \lor \neg \left(\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \le 2.9483588165168357 \cdot 10^{293}\right):\\ \;\;\;\;\frac{x \cdot y}{a \cdot 2} - \frac{z \cdot 9}{2} \cdot \frac{t - \left(\left(-t\right) + t\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;\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)}{a \cdot 2}\\ \end{array}\]

Reproduce

herbie shell --seed 2020020 +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)))