Average Error: 20.8 → 8.5
Time: 7.5s
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 -1.543905335657327018667500024760689729908 \cdot 10^{-60} \lor \neg \left(z \le 1.922500653134763196019662841029122258793 \cdot 10^{-48}\right):\\ \;\;\;\;\mathsf{fma}\left(-4, \frac{t \cdot a}{c}, \frac{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z}}{c}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-4, \frac{t}{\sqrt[3]{c} \cdot \sqrt[3]{c}} \cdot \frac{a}{\sqrt[3]{c}}, \frac{\sqrt[3]{\mathsf{fma}\left(x, 9 \cdot y, b\right)} \cdot \sqrt[3]{\mathsf{fma}\left(x, 9 \cdot y, b\right)}}{\frac{z \cdot c}{\sqrt[3]{\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 -1.543905335657327018667500024760689729908 \cdot 10^{-60} \lor \neg \left(z \le 1.922500653134763196019662841029122258793 \cdot 10^{-48}\right):\\
\;\;\;\;\mathsf{fma}\left(-4, \frac{t \cdot a}{c}, \frac{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z}}{c}\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-4, \frac{t}{\sqrt[3]{c} \cdot \sqrt[3]{c}} \cdot \frac{a}{\sqrt[3]{c}}, \frac{\sqrt[3]{\mathsf{fma}\left(x, 9 \cdot y, b\right)} \cdot \sqrt[3]{\mathsf{fma}\left(x, 9 \cdot y, b\right)}}{\frac{z \cdot c}{\sqrt[3]{\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 r693713 = x;
        double r693714 = 9.0;
        double r693715 = r693713 * r693714;
        double r693716 = y;
        double r693717 = r693715 * r693716;
        double r693718 = z;
        double r693719 = 4.0;
        double r693720 = r693718 * r693719;
        double r693721 = t;
        double r693722 = r693720 * r693721;
        double r693723 = a;
        double r693724 = r693722 * r693723;
        double r693725 = r693717 - r693724;
        double r693726 = b;
        double r693727 = r693725 + r693726;
        double r693728 = c;
        double r693729 = r693718 * r693728;
        double r693730 = r693727 / r693729;
        return r693730;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r693731 = z;
        double r693732 = -1.543905335657327e-60;
        bool r693733 = r693731 <= r693732;
        double r693734 = 1.9225006531347632e-48;
        bool r693735 = r693731 <= r693734;
        double r693736 = !r693735;
        bool r693737 = r693733 || r693736;
        double r693738 = 4.0;
        double r693739 = -r693738;
        double r693740 = t;
        double r693741 = a;
        double r693742 = r693740 * r693741;
        double r693743 = c;
        double r693744 = r693742 / r693743;
        double r693745 = 9.0;
        double r693746 = x;
        double r693747 = r693745 * r693746;
        double r693748 = y;
        double r693749 = b;
        double r693750 = fma(r693747, r693748, r693749);
        double r693751 = r693750 / r693731;
        double r693752 = r693751 / r693743;
        double r693753 = fma(r693739, r693744, r693752);
        double r693754 = cbrt(r693743);
        double r693755 = r693754 * r693754;
        double r693756 = r693740 / r693755;
        double r693757 = r693741 / r693754;
        double r693758 = r693756 * r693757;
        double r693759 = r693745 * r693748;
        double r693760 = fma(r693746, r693759, r693749);
        double r693761 = cbrt(r693760);
        double r693762 = r693761 * r693761;
        double r693763 = r693731 * r693743;
        double r693764 = r693763 / r693761;
        double r693765 = r693762 / r693764;
        double r693766 = fma(r693739, r693758, r693765);
        double r693767 = r693737 ? r693753 : r693766;
        return r693767;
}

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.4
Herbie8.5
\[\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 2 regimes
  2. if z < -1.543905335657327e-60 or 1.9225006531347632e-48 < z

    1. Initial program 27.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. Simplified12.8

      \[\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-/r*9.4

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

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

    if -1.543905335657327e-60 < z < 1.9225006531347632e-48

    1. Initial program 6.3

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

      \[\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 add-cube-cbrt9.6

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.543905335657327018667500024760689729908 \cdot 10^{-60} \lor \neg \left(z \le 1.922500653134763196019662841029122258793 \cdot 10^{-48}\right):\\ \;\;\;\;\mathsf{fma}\left(-4, \frac{t \cdot a}{c}, \frac{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z}}{c}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-4, \frac{t}{\sqrt[3]{c} \cdot \sqrt[3]{c}} \cdot \frac{a}{\sqrt[3]{c}}, \frac{\sqrt[3]{\mathsf{fma}\left(x, 9 \cdot y, b\right)} \cdot \sqrt[3]{\mathsf{fma}\left(x, 9 \cdot y, b\right)}}{\frac{z \cdot c}{\sqrt[3]{\mathsf{fma}\left(x, 9 \cdot y, b\right)}}}\right)\\ \end{array}\]

Reproduce

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