Average Error: 7.3 → 6.2
Time: 17.1s
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 r36725398 = x;
        double r36725399 = y;
        double r36725400 = r36725398 * r36725399;
        double r36725401 = z;
        double r36725402 = 9.0;
        double r36725403 = r36725401 * r36725402;
        double r36725404 = t;
        double r36725405 = r36725403 * r36725404;
        double r36725406 = r36725400 - r36725405;
        double r36725407 = a;
        double r36725408 = 2.0;
        double r36725409 = r36725407 * r36725408;
        double r36725410 = r36725406 / r36725409;
        return r36725410;
}

double f(double x, double y, double z, double t, double a) {
        double r36725411 = a;
        double r36725412 = 2.0;
        double r36725413 = r36725411 * r36725412;
        double r36725414 = -8.452560769864224e+197;
        bool r36725415 = r36725413 <= r36725414;
        double r36725416 = x;
        double r36725417 = y;
        double r36725418 = r36725417 / r36725411;
        double r36725419 = r36725416 * r36725418;
        double r36725420 = 0.5;
        double r36725421 = r36725419 * r36725420;
        double r36725422 = 4.5;
        double r36725423 = z;
        double r36725424 = t;
        double r36725425 = r36725423 * r36725424;
        double r36725426 = r36725425 / r36725411;
        double r36725427 = r36725422 * r36725426;
        double r36725428 = r36725421 - r36725427;
        double r36725429 = 1.9902573105400113e+77;
        bool r36725430 = r36725413 <= r36725429;
        double r36725431 = r36725417 * r36725416;
        double r36725432 = r36725431 / r36725411;
        double r36725433 = r36725420 * r36725432;
        double r36725434 = r36725425 * r36725422;
        double r36725435 = r36725434 / r36725411;
        double r36725436 = r36725433 - r36725435;
        double r36725437 = 3.2154246053472375e+277;
        bool r36725438 = r36725413 <= r36725437;
        double r36725439 = r36725411 / r36725423;
        double r36725440 = r36725424 / r36725439;
        double r36725441 = r36725440 * r36725422;
        double r36725442 = r36725433 - r36725441;
        double r36725443 = r36725438 ? r36725442 : r36725428;
        double r36725444 = r36725430 ? r36725436 : r36725443;
        double r36725445 = r36725415 ? r36725428 : r36725444;
        return r36725445;
}

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)))