Average Error: 7.4 → 0.7
Time: 4.4s
Precision: 64
\[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - \left(z \cdot 9\right) \cdot t = -\infty:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le 6.141503698191325974880769654002209246573 \cdot 10^{255}:\\ \;\;\;\;0.5 \cdot \left(\frac{1}{a} \cdot \left(x \cdot y\right)\right) - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - \left(t \cdot 4.5\right) \cdot \frac{z}{a}\\ \end{array}\]
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
\begin{array}{l}
\mathbf{if}\;x \cdot y - \left(z \cdot 9\right) \cdot t = -\infty:\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t}{\frac{a}{z}}\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r847996 = x;
        double r847997 = y;
        double r847998 = r847996 * r847997;
        double r847999 = z;
        double r848000 = 9.0;
        double r848001 = r847999 * r848000;
        double r848002 = t;
        double r848003 = r848001 * r848002;
        double r848004 = r847998 - r848003;
        double r848005 = a;
        double r848006 = 2.0;
        double r848007 = r848005 * r848006;
        double r848008 = r848004 / r848007;
        return r848008;
}

double f(double x, double y, double z, double t, double a) {
        double r848009 = x;
        double r848010 = y;
        double r848011 = r848009 * r848010;
        double r848012 = z;
        double r848013 = 9.0;
        double r848014 = r848012 * r848013;
        double r848015 = t;
        double r848016 = r848014 * r848015;
        double r848017 = r848011 - r848016;
        double r848018 = -inf.0;
        bool r848019 = r848017 <= r848018;
        double r848020 = 0.5;
        double r848021 = a;
        double r848022 = r848021 / r848010;
        double r848023 = r848009 / r848022;
        double r848024 = r848020 * r848023;
        double r848025 = 4.5;
        double r848026 = r848021 / r848012;
        double r848027 = r848015 / r848026;
        double r848028 = r848025 * r848027;
        double r848029 = r848024 - r848028;
        double r848030 = 6.141503698191326e+255;
        bool r848031 = r848017 <= r848030;
        double r848032 = 1.0;
        double r848033 = r848032 / r848021;
        double r848034 = r848033 * r848011;
        double r848035 = r848020 * r848034;
        double r848036 = r848015 * r848012;
        double r848037 = r848036 / r848021;
        double r848038 = r848025 * r848037;
        double r848039 = r848035 - r848038;
        double r848040 = r848015 * r848025;
        double r848041 = r848012 / r848021;
        double r848042 = r848040 * r848041;
        double r848043 = r848024 - r848042;
        double r848044 = r848031 ? r848039 : r848043;
        double r848045 = r848019 ? r848029 : r848044;
        return r848045;
}

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.4
Target5.6
Herbie0.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) (* (* z 9.0) t)) < -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 63.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 associate-/l*32.6

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

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

    if -inf.0 < (- (* x y) (* (* z 9.0) t)) < 6.141503698191326e+255

    1. Initial program 0.7

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

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

      \[\leadsto 0.5 \cdot \frac{x}{\color{blue}{a \cdot \frac{1}{y}}} - 4.5 \cdot \frac{t \cdot z}{a}\]
    7. Applied *-un-lft-identity4.9

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

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

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

    if 6.141503698191326e+255 < (- (* x y) (* (* z 9.0) t))

    1. Initial program 43.3

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

      \[\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 *-un-lft-identity22.6

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - \left(z \cdot 9\right) \cdot t = -\infty:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le 6.141503698191325974880769654002209246573 \cdot 10^{255}:\\ \;\;\;\;0.5 \cdot \left(\frac{1}{a} \cdot \left(x \cdot y\right)\right) - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - \left(t \cdot 4.5\right) \cdot \frac{z}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019362 +o rules:numerics
(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)))