Average Error: 7.5 → 4.4
Time: 3.1s
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 r830265 = x;
        double r830266 = y;
        double r830267 = r830265 * r830266;
        double r830268 = z;
        double r830269 = 9.0;
        double r830270 = r830268 * r830269;
        double r830271 = t;
        double r830272 = r830270 * r830271;
        double r830273 = r830267 - r830272;
        double r830274 = a;
        double r830275 = 2.0;
        double r830276 = r830274 * r830275;
        double r830277 = r830273 / r830276;
        return r830277;
}

double f(double x, double y, double z, double t, double a) {
        double r830278 = x;
        double r830279 = y;
        double r830280 = r830278 * r830279;
        double r830281 = z;
        double r830282 = 9.0;
        double r830283 = r830281 * r830282;
        double r830284 = t;
        double r830285 = r830283 * r830284;
        double r830286 = r830280 - r830285;
        double r830287 = a;
        double r830288 = 2.0;
        double r830289 = r830287 * r830288;
        double r830290 = r830286 / r830289;
        double r830291 = -6.974559734740129e+306;
        bool r830292 = r830290 <= r830291;
        double r830293 = 0.5;
        double r830294 = r830279 / r830287;
        double r830295 = r830278 * r830294;
        double r830296 = r830293 * r830295;
        double r830297 = 4.5;
        double r830298 = r830284 * r830281;
        double r830299 = r830298 / r830287;
        double r830300 = r830297 * r830299;
        double r830301 = r830296 - r830300;
        double r830302 = 1.4081513490321862e+308;
        bool r830303 = r830290 <= r830302;
        double r830304 = r830280 / r830287;
        double r830305 = r830293 * r830304;
        double r830306 = r830284 * r830297;
        double r830307 = r830281 / r830287;
        double r830308 = r830306 * r830307;
        double r830309 = r830305 - r830308;
        double r830310 = r830303 ? r830290 : r830309;
        double r830311 = r830292 ? r830301 : r830310;
        return r830311;
}

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