Average Error: 7.9 → 5.1
Time: 4.7s
Precision: 64
\[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y \le -1.84154847940333438 \cdot 10^{268}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{elif}\;x \cdot y \le 5.0132949514285239 \cdot 10^{-62}:\\ \;\;\;\;\frac{1}{\frac{a}{\mathsf{fma}\left(z \cdot 9, \left(-t\right) + t, x \cdot y - 9 \cdot \left(t \cdot z\right)\right)} \cdot 2}\\ \mathbf{elif}\;x \cdot y \le 1.33984155606375487 \cdot 10^{175}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(t \cdot 4.5\right) \cdot \frac{z}{a}\\ \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 \le -1.84154847940333438 \cdot 10^{268}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\

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

\mathbf{elif}\;x \cdot y \le 1.33984155606375487 \cdot 10^{175}:\\
\;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(t \cdot 4.5\right) \cdot \frac{z}{a}\\

\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 r791499 = x;
        double r791500 = y;
        double r791501 = r791499 * r791500;
        double r791502 = z;
        double r791503 = 9.0;
        double r791504 = r791502 * r791503;
        double r791505 = t;
        double r791506 = r791504 * r791505;
        double r791507 = r791501 - r791506;
        double r791508 = a;
        double r791509 = 2.0;
        double r791510 = r791508 * r791509;
        double r791511 = r791507 / r791510;
        return r791511;
}

double f(double x, double y, double z, double t, double a) {
        double r791512 = x;
        double r791513 = y;
        double r791514 = r791512 * r791513;
        double r791515 = -1.8415484794033344e+268;
        bool r791516 = r791514 <= r791515;
        double r791517 = 0.5;
        double r791518 = a;
        double r791519 = r791513 / r791518;
        double r791520 = r791512 * r791519;
        double r791521 = r791517 * r791520;
        double r791522 = 4.5;
        double r791523 = t;
        double r791524 = z;
        double r791525 = r791523 * r791524;
        double r791526 = r791525 / r791518;
        double r791527 = r791522 * r791526;
        double r791528 = r791521 - r791527;
        double r791529 = 5.013294951428524e-62;
        bool r791530 = r791514 <= r791529;
        double r791531 = 1.0;
        double r791532 = 9.0;
        double r791533 = r791524 * r791532;
        double r791534 = -r791523;
        double r791535 = r791534 + r791523;
        double r791536 = r791532 * r791525;
        double r791537 = r791514 - r791536;
        double r791538 = fma(r791533, r791535, r791537);
        double r791539 = r791518 / r791538;
        double r791540 = 2.0;
        double r791541 = r791539 * r791540;
        double r791542 = r791531 / r791541;
        double r791543 = 1.3398415560637549e+175;
        bool r791544 = r791514 <= r791543;
        double r791545 = r791514 / r791518;
        double r791546 = r791517 * r791545;
        double r791547 = r791523 * r791522;
        double r791548 = r791524 / r791518;
        double r791549 = r791547 * r791548;
        double r791550 = r791546 - r791549;
        double r791551 = r791544 ? r791550 : r791528;
        double r791552 = r791530 ? r791542 : r791551;
        double r791553 = r791516 ? r791528 : r791552;
        return r791553;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original7.9
Target5.5
Herbie5.1
\[\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) < -1.8415484794033344e+268 or 1.3398415560637549e+175 < (* x y)

    1. Initial program 33.3

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

      \[\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-identity33.2

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

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

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

    if -1.8415484794033344e+268 < (* x y) < 5.013294951428524e-62

    1. Initial program 4.6

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
    2. Using strategy rm
    3. Applied prod-diff4.6

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

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

      \[\leadsto \frac{\left(x \cdot y - 9 \cdot \left(t \cdot z\right)\right) + \color{blue}{\left(z \cdot 9\right) \cdot \left(\left(-t\right) + t\right)}}{a \cdot 2}\]
    6. Using strategy rm
    7. Applied clear-num5.0

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

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

    if 5.013294951428524e-62 < (* x y) < 1.3398415560637549e+175

    1. Initial program 3.5

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

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

      \[\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 simplification5.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \le -1.84154847940333438 \cdot 10^{268}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{elif}\;x \cdot y \le 5.0132949514285239 \cdot 10^{-62}:\\ \;\;\;\;\frac{1}{\frac{a}{\mathsf{fma}\left(z \cdot 9, \left(-t\right) + t, x \cdot y - 9 \cdot \left(t \cdot z\right)\right)} \cdot 2}\\ \mathbf{elif}\;x \cdot y \le 1.33984155606375487 \cdot 10^{175}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(t \cdot 4.5\right) \cdot \frac{z}{a}\\ \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 2020025 +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)))