Average Error: 7.7 → 4.3
Time: 19.1s
Precision: 64
\[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y = -\infty:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{elif}\;x \cdot y \le -2.325399801639216975878730762048415990222 \cdot 10^{-108}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(4.5 \cdot \frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}}\right) \cdot \frac{z}{\sqrt[3]{a}}\\ \mathbf{elif}\;x \cdot y \le 5.162788372782689888027473257955766052666 \cdot 10^{-319}:\\ \;\;\;\;0.5 \cdot \left(\frac{x}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{y}{\sqrt[3]{a}}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{elif}\;x \cdot y \le 2.006042602196822974594038209112314781323 \cdot 10^{-82}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(4.5 \cdot \frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}}\right) \cdot \frac{z}{\sqrt[3]{a}}\\ \mathbf{elif}\;x \cdot y \le 9.067555230001552688088291073346960474377 \cdot 10^{283}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, y, -z \cdot \left(9 \cdot t\right)\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\ \end{array}\]
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
\begin{array}{l}
\mathbf{if}\;x \cdot y = -\infty:\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t \cdot z}{a}\\

\mathbf{elif}\;x \cdot y \le -2.325399801639216975878730762048415990222 \cdot 10^{-108}:\\
\;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(4.5 \cdot \frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}}\right) \cdot \frac{z}{\sqrt[3]{a}}\\

\mathbf{elif}\;x \cdot y \le 5.162788372782689888027473257955766052666 \cdot 10^{-319}:\\
\;\;\;\;0.5 \cdot \left(\frac{x}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{y}{\sqrt[3]{a}}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\

\mathbf{elif}\;x \cdot y \le 2.006042602196822974594038209112314781323 \cdot 10^{-82}:\\
\;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(4.5 \cdot \frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}}\right) \cdot \frac{z}{\sqrt[3]{a}}\\

\mathbf{elif}\;x \cdot y \le 9.067555230001552688088291073346960474377 \cdot 10^{283}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y, -z \cdot \left(9 \cdot t\right)\right)}{a \cdot 2}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r1206332 = x;
        double r1206333 = y;
        double r1206334 = r1206332 * r1206333;
        double r1206335 = z;
        double r1206336 = 9.0;
        double r1206337 = r1206335 * r1206336;
        double r1206338 = t;
        double r1206339 = r1206337 * r1206338;
        double r1206340 = r1206334 - r1206339;
        double r1206341 = a;
        double r1206342 = 2.0;
        double r1206343 = r1206341 * r1206342;
        double r1206344 = r1206340 / r1206343;
        return r1206344;
}

