Average Error: 20.4 → 7.5
Time: 6.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} \le -4.467871422320185237629772284274375035079 \cdot 10^{-213}:\\ \;\;\;\;\mathsf{fma}\left(-4, t \cdot \frac{a}{c}, {\left(\mathsf{fma}\left(9, \frac{x \cdot y}{z \cdot c}, \frac{b}{z \cdot c}\right)\right)}^{1}\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 1.612423463345041752995521763691113217843 \cdot 10^{-303}:\\ \;\;\;\;\mathsf{fma}\left(-4, \frac{1}{\frac{c}{t \cdot a}}, \frac{1}{z} \cdot \frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{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 1.228454670464632119386236983422480410104 \cdot 10^{305}:\\ \;\;\;\;\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(-4, t \cdot \frac{a}{c}, \frac{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z}}{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 -4.467871422320185237629772284274375035079 \cdot 10^{-213}:\\
\;\;\;\;\mathsf{fma}\left(-4, t \cdot \frac{a}{c}, {\left(\mathsf{fma}\left(9, \frac{x \cdot y}{z \cdot c}, \frac{b}{z \cdot c}\right)\right)}^{1}\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 1.612423463345041752995521763691113217843 \cdot 10^{-303}:\\
\;\;\;\;\mathsf{fma}\left(-4, \frac{1}{\frac{c}{t \cdot a}}, \frac{1}{z} \cdot \frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{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 1.228454670464632119386236983422480410104 \cdot 10^{305}:\\
\;\;\;\;\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(-4, t \cdot \frac{a}{c}, \frac{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z}}{c}\right)\\

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r652728 = x;
        double r652729 = 9.0;
        double r652730 = r652728 * r652729;
        double r652731 = y;
        double r652732 = r652730 * r652731;
        double r652733 = z;
        double r652734 = 4.0;
        double r652735 = r652733 * r652734;
        double r652736 = t;
        double r652737 = r652735 * r652736;
        double r652738 = a;
        double r652739 = r652737 * r652738;
        double r652740 = r652732 - r652739;
        double r652741 = b;
        double r652742 = r652740 + r652741;
        double r652743 = c;
        double r652744 = r652733 * r652743;
        double r652745 = r652742 / r652744;
        return r652745;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r652746 = x;
        double r652747 = 9.0;
        double r652748 = r652746 * r652747;
        double r652749 = y;
        double r652750 = r652748 * r652749;
        double r652751 = z;
        double r652752 = 4.0;
        double r652753 = r652751 * r652752;
        double r652754 = t;
        double r652755 = r652753 * r652754;
        double r652756 = a;
        double r652757 = r652755 * r652756;
        double r652758 = r652750 - r652757;
        double r652759 = b;
        double r652760 = r652758 + r652759;
        double r652761 = c;
        double r652762 = r652751 * r652761;
        double r652763 = r652760 / r652762;
        double r652764 = -4.467871422320185e-213;
        bool r652765 = r652763 <= r652764;
        double r652766 = -r652752;
        double r652767 = r652756 / r652761;
        double r652768 = r652754 * r652767;
        double r652769 = r652746 * r652749;
        double r652770 = r652769 / r652762;
        double r652771 = r652759 / r652762;
        double r652772 = fma(r652747, r652770, r652771);
        double r652773 = 1.0;
        double r652774 = pow(r652772, r652773);
        double r652775 = fma(r652766, r652768, r652774);
        double r652776 = 1.6124234633450418e-303;
        bool r652777 = r652763 <= r652776;
        double r652778 = r652754 * r652756;
        double r652779 = r652761 / r652778;
        double r652780 = r652773 / r652779;
        double r652781 = r652773 / r652751;
        double r652782 = r652747 * r652746;
        double r652783 = fma(r652782, r652749, r652759);
        double r652784 = r652783 / r652761;
        double r652785 = r652781 * r652784;
        double r652786 = fma(r652766, r652780, r652785);
        double r652787 = 1.2284546704646321e+305;
        bool r652788 = r652763 <= r652787;
        double r652789 = r652783 / r652751;
        double r652790 = r652789 / r652761;
        double r652791 = fma(r652766, r652768, r652790);
        double r652792 = r652788 ? r652763 : r652791;
        double r652793 = r652777 ? r652786 : r652792;
        double r652794 = r652765 ? r652775 : r652793;
        return r652794;
}

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

    1. Initial program 12.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. Simplified8.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 *-un-lft-identity8.4

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 *-un-lft-identity20.9

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

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

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

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

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

    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 1.2284546704646321e+305 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c))

    1. Initial program 63.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. Simplified31.5

      \[\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 *-un-lft-identity31.5

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(-4, \color{blue}{t} \cdot \frac{a}{c}, \frac{1}{z} \cdot \frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{c}\right)\]
    11. Using strategy rm
    12. Applied associate-*r/22.4

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

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

    \[\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 -4.467871422320185237629772284274375035079 \cdot 10^{-213}:\\ \;\;\;\;\mathsf{fma}\left(-4, t \cdot \frac{a}{c}, {\left(\mathsf{fma}\left(9, \frac{x \cdot y}{z \cdot c}, \frac{b}{z \cdot c}\right)\right)}^{1}\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 1.612423463345041752995521763691113217843 \cdot 10^{-303}:\\ \;\;\;\;\mathsf{fma}\left(-4, \frac{1}{\frac{c}{t \cdot a}}, \frac{1}{z} \cdot \frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{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 1.228454670464632119386236983422480410104 \cdot 10^{305}:\\ \;\;\;\;\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(-4, t \cdot \frac{a}{c}, \frac{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z}}{c}\right)\\ \end{array}\]

Reproduce

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