Average Error: 21.4 → 4.0
Time: 23.6s
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) - \left(\frac{a \cdot 4}{\sqrt[3]{c} \cdot \sqrt[3]{c}} \cdot \frac{\sqrt[3]{t} \cdot \sqrt[3]{t}}{\sqrt[3]{\sqrt[3]{c} \cdot \sqrt[3]{c}}}\right) \cdot \frac{\sqrt[3]{t}}{\sqrt[3]{\sqrt[3]{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.044945372715348494311419335429311721877 \cdot 10^{-258}:\\ \;\;\;\;\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:\\ \;\;\;\;\frac{\mathsf{fma}\left(9, \frac{x \cdot y}{z}, \frac{b}{z}\right) - \left(a \cdot 4\right) \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} \le 5.226249926821728616154563669432090090445 \cdot 10^{297}:\\ \;\;\;\;\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}{\frac{z \cdot c}{y}}, 9, \frac{b}{z \cdot c}\right) - \left(\frac{a \cdot 4}{\sqrt[3]{c} \cdot \sqrt[3]{c}} \cdot \frac{\sqrt[3]{t} \cdot \sqrt[3]{t}}{\sqrt[3]{\sqrt[3]{c} \cdot \sqrt[3]{c}}}\right) \cdot \frac{\sqrt[3]{t}}{\sqrt[3]{\sqrt[3]{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}{\frac{z \cdot c}{y}}, 9, \frac{b}{z \cdot c}\right) - \left(\frac{a \cdot 4}{\sqrt[3]{c} \cdot \sqrt[3]{c}} \cdot \frac{\sqrt[3]{t} \cdot \sqrt[3]{t}}{\sqrt[3]{\sqrt[3]{c} \cdot \sqrt[3]{c}}}\right) \cdot \frac{\sqrt[3]{t}}{\sqrt[3]{\sqrt[3]{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.044945372715348494311419335429311721877 \cdot 10^{-258}:\\
\;\;\;\;\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:\\
\;\;\;\;\frac{\mathsf{fma}\left(9, \frac{x \cdot y}{z}, \frac{b}{z}\right) - \left(a \cdot 4\right) \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} \le 5.226249926821728616154563669432090090445 \cdot 10^{297}:\\
\;\;\;\;\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}{\frac{z \cdot c}{y}}, 9, \frac{b}{z \cdot c}\right) - \left(\frac{a \cdot 4}{\sqrt[3]{c} \cdot \sqrt[3]{c}} \cdot \frac{\sqrt[3]{t} \cdot \sqrt[3]{t}}{\sqrt[3]{\sqrt[3]{c} \cdot \sqrt[3]{c}}}\right) \cdot \frac{\sqrt[3]{t}}{\sqrt[3]{\sqrt[3]{c}}}\\

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r406764 = x;
        double r406765 = 9.0;
        double r406766 = r406764 * r406765;
        double r406767 = y;
        double r406768 = r406766 * r406767;
        double r406769 = z;
        double r406770 = 4.0;
        double r406771 = r406769 * r406770;
        double r406772 = t;
        double r406773 = r406771 * r406772;
        double r406774 = a;
        double r406775 = r406773 * r406774;
        double r406776 = r406768 - r406775;
        double r406777 = b;
        double r406778 = r406776 + r406777;
        double r406779 = c;
        double r406780 = r406769 * r406779;
        double r406781 = r406778 / r406780;
        return r406781;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r406782 = x;
        double r406783 = 9.0;
        double r406784 = r406782 * r406783;
        double r406785 = y;
        double r406786 = r406784 * r406785;
        double r406787 = z;
        double r406788 = 4.0;
        double r406789 = r406787 * r406788;
        double r406790 = t;
        double r406791 = r406789 * r406790;
        double r406792 = a;
        double r406793 = r406791 * r406792;
        double r406794 = r406786 - r406793;
        double r406795 = b;
        double r406796 = r406794 + r406795;
        double r406797 = c;
        double r406798 = r406787 * r406797;
        double r406799 = r406796 / r406798;
        double r406800 = -inf.0;
        bool r406801 = r406799 <= r406800;
        double r406802 = r406798 / r406785;
        double r406803 = r406782 / r406802;
        double r406804 = r406795 / r406798;
        double r406805 = fma(r406803, r406783, r406804);
        double r406806 = r406792 * r406788;
        double r406807 = cbrt(r406797);
        double r406808 = r406807 * r406807;
        double r406809 = r406806 / r406808;
        double r406810 = cbrt(r406790);
        double r406811 = r406810 * r406810;
        double r406812 = cbrt(r406808);
        double r406813 = r406811 / r406812;
        double r406814 = r406809 * r406813;
        double r406815 = cbrt(r406807);
        double r406816 = r406810 / r406815;
        double r406817 = r406814 * r406816;
        double r406818 = r406805 - r406817;
        double r406819 = -2.0449453727153485e-258;
        bool r406820 = r406799 <= r406819;
        double r406821 = 0.0;
        bool r406822 = r406799 <= r406821;
        double r406823 = r406782 * r406785;
        double r406824 = r406823 / r406787;
        double r406825 = r406795 / r406787;
        double r406826 = fma(r406783, r406824, r406825);
        double r406827 = r406806 * r406790;
        double r406828 = r406826 - r406827;
        double r406829 = r406828 / r406797;
        double r406830 = 5.2262499268217286e+297;
        bool r406831 = r406799 <= r406830;
        double r406832 = r406831 ? r406799 : r406818;
        double r406833 = r406822 ? r406829 : r406832;
        double r406834 = r406820 ? r406799 : r406833;
        double r406835 = r406801 ? r406818 : r406834;
        return r406835;
}

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

Original21.4
Target14.7
Herbie4.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.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 3 regimes
  2. if (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -inf.0 or 5.2262499268217286e+297 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c))

    1. Initial program 62.4

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

      \[\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 29.9

      \[\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. Simplified30.0

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

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

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

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

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

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

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

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

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

    if -inf.0 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -2.0449453727153485e-258 or 0.0 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 5.2262499268217286e+297

    1. Initial program 3.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 -2.0449453727153485e-258 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 0.0

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

      \[\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 0.9

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

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(9, \frac{x \cdot y}{z}, \frac{b}{z}\right)} - \left(a \cdot 4\right) \cdot t}{c}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification4.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) - \left(\frac{a \cdot 4}{\sqrt[3]{c} \cdot \sqrt[3]{c}} \cdot \frac{\sqrt[3]{t} \cdot \sqrt[3]{t}}{\sqrt[3]{\sqrt[3]{c} \cdot \sqrt[3]{c}}}\right) \cdot \frac{\sqrt[3]{t}}{\sqrt[3]{\sqrt[3]{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.044945372715348494311419335429311721877 \cdot 10^{-258}:\\ \;\;\;\;\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:\\ \;\;\;\;\frac{\mathsf{fma}\left(9, \frac{x \cdot y}{z}, \frac{b}{z}\right) - \left(a \cdot 4\right) \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} \le 5.226249926821728616154563669432090090445 \cdot 10^{297}:\\ \;\;\;\;\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}{\frac{z \cdot c}{y}}, 9, \frac{b}{z \cdot c}\right) - \left(\frac{a \cdot 4}{\sqrt[3]{c} \cdot \sqrt[3]{c}} \cdot \frac{\sqrt[3]{t} \cdot \sqrt[3]{t}}{\sqrt[3]{\sqrt[3]{c} \cdot \sqrt[3]{c}}}\right) \cdot \frac{\sqrt[3]{t}}{\sqrt[3]{\sqrt[3]{c}}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019322 +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.100156740804105e-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)))