Average Error: 20.7 → 9.1
Time: 6.9s
Precision: 64
\[\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]
\[\begin{array}{l} \mathbf{if}\;z \le -5.3530085862134982 \cdot 10^{-146} \lor \neg \left(z \le 2.15005537231926563 \cdot 10^{156}\right):\\ \;\;\;\;\mathsf{fma}\left(-4, \frac{1}{\frac{c}{t \cdot a}}, \frac{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z}}{c}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-4, t \cdot \frac{a}{c}, \mathsf{fma}\left(9, \frac{x \cdot y}{z \cdot c}, \frac{b}{z \cdot c}\right)\right)\\ \end{array}\]
\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}
\begin{array}{l}
\mathbf{if}\;z \le -5.3530085862134982 \cdot 10^{-146} \lor \neg \left(z \le 2.15005537231926563 \cdot 10^{156}\right):\\
\;\;\;\;\mathsf{fma}\left(-4, \frac{1}{\frac{c}{t \cdot a}}, \frac{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z}}{c}\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-4, t \cdot \frac{a}{c}, \mathsf{fma}\left(9, \frac{x \cdot y}{z \cdot c}, \frac{b}{z \cdot c}\right)\right)\\

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r672590 = x;
        double r672591 = 9.0;
        double r672592 = r672590 * r672591;
        double r672593 = y;
        double r672594 = r672592 * r672593;
        double r672595 = z;
        double r672596 = 4.0;
        double r672597 = r672595 * r672596;
        double r672598 = t;
        double r672599 = r672597 * r672598;
        double r672600 = a;
        double r672601 = r672599 * r672600;
        double r672602 = r672594 - r672601;
        double r672603 = b;
        double r672604 = r672602 + r672603;
        double r672605 = c;
        double r672606 = r672595 * r672605;
        double r672607 = r672604 / r672606;
        return r672607;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r672608 = z;
        double r672609 = -5.353008586213498e-146;
        bool r672610 = r672608 <= r672609;
        double r672611 = 2.1500553723192656e+156;
        bool r672612 = r672608 <= r672611;
        double r672613 = !r672612;
        bool r672614 = r672610 || r672613;
        double r672615 = 4.0;
        double r672616 = -r672615;
        double r672617 = 1.0;
        double r672618 = c;
        double r672619 = t;
        double r672620 = a;
        double r672621 = r672619 * r672620;
        double r672622 = r672618 / r672621;
        double r672623 = r672617 / r672622;
        double r672624 = 9.0;
        double r672625 = x;
        double r672626 = r672624 * r672625;
        double r672627 = y;
        double r672628 = b;
        double r672629 = fma(r672626, r672627, r672628);
        double r672630 = r672629 / r672608;
        double r672631 = r672630 / r672618;
        double r672632 = fma(r672616, r672623, r672631);
        double r672633 = r672620 / r672618;
        double r672634 = r672619 * r672633;
        double r672635 = r672625 * r672627;
        double r672636 = r672608 * r672618;
        double r672637 = r672635 / r672636;
        double r672638 = r672628 / r672636;
        double r672639 = fma(r672624, r672637, r672638);
        double r672640 = fma(r672616, r672634, r672639);
        double r672641 = r672614 ? r672632 : r672640;
        return r672641;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Bits error versus b

Bits error versus c

Target

