Average Error: 7.8 → 4.5
Time: 3.8s
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 -9.5426047000982363 \cdot 10^{225} \lor \neg \left(x \cdot y - \left(z \cdot 9\right) \cdot t \le 5.16846887088953994 \cdot 10^{206}\right):\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \frac{4.5}{\frac{a}{t \cdot z}}\\ \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 -9.5426047000982363 \cdot 10^{225} \lor \neg \left(x \cdot y - \left(z \cdot 9\right) \cdot t \le 5.16846887088953994 \cdot 10^{206}\right):\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t \cdot z}{a}\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \frac{4.5}{\frac{a}{t \cdot z}}\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r677600 = x;
        double r677601 = y;
        double r677602 = r677600 * r677601;
        double r677603 = z;
        double r677604 = 9.0;
        double r677605 = r677603 * r677604;
        double r677606 = t;
        double r677607 = r677605 * r677606;
        double r677608 = r677602 - r677607;
        double r677609 = a;
        double r677610 = 2.0;
        double r677611 = r677609 * r677610;
        double r677612 = r677608 / r677611;
        return r677612;
}

double f(double x, double y, double z, double t, double a) {
        double r677613 = x;
        double r677614 = y;
        double r677615 = r677613 * r677614;
        double r677616 = z;
        double r677617 = 9.0;
        double r677618 = r677616 * r677617;
        double r677619 = t;
        double r677620 = r677618 * r677619;
        double r677621 = r677615 - r677620;
        double r677622 = -9.542604700098236e+225;
        bool r677623 = r677621 <= r677622;
        double r677624 = 5.16846887088954e+206;
        bool r677625 = r677621 <= r677624;
        double r677626 = !r677625;
        bool r677627 = r677623 || r677626;
        double r677628 = 0.5;
        double r677629 = a;
        double r677630 = r677629 / r677614;
        double r677631 = r677613 / r677630;
        double r677632 = r677628 * r677631;
        double r677633 = 4.5;
        double r677634 = r677619 * r677616;
        double r677635 = r677634 / r677629;
        double r677636 = r677633 * r677635;
        double r677637 = r677632 - r677636;
        double r677638 = r677615 / r677629;
        double r677639 = r677628 * r677638;
        double r677640 = r677629 / r677634;
        double r677641 = r677633 / r677640;
        double r677642 = r677639 - r677641;
        double r677643 = r677627 ? r677637 : r677642;
        return r677643;
}

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.8
Target5.8
Herbie4.5
\[\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)) < -9.542604700098236e+225 or 5.16846887088954e+206 < (- (* x y) (* (* z 9.0) t))

    1. Initial program 31.0

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
    2. Taylor expanded around 0 30.7

      \[\leadsto \color{blue}{0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \frac{t \cdot z}{a}}\]
    3. Using strategy rm
    4. Applied associate-/l*16.2

      \[\leadsto 0.5 \cdot \color{blue}{\frac{x}{\frac{a}{y}}} - 4.5 \cdot \frac{t \cdot z}{a}\]

    if -9.542604700098236e+225 < (- (* x y) (* (* z 9.0) t)) < 5.16846887088954e+206

    1. Initial program 0.9

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
    2. Taylor expanded around 0 0.9

      \[\leadsto \color{blue}{0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \frac{t \cdot z}{a}}\]
    3. Using strategy rm
    4. Applied clear-num1.1

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \color{blue}{\frac{1}{\frac{a}{t \cdot z}}}\]
    5. Using strategy rm
    6. Applied un-div-inv1.1

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} - \color{blue}{\frac{4.5}{\frac{a}{t \cdot z}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification4.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le -9.5426047000982363 \cdot 10^{225} \lor \neg \left(x \cdot y - \left(z \cdot 9\right) \cdot t \le 5.16846887088953994 \cdot 10^{206}\right):\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \frac{4.5}{\frac{a}{t \cdot z}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020034 
(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)))