Average Error: 20.8 → 9.6
Time: 6.3s
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 -7.31923342190711207 \cdot 10^{-54} \lor \neg \left(z \le 1.7491363804533648 \cdot 10^{-85}\right):\\ \;\;\;\;\mathsf{fma}\left(-4, \frac{t}{c} \cdot a, \frac{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z}}{c}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-4, \frac{t}{c} \cdot a, \frac{1}{\frac{z \cdot c}{\mathsf{fma}\left(x, 9 \cdot y, b\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 -7.31923342190711207 \cdot 10^{-54} \lor \neg \left(z \le 1.7491363804533648 \cdot 10^{-85}\right):\\
\;\;\;\;\mathsf{fma}\left(-4, \frac{t}{c} \cdot a, \frac{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z}}{c}\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r841012 = x;
        double r841013 = 9.0;
        double r841014 = r841012 * r841013;
        double r841015 = y;
        double r841016 = r841014 * r841015;
        double r841017 = z;
        double r841018 = 4.0;
        double r841019 = r841017 * r841018;
        double r841020 = t;
        double r841021 = r841019 * r841020;
        double r841022 = a;
        double r841023 = r841021 * r841022;
        double r841024 = r841016 - r841023;
        double r841025 = b;
        double r841026 = r841024 + r841025;
        double r841027 = c;
        double r841028 = r841017 * r841027;
        double r841029 = r841026 / r841028;
        return r841029;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r841030 = z;
        double r841031 = -7.319233421907112e-54;
        bool r841032 = r841030 <= r841031;
        double r841033 = 1.7491363804533648e-85;
        bool r841034 = r841030 <= r841033;
        double r841035 = !r841034;
        bool r841036 = r841032 || r841035;
        double r841037 = 4.0;
        double r841038 = -r841037;
        double r841039 = t;
        double r841040 = c;
        double r841041 = r841039 / r841040;
        double r841042 = a;
        double r841043 = r841041 * r841042;
        double r841044 = 9.0;
        double r841045 = x;
        double r841046 = r841044 * r841045;
        double r841047 = y;
        double r841048 = b;
        double r841049 = fma(r841046, r841047, r841048);
        double r841050 = r841049 / r841030;
        double r841051 = r841050 / r841040;
        double r841052 = fma(r841038, r841043, r841051);
        double r841053 = 1.0;
        double r841054 = r841030 * r841040;
        double r841055 = r841044 * r841047;
        double r841056 = fma(r841045, r841055, r841048);
        double r841057 = r841054 / r841056;
        double r841058 = r841053 / r841057;
        double r841059 = fma(r841038, r841043, r841058);
        double r841060 = r841036 ? r841052 : r841059;
        return r841060;
}

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.8
Target14.9
Herbie9.6
\[\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 < -7.319233421907112e-54 or 1.7491363804533648e-85 < z

    1. Initial program 26.6

      \[\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-/l*13.4

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

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

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

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

    if -7.319233421907112e-54 < z < 1.7491363804533648e-85

    1. Initial program 6.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. Simplified9.6

      \[\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-/l*6.3

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

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

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

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

Reproduce

herbie shell --seed 2020057 +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)))