Average Error: 20.3 → 6.0
Time: 17.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}{\frac{z \cdot c}{y}}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \frac{t}{\frac{c}{a}}\\ \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 -5.217007323286379530382095589966879256057 \cdot 10^{-167}:\\ \;\;\;\;\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 4.053529705634986576915069686000450189203 \cdot 10^{267}:\\ \;\;\;\;\frac{\frac{1}{\frac{z}{\mathsf{fma}\left(y, x \cdot 9, b\right)}} - \left(a \cdot 4\right) \cdot t}{c}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z} \cdot \frac{y}{c}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \frac{t}{\frac{c}{a}}\\ \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}{\frac{z \cdot c}{y}}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \frac{t}{\frac{c}{a}}\\

\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 -5.217007323286379530382095589966879256057 \cdot 10^{-167}:\\
\;\;\;\;\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 4.053529705634986576915069686000450189203 \cdot 10^{267}:\\
\;\;\;\;\frac{\frac{1}{\frac{z}{\mathsf{fma}\left(y, x \cdot 9, b\right)}} - \left(a \cdot 4\right) \cdot t}{c}\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r420974 = x;
        double r420975 = 9.0;
        double r420976 = r420974 * r420975;
        double r420977 = y;
        double r420978 = r420976 * r420977;
        double r420979 = z;
        double r420980 = 4.0;
        double r420981 = r420979 * r420980;
        double r420982 = t;
        double r420983 = r420981 * r420982;
        double r420984 = a;
        double r420985 = r420983 * r420984;
        double r420986 = r420978 - r420985;
        double r420987 = b;
        double r420988 = r420986 + r420987;
        double r420989 = c;
        double r420990 = r420979 * r420989;
        double r420991 = r420988 / r420990;
        return r420991;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r420992 = x;
        double r420993 = 9.0;
        double r420994 = r420992 * r420993;
        double r420995 = y;
        double r420996 = r420994 * r420995;
        double r420997 = z;
        double r420998 = 4.0;
        double r420999 = r420997 * r420998;
        double r421000 = t;
        double r421001 = r420999 * r421000;
        double r421002 = a;
        double r421003 = r421001 * r421002;
        double r421004 = r420996 - r421003;
        double r421005 = b;
        double r421006 = r421004 + r421005;
        double r421007 = c;
        double r421008 = r420997 * r421007;
        double r421009 = r421006 / r421008;
        double r421010 = -inf.0;
        bool r421011 = r421009 <= r421010;
        double r421012 = r421008 / r420995;
        double r421013 = r420992 / r421012;
        double r421014 = r421005 / r421008;
        double r421015 = fma(r421013, r420993, r421014);
        double r421016 = r421007 / r421002;
        double r421017 = r421000 / r421016;
        double r421018 = r420998 * r421017;
        double r421019 = r421015 - r421018;
        double r421020 = -5.2170073232863795e-167;
        bool r421021 = r421009 <= r421020;
        double r421022 = 4.0535297056349866e+267;
        bool r421023 = r421009 <= r421022;
        double r421024 = 1.0;
        double r421025 = fma(r420995, r420994, r421005);
        double r421026 = r420997 / r421025;
        double r421027 = r421024 / r421026;
        double r421028 = r421002 * r420998;
        double r421029 = r421028 * r421000;
        double r421030 = r421027 - r421029;
        double r421031 = r421030 / r421007;
        double r421032 = r420992 / r420997;
        double r421033 = r420995 / r421007;
        double r421034 = r421032 * r421033;
        double r421035 = fma(r421034, r420993, r421014);
        double r421036 = r421035 - r421018;
        double r421037 = r421023 ? r421031 : r421036;
        double r421038 = r421021 ? r421009 : r421037;
        double r421039 = r421011 ? r421019 : r421038;
        return r421039;
}

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.3
Target14.3
Herbie6.0
\[\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.100156740804105117061698089246936481893 \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.170887791174748819600820354912645756062 \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.876823679546137226963937101710277849382 \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.383851504245631860711731716196098366993 \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. Simplified23.1

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

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

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

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

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

    if -inf.0 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -5.2170073232863795e-167

    1. Initial program 0.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}\]

    if -5.2170073232863795e-167 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 4.0535297056349866e+267

    1. Initial program 9.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. Simplified6.1

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

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

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

    1. Initial program 55.5

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

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

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

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

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

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

    \[\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}{\frac{z \cdot c}{y}}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \frac{t}{\frac{c}{a}}\\ \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 -5.217007323286379530382095589966879256057 \cdot 10^{-167}:\\ \;\;\;\;\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 4.053529705634986576915069686000450189203 \cdot 10^{267}:\\ \;\;\;\;\frac{\frac{1}{\frac{z}{\mathsf{fma}\left(y, x \cdot 9, b\right)}} - \left(a \cdot 4\right) \cdot t}{c}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z} \cdot \frac{y}{c}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \frac{t}{\frac{c}{a}}\\ \end{array}\]

Reproduce

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