Average Error: 7.3 → 4.2
Time: 4.2s
Precision: 64
\[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
\[\begin{array}{l} \mathbf{if}\;a \cdot 2 \le -1.186352449555409772300601511929585285543 \cdot 10^{-4}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;a \cdot 2 \le 1.991114129634725570451632963990079700412 \cdot 10^{-22}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(4.5 \cdot \left(t \cdot z\right)\right) \cdot \frac{1}{a}\\ \mathbf{elif}\;a \cdot 2 \le 2.613794900569257027791129745425388273253 \cdot 10^{222}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;a \cdot 2 \le 3.349885366301817315811260673424127640942 \cdot 10^{285}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \left(\frac{t}{a} \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(4.5 \cdot \left(t \cdot z\right)\right) \cdot \frac{1}{a}\\ \end{array}\]
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
\begin{array}{l}
\mathbf{if}\;a \cdot 2 \le -1.186352449555409772300601511929585285543 \cdot 10^{-4}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t}{\frac{a}{z}}\\

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

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

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r708802 = x;
        double r708803 = y;
        double r708804 = r708802 * r708803;
        double r708805 = z;
        double r708806 = 9.0;
        double r708807 = r708805 * r708806;
        double r708808 = t;
        double r708809 = r708807 * r708808;
        double r708810 = r708804 - r708809;
        double r708811 = a;
        double r708812 = 2.0;
        double r708813 = r708811 * r708812;
        double r708814 = r708810 / r708813;
        return r708814;
}

double f(double x, double y, double z, double t, double a) {
        double r708815 = a;
        double r708816 = 2.0;
        double r708817 = r708815 * r708816;
        double r708818 = -0.00011863524495554098;
        bool r708819 = r708817 <= r708818;
        double r708820 = 0.5;
        double r708821 = x;
        double r708822 = y;
        double r708823 = r708822 / r708815;
        double r708824 = r708821 * r708823;
        double r708825 = r708820 * r708824;
        double r708826 = 4.5;
        double r708827 = t;
        double r708828 = z;
        double r708829 = r708815 / r708828;
        double r708830 = r708827 / r708829;
        double r708831 = r708826 * r708830;
        double r708832 = r708825 - r708831;
        double r708833 = 1.9911141296347256e-22;
        bool r708834 = r708817 <= r708833;
        double r708835 = r708821 * r708822;
        double r708836 = r708835 / r708815;
        double r708837 = r708820 * r708836;
        double r708838 = r708827 * r708828;
        double r708839 = r708826 * r708838;
        double r708840 = 1.0;
        double r708841 = r708840 / r708815;
        double r708842 = r708839 * r708841;
        double r708843 = r708837 - r708842;
        double r708844 = 2.613794900569257e+222;
        bool r708845 = r708817 <= r708844;
        double r708846 = 3.3498853663018173e+285;
        bool r708847 = r708817 <= r708846;
        double r708848 = r708827 / r708815;
        double r708849 = r708848 * r708828;
        double r708850 = r708826 * r708849;
        double r708851 = r708837 - r708850;
        double r708852 = r708847 ? r708851 : r708843;
        double r708853 = r708845 ? r708832 : r708852;
        double r708854 = r708834 ? r708843 : r708853;
        double r708855 = r708819 ? r708832 : r708854;
        return r708855;
}

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.3
Target5.5
Herbie4.2
\[\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 (* a 2.0) < -0.00011863524495554098 or 1.9911141296347256e-22 < (* a 2.0) < 2.613794900569257e+222

    1. Initial program 9.6

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

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

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

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

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

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

    if -0.00011863524495554098 < (* a 2.0) < 1.9911141296347256e-22 or 3.3498853663018173e+285 < (* a 2.0)

    1. Initial program 2.4

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

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

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

    if 2.613794900569257e+222 < (* a 2.0) < 3.3498853663018173e+285

    1. Initial program 13.6

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

      \[\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-/r/8.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot 2 \le -1.186352449555409772300601511929585285543 \cdot 10^{-4}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;a \cdot 2 \le 1.991114129634725570451632963990079700412 \cdot 10^{-22}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(4.5 \cdot \left(t \cdot z\right)\right) \cdot \frac{1}{a}\\ \mathbf{elif}\;a \cdot 2 \le 2.613794900569257027791129745425388273253 \cdot 10^{222}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;a \cdot 2 \le 3.349885366301817315811260673424127640942 \cdot 10^{285}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \left(\frac{t}{a} \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(4.5 \cdot \left(t \cdot z\right)\right) \cdot \frac{1}{a}\\ \end{array}\]

Reproduce

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