Average Error: 7.5 → 4.4
Time: 3.3s
Precision: 64
\[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \le -6.9745597347401287 \cdot 10^{306}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{elif}\;\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \le 1.4081513490321862 \cdot 10^{308}:\\ \;\;\;\;\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(t \cdot 4.5\right) \cdot \frac{z}{a}\\ \end{array}\]
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \le -6.9745597347401287 \cdot 10^{306}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r747295 = x;
        double r747296 = y;
        double r747297 = r747295 * r747296;
        double r747298 = z;
        double r747299 = 9.0;
        double r747300 = r747298 * r747299;
        double r747301 = t;
        double r747302 = r747300 * r747301;
        double r747303 = r747297 - r747302;
        double r747304 = a;
        double r747305 = 2.0;
        double r747306 = r747304 * r747305;
        double r747307 = r747303 / r747306;
        return r747307;
}

double f(double x, double y, double z, double t, double a) {
        double r747308 = x;
        double r747309 = y;
        double r747310 = r747308 * r747309;
        double r747311 = z;
        double r747312 = 9.0;
        double r747313 = r747311 * r747312;
        double r747314 = t;
        double r747315 = r747313 * r747314;
        double r747316 = r747310 - r747315;
        double r747317 = a;
        double r747318 = 2.0;
        double r747319 = r747317 * r747318;
        double r747320 = r747316 / r747319;
        double r747321 = -6.974559734740129e+306;
        bool r747322 = r747320 <= r747321;
        double r747323 = 0.5;
        double r747324 = r747309 / r747317;
        double r747325 = r747308 * r747324;
        double r747326 = r747323 * r747325;
        double r747327 = 4.5;
        double r747328 = r747314 * r747311;
        double r747329 = r747328 / r747317;
        double r747330 = r747327 * r747329;
        double r747331 = r747326 - r747330;
        double r747332 = 1.4081513490321862e+308;
        bool r747333 = r747320 <= r747332;
        double r747334 = r747310 / r747317;
        double r747335 = r747323 * r747334;
        double r747336 = r747314 * r747327;
        double r747337 = r747311 / r747317;
        double r747338 = r747336 * r747337;
        double r747339 = r747335 - r747338;
        double r747340 = r747333 ? r747320 : r747339;
        double r747341 = r747322 ? r747331 : r747340;
        return r747341;
}

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.5
Target5.4
Herbie4.4
\[\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.14403070783397609 \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)) (* a 2.0)) < -6.974559734740129e+306

    1. Initial program 62.8

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

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

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

    if -6.974559734740129e+306 < (/ (- (* x y) (* (* z 9.0) t)) (* a 2.0)) < 1.4081513490321862e+308

    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 associate-*l*0.8

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

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

    if 1.4081513490321862e+308 < (/ (- (* x y) (* (* z 9.0) t)) (* a 2.0))

    1. Initial program 64.0

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \le -6.9745597347401287 \cdot 10^{306}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{elif}\;\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \le 1.4081513490321862 \cdot 10^{308}:\\ \;\;\;\;\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(t \cdot 4.5\right) \cdot \frac{z}{a}\\ \end{array}\]

Reproduce

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