Average Error: 19.4 → 4.7
Time: 22.4s
Precision: 64
\[\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le -3.274372812508611 \cdot 10^{+48}:\\ \;\;\;\;\left(\frac{b}{c \cdot z} + 9.0 \cdot \frac{\frac{x}{c \cdot z}}{\frac{1}{y}}\right) - \left(t \cdot \frac{a}{c}\right) \cdot 4.0\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le 1.1024395663495743 \cdot 10^{-15}:\\ \;\;\;\;\frac{\frac{1}{z} \cdot \mathsf{fma}\left(y \cdot 9.0, x, b\right) - 4.0 \cdot \left(t \cdot a\right)}{c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le 9.789607562183863 \cdot 10^{+295}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{b}{c \cdot z} + \frac{x}{z \cdot \frac{c}{y}} \cdot 9.0\right) - \left(t \cdot \frac{a}{c}\right) \cdot 4.0\\ \end{array}\]
\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}
\begin{array}{l}
\mathbf{if}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le -3.274372812508611 \cdot 10^{+48}:\\
\;\;\;\;\left(\frac{b}{c \cdot z} + 9.0 \cdot \frac{\frac{x}{c \cdot z}}{\frac{1}{y}}\right) - \left(t \cdot \frac{a}{c}\right) \cdot 4.0\\

\mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le 1.1024395663495743 \cdot 10^{-15}:\\
\;\;\;\;\frac{\frac{1}{z} \cdot \mathsf{fma}\left(y \cdot 9.0, x, b\right) - 4.0 \cdot \left(t \cdot a\right)}{c}\\

\mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le 9.789607562183863 \cdot 10^{+295}:\\
\;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z}\\

\mathbf{else}:\\
\;\;\;\;\left(\frac{b}{c \cdot z} + \frac{x}{z \cdot \frac{c}{y}} \cdot 9.0\right) - \left(t \cdot \frac{a}{c}\right) \cdot 4.0\\

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r32190191 = x;
        double r32190192 = 9.0;
        double r32190193 = r32190191 * r32190192;
        double r32190194 = y;
        double r32190195 = r32190193 * r32190194;
        double r32190196 = z;
        double r32190197 = 4.0;
        double r32190198 = r32190196 * r32190197;
        double r32190199 = t;
        double r32190200 = r32190198 * r32190199;
        double r32190201 = a;
        double r32190202 = r32190200 * r32190201;
        double r32190203 = r32190195 - r32190202;
        double r32190204 = b;
        double r32190205 = r32190203 + r32190204;
        double r32190206 = c;
        double r32190207 = r32190196 * r32190206;
        double r32190208 = r32190205 / r32190207;
        return r32190208;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r32190209 = x;
        double r32190210 = 9.0;
        double r32190211 = r32190209 * r32190210;
        double r32190212 = y;
        double r32190213 = r32190211 * r32190212;
        double r32190214 = z;
        double r32190215 = 4.0;
        double r32190216 = r32190214 * r32190215;
        double r32190217 = t;
        double r32190218 = r32190216 * r32190217;
        double r32190219 = a;
        double r32190220 = r32190218 * r32190219;
        double r32190221 = r32190213 - r32190220;
        double r32190222 = b;
        double r32190223 = r32190221 + r32190222;
        double r32190224 = c;
        double r32190225 = r32190224 * r32190214;
        double r32190226 = r32190223 / r32190225;
        double r32190227 = -3.274372812508611e+48;
        bool r32190228 = r32190226 <= r32190227;
        double r32190229 = r32190222 / r32190225;
        double r32190230 = r32190209 / r32190225;
        double r32190231 = 1.0;
        double r32190232 = r32190231 / r32190212;
        double r32190233 = r32190230 / r32190232;
        double r32190234 = r32190210 * r32190233;
        double r32190235 = r32190229 + r32190234;
        double r32190236 = r32190219 / r32190224;
        double r32190237 = r32190217 * r32190236;
        double r32190238 = r32190237 * r32190215;
        double r32190239 = r32190235 - r32190238;
        double r32190240 = 1.1024395663495743e-15;
        bool r32190241 = r32190226 <= r32190240;
        double r32190242 = r32190231 / r32190214;
        double r32190243 = r32190212 * r32190210;
        double r32190244 = fma(r32190243, r32190209, r32190222);
        double r32190245 = r32190242 * r32190244;
        double r32190246 = r32190217 * r32190219;
        double r32190247 = r32190215 * r32190246;
        double r32190248 = r32190245 - r32190247;
        double r32190249 = r32190248 / r32190224;
        double r32190250 = 9.789607562183863e+295;
        bool r32190251 = r32190226 <= r32190250;
        double r32190252 = r32190224 / r32190212;
        double r32190253 = r32190214 * r32190252;
        double r32190254 = r32190209 / r32190253;
        double r32190255 = r32190254 * r32190210;
        double r32190256 = r32190229 + r32190255;
        double r32190257 = r32190256 - r32190238;
        double r32190258 = r32190251 ? r32190226 : r32190257;
        double r32190259 = r32190241 ? r32190249 : r32190258;
        double r32190260 = r32190228 ? r32190239 : r32190259;
        return r32190260;
}

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

