Average Error: 8.0 → 4.7
Time: 41.0s
Precision: 64
\[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y = -\infty:\\ \;\;\;\;\frac{x}{\frac{a}{y}} \cdot 0.5 - \frac{t \cdot z}{a} \cdot 4.5\\ \mathbf{elif}\;x \cdot y \le -1.700987122981420393486078836562591273693 \cdot 10^{-138}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \left(\frac{z}{a} \cdot t\right)\\ \mathbf{elif}\;x \cdot y \le 4.218770597730928417548533567320967175831 \cdot 10^{-132}:\\ \;\;\;\;0.5 \cdot \left(\frac{y}{a} \cdot x\right) - \frac{t \cdot z}{a} \cdot 4.5\\ \mathbf{elif}\;x \cdot y \le 6.886896017153368770786747800397779805695 \cdot 10^{170}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \left(\frac{z}{a} \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\frac{y}{a} \cdot x\right) - \frac{t \cdot z}{a} \cdot 4.5\\ \end{array}\]
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
\begin{array}{l}
\mathbf{if}\;x \cdot y = -\infty:\\
\;\;\;\;\frac{x}{\frac{a}{y}} \cdot 0.5 - \frac{t \cdot z}{a} \cdot 4.5\\

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

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

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r29496581 = x;
        double r29496582 = y;
        double r29496583 = r29496581 * r29496582;
        double r29496584 = z;
        double r29496585 = 9.0;
        double r29496586 = r29496584 * r29496585;
        double r29496587 = t;
        double r29496588 = r29496586 * r29496587;
        double r29496589 = r29496583 - r29496588;
        double r29496590 = a;
        double r29496591 = 2.0;
        double r29496592 = r29496590 * r29496591;
        double r29496593 = r29496589 / r29496592;
        return r29496593;
}

double f(double x, double y, double z, double t, double a) {
        double r29496594 = x;
        double r29496595 = y;
        double r29496596 = r29496594 * r29496595;
        double r29496597 = -inf.0;
        bool r29496598 = r29496596 <= r29496597;
        double r29496599 = a;
        double r29496600 = r29496599 / r29496595;
        double r29496601 = r29496594 / r29496600;
        double r29496602 = 0.5;
        double r29496603 = r29496601 * r29496602;
        double r29496604 = t;
        double r29496605 = z;
        double r29496606 = r29496604 * r29496605;
        double r29496607 = r29496606 / r29496599;
        double r29496608 = 4.5;
        double r29496609 = r29496607 * r29496608;
        double r29496610 = r29496603 - r29496609;
        double r29496611 = -1.7009871229814204e-138;
        bool r29496612 = r29496596 <= r29496611;
        double r29496613 = r29496596 / r29496599;
        double r29496614 = r29496602 * r29496613;
        double r29496615 = r29496605 / r29496599;
        double r29496616 = r29496615 * r29496604;
        double r29496617 = r29496608 * r29496616;
        double r29496618 = r29496614 - r29496617;
        double r29496619 = 4.2187705977309284e-132;
        bool r29496620 = r29496596 <= r29496619;
        double r29496621 = r29496595 / r29496599;
        double r29496622 = r29496621 * r29496594;
        double r29496623 = r29496602 * r29496622;
        double r29496624 = r29496623 - r29496609;
        double r29496625 = 6.886896017153369e+170;
        bool r29496626 = r29496596 <= r29496625;
        double r29496627 = r29496626 ? r29496618 : r29496624;
        double r29496628 = r29496620 ? r29496624 : r29496627;
        double r29496629 = r29496612 ? r29496618 : r29496628;
        double r29496630 = r29496598 ? r29496610 : r29496629;
        return r29496630;
}

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

Original8.0
Target5.6
Herbie4.7
\[\begin{array}{l} \mathbf{if}\;a \lt -2.090464557976709043451944897028999329376 \cdot 10^{86}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot x}{a} - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;a \lt 2.144030707833976090627817222818061808815 \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) < -inf.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 64.0

      \[\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-/l*6.9

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

    if -inf.0 < (* x y) < -1.7009871229814204e-138 or 4.2187705977309284e-132 < (* x y) < 6.886896017153369e+170

    1. Initial program 3.9

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
    2. Taylor expanded around 0 3.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-identity3.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-frac3.7

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

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

    if -1.7009871229814204e-138 < (* x y) < 4.2187705977309284e-132 or 6.886896017153369e+170 < (* x y)

    1. Initial program 8.9

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

      \[\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-identity8.9

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y = -\infty:\\ \;\;\;\;\frac{x}{\frac{a}{y}} \cdot 0.5 - \frac{t \cdot z}{a} \cdot 4.5\\ \mathbf{elif}\;x \cdot y \le -1.700987122981420393486078836562591273693 \cdot 10^{-138}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \left(\frac{z}{a} \cdot t\right)\\ \mathbf{elif}\;x \cdot y \le 4.218770597730928417548533567320967175831 \cdot 10^{-132}:\\ \;\;\;\;0.5 \cdot \left(\frac{y}{a} \cdot x\right) - \frac{t \cdot z}{a} \cdot 4.5\\ \mathbf{elif}\;x \cdot y \le 6.886896017153368770786747800397779805695 \cdot 10^{170}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \left(\frac{z}{a} \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\frac{y}{a} \cdot x\right) - \frac{t \cdot z}{a} \cdot 4.5\\ \end{array}\]

Reproduce

herbie shell --seed 2019168 +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)))