Average Error: 7.5 → 4.4
Time: 20.1s
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:\\ \;\;\;\;\frac{x}{\frac{a}{y}} \cdot 0.5 - \frac{t \cdot z}{a} \cdot 4.5\\ \mathbf{elif}\;x \cdot y \le -1.7009871229814204 \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 3.02867825195745 \cdot 10^{-161}:\\ \;\;\;\;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.886896017153369 \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.0\right) \cdot t}{a \cdot 2.0}
\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.7009871229814204 \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 3.02867825195745 \cdot 10^{-161}:\\
\;\;\;\;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.886896017153369 \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 r31286750 = x;
        double r31286751 = y;
        double r31286752 = r31286750 * r31286751;
        double r31286753 = z;
        double r31286754 = 9.0;
        double r31286755 = r31286753 * r31286754;
        double r31286756 = t;
        double r31286757 = r31286755 * r31286756;
        double r31286758 = r31286752 - r31286757;
        double r31286759 = a;
        double r31286760 = 2.0;
        double r31286761 = r31286759 * r31286760;
        double r31286762 = r31286758 / r31286761;
        return r31286762;
}

double f(double x, double y, double z, double t, double a) {
        double r31286763 = x;
        double r31286764 = y;
        double r31286765 = r31286763 * r31286764;
        double r31286766 = -inf.0;
        bool r31286767 = r31286765 <= r31286766;
        double r31286768 = a;
        double r31286769 = r31286768 / r31286764;
        double r31286770 = r31286763 / r31286769;
        double r31286771 = 0.5;
        double r31286772 = r31286770 * r31286771;
        double r31286773 = t;
        double r31286774 = z;
        double r31286775 = r31286773 * r31286774;
        double r31286776 = r31286775 / r31286768;
        double r31286777 = 4.5;
        double r31286778 = r31286776 * r31286777;
        double r31286779 = r31286772 - r31286778;
        double r31286780 = -1.7009871229814204e-138;
        bool r31286781 = r31286765 <= r31286780;
        double r31286782 = r31286765 / r31286768;
        double r31286783 = r31286771 * r31286782;
        double r31286784 = r31286774 / r31286768;
        double r31286785 = r31286784 * r31286773;
        double r31286786 = r31286777 * r31286785;
        double r31286787 = r31286783 - r31286786;
        double r31286788 = 3.02867825195745e-161;
        bool r31286789 = r31286765 <= r31286788;
        double r31286790 = r31286764 / r31286768;
        double r31286791 = r31286790 * r31286763;
        double r31286792 = r31286771 * r31286791;
        double r31286793 = r31286792 - r31286778;
        double r31286794 = 6.886896017153369e+170;
        bool r31286795 = r31286765 <= r31286794;
        double r31286796 = r31286795 ? r31286787 : r31286793;
        double r31286797 = r31286789 ? r31286793 : r31286796;
        double r31286798 = r31286781 ? r31286787 : r31286797;
        double r31286799 = r31286767 ? r31286779 : r31286798;
        return r31286799;
}

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.5
Target5.5
Herbie4.4
\[\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) < -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 60.1

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

      \[\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 3.02867825195745e-161 < (* x y) < 6.886896017153369e+170

    1. Initial program 3.6

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

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

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

      \[\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) < 3.02867825195745e-161 or 6.886896017153369e+170 < (* x y)

    1. Initial program 8.7

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

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

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

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

    \[\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.7009871229814204 \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 3.02867825195745 \cdot 10^{-161}:\\ \;\;\;\;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.886896017153369 \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)))