Average Error: 7.4 → 1.0
Time: 17.5s
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 \le -6.688241611838755979686355728063303939799 \cdot 10^{191}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} \cdot 0.5 - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le 1.623858966667658017012234116157301497207 \cdot 10^{298}:\\ \;\;\;\;\frac{x \cdot y - z \cdot \left(t \cdot 9\right)}{2} \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} \cdot 0.5 - 4.5 \cdot \left(t \cdot \frac{z}{a}\right)\\ \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 \le -6.688241611838755979686355728063303939799 \cdot 10^{191}:\\
\;\;\;\;\frac{x}{\frac{a}{y}} \cdot 0.5 - 4.5 \cdot \frac{t}{\frac{a}{z}}\\

\mathbf{elif}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le 1.623858966667658017012234116157301497207 \cdot 10^{298}:\\
\;\;\;\;\frac{x \cdot y - z \cdot \left(t \cdot 9\right)}{2} \cdot \frac{1}{a}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r32294791 = x;
        double r32294792 = y;
        double r32294793 = r32294791 * r32294792;
        double r32294794 = z;
        double r32294795 = 9.0;
        double r32294796 = r32294794 * r32294795;
        double r32294797 = t;
        double r32294798 = r32294796 * r32294797;
        double r32294799 = r32294793 - r32294798;
        double r32294800 = a;
        double r32294801 = 2.0;
        double r32294802 = r32294800 * r32294801;
        double r32294803 = r32294799 / r32294802;
        return r32294803;
}

double f(double x, double y, double z, double t, double a) {
        double r32294804 = x;
        double r32294805 = y;
        double r32294806 = r32294804 * r32294805;
        double r32294807 = z;
        double r32294808 = 9.0;
        double r32294809 = r32294807 * r32294808;
        double r32294810 = t;
        double r32294811 = r32294809 * r32294810;
        double r32294812 = r32294806 - r32294811;
        double r32294813 = -6.688241611838756e+191;
        bool r32294814 = r32294812 <= r32294813;
        double r32294815 = a;
        double r32294816 = r32294815 / r32294805;
        double r32294817 = r32294804 / r32294816;
        double r32294818 = 0.5;
        double r32294819 = r32294817 * r32294818;
        double r32294820 = 4.5;
        double r32294821 = r32294815 / r32294807;
        double r32294822 = r32294810 / r32294821;
        double r32294823 = r32294820 * r32294822;
        double r32294824 = r32294819 - r32294823;
        double r32294825 = 1.623858966667658e+298;
        bool r32294826 = r32294812 <= r32294825;
        double r32294827 = r32294810 * r32294808;
        double r32294828 = r32294807 * r32294827;
        double r32294829 = r32294806 - r32294828;
        double r32294830 = 2.0;
        double r32294831 = r32294829 / r32294830;
        double r32294832 = 1.0;
        double r32294833 = r32294832 / r32294815;
        double r32294834 = r32294831 * r32294833;
        double r32294835 = r32294807 / r32294815;
        double r32294836 = r32294810 * r32294835;
        double r32294837 = r32294820 * r32294836;
        double r32294838 = r32294819 - r32294837;
        double r32294839 = r32294826 ? r32294834 : r32294838;
        double r32294840 = r32294814 ? r32294824 : r32294839;
        return r32294840;
}

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.5
Herbie1.0
\[\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)) < -6.688241611838756e+191

    1. Initial program 25.8

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

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

    if -6.688241611838756e+191 < (- (* x y) (* (* z 9.0) t)) < 1.623858966667658e+298

    1. Initial program 0.8

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity0.8

      \[\leadsto \frac{\color{blue}{1 \cdot \left(x \cdot y - \left(z \cdot 9\right) \cdot t\right)}}{a \cdot 2}\]
    4. Applied times-frac0.9

      \[\leadsto \color{blue}{\frac{1}{a} \cdot \frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{2}}\]
    5. Using strategy rm
    6. Applied associate-*l*1.0

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

    if 1.623858966667658e+298 < (- (* x y) (* (* z 9.0) t))

    1. Initial program 58.9

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le -6.688241611838755979686355728063303939799 \cdot 10^{191}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} \cdot 0.5 - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le 1.623858966667658017012234116157301497207 \cdot 10^{298}:\\ \;\;\;\;\frac{x \cdot y - z \cdot \left(t \cdot 9\right)}{2} \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} \cdot 0.5 - 4.5 \cdot \left(t \cdot \frac{z}{a}\right)\\ \end{array}\]

Reproduce

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