Average Error: 20.8 → 5.1
Time: 10.1s
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}{z \cdot \frac{c}{y}}, 9, \frac{b}{z \cdot c}\right) - \frac{\left(t \cdot a\right) \cdot 4}{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 -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, 9 \cdot y, b\right)}{z} - \left(t \cdot a\right) \cdot 4\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}{z} \cdot \frac{y}{c}, 9, b \cdot \frac{1}{z \cdot c}\right) - \frac{\left(t \cdot a\right) \cdot 4}{c}\\ \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}{z \cdot \frac{c}{y}}, 9, \frac{b}{z \cdot c}\right) - \frac{\left(t \cdot a\right) \cdot 4}{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 -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, 9 \cdot y, b\right)}{z} - \left(t \cdot a\right) \cdot 4\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}{z} \cdot \frac{y}{c}, 9, b \cdot \frac{1}{z \cdot c}\right) - \frac{\left(t \cdot a\right) \cdot 4}{c}\\

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r791225 = x;
        double r791226 = 9.0;
        double r791227 = r791225 * r791226;
        double r791228 = y;
        double r791229 = r791227 * r791228;
        double r791230 = z;
        double r791231 = 4.0;
        double r791232 = r791230 * r791231;
        double r791233 = t;
        double r791234 = r791232 * r791233;
        double r791235 = a;
        double r791236 = r791234 * r791235;
        double r791237 = r791229 - r791236;
        double r791238 = b;
        double r791239 = r791237 + r791238;
        double r791240 = c;
        double r791241 = r791230 * r791240;
        double r791242 = r791239 / r791241;
        return r791242;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r791243 = x;
        double r791244 = 9.0;
        double r791245 = r791243 * r791244;
        double r791246 = y;
        double r791247 = r791245 * r791246;
        double r791248 = z;
        double r791249 = 4.0;
        double r791250 = r791248 * r791249;
        double r791251 = t;
        double r791252 = r791250 * r791251;
        double r791253 = a;
        double r791254 = r791252 * r791253;
        double r791255 = r791247 - r791254;
        double r791256 = b;
        double r791257 = r791255 + r791256;
        double r791258 = c;
        double r791259 = r791248 * r791258;
        double r791260 = r791257 / r791259;
        double r791261 = -inf.0;
        bool r791262 = r791260 <= r791261;
        double r791263 = r791258 / r791246;
        double r791264 = r791248 * r791263;
        double r791265 = r791243 / r791264;
        double r791266 = r791256 / r791259;
        double r791267 = fma(r791265, r791244, r791266);
        double r791268 = r791251 * r791253;
        double r791269 = r791268 * r791249;
        double r791270 = r791269 / r791258;
        double r791271 = r791267 - r791270;
        double r791272 = -3.8657556775396997e-184;
        bool r791273 = r791260 <= r791272;
        double r791274 = -0.0;
        bool r791275 = r791260 <= r791274;
        double r791276 = r791244 * r791246;
        double r791277 = fma(r791243, r791276, r791256);
        double r791278 = r791277 / r791248;
        double r791279 = r791278 - r791269;
        double r791280 = 1.0;
        double r791281 = r791280 / r791258;
        double r791282 = r791279 * r791281;
        double r791283 = 2.5630952637815053e+303;
        bool r791284 = r791260 <= r791283;
        double r791285 = r791243 / r791248;
        double r791286 = r791246 / r791258;
        double r791287 = r791285 * r791286;
        double r791288 = r791280 / r791259;
        double r791289 = r791256 * r791288;
        double r791290 = fma(r791287, r791244, r791289);
        double r791291 = r791290 - r791270;
        double r791292 = r791284 ? r791260 : r791291;
        double r791293 = r791275 ? r791282 : r791292;
        double r791294 = r791273 ? r791260 : r791293;
        double r791295 = r791262 ? r791271 : r791294;
        return r791295;
}

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
Herbie5.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 4 regimes
  2. if (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -inf.0

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

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

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

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

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

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

    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, 9 \cdot y, b\right)}{z} - \left(t \cdot a\right) \cdot 4}{c}}\]
    3. Using strategy rm
    4. Applied div-inv0.7

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

    if 2.5630952637815053e+303 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c))

    1. Initial program 62.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}\]
    2. Simplified27.1

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

      \[\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.4

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

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

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

    \[\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}{z \cdot \frac{c}{y}}, 9, \frac{b}{z \cdot c}\right) - \frac{\left(t \cdot a\right) \cdot 4}{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 -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, 9 \cdot y, b\right)}{z} - \left(t \cdot a\right) \cdot 4\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}{z} \cdot \frac{y}{c}, 9, b \cdot \frac{1}{z \cdot c}\right) - \frac{\left(t \cdot a\right) \cdot 4}{c}\\ \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)))