Average Error: 7.5 → 4.4
Time: 3.1s
Precision: 64
\[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \le -6.9745597347401287 \cdot 10^{306}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{elif}\;\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \le 1.4081513490321862 \cdot 10^{308}:\\ \;\;\;\;\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(t \cdot 4.5\right) \cdot \frac{z}{a}\\ \end{array}\]
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \le -6.9745597347401287 \cdot 10^{306}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r695758 = x;
        double r695759 = y;
        double r695760 = r695758 * r695759;
        double r695761 = z;
        double r695762 = 9.0;
        double r695763 = r695761 * r695762;
        double r695764 = t;
        double r695765 = r695763 * r695764;
        double r695766 = r695760 - r695765;
        double r695767 = a;
        double r695768 = 2.0;
        double r695769 = r695767 * r695768;
        double r695770 = r695766 / r695769;
        return r695770;
}

double f(double x, double y, double z, double t, double a) {
        double r695771 = x;
        double r695772 = y;
        double r695773 = r695771 * r695772;
        double r695774 = z;
        double r695775 = 9.0;
        double r695776 = r695774 * r695775;
        double r695777 = t;
        double r695778 = r695776 * r695777;
        double r695779 = r695773 - r695778;
        double r695780 = a;
        double r695781 = 2.0;
        double r695782 = r695780 * r695781;
        double r695783 = r695779 / r695782;
        double r695784 = -6.974559734740129e+306;
        bool r695785 = r695783 <= r695784;
        double r695786 = 0.5;
        double r695787 = r695772 / r695780;
        double r695788 = r695771 * r695787;
        double r695789 = r695786 * r695788;
        double r695790 = 4.5;
        double r695791 = r695777 * r695774;
        double r695792 = r695791 / r695780;
        double r695793 = r695790 * r695792;
        double r695794 = r695789 - r695793;
        double r695795 = 1.4081513490321862e+308;
        bool r695796 = r695783 <= r695795;
        double r695797 = r695773 / r695780;
        double r695798 = r695786 * r695797;
        double r695799 = r695777 * r695790;
        double r695800 = r695774 / r695780;
        double r695801 = r695799 * r695800;
        double r695802 = r695798 - r695801;
        double r695803 = r695796 ? r695783 : r695802;
        double r695804 = r695785 ? r695794 : r695803;
        return r695804;
}

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.5
Target5.4
Herbie4.4
\[\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 3 regimes
  2. if (/ (- (* x y) (* (* z 9.0) t)) (* a 2.0)) < -6.974559734740129e+306

    1. Initial program 62.8

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

      \[\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-identity62.5

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

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

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

    if -6.974559734740129e+306 < (/ (- (* x y) (* (* z 9.0) t)) (* a 2.0)) < 1.4081513490321862e+308

    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 associate-*l*0.8

      \[\leadsto \frac{x \cdot y - \color{blue}{z \cdot \left(9 \cdot t\right)}}{a \cdot 2}\]
    4. Using strategy rm
    5. Applied associate-*r*0.8

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

    if 1.4081513490321862e+308 < (/ (- (* x y) (* (* z 9.0) t)) (* a 2.0))

    1. Initial program 64.0

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \le -6.9745597347401287 \cdot 10^{306}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{elif}\;\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \le 1.4081513490321862 \cdot 10^{308}:\\ \;\;\;\;\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(t \cdot 4.5\right) \cdot \frac{z}{a}\\ \end{array}\]

Reproduce

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