double f(double x, double y, double z, double t, double a) {
        double r1206345 = x;
        double r1206346 = y;
        double r1206347 = r1206345 * r1206346;
        double r1206348 = -inf.0;
        bool r1206349 = r1206347 <= r1206348;
        double r1206350 = 0.5;
        double r1206351 = a;
        double r1206352 = r1206351 / r1206346;
        double r1206353 = r1206345 / r1206352;
        double r1206354 = r1206350 * r1206353;
        double r1206355 = 4.5;
        double r1206356 = t;
        double r1206357 = z;
        double r1206358 = r1206356 * r1206357;
        double r1206359 = r1206358 / r1206351;
        double r1206360 = r1206355 * r1206359;
        double r1206361 = r1206354 - r1206360;
        double r1206362 = -2.325399801639217e-108;
        bool r1206363 = r1206347 <= r1206362;
        double r1206364 = r1206347 / r1206351;
        double r1206365 = r1206350 * r1206364;
        double r1206366 = cbrt(r1206351);
        double r1206367 = r1206366 * r1206366;
        double r1206368 = r1206356 / r1206367;
        double r1206369 = r1206355 * r1206368;
        double r1206370 = r1206357 / r1206366;
        double r1206371 = r1206369 * r1206370;
        double r1206372 = r1206365 - r1206371;
        double r1206373 = 5.1627883727827e-319;
        bool r1206374 = r1206347 <= r1206373;
        double r1206375 = r1206345 / r1206367;
        double r1206376 = r1206346 / r1206366;
        double r1206377 = r1206375 * r1206376;
        double r1206378 = r1206350 * r1206377;
        double r1206379 = r1206378 - r1206360;
        double r1206380 = 2.006042602196823e-82;
        bool r1206381 = r1206347 <= r1206380;
        double r1206382 = 9.067555230001553e+283;
        bool r1206383 = r1206347 <= r1206382;
        double r1206384 = 9.0;
        double r1206385 = r1206384 * r1206356;
        double r1206386 = r1206357 * r1206385;
        double r1206387 = -r1206386;
        double r1206388 = fma(r1206345, r1206346, r1206387);
        double r1206389 = 2.0;
        double r1206390 = r1206351 * r1206389;
        double r1206391 = r1206388 / r1206390;
        double r1206392 = r1206346 / r1206351;
        double r1206393 = r1206345 * r1206392;
        double r1206394 = r1206350 * r1206393;
        double r1206395 = r1206394 - r1206360;
        double r1206396 = r1206383 ? r1206391 : r1206395;
        double r1206397 = r1206381 ? r1206372 : r1206396;
        double r1206398 = r1206374 ? r1206379 : r1206397;
        double r1206399 = r1206363 ? r1206372 : r1206398;
        double r1206400 = r1206349 ? r1206361 : r1206399;
        return r1206400;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original7.7
Target5.4
Herbie4.3
\[\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 5 regimes
  2. if (* x y) < -inf.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 64.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*7.0

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

    if -inf.0 < (* x y) < -2.325399801639217e-108 or 5.1627883727827e-319 < (* x y) < 2.006042602196823e-82

    1. Initial program 3.9

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
    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 add-cube-cbrt4.2

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \frac{t \cdot z}{\color{blue}{\left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right) \cdot \sqrt[3]{a}}}\]
    5. Applied times-frac3.7

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

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

    if -2.325399801639217e-108 < (* x y) < 5.1627883727827e-319

    1. Initial program 5.1

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

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{\color{blue}{\left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right) \cdot \sqrt[3]{a}}} - 4.5 \cdot \frac{t \cdot z}{a}\]
    5. Applied times-frac5.0

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

    if 2.006042602196823e-82 < (* x y) < 9.067555230001553e+283

    1. Initial program 4.0

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

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

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

    if 9.067555230001553e+283 < (* x y)

    1. Initial program 52.9

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

      \[\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-identity52.9

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y = -\infty:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{elif}\;x \cdot y \le -2.325399801639216975878730762048415990222 \cdot 10^{-108}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(4.5 \cdot \frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}}\right) \cdot \frac{z}{\sqrt[3]{a}}\\ \mathbf{elif}\;x \cdot y \le 5.162788372782689888027473257955766052666 \cdot 10^{-319}:\\ \;\;\;\;0.5 \cdot \left(\frac{x}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{y}{\sqrt[3]{a}}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{elif}\;x \cdot y \le 2.006042602196822974594038209112314781323 \cdot 10^{-82}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(4.5 \cdot \frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}}\right) \cdot \frac{z}{\sqrt[3]{a}}\\ \mathbf{elif}\;x \cdot y \le 9.067555230001552688088291073346960474377 \cdot 10^{283}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, y, -z \cdot \left(9 \cdot t\right)\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019306 +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.090464557976709e86) (- (* 0.5 (/ (* y x) a)) (* 4.5 (/ t (/ a z)))) (if (< a 2.14403070783397609e99) (/ (- (* x y) (* z (* 9 t))) (* a 2)) (- (* (/ y a) (* x 0.5)) (* (/ t a) (* z 4.5)))))

  (/ (- (* x y) (* (* z 9) t)) (* a 2)))