Average Error: 7.7 → 6.7
Time: 14.3s
Precision: 64
\[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
\[\begin{array}{l} \mathbf{if}\;t \le -5.258769420001926597471570957877483246948 \cdot 10^{108}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - \frac{4.5 \cdot \left(t \cdot z\right)}{a}\\ \mathbf{elif}\;t \le -1.004492575604983216075165247832217389845 \cdot 10^{46}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(t \cdot 4.5\right) \cdot \frac{z}{a}\\ \mathbf{elif}\;t \le 7477629592254325719040:\\ \;\;\;\;\frac{x \cdot y - z \cdot \left(9 \cdot t\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \end{array}\]
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
\begin{array}{l}
\mathbf{if}\;t \le -5.258769420001926597471570957877483246948 \cdot 10^{108}:\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - \frac{4.5 \cdot \left(t \cdot z\right)}{a}\\

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

\mathbf{elif}\;t \le 7477629592254325719040:\\
\;\;\;\;\frac{x \cdot y - z \cdot \left(9 \cdot t\right)}{a \cdot 2}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r477883 = x;
        double r477884 = y;
        double r477885 = r477883 * r477884;
        double r477886 = z;
        double r477887 = 9.0;
        double r477888 = r477886 * r477887;
        double r477889 = t;
        double r477890 = r477888 * r477889;
        double r477891 = r477885 - r477890;
        double r477892 = a;
        double r477893 = 2.0;
        double r477894 = r477892 * r477893;
        double r477895 = r477891 / r477894;
        return r477895;
}

double f(double x, double y, double z, double t, double a) {
        double r477896 = t;
        double r477897 = -5.258769420001927e+108;
        bool r477898 = r477896 <= r477897;
        double r477899 = 0.5;
        double r477900 = x;
        double r477901 = a;
        double r477902 = y;
        double r477903 = r477901 / r477902;
        double r477904 = r477900 / r477903;
        double r477905 = r477899 * r477904;
        double r477906 = 4.5;
        double r477907 = z;
        double r477908 = r477896 * r477907;
        double r477909 = r477906 * r477908;
        double r477910 = r477909 / r477901;
        double r477911 = r477905 - r477910;
        double r477912 = -1.0044925756049832e+46;
        bool r477913 = r477896 <= r477912;
        double r477914 = r477900 * r477902;
        double r477915 = r477914 / r477901;
        double r477916 = r477899 * r477915;
        double r477917 = r477896 * r477906;
        double r477918 = r477907 / r477901;
        double r477919 = r477917 * r477918;
        double r477920 = r477916 - r477919;
        double r477921 = 7.477629592254326e+21;
        bool r477922 = r477896 <= r477921;
        double r477923 = 9.0;
        double r477924 = r477923 * r477896;
        double r477925 = r477907 * r477924;
        double r477926 = r477914 - r477925;
        double r477927 = 2.0;
        double r477928 = r477901 * r477927;
        double r477929 = r477926 / r477928;
        double r477930 = r477901 / r477907;
        double r477931 = r477896 / r477930;
        double r477932 = r477906 * r477931;
        double r477933 = r477916 - r477932;
        double r477934 = r477922 ? r477929 : r477933;
        double r477935 = r477913 ? r477920 : r477934;
        double r477936 = r477898 ? r477911 : r477935;
        return r477936;
}

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.7
Target5.4
Herbie6.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 4 regimes
  2. if t < -5.258769420001927e+108

    1. Initial program 14.2

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

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

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

    if -5.258769420001927e+108 < t < -1.0044925756049832e+46

    1. Initial program 10.0

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

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

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

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

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

    if -1.0044925756049832e+46 < t < 7.477629592254326e+21

    1. Initial program 4.6

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

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

    if 7.477629592254326e+21 < t

    1. Initial program 12.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -5.258769420001926597471570957877483246948 \cdot 10^{108}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - \frac{4.5 \cdot \left(t \cdot z\right)}{a}\\ \mathbf{elif}\;t \le -1.004492575604983216075165247832217389845 \cdot 10^{46}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(t \cdot 4.5\right) \cdot \frac{z}{a}\\ \mathbf{elif}\;t \le 7477629592254325719040:\\ \;\;\;\;\frac{x \cdot y - z \cdot \left(9 \cdot t\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019322 
(FPCore (x y z t a)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, I"
  :precision binary64

  :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 t))) (* a 2)) (- (* (/ y a) (* x 0.5)) (* (/ t a) (* z 4.5)))))

  (/ (- (* x y) (* (* z 9) t)) (* a 2)))