Average Error: 7.4 → 0.9
Time: 21.1s
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.378384659417442190831979112913996094847 \cdot 10^{220}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} \cdot 0.5 - \frac{z}{a} \cdot \left(t \cdot 4.5\right)\\ \mathbf{elif}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le 1.623858966667658017012234116157301497207 \cdot 10^{298}:\\ \;\;\;\;\frac{1}{2 \cdot a} \cdot \left(x \cdot y - \left(z \cdot 9\right) \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} \cdot 0.5 - \left(\frac{z}{a} \cdot t\right) \cdot 4.5\\ \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.378384659417442190831979112913996094847 \cdot 10^{220}:\\
\;\;\;\;\frac{x}{\frac{a}{y}} \cdot 0.5 - \frac{z}{a} \cdot \left(t \cdot 4.5\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r34839664 = x;
        double r34839665 = y;
        double r34839666 = r34839664 * r34839665;
        double r34839667 = z;
        double r34839668 = 9.0;
        double r34839669 = r34839667 * r34839668;
        double r34839670 = t;
        double r34839671 = r34839669 * r34839670;
        double r34839672 = r34839666 - r34839671;
        double r34839673 = a;
        double r34839674 = 2.0;
        double r34839675 = r34839673 * r34839674;
        double r34839676 = r34839672 / r34839675;
        return r34839676;
}

double f(double x, double y, double z, double t, double a) {
        double r34839677 = x;
        double r34839678 = y;
        double r34839679 = r34839677 * r34839678;
        double r34839680 = z;
        double r34839681 = 9.0;
        double r34839682 = r34839680 * r34839681;
        double r34839683 = t;
        double r34839684 = r34839682 * r34839683;
        double r34839685 = r34839679 - r34839684;
        double r34839686 = -1.3783846594174422e+220;
        bool r34839687 = r34839685 <= r34839686;
        double r34839688 = a;
        double r34839689 = r34839688 / r34839678;
        double r34839690 = r34839677 / r34839689;
        double r34839691 = 0.5;
        double r34839692 = r34839690 * r34839691;
        double r34839693 = r34839680 / r34839688;
        double r34839694 = 4.5;
        double r34839695 = r34839683 * r34839694;
        double r34839696 = r34839693 * r34839695;
        double r34839697 = r34839692 - r34839696;
        double r34839698 = 1.623858966667658e+298;
        bool r34839699 = r34839685 <= r34839698;
        double r34839700 = 1.0;
        double r34839701 = 2.0;
        double r34839702 = r34839701 * r34839688;
        double r34839703 = r34839700 / r34839702;
        double r34839704 = r34839703 * r34839685;
        double r34839705 = r34839693 * r34839683;
        double r34839706 = r34839705 * r34839694;
        double r34839707 = r34839692 - r34839706;
        double r34839708 = r34839699 ? r34839704 : r34839707;
        double r34839709 = r34839687 ? r34839697 : r34839708;
        return r34839709;
}

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.5
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.3783846594174422e+220

    1. Initial program 30.4

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
    2. Taylor expanded around 0 30.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 associate-/l*15.8

      \[\leadsto 0.5 \cdot \color{blue}{\frac{x}{\frac{a}{y}}} - 4.5 \cdot \frac{t \cdot z}{a}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity15.8

      \[\leadsto 0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t \cdot z}{\color{blue}{1 \cdot a}}\]
    7. Applied times-frac0.9

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

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

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

    if -1.3783846594174422e+220 < (- (* x y) (* (* z 9.0) t)) < 1.623858966667658e+298

    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}}\]

    if 1.623858966667658e+298 < (- (* x y) (* (* z 9.0) t))

    1. Initial program 58.9

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\frac{x}{\frac{a}{y}}} - 4.5 \cdot \frac{t \cdot z}{a}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity32.7

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

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

      \[\leadsto 0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \left(\color{blue}{t} \cdot \frac{z}{a}\right)\]
  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.378384659417442190831979112913996094847 \cdot 10^{220}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} \cdot 0.5 - \frac{z}{a} \cdot \left(t \cdot 4.5\right)\\ \mathbf{elif}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le 1.623858966667658017012234116157301497207 \cdot 10^{298}:\\ \;\;\;\;\frac{1}{2 \cdot a} \cdot \left(x \cdot y - \left(z \cdot 9\right) \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} \cdot 0.5 - \left(\frac{z}{a} \cdot t\right) \cdot 4.5\\ \end{array}\]

Reproduce

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