Average Error: 7.5 → 0.9
Time: 49.8s
Precision: 64
\[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot x - \left(9 \cdot z\right) \cdot t \le -2.729495768240093014714208059823501869336 \cdot 10^{200}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - \frac{t}{\frac{a}{z}} \cdot 4.5\\ \mathbf{elif}\;y \cdot x - \left(9 \cdot z\right) \cdot t \le 7.567737085414772222969211502170718139615 \cdot 10^{268}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot x}{a} - \left(\sqrt[3]{4.5} \cdot \sqrt[3]{4.5}\right) \cdot \left(\frac{t \cdot z}{a} \cdot \sqrt[3]{4.5}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} \cdot 0.5 - \frac{t}{\frac{a}{z}} \cdot 4.5\\ \end{array}\]
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
\begin{array}{l}
\mathbf{if}\;y \cdot x - \left(9 \cdot z\right) \cdot t \le -2.729495768240093014714208059823501869336 \cdot 10^{200}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - \frac{t}{\frac{a}{z}} \cdot 4.5\\

\mathbf{elif}\;y \cdot x - \left(9 \cdot z\right) \cdot t \le 7.567737085414772222969211502170718139615 \cdot 10^{268}:\\
\;\;\;\;0.5 \cdot \frac{y \cdot x}{a} - \left(\sqrt[3]{4.5} \cdot \sqrt[3]{4.5}\right) \cdot \left(\frac{t \cdot z}{a} \cdot \sqrt[3]{4.5}\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r16191894 = x;
        double r16191895 = y;
        double r16191896 = r16191894 * r16191895;
        double r16191897 = z;
        double r16191898 = 9.0;
        double r16191899 = r16191897 * r16191898;
        double r16191900 = t;
        double r16191901 = r16191899 * r16191900;
        double r16191902 = r16191896 - r16191901;
        double r16191903 = a;
        double r16191904 = 2.0;
        double r16191905 = r16191903 * r16191904;
        double r16191906 = r16191902 / r16191905;
        return r16191906;
}

double f(double x, double y, double z, double t, double a) {
        double r16191907 = y;
        double r16191908 = x;
        double r16191909 = r16191907 * r16191908;
        double r16191910 = 9.0;
        double r16191911 = z;
        double r16191912 = r16191910 * r16191911;
        double r16191913 = t;
        double r16191914 = r16191912 * r16191913;
        double r16191915 = r16191909 - r16191914;
        double r16191916 = -2.729495768240093e+200;
        bool r16191917 = r16191915 <= r16191916;
        double r16191918 = 0.5;
        double r16191919 = a;
        double r16191920 = r16191907 / r16191919;
        double r16191921 = r16191908 * r16191920;
        double r16191922 = r16191918 * r16191921;
        double r16191923 = r16191919 / r16191911;
        double r16191924 = r16191913 / r16191923;
        double r16191925 = 4.5;
        double r16191926 = r16191924 * r16191925;
        double r16191927 = r16191922 - r16191926;
        double r16191928 = 7.567737085414772e+268;
        bool r16191929 = r16191915 <= r16191928;
        double r16191930 = r16191909 / r16191919;
        double r16191931 = r16191918 * r16191930;
        double r16191932 = cbrt(r16191925);
        double r16191933 = r16191932 * r16191932;
        double r16191934 = r16191913 * r16191911;
        double r16191935 = r16191934 / r16191919;
        double r16191936 = r16191935 * r16191932;
        double r16191937 = r16191933 * r16191936;
        double r16191938 = r16191931 - r16191937;
        double r16191939 = r16191919 / r16191907;
        double r16191940 = r16191908 / r16191939;
        double r16191941 = r16191940 * r16191918;
        double r16191942 = r16191941 - r16191926;
        double r16191943 = r16191929 ? r16191938 : r16191942;
        double r16191944 = r16191917 ? r16191927 : r16191943;
        return r16191944;
}

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.4
Herbie0.9
\[\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) (* (* z 9.0) t)) < -2.729495768240093e+200

    1. Initial program 27.7

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
    2. Taylor expanded around 0 27.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 associate-/l*14.2

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

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

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

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

    if -2.729495768240093e+200 < (- (* x y) (* (* z 9.0) t)) < 7.567737085414772e+268

    1. Initial program 0.8

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

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} - \color{blue}{\left(\left(\sqrt[3]{4.5} \cdot \sqrt[3]{4.5}\right) \cdot \sqrt[3]{4.5}\right)} \cdot \frac{t \cdot z}{a}\]
    5. Applied associate-*l*0.9

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

    if 7.567737085414772e+268 < (- (* x y) (* (* z 9.0) t))

    1. Initial program 44.7

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\frac{x}{\frac{a}{y}}} - 4.5 \cdot \frac{t}{\frac{a}{z}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot x - \left(9 \cdot z\right) \cdot t \le -2.729495768240093014714208059823501869336 \cdot 10^{200}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - \frac{t}{\frac{a}{z}} \cdot 4.5\\ \mathbf{elif}\;y \cdot x - \left(9 \cdot z\right) \cdot t \le 7.567737085414772222969211502170718139615 \cdot 10^{268}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot x}{a} - \left(\sqrt[3]{4.5} \cdot \sqrt[3]{4.5}\right) \cdot \left(\frac{t \cdot z}{a} \cdot \sqrt[3]{4.5}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} \cdot 0.5 - \frac{t}{\frac{a}{z}} \cdot 4.5\\ \end{array}\]

Reproduce

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