Average Error: 20.8 → 8.5
Time: 12.0s
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 -5.7467453432494554 \cdot 10^{-25} \lor \neg \left(z \le 1.660011137319099 \cdot 10^{-94}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{c \cdot \frac{z}{y}}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \frac{t \cdot a}{c}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x \cdot y}{z \cdot c}, 9, \frac{1}{z} \cdot \frac{b}{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}\;z \le -5.7467453432494554 \cdot 10^{-25} \lor \neg \left(z \le 1.660011137319099 \cdot 10^{-94}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{c \cdot \frac{z}{y}}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \frac{t \cdot a}{c}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x \cdot y}{z \cdot c}, 9, \frac{1}{z} \cdot \frac{b}{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 r806685 = x;
        double r806686 = 9.0;
        double r806687 = r806685 * r806686;
        double r806688 = y;
        double r806689 = r806687 * r806688;
        double r806690 = z;
        double r806691 = 4.0;
        double r806692 = r806690 * r806691;
        double r806693 = t;
        double r806694 = r806692 * r806693;
        double r806695 = a;
        double r806696 = r806694 * r806695;
        double r806697 = r806689 - r806696;
        double r806698 = b;
        double r806699 = r806697 + r806698;
        double r806700 = c;
        double r806701 = r806690 * r806700;
        double r806702 = r806699 / r806701;
        return r806702;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r806703 = z;
        double r806704 = -5.746745343249455e-25;
        bool r806705 = r806703 <= r806704;
        double r806706 = 1.660011137319099e-94;
        bool r806707 = r806703 <= r806706;
        double r806708 = !r806707;
        bool r806709 = r806705 || r806708;
        double r806710 = x;
        double r806711 = c;
        double r806712 = y;
        double r806713 = r806703 / r806712;
        double r806714 = r806711 * r806713;
        double r806715 = r806710 / r806714;
        double r806716 = 9.0;
        double r806717 = b;
        double r806718 = r806703 * r806711;
        double r806719 = r806717 / r806718;
        double r806720 = fma(r806715, r806716, r806719);
        double r806721 = 4.0;
        double r806722 = t;
        double r806723 = a;
        double r806724 = r806722 * r806723;
        double r806725 = r806724 / r806711;
        double r806726 = r806721 * r806725;
        double r806727 = r806720 - r806726;
        double r806728 = r806710 * r806712;
        double r806729 = r806728 / r806718;
        double r806730 = 1.0;
        double r806731 = r806730 / r806703;
        double r806732 = r806717 / r806711;
        double r806733 = r806731 * r806732;
        double r806734 = fma(r806729, r806716, r806733);
        double r806735 = r806723 / r806711;
        double r806736 = r806722 * r806735;
        double r806737 = r806721 * r806736;
        double r806738 = r806734 - r806737;
        double r806739 = r806709 ? r806727 : r806738;
        return r806739;
}

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.9
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.10015674080410512 \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.17088779117474882 \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.8768236795461372 \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.3838515042456319 \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 < -5.746745343249455e-25 or 1.660011137319099e-94 < 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. Simplified10.0

      \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z} - a \cdot \left(4 \cdot t\right)}{c}}\]
    3. Taylor expanded around 0 13.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. Simplified13.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 associate-/l*11.0

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

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

    if -5.746745343249455e-25 < z < 1.660011137319099e-94

    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. Simplified22.1

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

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

      \[\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-identity9.8

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

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

      \[\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 *-un-lft-identity6.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -5.7467453432494554 \cdot 10^{-25} \lor \neg \left(z \le 1.660011137319099 \cdot 10^{-94}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{c \cdot \frac{z}{y}}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \frac{t \cdot a}{c}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x \cdot y}{z \cdot c}, 9, \frac{1}{z} \cdot \frac{b}{c}\right) - 4 \cdot \left(t \cdot \frac{a}{c}\right)\\ \end{array}\]

Reproduce

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