Average Error: 8.0 → 5.0
Time: 45.8s
Precision: 64
\[\frac{x \cdot y - \left(z \cdot 9.0\right) \cdot t}{a \cdot 2.0}\]
\[\begin{array}{l} \mathbf{if}\;\left(z \cdot 9.0\right) \cdot t = -\infty:\\ \;\;\;\;\frac{y \cdot x}{a} \cdot 0.5 - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;\left(z \cdot 9.0\right) \cdot t \le -2.358333099751814 \cdot 10^{+164}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} \cdot 0.5 - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{elif}\;\left(z \cdot 9.0\right) \cdot t \le -1.5607886910748142 \cdot 10^{-196}:\\ \;\;\;\;\frac{y \cdot x - 9.0 \cdot \left(t \cdot z\right)}{a \cdot 2.0}\\ \mathbf{elif}\;\left(z \cdot 9.0\right) \cdot t \le -0.0:\\ \;\;\;\;\frac{x}{\frac{a}{y}} \cdot 0.5 - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{elif}\;\left(z \cdot 9.0\right) \cdot t \le 3.5584329894682383 \cdot 10^{-84}:\\ \;\;\;\;\frac{y \cdot x}{a} \cdot 0.5 - \left(4.5 \cdot t\right) \cdot \frac{z}{a}\\ \mathbf{elif}\;\left(z \cdot 9.0\right) \cdot t \le 3.6091915721029346 \cdot 10^{+193}:\\ \;\;\;\;\left(\frac{y}{a} \cdot x\right) \cdot 0.5 - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{a} \cdot 0.5 - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \end{array}\]
\frac{x \cdot y - \left(z \cdot 9.0\right) \cdot t}{a \cdot 2.0}
\begin{array}{l}
\mathbf{if}\;\left(z \cdot 9.0\right) \cdot t = -\infty:\\
\;\;\;\;\frac{y \cdot x}{a} \cdot 0.5 - 4.5 \cdot \frac{t}{\frac{a}{z}}\\

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

\mathbf{elif}\;\left(z \cdot 9.0\right) \cdot t \le -1.5607886910748142 \cdot 10^{-196}:\\
\;\;\;\;\frac{y \cdot x - 9.0 \cdot \left(t \cdot z\right)}{a \cdot 2.0}\\

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

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

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r31791881 = x;
        double r31791882 = y;
        double r31791883 = r31791881 * r31791882;
        double r31791884 = z;
        double r31791885 = 9.0;
        double r31791886 = r31791884 * r31791885;
        double r31791887 = t;
        double r31791888 = r31791886 * r31791887;
        double r31791889 = r31791883 - r31791888;
        double r31791890 = a;
        double r31791891 = 2.0;
        double r31791892 = r31791890 * r31791891;
        double r31791893 = r31791889 / r31791892;
        return r31791893;
}

