Average Error: 7.9 → 5.1
Time: 22.0s
Precision: 64
\[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
\[\begin{array}{l} \mathbf{if}\;\left(z \cdot 9\right) \cdot t \le -5.588536951192011766760384954663213229832 \cdot 10^{216}:\\ \;\;\;\;\frac{y \cdot x}{a} \cdot 0.5 - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;\left(z \cdot 9\right) \cdot t \le 220957729404425301813777018323200120979500:\\ \;\;\;\;\frac{y \cdot x - \left(t \cdot 9\right) \cdot z}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{a} \cdot 0.5 - \left(4.5 \cdot t\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}\;\left(z \cdot 9\right) \cdot t \le -5.588536951192011766760384954663213229832 \cdot 10^{216}:\\
\;\;\;\;\frac{y \cdot x}{a} \cdot 0.5 - 4.5 \cdot \frac{t}{\frac{a}{z}}\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r30165311 = x;
        double r30165312 = y;
        double r30165313 = r30165311 * r30165312;
        double r30165314 = z;
        double r30165315 = 9.0;
        double r30165316 = r30165314 * r30165315;
        double r30165317 = t;
        double r30165318 = r30165316 * r30165317;
        double r30165319 = r30165313 - r30165318;
        double r30165320 = a;
        double r30165321 = 2.0;
        double r30165322 = r30165320 * r30165321;
        double r30165323 = r30165319 / r30165322;
        return r30165323;
}

double f(double x, double y, double z, double t, double a) {
        double r30165324 = z;
        double r30165325 = 9.0;
        double r30165326 = r30165324 * r30165325;
        double r30165327 = t;
        double r30165328 = r30165326 * r30165327;
        double r30165329 = -5.588536951192012e+216;
        bool r30165330 = r30165328 <= r30165329;
        double r30165331 = y;
        double r30165332 = x;
        double r30165333 = r30165331 * r30165332;
        double r30165334 = a;
        double r30165335 = r30165333 / r30165334;
        double r30165336 = 0.5;
        double r30165337 = r30165335 * r30165336;
        double r30165338 = 4.5;
        double r30165339 = r30165334 / r30165324;
        double r30165340 = r30165327 / r30165339;
        double r30165341 = r30165338 * r30165340;
        double r30165342 = r30165337 - r30165341;
        double r30165343 = 2.209577294044253e+41;
        bool r30165344 = r30165328 <= r30165343;
        double r30165345 = r30165327 * r30165325;
        double r30165346 = r30165345 * r30165324;
        double r30165347 = r30165333 - r30165346;
        double r30165348 = 2.0;
        double r30165349 = r30165334 * r30165348;
        double r30165350 = r30165347 / r30165349;
        double r30165351 = r30165338 * r30165327;
        double r30165352 = r30165324 / r30165334;
        double r30165353 = r30165351 * r30165352;
        double r30165354 = r30165337 - r30165353;
        double r30165355 = r30165344 ? r30165350 : r30165354;
        double r30165356 = r30165330 ? r30165342 : r30165355;
        return r30165356;
}

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.4
Herbie5.1
\[\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 (* (* z 9.0) t) < -5.588536951192012e+216

    1. Initial program 33.8

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

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

    if -5.588536951192012e+216 < (* (* z 9.0) t) < 2.209577294044253e+41

    1. Initial program 4.1

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
    2. Using strategy rm
    3. Applied associate-*l*4.2

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

    if 2.209577294044253e+41 < (* (* z 9.0) t)

    1. Initial program 15.4

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

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

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

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

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

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

Reproduce

herbie shell --seed 2019171 +o rules:numerics
(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)))