Average Error: 7.2 → 0.8
Time: 13.5s
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:\\ \;\;\;\;\left(\frac{y}{a} \cdot x\right) \cdot 0.5 - \frac{z}{a} \cdot \left(t \cdot 4.5\right)\\ \mathbf{elif}\;x \cdot y - \left(z \cdot 9.0\right) \cdot t \le 1.553517178096751 \cdot 10^{+221}:\\ \;\;\;\;\frac{x \cdot y}{a} \cdot 0.5 - \frac{\left(z \cdot t\right) \cdot 4.5}{a}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{y}{a} \cdot x\right) \cdot 0.5 - \frac{z}{a} \cdot \left(t \cdot 4.5\right)\\ \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:\\
\;\;\;\;\left(\frac{y}{a} \cdot x\right) \cdot 0.5 - \frac{z}{a} \cdot \left(t \cdot 4.5\right)\\

\mathbf{elif}\;x \cdot y - \left(z \cdot 9.0\right) \cdot t \le 1.553517178096751 \cdot 10^{+221}:\\
\;\;\;\;\frac{x \cdot y}{a} \cdot 0.5 - \frac{\left(z \cdot t\right) \cdot 4.5}{a}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r12987169 = x;
        double r12987170 = y;
        double r12987171 = r12987169 * r12987170;
        double r12987172 = z;
        double r12987173 = 9.0;
        double r12987174 = r12987172 * r12987173;
        double r12987175 = t;
        double r12987176 = r12987174 * r12987175;
        double r12987177 = r12987171 - r12987176;
        double r12987178 = a;
        double r12987179 = 2.0;
        double r12987180 = r12987178 * r12987179;
        double r12987181 = r12987177 / r12987180;
        return r12987181;
}

double f(double x, double y, double z, double t, double a) {
        double r12987182 = x;
        double r12987183 = y;
        double r12987184 = r12987182 * r12987183;
        double r12987185 = z;
        double r12987186 = 9.0;
        double r12987187 = r12987185 * r12987186;
        double r12987188 = t;
        double r12987189 = r12987187 * r12987188;
        double r12987190 = r12987184 - r12987189;
        double r12987191 = -inf.0;
        bool r12987192 = r12987190 <= r12987191;
        double r12987193 = a;
        double r12987194 = r12987183 / r12987193;
        double r12987195 = r12987194 * r12987182;
        double r12987196 = 0.5;
        double r12987197 = r12987195 * r12987196;
        double r12987198 = r12987185 / r12987193;
        double r12987199 = 4.5;
        double r12987200 = r12987188 * r12987199;
        double r12987201 = r12987198 * r12987200;
        double r12987202 = r12987197 - r12987201;
        double r12987203 = 1.553517178096751e+221;
        bool r12987204 = r12987190 <= r12987203;
        double r12987205 = r12987184 / r12987193;
        double r12987206 = r12987205 * r12987196;
        double r12987207 = r12987185 * r12987188;
        double r12987208 = r12987207 * r12987199;
        double r12987209 = r12987208 / r12987193;
        double r12987210 = r12987206 - r12987209;
        double r12987211 = r12987204 ? r12987210 : r12987202;
        double r12987212 = r12987192 ? r12987202 : r12987211;
        return r12987212;
}

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.4
Herbie0.8
\[\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 2 regimes
  2. if (- (* x y) (* (* z 9.0) t)) < -inf.0 or 1.553517178096751e+221 < (- (* x y) (* (* z 9.0) t))

    1. Initial program 40.7

      \[\frac{x \cdot y - \left(z \cdot 9.0\right) \cdot t}{a \cdot 2.0}\]
    2. Taylor expanded around 0 40.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-identity40.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-frac20.4

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

      \[\leadsto 0.5 \cdot \left(\color{blue}{x} \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t \cdot z}{a}\]
    7. Using strategy rm
    8. Applied *-un-lft-identity20.4

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

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

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

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

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

    1. Initial program 0.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - \left(z \cdot 9.0\right) \cdot t = -\infty:\\ \;\;\;\;\left(\frac{y}{a} \cdot x\right) \cdot 0.5 - \frac{z}{a} \cdot \left(t \cdot 4.5\right)\\ \mathbf{elif}\;x \cdot y - \left(z \cdot 9.0\right) \cdot t \le 1.553517178096751 \cdot 10^{+221}:\\ \;\;\;\;\frac{x \cdot y}{a} \cdot 0.5 - \frac{\left(z \cdot t\right) \cdot 4.5}{a}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{y}{a} \cdot x\right) \cdot 0.5 - \frac{z}{a} \cdot \left(t \cdot 4.5\right)\\ \end{array}\]

Reproduce

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