double f(double x, double y, double z, double t, double a) {
        double r31791894 = z;
        double r31791895 = 9.0;
        double r31791896 = r31791894 * r31791895;
        double r31791897 = t;
        double r31791898 = r31791896 * r31791897;
        double r31791899 = -inf.0;
        bool r31791900 = r31791898 <= r31791899;
        double r31791901 = y;
        double r31791902 = x;
        double r31791903 = r31791901 * r31791902;
        double r31791904 = a;
        double r31791905 = r31791903 / r31791904;
        double r31791906 = 0.5;
        double r31791907 = r31791905 * r31791906;
        double r31791908 = 4.5;
        double r31791909 = r31791904 / r31791894;
        double r31791910 = r31791897 / r31791909;
        double r31791911 = r31791908 * r31791910;
        double r31791912 = r31791907 - r31791911;
        double r31791913 = -2.358333099751814e+164;
        bool r31791914 = r31791898 <= r31791913;
        double r31791915 = r31791904 / r31791901;
        double r31791916 = r31791902 / r31791915;
        double r31791917 = r31791916 * r31791906;
        double r31791918 = r31791897 * r31791894;
        double r31791919 = r31791918 / r31791904;
        double r31791920 = r31791908 * r31791919;
        double r31791921 = r31791917 - r31791920;
        double r31791922 = -1.5607886910748142e-196;
        bool r31791923 = r31791898 <= r31791922;
        double r31791924 = r31791895 * r31791918;
        double r31791925 = r31791903 - r31791924;
        double r31791926 = 2.0;
        double r31791927 = r31791904 * r31791926;
        double r31791928 = r31791925 / r31791927;
        double r31791929 = -0.0;
        bool r31791930 = r31791898 <= r31791929;
        double r31791931 = 3.5584329894682383e-84;
        bool r31791932 = r31791898 <= r31791931;
        double r31791933 = r31791908 * r31791897;
        double r31791934 = r31791894 / r31791904;
        double r31791935 = r31791933 * r31791934;
        double r31791936 = r31791907 - r31791935;
        double r31791937 = 3.6091915721029346e+193;
        bool r31791938 = r31791898 <= r31791937;
        double r31791939 = r31791901 / r31791904;
        double r31791940 = r31791939 * r31791902;
        double r31791941 = r31791940 * r31791906;
        double r31791942 = r31791941 - r31791920;
        double r31791943 = r31791938 ? r31791942 : r31791912;
        double r31791944 = r31791932 ? r31791936 : r31791943;
        double r31791945 = r31791930 ? r31791921 : r31791944;
        double r31791946 = r31791923 ? r31791928 : r31791945;
        double r31791947 = r31791914 ? r31791921 : r31791946;
        double r31791948 = r31791900 ? r31791912 : r31791947;
        return r31791948;
}

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.8
Herbie5.0
\[\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 5 regimes
  2. if (* (* z 9.0) t) < -inf.0 or 3.6091915721029346e+193 < (* (* z 9.0) t)

    1. Initial program 39.6

      \[\frac{x \cdot y - \left(z \cdot 9.0\right) \cdot t}{a \cdot 2.0}\]
    2. Using strategy rm
    3. Applied div-inv39.7

      \[\leadsto \color{blue}{\left(x \cdot y - \left(z \cdot 9.0\right) \cdot t\right) \cdot \frac{1}{a \cdot 2.0}}\]
    4. Taylor expanded around 0 39.2

      \[\leadsto \color{blue}{0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \frac{t \cdot z}{a}}\]
    5. Using strategy rm
    6. Applied associate-/l*5.9

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

    if -inf.0 < (* (* z 9.0) t) < -2.358333099751814e+164 or -1.5607886910748142e-196 < (* (* z 9.0) t) < -0.0

    1. Initial program 5.6

      \[\frac{x \cdot y - \left(z \cdot 9.0\right) \cdot t}{a \cdot 2.0}\]
    2. Using strategy rm
    3. Applied div-inv5.6

      \[\leadsto \color{blue}{\left(x \cdot y - \left(z \cdot 9.0\right) \cdot t\right) \cdot \frac{1}{a \cdot 2.0}}\]
    4. Taylor expanded around 0 5.5

      \[\leadsto \color{blue}{0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \frac{t \cdot z}{a}}\]
    5. Using strategy rm
    6. Applied associate-/l*6.1

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

    if -2.358333099751814e+164 < (* (* z 9.0) t) < -1.5607886910748142e-196

    1. Initial program 3.9

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

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

    if -0.0 < (* (* z 9.0) t) < 3.5584329894682383e-84

    1. Initial program 3.6

      \[\frac{x \cdot y - \left(z \cdot 9.0\right) \cdot t}{a \cdot 2.0}\]
    2. Using strategy rm
    3. Applied div-inv3.7

      \[\leadsto \color{blue}{\left(x \cdot y - \left(z \cdot 9.0\right) \cdot t\right) \cdot \frac{1}{a \cdot 2.0}}\]
    4. Taylor expanded around 0 3.7

      \[\leadsto \color{blue}{0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \frac{t \cdot z}{a}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity3.7

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

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

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

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

    if 3.5584329894682383e-84 < (* (* z 9.0) t) < 3.6091915721029346e+193

    1. Initial program 4.6

      \[\frac{x \cdot y - \left(z \cdot 9.0\right) \cdot t}{a \cdot 2.0}\]
    2. Using strategy rm
    3. Applied div-inv4.6

      \[\leadsto \color{blue}{\left(x \cdot y - \left(z \cdot 9.0\right) \cdot t\right) \cdot \frac{1}{a \cdot 2.0}}\]
    4. Taylor expanded around 0 4.6

      \[\leadsto \color{blue}{0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \frac{t \cdot z}{a}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity4.6

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{\color{blue}{1 \cdot a}} - 4.5 \cdot \frac{t \cdot z}{a}\]
    7. Applied times-frac4.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(z \cdot 9.0\right) \cdot t = -\infty:\\ \;\;\;\;\frac{y \cdot x}{a} \cdot 0.5 - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;\left(z \cdot 9.0\right) \cdot t \le -2.358333099751814 \cdot 10^{+164}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} \cdot 0.5 - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{elif}\;\left(z \cdot 9.0\right) \cdot t \le -1.5607886910748142 \cdot 10^{-196}:\\ \;\;\;\;\frac{y \cdot x - 9.0 \cdot \left(t \cdot z\right)}{a \cdot 2.0}\\ \mathbf{elif}\;\left(z \cdot 9.0\right) \cdot t \le -0.0:\\ \;\;\;\;\frac{x}{\frac{a}{y}} \cdot 0.5 - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{elif}\;\left(z \cdot 9.0\right) \cdot t \le 3.5584329894682383 \cdot 10^{-84}:\\ \;\;\;\;\frac{y \cdot x}{a} \cdot 0.5 - \left(4.5 \cdot t\right) \cdot \frac{z}{a}\\ \mathbf{elif}\;\left(z \cdot 9.0\right) \cdot t \le 3.6091915721029346 \cdot 10^{+193}:\\ \;\;\;\;\left(\frac{y}{a} \cdot x\right) \cdot 0.5 - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{a} \cdot 0.5 - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \end{array}\]

Reproduce

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