Average Error: 7.2 → 4.5
Time: 18.8s
Precision: 64
\[\frac{x \cdot y - \left(z \cdot 9.0\right) \cdot t}{a \cdot 2.0}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - \left(z \cdot 9.0\right) \cdot t = -\infty:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(4.5 \cdot t\right) \cdot \frac{z}{a}\\ \mathbf{elif}\;x \cdot y - \left(z \cdot 9.0\right) \cdot t \le 8.023894752689931 \cdot 10^{+118}:\\ \;\;\;\;\frac{x \cdot y - \left(z \cdot 9.0\right) \cdot t}{2.0} \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{y}{a} \cdot x\right) \cdot 0.5 - 4.5 \cdot \frac{z \cdot t}{a}\\ \end{array}\]
\frac{x \cdot y - \left(z \cdot 9.0\right) \cdot t}{a \cdot 2.0}
\begin{array}{l}
\mathbf{if}\;x \cdot y - \left(z \cdot 9.0\right) \cdot t = -\infty:\\
\;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(4.5 \cdot t\right) \cdot \frac{z}{a}\\

\mathbf{elif}\;x \cdot y - \left(z \cdot 9.0\right) \cdot t \le 8.023894752689931 \cdot 10^{+118}:\\
\;\;\;\;\frac{x \cdot y - \left(z \cdot 9.0\right) \cdot t}{2.0} \cdot \frac{1}{a}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r34339907 = x;
        double r34339908 = y;
        double r34339909 = r34339907 * r34339908;
        double r34339910 = z;
        double r34339911 = 9.0;
        double r34339912 = r34339910 * r34339911;
        double r34339913 = t;
        double r34339914 = r34339912 * r34339913;
        double r34339915 = r34339909 - r34339914;
        double r34339916 = a;
        double r34339917 = 2.0;
        double r34339918 = r34339916 * r34339917;
        double r34339919 = r34339915 / r34339918;
        return r34339919;
}

double f(double x, double y, double z, double t, double a) {
        double r34339920 = x;
        double r34339921 = y;
        double r34339922 = r34339920 * r34339921;
        double r34339923 = z;
        double r34339924 = 9.0;
        double r34339925 = r34339923 * r34339924;
        double r34339926 = t;
        double r34339927 = r34339925 * r34339926;
        double r34339928 = r34339922 - r34339927;
        double r34339929 = -inf.0;
        bool r34339930 = r34339928 <= r34339929;
        double r34339931 = 0.5;
        double r34339932 = a;
        double r34339933 = r34339922 / r34339932;
        double r34339934 = r34339931 * r34339933;
        double r34339935 = 4.5;
        double r34339936 = r34339935 * r34339926;
        double r34339937 = r34339923 / r34339932;
        double r34339938 = r34339936 * r34339937;
        double r34339939 = r34339934 - r34339938;
        double r34339940 = 8.023894752689931e+118;
        bool r34339941 = r34339928 <= r34339940;
        double r34339942 = 2.0;
        double r34339943 = r34339928 / r34339942;
        double r34339944 = 1.0;
        double r34339945 = r34339944 / r34339932;
        double r34339946 = r34339943 * r34339945;
        double r34339947 = r34339921 / r34339932;
        double r34339948 = r34339947 * r34339920;
        double r34339949 = r34339948 * r34339931;
        double r34339950 = r34339923 * r34339926;
        double r34339951 = r34339950 / r34339932;
        double r34339952 = r34339935 * r34339951;
        double r34339953 = r34339949 - r34339952;
        double r34339954 = r34339941 ? r34339946 : r34339953;
        double r34339955 = r34339930 ? r34339939 : r34339954;
        return r34339955;
}

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.2
Target5.0
Herbie4.5
\[\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.144030707833976 \cdot 10^{+99}:\\ \;\;\;\;\frac{x \cdot y - z \cdot \left(9.0 \cdot t\right)}{a \cdot 2.0}\\ \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)) < -inf.0

    1. Initial program 60.1

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

      \[\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-identity59.8

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

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

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

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

    if -inf.0 < (- (* x y) (* (* z 9.0) t)) < 8.023894752689931e+118

    1. Initial program 0.9

      \[\frac{x \cdot y - \left(z \cdot 9.0\right) \cdot t}{a \cdot 2.0}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity0.9

      \[\leadsto \frac{\color{blue}{1 \cdot \left(x \cdot y - \left(z \cdot 9.0\right) \cdot t\right)}}{a \cdot 2.0}\]
    4. Applied times-frac1.0

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

    if 8.023894752689931e+118 < (- (* x y) (* (* z 9.0) t))

    1. Initial program 17.4

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

      \[\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-identity17.3

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

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

      \[\leadsto 0.5 \cdot \left(\color{blue}{x} \cdot \frac{y}{a}\right) - 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.0\right) \cdot t = -\infty:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(4.5 \cdot t\right) \cdot \frac{z}{a}\\ \mathbf{elif}\;x \cdot y - \left(z \cdot 9.0\right) \cdot t \le 8.023894752689931 \cdot 10^{+118}:\\ \;\;\;\;\frac{x \cdot y - \left(z \cdot 9.0\right) \cdot t}{2.0} \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{y}{a} \cdot x\right) \cdot 0.5 - 4.5 \cdot \frac{z \cdot t}{a}\\ \end{array}\]

Reproduce

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