Average Error: 6.8 → 5.6
Time: 20.9s
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 = -\infty:\\ \;\;\;\;\left(\frac{y}{a} \cdot x\right) \cdot 0.5 - \frac{t \cdot z}{a} \cdot 4.5\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y - \left(9.0 \cdot t\right) \cdot z}{2.0} \cdot \frac{1}{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 = -\infty:\\
\;\;\;\;\left(\frac{y}{a} \cdot x\right) \cdot 0.5 - \frac{t \cdot z}{a} \cdot 4.5\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y - \left(9.0 \cdot t\right) \cdot z}{2.0} \cdot \frac{1}{a}\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r35345724 = x;
        double r35345725 = y;
        double r35345726 = r35345724 * r35345725;
        double r35345727 = z;
        double r35345728 = 9.0;
        double r35345729 = r35345727 * r35345728;
        double r35345730 = t;
        double r35345731 = r35345729 * r35345730;
        double r35345732 = r35345726 - r35345731;
        double r35345733 = a;
        double r35345734 = 2.0;
        double r35345735 = r35345733 * r35345734;
        double r35345736 = r35345732 / r35345735;
        return r35345736;
}

double f(double x, double y, double z, double t, double a) {
        double r35345737 = x;
        double r35345738 = y;
        double r35345739 = r35345737 * r35345738;
        double r35345740 = -inf.0;
        bool r35345741 = r35345739 <= r35345740;
        double r35345742 = a;
        double r35345743 = r35345738 / r35345742;
        double r35345744 = r35345743 * r35345737;
        double r35345745 = 0.5;
        double r35345746 = r35345744 * r35345745;
        double r35345747 = t;
        double r35345748 = z;
        double r35345749 = r35345747 * r35345748;
        double r35345750 = r35345749 / r35345742;
        double r35345751 = 4.5;
        double r35345752 = r35345750 * r35345751;
        double r35345753 = r35345746 - r35345752;
        double r35345754 = 9.0;
        double r35345755 = r35345754 * r35345747;
        double r35345756 = r35345755 * r35345748;
        double r35345757 = r35345739 - r35345756;
        double r35345758 = 2.0;
        double r35345759 = r35345757 / r35345758;
        double r35345760 = 1.0;
        double r35345761 = r35345760 / r35345742;
        double r35345762 = r35345759 * r35345761;
        double r35345763 = r35345741 ? r35345753 : r35345762;
        return r35345763;
}

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

Original6.8
Target5.2
Herbie5.6
\[\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) < -inf.0

    1. Initial program 60.3

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

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

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

    if -inf.0 < (* x y)

    1. Initial program 5.4

      \[\frac{x \cdot y - \left(z \cdot 9.0\right) \cdot t}{a \cdot 2.0}\]
    2. Using strategy rm
    3. Applied associate-*l*5.4

      \[\leadsto \frac{x \cdot y - \color{blue}{z \cdot \left(9.0 \cdot t\right)}}{a \cdot 2.0}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity5.4

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

      \[\leadsto \color{blue}{\frac{1}{a} \cdot \frac{x \cdot y - z \cdot \left(9.0 \cdot t\right)}{2.0}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification5.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y = -\infty:\\ \;\;\;\;\left(\frac{y}{a} \cdot x\right) \cdot 0.5 - \frac{t \cdot z}{a} \cdot 4.5\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y - \left(9.0 \cdot t\right) \cdot z}{2.0} \cdot \frac{1}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019158 +o rules:numerics
(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)))