Original20.7
Target14.5
Herbie9.1
\[\begin{array}{l} \mathbf{if}\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt -1.10015674080410512 \cdot 10^{-171}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(z \cdot 4\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt -0.0:\\ \;\;\;\;\frac{\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z}}{c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt 1.17088779117474882 \cdot 10^{-53}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(z \cdot 4\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt 2.8768236795461372 \cdot 10^{130}:\\ \;\;\;\;\left(\left(9 \cdot \frac{y}{c}\right) \cdot \frac{x}{z} + \frac{b}{c \cdot z}\right) - 4 \cdot \frac{a \cdot t}{c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt 1.3838515042456319 \cdot 10^{158}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(z \cdot 4\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\left(9 \cdot \left(\frac{y}{c \cdot z} \cdot x\right) + \frac{b}{c \cdot z}\right) - 4 \cdot \frac{a \cdot t}{c}\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -5.353008586213498e-146 or 2.1500553723192656e+156 < z

    1. Initial program 28.0

      \[\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]
    2. Simplified13.1

      \[\leadsto \color{blue}{\mathsf{fma}\left(-4, \frac{t \cdot a}{c}, \frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z \cdot c}\right)}\]
    3. Using strategy rm
    4. Applied associate-/r*9.9

      \[\leadsto \mathsf{fma}\left(-4, \frac{t \cdot a}{c}, \color{blue}{\frac{\frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z}}{c}}\right)\]
    5. Simplified9.8

      \[\leadsto \mathsf{fma}\left(-4, \frac{t \cdot a}{c}, \frac{\color{blue}{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z}}}{c}\right)\]
    6. Using strategy rm
    7. Applied clear-num9.9

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

    if -5.353008586213498e-146 < z < 2.1500553723192656e+156

    1. Initial program 10.8

      \[\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]
    2. Simplified9.9

      \[\leadsto \color{blue}{\mathsf{fma}\left(-4, \frac{t \cdot a}{c}, \frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z \cdot c}\right)}\]
    3. Using strategy rm
    4. Applied associate-/r*16.8

      \[\leadsto \mathsf{fma}\left(-4, \frac{t \cdot a}{c}, \color{blue}{\frac{\frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z}}{c}}\right)\]
    5. Simplified16.8

      \[\leadsto \mathsf{fma}\left(-4, \frac{t \cdot a}{c}, \frac{\color{blue}{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z}}}{c}\right)\]
    6. Using strategy rm
    7. Applied *-un-lft-identity16.8

      \[\leadsto \mathsf{fma}\left(-4, \frac{t \cdot a}{\color{blue}{1 \cdot c}}, \frac{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z}}{c}\right)\]
    8. Applied times-frac16.3

      \[\leadsto \mathsf{fma}\left(-4, \color{blue}{\frac{t}{1} \cdot \frac{a}{c}}, \frac{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z}}{c}\right)\]
    9. Simplified16.3

      \[\leadsto \mathsf{fma}\left(-4, \color{blue}{t} \cdot \frac{a}{c}, \frac{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z}}{c}\right)\]
    10. Taylor expanded around 0 8.0

      \[\leadsto \mathsf{fma}\left(-4, t \cdot \frac{a}{c}, \color{blue}{\frac{b}{z \cdot c} + 9 \cdot \frac{x \cdot y}{z \cdot c}}\right)\]
    11. Simplified8.0

      \[\leadsto \mathsf{fma}\left(-4, t \cdot \frac{a}{c}, \color{blue}{\mathsf{fma}\left(9, \frac{x \cdot y}{z \cdot c}, \frac{b}{z \cdot c}\right)}\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification9.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -5.3530085862134982 \cdot 10^{-146} \lor \neg \left(z \le 2.15005537231926563 \cdot 10^{156}\right):\\ \;\;\;\;\mathsf{fma}\left(-4, \frac{1}{\frac{c}{t \cdot a}}, \frac{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z}}{c}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-4, t \cdot \frac{a}{c}, \mathsf{fma}\left(9, \frac{x \cdot y}{z \cdot c}, \frac{b}{z \cdot c}\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020033 +o rules:numerics
(FPCore (x y z t a b c)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, J"
  :precision binary64

  :herbie-target
  (if (< (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) (* z c)) -1.1001567408041051e-171) (/ (+ (- (* (* x 9) y) (* (* z 4) (* t a))) b) (* z c)) (if (< (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) (* z c)) -0.0) (/ (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) z) c) (if (< (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) (* z c)) 1.1708877911747488e-53) (/ (+ (- (* (* x 9) y) (* (* z 4) (* t a))) b) (* z c)) (if (< (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) (* z c)) 2.876823679546137e+130) (- (+ (* (* 9 (/ y c)) (/ x z)) (/ b (* c z))) (* 4 (/ (* a t) c))) (if (< (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) (* z c)) 1.3838515042456319e+158) (/ (+ (- (* (* x 9) y) (* (* z 4) (* t a))) b) (* z c)) (- (+ (* 9 (* (/ y (* c z)) x)) (/ b (* c z))) (* 4 (/ (* a t) c))))))))

  (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) (* z c)))