Average Error: 7.2 → 4.5
Time: 17.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 r39748603 = x;
        double r39748604 = y;
        double r39748605 = r39748603 * r39748604;
        double r39748606 = z;
        double r39748607 = 9.0;
        double r39748608 = r39748606 * r39748607;
        double r39748609 = t;
        double r39748610 = r39748608 * r39748609;
        double r39748611 = r39748605 - r39748610;
        double r39748612 = a;
        double r39748613 = 2.0;
        double r39748614 = r39748612 * r39748613;
        double r39748615 = r39748611 / r39748614;
        return r39748615;
}

double f(double x, double y, double z, double t, double a) {
        double r39748616 = x;
        double r39748617 = y;
        double r39748618 = r39748616 * r39748617;
        double r39748619 = z;
        double r39748620 = 9.0;
        double r39748621 = r39748619 * r39748620;
        double r39748622 = t;
        double r39748623 = r39748621 * r39748622;
        double r39748624 = r39748618 - r39748623;
        double r39748625 = -inf.0;
        bool r39748626 = r39748624 <= r39748625;
        double r39748627 = 0.5;
        double r39748628 = a;
        double r39748629 = r39748618 / r39748628;
        double r39748630 = r39748627 * r39748629;
        double r39748631 = 4.5;
        double r39748632 = r39748631 * r39748622;
        double r39748633 = r39748619 / r39748628;
        double r39748634 = r39748632 * r39748633;
        double r39748635 = r39748630 - r39748634;
        double r39748636 = 8.023894752689931e+118;
        bool r39748637 = r39748624 <= r39748636;
        double r39748638 = 2.0;
        double r39748639 = r39748624 / r39748638;
        double r39748640 = 1.0;
        double r39748641 = r39748640 / r39748628;
        double r39748642 = r39748639 * r39748641;
        double r39748643 = r39748617 / r39748628;
        double r39748644 = r39748643 * r39748616;
        double r39748645 = r39748644 * r39748627;
        double r39748646 = r39748619 * r39748622;
        double r39748647 = r39748646 / r39748628;
        double r39748648 = r39748631 * r39748647;
        double r39748649 = r39748645 - r39748648;
        double r39748650 = r39748637 ? r39748642 : r39748649;
        double r39748651 = r39748626 ? r39748635 : r39748650;
        return r39748651;
}

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)))