Average Error: 7.3 → 6.2
Time: 15.9s
Precision: 64
\[\frac{x \cdot y - \left(z \cdot 9.0\right) \cdot t}{a \cdot 2.0}\]
\[\begin{array}{l} \mathbf{if}\;a \cdot 2.0 \le -8.452560769864224 \cdot 10^{+197}:\\ \;\;\;\;\left(x \cdot \frac{y}{a}\right) \cdot 0.5 - 4.5 \cdot \frac{z \cdot t}{a}\\ \mathbf{elif}\;a \cdot 2.0 \le 1.9902573105400113 \cdot 10^{+77}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot x}{a} - \frac{\left(z \cdot t\right) \cdot 4.5}{a}\\ \mathbf{elif}\;a \cdot 2.0 \le 3.2154246053472375 \cdot 10^{+277}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot x}{a} - \frac{t}{\frac{a}{z}} \cdot 4.5\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot \frac{y}{a}\right) \cdot 0.5 - 4.5 \cdot \frac{z \cdot t}{a}\\ \end{array}\]
\frac{x \cdot y - \left(z \cdot 9.0\right) \cdot t}{a \cdot 2.0}
\begin{array}{l}
\mathbf{if}\;a \cdot 2.0 \le -8.452560769864224 \cdot 10^{+197}:\\
\;\;\;\;\left(x \cdot \frac{y}{a}\right) \cdot 0.5 - 4.5 \cdot \frac{z \cdot t}{a}\\

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

\mathbf{elif}\;a \cdot 2.0 \le 3.2154246053472375 \cdot 10^{+277}:\\
\;\;\;\;0.5 \cdot \frac{y \cdot x}{a} - \frac{t}{\frac{a}{z}} \cdot 4.5\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r35099411 = x;
        double r35099412 = y;
        double r35099413 = r35099411 * r35099412;
        double r35099414 = z;
        double r35099415 = 9.0;
        double r35099416 = r35099414 * r35099415;
        double r35099417 = t;
        double r35099418 = r35099416 * r35099417;
        double r35099419 = r35099413 - r35099418;
        double r35099420 = a;
        double r35099421 = 2.0;
        double r35099422 = r35099420 * r35099421;
        double r35099423 = r35099419 / r35099422;
        return r35099423;
}

double f(double x, double y, double z, double t, double a) {
        double r35099424 = a;
        double r35099425 = 2.0;
        double r35099426 = r35099424 * r35099425;
        double r35099427 = -8.452560769864224e+197;
        bool r35099428 = r35099426 <= r35099427;
        double r35099429 = x;
        double r35099430 = y;
        double r35099431 = r35099430 / r35099424;
        double r35099432 = r35099429 * r35099431;
        double r35099433 = 0.5;
        double r35099434 = r35099432 * r35099433;
        double r35099435 = 4.5;
        double r35099436 = z;
        double r35099437 = t;
        double r35099438 = r35099436 * r35099437;
        double r35099439 = r35099438 / r35099424;
        double r35099440 = r35099435 * r35099439;
        double r35099441 = r35099434 - r35099440;
        double r35099442 = 1.9902573105400113e+77;
        bool r35099443 = r35099426 <= r35099442;
        double r35099444 = r35099430 * r35099429;
        double r35099445 = r35099444 / r35099424;
        double r35099446 = r35099433 * r35099445;
        double r35099447 = r35099438 * r35099435;
        double r35099448 = r35099447 / r35099424;
        double r35099449 = r35099446 - r35099448;
        double r35099450 = 3.2154246053472375e+277;
        bool r35099451 = r35099426 <= r35099450;
        double r35099452 = r35099424 / r35099436;
        double r35099453 = r35099437 / r35099452;
        double r35099454 = r35099453 * r35099435;
        double r35099455 = r35099446 - r35099454;
        double r35099456 = r35099451 ? r35099455 : r35099441;
        double r35099457 = r35099443 ? r35099449 : r35099456;
        double r35099458 = r35099428 ? r35099441 : r35099457;
        return r35099458;
}

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
Herbie6.2
\[\begin{array}{l} \mathbf{if}\;a \lt -2.090464557976709 \cdot 10^{+86}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot x}{a} - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;a \lt 2.144030707833976 \cdot 10^{+99}:\\ \;\;\;\;\frac{x \cdot y - z \cdot \left(9.0 \cdot t\right)}{a \cdot 2.0}\\ \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) < -8.452560769864224e+197 or 3.2154246053472375e+277 < (* a 2.0)

    1. Initial program 13.7

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

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

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

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

    if -8.452560769864224e+197 < (* a 2.0) < 1.9902573105400113e+77

    1. Initial program 3.8

      \[\frac{x \cdot y - \left(z \cdot 9.0\right) \cdot t}{a \cdot 2.0}\]
    2. Taylor expanded around 0 3.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-*r/3.8

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

    if 1.9902573105400113e+77 < (* a 2.0) < 3.2154246053472375e+277

    1. Initial program 12.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot 2.0 \le -8.452560769864224 \cdot 10^{+197}:\\ \;\;\;\;\left(x \cdot \frac{y}{a}\right) \cdot 0.5 - 4.5 \cdot \frac{z \cdot t}{a}\\ \mathbf{elif}\;a \cdot 2.0 \le 1.9902573105400113 \cdot 10^{+77}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot x}{a} - \frac{\left(z \cdot t\right) \cdot 4.5}{a}\\ \mathbf{elif}\;a \cdot 2.0 \le 3.2154246053472375 \cdot 10^{+277}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot x}{a} - \frac{t}{\frac{a}{z}} \cdot 4.5\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot \frac{y}{a}\right) \cdot 0.5 - 4.5 \cdot \frac{z \cdot t}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019163 
(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)))