Average Error: 7.4 → 4.5
Time: 19.7s
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 -3.064460597238737029017843662512546220896 \cdot 10^{184}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(\sqrt[3]{4.5} \cdot \sqrt[3]{4.5}\right) \cdot \left(\sqrt[3]{4.5} \cdot \left(t \cdot \frac{z}{a}\right)\right)\\ \mathbf{elif}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le 3.480366367306107885049135945454284898546 \cdot 10^{170}:\\ \;\;\;\;\frac{x \cdot y - z \cdot \left(9 \cdot t\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot x\right) \cdot \frac{y}{a} - 4.5 \cdot \frac{t \cdot z}{a}\\ \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 -3.064460597238737029017843662512546220896 \cdot 10^{184}:\\
\;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(\sqrt[3]{4.5} \cdot \sqrt[3]{4.5}\right) \cdot \left(\sqrt[3]{4.5} \cdot \left(t \cdot \frac{z}{a}\right)\right)\\

\mathbf{elif}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le 3.480366367306107885049135945454284898546 \cdot 10^{170}:\\
\;\;\;\;\frac{x \cdot y - z \cdot \left(9 \cdot t\right)}{a \cdot 2}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r495529 = x;
        double r495530 = y;
        double r495531 = r495529 * r495530;
        double r495532 = z;
        double r495533 = 9.0;
        double r495534 = r495532 * r495533;
        double r495535 = t;
        double r495536 = r495534 * r495535;
        double r495537 = r495531 - r495536;
        double r495538 = a;
        double r495539 = 2.0;
        double r495540 = r495538 * r495539;
        double r495541 = r495537 / r495540;
        return r495541;
}

double f(double x, double y, double z, double t, double a) {
        double r495542 = x;
        double r495543 = y;
        double r495544 = r495542 * r495543;
        double r495545 = z;
        double r495546 = 9.0;
        double r495547 = r495545 * r495546;
        double r495548 = t;
        double r495549 = r495547 * r495548;
        double r495550 = r495544 - r495549;
        double r495551 = -3.064460597238737e+184;
        bool r495552 = r495550 <= r495551;
        double r495553 = 0.5;
        double r495554 = a;
        double r495555 = r495544 / r495554;
        double r495556 = r495553 * r495555;
        double r495557 = 4.5;
        double r495558 = cbrt(r495557);
        double r495559 = r495558 * r495558;
        double r495560 = r495545 / r495554;
        double r495561 = r495548 * r495560;
        double r495562 = r495558 * r495561;
        double r495563 = r495559 * r495562;
        double r495564 = r495556 - r495563;
        double r495565 = 3.480366367306108e+170;
        bool r495566 = r495550 <= r495565;
        double r495567 = r495546 * r495548;
        double r495568 = r495545 * r495567;
        double r495569 = r495544 - r495568;
        double r495570 = 2.0;
        double r495571 = r495554 * r495570;
        double r495572 = r495569 / r495571;
        double r495573 = r495553 * r495542;
        double r495574 = r495543 / r495554;
        double r495575 = r495573 * r495574;
        double r495576 = r495548 * r495545;
        double r495577 = r495576 / r495554;
        double r495578 = r495557 * r495577;
        double r495579 = r495575 - r495578;
        double r495580 = r495566 ? r495572 : r495579;
        double r495581 = r495552 ? r495564 : r495580;
        return r495581;
}

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.6
Herbie4.5
\[\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 3 regimes
  2. if (- (* x y) (* (* z 9.0) t)) < -3.064460597238737e+184

    1. Initial program 26.4

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

      \[\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 add-cube-cbrt26.2

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} - \color{blue}{\left(\left(\sqrt[3]{4.5} \cdot \sqrt[3]{4.5}\right) \cdot \sqrt[3]{4.5}\right)} \cdot \frac{t \cdot z}{a}\]
    5. Applied associate-*l*26.2

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} - \color{blue}{\left(\sqrt[3]{4.5} \cdot \sqrt[3]{4.5}\right) \cdot \left(\sqrt[3]{4.5} \cdot \frac{t \cdot z}{a}\right)}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity26.2

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} - \left(\sqrt[3]{4.5} \cdot \sqrt[3]{4.5}\right) \cdot \left(\sqrt[3]{4.5} \cdot \frac{t \cdot z}{\color{blue}{1 \cdot a}}\right)\]
    8. Applied times-frac14.2

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

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} - \left(\sqrt[3]{4.5} \cdot \sqrt[3]{4.5}\right) \cdot \left(\sqrt[3]{4.5} \cdot \left(\color{blue}{t} \cdot \frac{z}{a}\right)\right)\]

    if -3.064460597238737e+184 < (- (* x y) (* (* z 9.0) t)) < 3.480366367306108e+170

    1. Initial program 1.0

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

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

    if 3.480366367306108e+170 < (- (* x y) (* (* z 9.0) t))

    1. Initial program 23.0

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
    2. Taylor expanded around 0 22.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 *-un-lft-identity22.7

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{\color{blue}{1 \cdot a}} - 4.5 \cdot \frac{t \cdot z}{a}\]
    5. Applied times-frac13.3

      \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{x}{1} \cdot \frac{y}{a}\right)} - 4.5 \cdot \frac{t \cdot z}{a}\]
    6. Applied associate-*r*13.3

      \[\leadsto \color{blue}{\left(0.5 \cdot \frac{x}{1}\right) \cdot \frac{y}{a}} - 4.5 \cdot \frac{t \cdot z}{a}\]
    7. Simplified13.3

      \[\leadsto \color{blue}{\left(0.5 \cdot x\right)} \cdot \frac{y}{a} - 4.5 \cdot \frac{t \cdot z}{a}\]
  3. Recombined 3 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 -3.064460597238737029017843662512546220896 \cdot 10^{184}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(\sqrt[3]{4.5} \cdot \sqrt[3]{4.5}\right) \cdot \left(\sqrt[3]{4.5} \cdot \left(t \cdot \frac{z}{a}\right)\right)\\ \mathbf{elif}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le 3.480366367306107885049135945454284898546 \cdot 10^{170}:\\ \;\;\;\;\frac{x \cdot y - z \cdot \left(9 \cdot t\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot x\right) \cdot \frac{y}{a} - 4.5 \cdot \frac{t \cdot z}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019208 +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.090464557976709e86) (- (* 0.5 (/ (* y x) a)) (* 4.5 (/ t (/ a z)))) (if (< a 2.14403070783397609e99) (/ (- (* x y) (* z (* 9 t))) (* a 2)) (- (* (/ y a) (* x 0.5)) (* (/ t a) (* z 4.5)))))

  (/ (- (* x y) (* (* z 9) t)) (* a 2)))