Average Error: 20.7 → 9.3
Time: 22.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}\;t \le -3.569570721395380273384909979735639197291 \cdot 10^{-79}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z \cdot \frac{c}{y}}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \left(t \cdot \frac{a}{c}\right)\\ \mathbf{elif}\;t \le -4.176278114991953551002343061171857552675 \cdot 10^{-212}:\\ \;\;\;\;\left(\frac{\mathsf{fma}\left(y, x \cdot 9, b\right)}{z} - \left(a \cdot 4\right) \cdot t\right) \cdot \frac{1}{c}\\ \mathbf{elif}\;t \le 3.076768144709861015030566940810711978373 \cdot 10^{-181}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z} \cdot \frac{y}{c}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \frac{t \cdot a}{c}\\ \mathbf{elif}\;t \le 1.320715977909021935256148670270400909605 \cdot 10^{-109}:\\ \;\;\;\;\left(\frac{\mathsf{fma}\left(y, x \cdot 9, b\right)}{z} - \left(a \cdot 4\right) \cdot t\right) \cdot \frac{1}{c}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z \cdot \frac{c}{y}}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \left(t \cdot \frac{a}{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}\;t \le -3.569570721395380273384909979735639197291 \cdot 10^{-79}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z \cdot \frac{c}{y}}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \left(t \cdot \frac{a}{c}\right)\\

\mathbf{elif}\;t \le -4.176278114991953551002343061171857552675 \cdot 10^{-212}:\\
\;\;\;\;\left(\frac{\mathsf{fma}\left(y, x \cdot 9, b\right)}{z} - \left(a \cdot 4\right) \cdot t\right) \cdot \frac{1}{c}\\

\mathbf{elif}\;t \le 3.076768144709861015030566940810711978373 \cdot 10^{-181}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z} \cdot \frac{y}{c}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \frac{t \cdot a}{c}\\

\mathbf{elif}\;t \le 1.320715977909021935256148670270400909605 \cdot 10^{-109}:\\
\;\;\;\;\left(\frac{\mathsf{fma}\left(y, x \cdot 9, b\right)}{z} - \left(a \cdot 4\right) \cdot t\right) \cdot \frac{1}{c}\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r604639 = x;
        double r604640 = 9.0;
        double r604641 = r604639 * r604640;
        double r604642 = y;
        double r604643 = r604641 * r604642;
        double r604644 = z;
        double r604645 = 4.0;
        double r604646 = r604644 * r604645;
        double r604647 = t;
        double r604648 = r604646 * r604647;
        double r604649 = a;
        double r604650 = r604648 * r604649;
        double r604651 = r604643 - r604650;
        double r604652 = b;
        double r604653 = r604651 + r604652;
        double r604654 = c;
        double r604655 = r604644 * r604654;
        double r604656 = r604653 / r604655;
        return r604656;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r604657 = t;
        double r604658 = -3.56957072139538e-79;
        bool r604659 = r604657 <= r604658;
        double r604660 = x;
        double r604661 = z;
        double r604662 = c;
        double r604663 = y;
        double r604664 = r604662 / r604663;
        double r604665 = r604661 * r604664;
        double r604666 = r604660 / r604665;
        double r604667 = 9.0;
        double r604668 = b;
        double r604669 = r604661 * r604662;
        double r604670 = r604668 / r604669;
        double r604671 = fma(r604666, r604667, r604670);
        double r604672 = 4.0;
        double r604673 = a;
        double r604674 = r604673 / r604662;
        double r604675 = r604657 * r604674;
        double r604676 = r604672 * r604675;
        double r604677 = r604671 - r604676;
        double r604678 = -4.1762781149919536e-212;
        bool r604679 = r604657 <= r604678;
        double r604680 = r604660 * r604667;
        double r604681 = fma(r604663, r604680, r604668);
        double r604682 = r604681 / r604661;
        double r604683 = r604673 * r604672;
        double r604684 = r604683 * r604657;
        double r604685 = r604682 - r604684;
        double r604686 = 1.0;
        double r604687 = r604686 / r604662;
        double r604688 = r604685 * r604687;
        double r604689 = 3.076768144709861e-181;
        bool r604690 = r604657 <= r604689;
        double r604691 = r604660 / r604661;
        double r604692 = r604663 / r604662;
        double r604693 = r604691 * r604692;
        double r604694 = fma(r604693, r604667, r604670);
        double r604695 = r604657 * r604673;
        double r604696 = r604695 / r604662;
        double r604697 = r604672 * r604696;
        double r604698 = r604694 - r604697;
        double r604699 = 1.320715977909022e-109;
        bool r604700 = r604657 <= r604699;
        double r604701 = r604700 ? r604688 : r604677;
        double r604702 = r604690 ? r604698 : r604701;
        double r604703 = r604679 ? r604688 : r604702;
        double r604704 = r604659 ? r604677 : r604703;
        return r604704;
}

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.6
Herbie9.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 3 regimes
  2. if t < -3.56957072139538e-79 or 1.320715977909022e-109 < t

    1. Initial program 25.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}\]
    2. Simplified14.8

      \[\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 12.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. Simplified12.9

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

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

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

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

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

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

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

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

    if -3.56957072139538e-79 < t < -4.1762781149919536e-212 or 3.076768144709861e-181 < t < 1.320715977909022e-109

    1. Initial program 14.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. Simplified9.0

      \[\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 div-inv9.1

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

    if -4.1762781149919536e-212 < t < 3.076768144709861e-181

    1. Initial program 11.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. Simplified10.4

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -3.569570721395380273384909979735639197291 \cdot 10^{-79}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z \cdot \frac{c}{y}}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \left(t \cdot \frac{a}{c}\right)\\ \mathbf{elif}\;t \le -4.176278114991953551002343061171857552675 \cdot 10^{-212}:\\ \;\;\;\;\left(\frac{\mathsf{fma}\left(y, x \cdot 9, b\right)}{z} - \left(a \cdot 4\right) \cdot t\right) \cdot \frac{1}{c}\\ \mathbf{elif}\;t \le 3.076768144709861015030566940810711978373 \cdot 10^{-181}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z} \cdot \frac{y}{c}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \frac{t \cdot a}{c}\\ \mathbf{elif}\;t \le 1.320715977909021935256148670270400909605 \cdot 10^{-109}:\\ \;\;\;\;\left(\frac{\mathsf{fma}\left(y, x \cdot 9, b\right)}{z} - \left(a \cdot 4\right) \cdot t\right) \cdot \frac{1}{c}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z \cdot \frac{c}{y}}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \left(t \cdot \frac{a}{c}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019306 +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.1001567408041049e-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.17088779117474882e-53) (/ (+ (- (* (* x 9) y) (* (* z 4) (* t a))) b) (* z c)) (if (< (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) (* z c)) 2.8768236795461372e130) (- (+ (* (* 9 (/ y c)) (/ x z)) (/ b (* c z))) (* 4 (/ (* a t) c))) (if (< (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) (* z c)) 1.3838515042456319e158) (/ (+ (- (* (* 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)))