Average Error: 7.7 → 4.4
Time: 18.9s
Precision: 64
\[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y \le -1.458727220089207535864960016002575750906 \cdot 10^{52} \lor \neg \left(x \cdot y \le 3.207670897783330876086711438188194021875 \cdot 10^{226}\right):\\ \;\;\;\;\frac{y}{\frac{a}{x}} \cdot 0.5 - \frac{4.5 \cdot t}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x \cdot y - \left(t \cdot z\right) \cdot 9}{a}}{2}\\ \end{array}\]
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
\begin{array}{l}
\mathbf{if}\;x \cdot y \le -1.458727220089207535864960016002575750906 \cdot 10^{52} \lor \neg \left(x \cdot y \le 3.207670897783330876086711438188194021875 \cdot 10^{226}\right):\\
\;\;\;\;\frac{y}{\frac{a}{x}} \cdot 0.5 - \frac{4.5 \cdot t}{\frac{a}{z}}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r556444 = x;
        double r556445 = y;
        double r556446 = r556444 * r556445;
        double r556447 = z;
        double r556448 = 9.0;
        double r556449 = r556447 * r556448;
        double r556450 = t;
        double r556451 = r556449 * r556450;
        double r556452 = r556446 - r556451;
        double r556453 = a;
        double r556454 = 2.0;
        double r556455 = r556453 * r556454;
        double r556456 = r556452 / r556455;
        return r556456;
}

double f(double x, double y, double z, double t, double a) {
        double r556457 = x;
        double r556458 = y;
        double r556459 = r556457 * r556458;
        double r556460 = -1.4587272200892075e+52;
        bool r556461 = r556459 <= r556460;
        double r556462 = 3.207670897783331e+226;
        bool r556463 = r556459 <= r556462;
        double r556464 = !r556463;
        bool r556465 = r556461 || r556464;
        double r556466 = a;
        double r556467 = r556466 / r556457;
        double r556468 = r556458 / r556467;
        double r556469 = 0.5;
        double r556470 = r556468 * r556469;
        double r556471 = 4.5;
        double r556472 = t;
        double r556473 = r556471 * r556472;
        double r556474 = z;
        double r556475 = r556466 / r556474;
        double r556476 = r556473 / r556475;
        double r556477 = r556470 - r556476;
        double r556478 = r556472 * r556474;
        double r556479 = 9.0;
        double r556480 = r556478 * r556479;
        double r556481 = r556459 - r556480;
        double r556482 = r556481 / r556466;
        double r556483 = 2.0;
        double r556484 = r556482 / r556483;
        double r556485 = r556465 ? r556477 : r556484;
        return r556485;
}

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.7
Target5.4
Herbie4.4
\[\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) < -1.4587272200892075e+52 or 3.207670897783331e+226 < (* x y)

    1. Initial program 20.1

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

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

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

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

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

    if -1.4587272200892075e+52 < (* x y) < 3.207670897783331e+226

    1. Initial program 4.5

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{a}{x \cdot y - \left(t \cdot 9\right) \cdot z} \cdot 2}}\]
    5. Using strategy rm
    6. Applied div-inv5.0

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

      \[\leadsto \frac{1}{\left(a \cdot \color{blue}{\frac{1}{x \cdot y - \left(9 \cdot z\right) \cdot t}}\right) \cdot 2}\]
    8. Using strategy rm
    9. Applied div-inv4.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \le -1.458727220089207535864960016002575750906 \cdot 10^{52} \lor \neg \left(x \cdot y \le 3.207670897783330876086711438188194021875 \cdot 10^{226}\right):\\ \;\;\;\;\frac{y}{\frac{a}{x}} \cdot 0.5 - \frac{4.5 \cdot t}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x \cdot y - \left(t \cdot z\right) \cdot 9}{a}}{2}\\ \end{array}\]

Reproduce

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