Average Error: 7.4 → 1.0
Time: 24.3s
Precision: 64
\[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le -1.260672820012323226836129159217138195956 \cdot 10^{196} \lor \neg \left(x \cdot y - \left(z \cdot 9\right) \cdot t \le 2.164485143325600003038481785230498460115 \cdot 10^{248}\right):\\ \;\;\;\;\frac{y}{a} \cdot \frac{x}{2} - t \cdot \left(\frac{z}{2} \cdot \frac{9}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{a}}{2} \cdot \left(x \cdot y - \left(z \cdot 9\right) \cdot t\right)\\ \end{array}\]
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
\begin{array}{l}
\mathbf{if}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le -1.260672820012323226836129159217138195956 \cdot 10^{196} \lor \neg \left(x \cdot y - \left(z \cdot 9\right) \cdot t \le 2.164485143325600003038481785230498460115 \cdot 10^{248}\right):\\
\;\;\;\;\frac{y}{a} \cdot \frac{x}{2} - t \cdot \left(\frac{z}{2} \cdot \frac{9}{a}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{a}}{2} \cdot \left(x \cdot y - \left(z \cdot 9\right) \cdot t\right)\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r619634 = x;
        double r619635 = y;
        double r619636 = r619634 * r619635;
        double r619637 = z;
        double r619638 = 9.0;
        double r619639 = r619637 * r619638;
        double r619640 = t;
        double r619641 = r619639 * r619640;
        double r619642 = r619636 - r619641;
        double r619643 = a;
        double r619644 = 2.0;
        double r619645 = r619643 * r619644;
        double r619646 = r619642 / r619645;
        return r619646;
}

double f(double x, double y, double z, double t, double a) {
        double r619647 = x;
        double r619648 = y;
        double r619649 = r619647 * r619648;
        double r619650 = z;
        double r619651 = 9.0;
        double r619652 = r619650 * r619651;
        double r619653 = t;
        double r619654 = r619652 * r619653;
        double r619655 = r619649 - r619654;
        double r619656 = -1.2606728200123232e+196;
        bool r619657 = r619655 <= r619656;
        double r619658 = 2.1644851433256e+248;
        bool r619659 = r619655 <= r619658;
        double r619660 = !r619659;
        bool r619661 = r619657 || r619660;
        double r619662 = a;
        double r619663 = r619648 / r619662;
        double r619664 = 2.0;
        double r619665 = r619647 / r619664;
        double r619666 = r619663 * r619665;
        double r619667 = r619650 / r619664;
        double r619668 = r619651 / r619662;
        double r619669 = r619667 * r619668;
        double r619670 = r619653 * r619669;
        double r619671 = r619666 - r619670;
        double r619672 = 1.0;
        double r619673 = r619672 / r619662;
        double r619674 = r619673 / r619664;
        double r619675 = r619674 * r619655;
        double r619676 = r619661 ? r619671 : r619675;
        return r619676;
}

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

Original7.4
Target5.4
Herbie1.0
\[\begin{array}{l} \mathbf{if}\;a \lt -2.090464557976709043451944897028999329376 \cdot 10^{86}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot x}{a} - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;a \lt 2.144030707833976090627817222818061808815 \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)) < -1.2606728200123232e+196 or 2.1644851433256e+248 < (- (* x y) (* (* z 9.0) t))

    1. Initial program 31.8

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

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

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

      \[\leadsto \frac{y}{a} \cdot \frac{x}{2} - \color{blue}{\frac{t \cdot 9}{a} \cdot \frac{z}{2}}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity1.1

      \[\leadsto \frac{y}{a} \cdot \frac{x}{2} - \frac{t \cdot 9}{\color{blue}{1 \cdot a}} \cdot \frac{z}{2}\]
    8. Applied times-frac1.0

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

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

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

    if -1.2606728200123232e+196 < (- (* x y) (* (* z 9.0) t)) < 2.1644851433256e+248

    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 div-inv0.9

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

      \[\leadsto \left(x \cdot y - \left(z \cdot 9\right) \cdot t\right) \cdot \color{blue}{\frac{\frac{1}{a}}{2}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le -1.260672820012323226836129159217138195956 \cdot 10^{196} \lor \neg \left(x \cdot y - \left(z \cdot 9\right) \cdot t \le 2.164485143325600003038481785230498460115 \cdot 10^{248}\right):\\ \;\;\;\;\frac{y}{a} \cdot \frac{x}{2} - t \cdot \left(\frac{z}{2} \cdot \frac{9}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{a}}{2} \cdot \left(x \cdot y - \left(z \cdot 9\right) \cdot t\right)\\ \end{array}\]

Reproduce

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

  :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.0 t))) (* a 2.0)) (- (* (/ y a) (* x 0.5)) (* (/ t a) (* z 4.5)))))

  (/ (- (* x y) (* (* z 9.0) t)) (* a 2.0)))