Original19.4
Target13.7
Herbie4.7
\[\begin{array}{l} \mathbf{if}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt -1.100156740804105 \cdot 10^{-171}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(z \cdot 4.0\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt -0.0:\\ \;\;\;\;\frac{\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z}}{c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt 1.1708877911747488 \cdot 10^{-53}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(z \cdot 4.0\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt 2.876823679546137 \cdot 10^{+130}:\\ \;\;\;\;\left(\left(9.0 \cdot \frac{y}{c}\right) \cdot \frac{x}{z} + \frac{b}{c \cdot z}\right) - 4.0 \cdot \frac{a \cdot t}{c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt 1.3838515042456319 \cdot 10^{+158}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(z \cdot 4.0\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\left(9.0 \cdot \left(\frac{y}{c \cdot z} \cdot x\right) + \frac{b}{c \cdot z}\right) - 4.0 \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)) < -3.274372812508611e+48

    1. Initial program 17.4

      \[\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]
    2. Simplified17.5

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

      \[\leadsto \color{blue}{\left(9.0 \cdot \frac{x \cdot y}{z \cdot c} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \frac{t \cdot a}{c}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity10.8

      \[\leadsto \left(9.0 \cdot \frac{x \cdot y}{z \cdot c} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \frac{t \cdot a}{\color{blue}{1 \cdot c}}\]
    6. Applied times-frac9.8

      \[\leadsto \left(9.0 \cdot \frac{x \cdot y}{z \cdot c} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \color{blue}{\left(\frac{t}{1} \cdot \frac{a}{c}\right)}\]
    7. Simplified9.8

      \[\leadsto \left(9.0 \cdot \frac{x \cdot y}{z \cdot c} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \left(\color{blue}{t} \cdot \frac{a}{c}\right)\]
    8. Using strategy rm
    9. Applied associate-/l*8.1

      \[\leadsto \left(9.0 \cdot \color{blue}{\frac{x}{\frac{z \cdot c}{y}}} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \left(t \cdot \frac{a}{c}\right)\]
    10. Using strategy rm
    11. Applied div-inv8.1

      \[\leadsto \left(9.0 \cdot \frac{x}{\color{blue}{\left(z \cdot c\right) \cdot \frac{1}{y}}} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \left(t \cdot \frac{a}{c}\right)\]
    12. Applied associate-/r*8.0

      \[\leadsto \left(9.0 \cdot \color{blue}{\frac{\frac{x}{z \cdot c}}{\frac{1}{y}}} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \left(t \cdot \frac{a}{c}\right)\]

    if -3.274372812508611e+48 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 1.1024395663495743e-15

    1. Initial program 11.7

      \[\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]
    2. Simplified1.2

      \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(y \cdot 9.0, x, b\right)}{z} - \left(a \cdot t\right) \cdot 4.0}{c}}\]
    3. Using strategy rm
    4. Applied div-inv1.2

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

    if 1.1024395663495743e-15 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 9.789607562183863e+295

    1. Initial program 0.6

      \[\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]

    if 9.789607562183863e+295 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c))

    1. Initial program 59.0

      \[\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]
    2. Simplified24.6

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

      \[\leadsto \color{blue}{\left(9.0 \cdot \frac{x \cdot y}{z \cdot c} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \frac{t \cdot a}{c}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity27.4

      \[\leadsto \left(9.0 \cdot \frac{x \cdot y}{z \cdot c} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \frac{t \cdot a}{\color{blue}{1 \cdot c}}\]
    6. Applied times-frac22.5

      \[\leadsto \left(9.0 \cdot \frac{x \cdot y}{z \cdot c} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \color{blue}{\left(\frac{t}{1} \cdot \frac{a}{c}\right)}\]
    7. Simplified22.5

      \[\leadsto \left(9.0 \cdot \frac{x \cdot y}{z \cdot c} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \left(\color{blue}{t} \cdot \frac{a}{c}\right)\]
    8. Using strategy rm
    9. Applied associate-/l*14.8

      \[\leadsto \left(9.0 \cdot \color{blue}{\frac{x}{\frac{z \cdot c}{y}}} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \left(t \cdot \frac{a}{c}\right)\]
    10. Using strategy rm
    11. Applied *-un-lft-identity14.8

      \[\leadsto \left(9.0 \cdot \frac{x}{\frac{z \cdot c}{\color{blue}{1 \cdot y}}} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \left(t \cdot \frac{a}{c}\right)\]
    12. Applied times-frac10.8

      \[\leadsto \left(9.0 \cdot \frac{x}{\color{blue}{\frac{z}{1} \cdot \frac{c}{y}}} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \left(t \cdot \frac{a}{c}\right)\]
    13. Simplified10.8

      \[\leadsto \left(9.0 \cdot \frac{x}{\color{blue}{z} \cdot \frac{c}{y}} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \left(t \cdot \frac{a}{c}\right)\]
  3. Recombined 4 regimes into one program.
  4. Final simplification4.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le -3.274372812508611 \cdot 10^{+48}:\\ \;\;\;\;\left(\frac{b}{c \cdot z} + 9.0 \cdot \frac{\frac{x}{c \cdot z}}{\frac{1}{y}}\right) - \left(t \cdot \frac{a}{c}\right) \cdot 4.0\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le 1.1024395663495743 \cdot 10^{-15}:\\ \;\;\;\;\frac{\frac{1}{z} \cdot \mathsf{fma}\left(y \cdot 9.0, x, b\right) - 4.0 \cdot \left(t \cdot a\right)}{c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le 9.789607562183863 \cdot 10^{+295}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{b}{c \cdot z} + \frac{x}{z \cdot \frac{c}{y}} \cdot 9.0\right) - \left(t \cdot \frac{a}{c}\right) \cdot 4.0\\ \end{array}\]

Reproduce

herbie shell --seed 2019162 +o rules:numerics
(FPCore (x y z t a b c)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, J"

  :herbie-target
  (if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) -1.100156740804105e-171) (/ (+ (- (* (* x 9.0) y) (* (* z 4.0) (* t a))) b) (* z c)) (if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) -0.0) (/ (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) z) c) (if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) 1.1708877911747488e-53) (/ (+ (- (* (* x 9.0) y) (* (* z 4.0) (* t a))) b) (* z c)) (if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) 2.876823679546137e+130) (- (+ (* (* 9.0 (/ y c)) (/ x z)) (/ b (* c z))) (* 4.0 (/ (* a t) c))) (if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) 1.3838515042456319e+158) (/ (+ (- (* (* x 9.0) y) (* (* z 4.0) (* t a))) b) (* z c)) (- (+ (* 9.0 (* (/ y (* c z)) x)) (/ b (* c z))) (* 4.0 (/ (* a t) c))))))))

  (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)))