Average Error: 7.9 → 0.9
Time: 20.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 -1.427431772388590456353738345747557666006 \cdot 10^{270}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \left(\frac{t}{a} \cdot z\right)\\ \mathbf{elif}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le 2.016237879537753043850615344011243625605 \cdot 10^{232}:\\ \;\;\;\;\frac{1}{a} \cdot \frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - \frac{4.5 \cdot t}{\frac{a}{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 -1.427431772388590456353738345747557666006 \cdot 10^{270}:\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \left(\frac{t}{a} \cdot z\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r423117 = x;
        double r423118 = y;
        double r423119 = r423117 * r423118;
        double r423120 = z;
        double r423121 = 9.0;
        double r423122 = r423120 * r423121;
        double r423123 = t;
        double r423124 = r423122 * r423123;
        double r423125 = r423119 - r423124;
        double r423126 = a;
        double r423127 = 2.0;
        double r423128 = r423126 * r423127;
        double r423129 = r423125 / r423128;
        return r423129;
}

double f(double x, double y, double z, double t, double a) {
        double r423130 = x;
        double r423131 = y;
        double r423132 = r423130 * r423131;
        double r423133 = z;
        double r423134 = 9.0;
        double r423135 = r423133 * r423134;
        double r423136 = t;
        double r423137 = r423135 * r423136;
        double r423138 = r423132 - r423137;
        double r423139 = -1.4274317723885905e+270;
        bool r423140 = r423138 <= r423139;
        double r423141 = 0.5;
        double r423142 = a;
        double r423143 = r423142 / r423131;
        double r423144 = r423130 / r423143;
        double r423145 = r423141 * r423144;
        double r423146 = 4.5;
        double r423147 = r423136 / r423142;
        double r423148 = r423147 * r423133;
        double r423149 = r423146 * r423148;
        double r423150 = r423145 - r423149;
        double r423151 = 2.016237879537753e+232;
        bool r423152 = r423138 <= r423151;
        double r423153 = 1.0;
        double r423154 = r423153 / r423142;
        double r423155 = 2.0;
        double r423156 = r423138 / r423155;
        double r423157 = r423154 * r423156;
        double r423158 = r423146 * r423136;
        double r423159 = r423142 / r423133;
        double r423160 = r423158 / r423159;
        double r423161 = r423145 - r423160;
        double r423162 = r423152 ? r423157 : r423161;
        double r423163 = r423140 ? r423150 : r423162;
        return r423163;
}

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.9
Target5.7
Herbie0.9
\[\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)) < -1.4274317723885905e+270

    1. Initial program 46.5

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

      \[\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*25.0

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

      \[\leadsto 0.5 \cdot \color{blue}{\frac{x}{\frac{a}{y}}} - 4.5 \cdot \frac{t}{\frac{a}{z}}\]
    7. Using strategy rm
    8. Applied associate-/r/0.4

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

    if -1.4274317723885905e+270 < (- (* x y) (* (* z 9.0) t)) < 2.016237879537753e+232

    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 *-un-lft-identity0.8

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

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

    if 2.016237879537753e+232 < (- (* x y) (* (* z 9.0) t))

    1. Initial program 34.4

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

      \[\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*18.9

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

      \[\leadsto 0.5 \cdot \color{blue}{\frac{x}{\frac{a}{y}}} - 4.5 \cdot \frac{t}{\frac{a}{z}}\]
    7. Using strategy rm
    8. Applied associate-*r/0.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le -1.427431772388590456353738345747557666006 \cdot 10^{270}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \left(\frac{t}{a} \cdot z\right)\\ \mathbf{elif}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le 2.016237879537753043850615344011243625605 \cdot 10^{232}:\\ \;\;\;\;\frac{1}{a} \cdot \frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - \frac{4.5 \cdot t}{\frac{a}{z}}\\ \end{array}\]

Reproduce

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