Average Error: 7.9 → 0.9
Time: 20.0s
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 -1.427431772388590456353738345747557666006 \cdot 10^{270}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \left(\frac{t}{a} \cdot z\right)\\ \mathbf{elif}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le 2.016237879537753043850615344011243625605 \cdot 10^{232}:\\ \;\;\;\;\left(x \cdot y - \left(z \cdot 9\right) \cdot t\right) \cdot \frac{1}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - \frac{4.5 \cdot t}{\frac{a}{z}}\\ \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 -1.427431772388590456353738345747557666006 \cdot 10^{270}:\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \left(\frac{t}{a} \cdot z\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r400363 = x;
        double r400364 = y;
        double r400365 = r400363 * r400364;
        double r400366 = z;
        double r400367 = 9.0;
        double r400368 = r400366 * r400367;
        double r400369 = t;
        double r400370 = r400368 * r400369;
        double r400371 = r400365 - r400370;
        double r400372 = a;
        double r400373 = 2.0;
        double r400374 = r400372 * r400373;
        double r400375 = r400371 / r400374;
        return r400375;
}

double f(double x, double y, double z, double t, double a) {
        double r400376 = x;
        double r400377 = y;
        double r400378 = r400376 * r400377;
        double r400379 = z;
        double r400380 = 9.0;
        double r400381 = r400379 * r400380;
        double r400382 = t;
        double r400383 = r400381 * r400382;
        double r400384 = r400378 - r400383;
        double r400385 = -1.4274317723885905e+270;
        bool r400386 = r400384 <= r400385;
        double r400387 = 0.5;
        double r400388 = a;
        double r400389 = r400388 / r400377;
        double r400390 = r400376 / r400389;
        double r400391 = r400387 * r400390;
        double r400392 = 4.5;
        double r400393 = r400382 / r400388;
        double r400394 = r400393 * r400379;
        double r400395 = r400392 * r400394;
        double r400396 = r400391 - r400395;
        double r400397 = 2.016237879537753e+232;
        bool r400398 = r400384 <= r400397;
        double r400399 = 1.0;
        double r400400 = 2.0;
        double r400401 = r400388 * r400400;
        double r400402 = r400399 / r400401;
        double r400403 = r400384 * r400402;
        double r400404 = r400392 * r400382;
        double r400405 = r400388 / r400379;
        double r400406 = r400404 / r400405;
        double r400407 = r400391 - r400406;
        double r400408 = r400398 ? r400403 : r400407;
        double r400409 = r400386 ? r400396 : r400408;
        return r400409;
}

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.9
Target5.7
Herbie0.9
\[\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)) < -1.4274317723885905e+270

    1. Initial program 46.5

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

      \[\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*25.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 associate-/l*0.6

      \[\leadsto 0.5 \cdot \color{blue}{\frac{x}{\frac{a}{y}}} - 4.5 \cdot \frac{t}{\frac{a}{z}}\]
    7. Using strategy rm
    8. Applied associate-/r/0.4

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

    if -1.4274317723885905e+270 < (- (* x y) (* (* z 9.0) t)) < 2.016237879537753e+232

    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 div-inv0.9

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

    if 2.016237879537753e+232 < (- (* x y) (* (* z 9.0) t))

    1. Initial program 34.4

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

      \[\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*18.9

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

      \[\leadsto 0.5 \cdot \color{blue}{\frac{x}{\frac{a}{y}}} - 4.5 \cdot \frac{t}{\frac{a}{z}}\]
    7. Using strategy rm
    8. Applied associate-*r/0.7

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

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

Reproduce

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