Average Error: 20.8 → 3.4
Time: 10.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}\;\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} = -\infty:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{c \cdot \frac{z}{y}}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \left(\frac{a}{c} \cdot t\right)\\ \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} \le -3.86575567753969965 \cdot 10^{-184}:\\ \;\;\;\;\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}\\ \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} \le -0.0:\\ \;\;\;\;\left(\frac{\mathsf{fma}\left(x \cdot 9, y, b\right)}{z} - 4 \cdot \left(t \cdot a\right)\right) \cdot \frac{1}{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} \le 2.5630952637815053 \cdot 10^{303}:\\ \;\;\;\;\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}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{c \cdot \frac{z}{y}}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \left(\frac{a}{c} \cdot t\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}\;\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} = -\infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{c \cdot \frac{z}{y}}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \left(\frac{a}{c} \cdot t\right)\\

\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} \le -3.86575567753969965 \cdot 10^{-184}:\\
\;\;\;\;\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}\\

\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} \le -0.0:\\
\;\;\;\;\left(\frac{\mathsf{fma}\left(x \cdot 9, y, b\right)}{z} - 4 \cdot \left(t \cdot a\right)\right) \cdot \frac{1}{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} \le 2.5630952637815053 \cdot 10^{303}:\\
\;\;\;\;\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}\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r812026 = x;
        double r812027 = 9.0;
        double r812028 = r812026 * r812027;
        double r812029 = y;
        double r812030 = r812028 * r812029;
        double r812031 = z;
        double r812032 = 4.0;
        double r812033 = r812031 * r812032;
        double r812034 = t;
        double r812035 = r812033 * r812034;
        double r812036 = a;
        double r812037 = r812035 * r812036;
        double r812038 = r812030 - r812037;
        double r812039 = b;
        double r812040 = r812038 + r812039;
        double r812041 = c;
        double r812042 = r812031 * r812041;
        double r812043 = r812040 / r812042;
        return r812043;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r812044 = x;
        double r812045 = 9.0;
        double r812046 = r812044 * r812045;
        double r812047 = y;
        double r812048 = r812046 * r812047;
        double r812049 = z;
        double r812050 = 4.0;
        double r812051 = r812049 * r812050;
        double r812052 = t;
        double r812053 = r812051 * r812052;
        double r812054 = a;
        double r812055 = r812053 * r812054;
        double r812056 = r812048 - r812055;
        double r812057 = b;
        double r812058 = r812056 + r812057;
        double r812059 = c;
        double r812060 = r812049 * r812059;
        double r812061 = r812058 / r812060;
        double r812062 = -inf.0;
        bool r812063 = r812061 <= r812062;
        double r812064 = r812049 / r812047;
        double r812065 = r812059 * r812064;
        double r812066 = r812044 / r812065;
        double r812067 = r812057 / r812060;
        double r812068 = fma(r812066, r812045, r812067);
        double r812069 = r812054 / r812059;
        double r812070 = r812069 * r812052;
        double r812071 = r812050 * r812070;
        double r812072 = r812068 - r812071;
        double r812073 = -3.8657556775396997e-184;
        bool r812074 = r812061 <= r812073;
        double r812075 = -0.0;
        bool r812076 = r812061 <= r812075;
        double r812077 = fma(r812046, r812047, r812057);
        double r812078 = r812077 / r812049;
        double r812079 = r812052 * r812054;
        double r812080 = r812050 * r812079;
        double r812081 = r812078 - r812080;
        double r812082 = 1.0;
        double r812083 = r812082 / r812059;
        double r812084 = r812081 * r812083;
        double r812085 = 2.5630952637815053e+303;
        bool r812086 = r812061 <= r812085;
        double r812087 = r812086 ? r812061 : r812072;
        double r812088 = r812076 ? r812084 : r812087;
        double r812089 = r812074 ? r812061 : r812088;
        double r812090 = r812063 ? r812072 : r812089;
        return r812090;
}

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
Herbie3.4
\[\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 3 regimes
  2. if (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -inf.0 or 2.5630952637815053e+303 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c))

    1. Initial program 63.1

      \[\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. Simplified26.8

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

      \[\leadsto \color{blue}{\left(\frac{b}{z \cdot c} + 9 \cdot \frac{x \cdot y}{z \cdot c}\right) - 4 \cdot \frac{a \cdot t}{c}}\]
    4. Simplified30.7

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

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

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

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

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

    if -inf.0 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -3.8657556775396997e-184 or -0.0 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 2.5630952637815053e+303

    1. Initial program 0.7

      \[\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}\]

    if -3.8657556775396997e-184 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -0.0

    1. Initial program 33.9

      \[\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. Simplified0.6

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

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

    \[\leadsto \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} = -\infty:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{c \cdot \frac{z}{y}}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \left(\frac{a}{c} \cdot t\right)\\ \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} \le -3.86575567753969965 \cdot 10^{-184}:\\ \;\;\;\;\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}\\ \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} \le -0.0:\\ \;\;\;\;\left(\frac{\mathsf{fma}\left(x \cdot 9, y, b\right)}{z} - 4 \cdot \left(t \cdot a\right)\right) \cdot \frac{1}{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} \le 2.5630952637815053 \cdot 10^{303}:\\ \;\;\;\;\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}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{c \cdot \frac{z}{y}}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \left(\frac{a}{c} \cdot t\right)\\ \end{array}\]

Reproduce

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