Average Error: 20.7 → 5.3
Time: 24.7s
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} \le -5.714617762619817600956632832341409108159 \cdot 10^{-177}:\\ \;\;\;\;\mathsf{fma}\left(9, \frac{x}{\frac{z \cdot c}{y}}, \frac{b}{z \cdot c}\right) - 4 \cdot \left(\left(a \cdot \left(\frac{\sqrt[3]{t}}{\sqrt[3]{c}} \cdot \frac{\sqrt[3]{t}}{\sqrt[3]{c}}\right)\right) \cdot \frac{\sqrt[3]{t}}{\sqrt[3]{c}}\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 2.987851345915281325406976623905108051725 \cdot 10^{-28}:\\ \;\;\;\;\frac{1}{\frac{c}{\frac{\mathsf{fma}\left(x \cdot 9, y, b\right)}{z} - \left(4 \cdot t\right) \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(9, \frac{x}{\frac{z \cdot c}{y}}, \frac{b}{z \cdot c}\right) - 4 \cdot \left(\left(a \cdot \left(\frac{\sqrt[3]{t}}{\sqrt[3]{c}} \cdot \frac{\sqrt[3]{t}}{\sqrt[3]{c}}\right)\right) \cdot \frac{\sqrt[3]{t}}{\sqrt[3]{c}}\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} \le -5.714617762619817600956632832341409108159 \cdot 10^{-177}:\\
\;\;\;\;\mathsf{fma}\left(9, \frac{x}{\frac{z \cdot c}{y}}, \frac{b}{z \cdot c}\right) - 4 \cdot \left(\left(a \cdot \left(\frac{\sqrt[3]{t}}{\sqrt[3]{c}} \cdot \frac{\sqrt[3]{t}}{\sqrt[3]{c}}\right)\right) \cdot \frac{\sqrt[3]{t}}{\sqrt[3]{c}}\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 2.987851345915281325406976623905108051725 \cdot 10^{-28}:\\
\;\;\;\;\frac{1}{\frac{c}{\frac{\mathsf{fma}\left(x \cdot 9, y, b\right)}{z} - \left(4 \cdot t\right) \cdot a}}\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r46374069 = x;
        double r46374070 = 9.0;
        double r46374071 = r46374069 * r46374070;
        double r46374072 = y;
        double r46374073 = r46374071 * r46374072;
        double r46374074 = z;
        double r46374075 = 4.0;
        double r46374076 = r46374074 * r46374075;
        double r46374077 = t;
        double r46374078 = r46374076 * r46374077;
        double r46374079 = a;
        double r46374080 = r46374078 * r46374079;
        double r46374081 = r46374073 - r46374080;
        double r46374082 = b;
        double r46374083 = r46374081 + r46374082;
        double r46374084 = c;
        double r46374085 = r46374074 * r46374084;
        double r46374086 = r46374083 / r46374085;
        return r46374086;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r46374087 = x;
        double r46374088 = 9.0;
        double r46374089 = r46374087 * r46374088;
        double r46374090 = y;
        double r46374091 = r46374089 * r46374090;
        double r46374092 = z;
        double r46374093 = 4.0;
        double r46374094 = r46374092 * r46374093;
        double r46374095 = t;
        double r46374096 = r46374094 * r46374095;
        double r46374097 = a;
        double r46374098 = r46374096 * r46374097;
        double r46374099 = r46374091 - r46374098;
        double r46374100 = b;
        double r46374101 = r46374099 + r46374100;
        double r46374102 = c;
        double r46374103 = r46374092 * r46374102;
        double r46374104 = r46374101 / r46374103;
        double r46374105 = -5.714617762619818e-177;
        bool r46374106 = r46374104 <= r46374105;
        double r46374107 = r46374103 / r46374090;
        double r46374108 = r46374087 / r46374107;
        double r46374109 = r46374100 / r46374103;
        double r46374110 = fma(r46374088, r46374108, r46374109);
        double r46374111 = cbrt(r46374095);
        double r46374112 = cbrt(r46374102);
        double r46374113 = r46374111 / r46374112;
        double r46374114 = r46374113 * r46374113;
        double r46374115 = r46374097 * r46374114;
        double r46374116 = r46374115 * r46374113;
        double r46374117 = r46374093 * r46374116;
        double r46374118 = r46374110 - r46374117;
        double r46374119 = 2.9878513459152813e-28;
        bool r46374120 = r46374104 <= r46374119;
        double r46374121 = 1.0;
        double r46374122 = fma(r46374089, r46374090, r46374100);
        double r46374123 = r46374122 / r46374092;
        double r46374124 = r46374093 * r46374095;
        double r46374125 = r46374124 * r46374097;
        double r46374126 = r46374123 - r46374125;
        double r46374127 = r46374102 / r46374126;
        double r46374128 = r46374121 / r46374127;
        double r46374129 = r46374120 ? r46374128 : r46374118;
        double r46374130 = r46374106 ? r46374118 : r46374129;
        return r46374130;
}

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
Herbie5.3
\[\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.100156740804104887233830094663413900721 \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 2 regimes
  2. if (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -5.714617762619818e-177 or 2.9878513459152813e-28 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c))

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(9, \frac{x}{\frac{z \cdot c}{y}}, \frac{b}{z \cdot c}\right) - 4 \cdot \left(a \cdot \frac{t}{\color{blue}{\left(\sqrt[3]{c} \cdot \sqrt[3]{c}\right) \cdot \sqrt[3]{c}}}\right)\]
    13. Applied add-cube-cbrt8.6

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

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

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

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

    if -5.714617762619818e-177 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 2.9878513459152813e-28

    1. Initial program 19.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. Simplified0.8

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

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

    \[\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} \le -5.714617762619817600956632832341409108159 \cdot 10^{-177}:\\ \;\;\;\;\mathsf{fma}\left(9, \frac{x}{\frac{z \cdot c}{y}}, \frac{b}{z \cdot c}\right) - 4 \cdot \left(\left(a \cdot \left(\frac{\sqrt[3]{t}}{\sqrt[3]{c}} \cdot \frac{\sqrt[3]{t}}{\sqrt[3]{c}}\right)\right) \cdot \frac{\sqrt[3]{t}}{\sqrt[3]{c}}\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 2.987851345915281325406976623905108051725 \cdot 10^{-28}:\\ \;\;\;\;\frac{1}{\frac{c}{\frac{\mathsf{fma}\left(x \cdot 9, y, b\right)}{z} - \left(4 \cdot t\right) \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(9, \frac{x}{\frac{z \cdot c}{y}}, \frac{b}{z \cdot c}\right) - 4 \cdot \left(\left(a \cdot \left(\frac{\sqrt[3]{t}}{\sqrt[3]{c}} \cdot \frac{\sqrt[3]{t}}{\sqrt[3]{c}}\right)\right) \cdot \frac{\sqrt[3]{t}}{\sqrt[3]{c}}\right)\\ \end{array}\]

Reproduce

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

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

  (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)))