Average Error: 20.1 → 5.0
Time: 24.8s
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} = -\infty:\\ \;\;\;\;\frac{\frac{1}{c}}{\frac{1}{\mathsf{fma}\left(y \cdot \frac{x}{z}, 9.0, \frac{b}{z}\right) - a \cdot \left(4.0 \cdot t\right)}}\\ \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 -5.462426595109968 \cdot 10^{-122}:\\ \;\;\;\;\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{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 0.0:\\ \;\;\;\;\frac{1}{\frac{1}{\sqrt[3]{\frac{\mathsf{fma}\left(x \cdot 9.0, y, b\right)}{z} - a \cdot \left(4.0 \cdot t\right)} \cdot \sqrt[3]{\frac{\mathsf{fma}\left(x \cdot 9.0, y, b\right)}{z} - a \cdot \left(4.0 \cdot t\right)}}} \cdot \frac{1}{\frac{c}{\sqrt[3]{\frac{\mathsf{fma}\left(x \cdot 9.0, y, b\right)}{z} - a \cdot \left(4.0 \cdot t\right)}}}\\ \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.076115171897018 \cdot 10^{+306}:\\ \;\;\;\;\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}:\\ \;\;\;\;\frac{\frac{1}{c}}{\frac{1}{\mathsf{fma}\left(y \cdot \frac{x}{z}, 9.0, \frac{b}{z}\right) - a \cdot \left(4.0 \cdot t\right)}}\\ \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} = -\infty:\\
\;\;\;\;\frac{\frac{1}{c}}{\frac{1}{\mathsf{fma}\left(y \cdot \frac{x}{z}, 9.0, \frac{b}{z}\right) - a \cdot \left(4.0 \cdot t\right)}}\\

\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 -5.462426595109968 \cdot 10^{-122}:\\
\;\;\;\;\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{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 0.0:\\
\;\;\;\;\frac{1}{\frac{1}{\sqrt[3]{\frac{\mathsf{fma}\left(x \cdot 9.0, y, b\right)}{z} - a \cdot \left(4.0 \cdot t\right)} \cdot \sqrt[3]{\frac{\mathsf{fma}\left(x \cdot 9.0, y, b\right)}{z} - a \cdot \left(4.0 \cdot t\right)}}} \cdot \frac{1}{\frac{c}{\sqrt[3]{\frac{\mathsf{fma}\left(x \cdot 9.0, y, b\right)}{z} - a \cdot \left(4.0 \cdot t\right)}}}\\

\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.076115171897018 \cdot 10^{+306}:\\
\;\;\;\;\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}:\\
\;\;\;\;\frac{\frac{1}{c}}{\frac{1}{\mathsf{fma}\left(y \cdot \frac{x}{z}, 9.0, \frac{b}{z}\right) - a \cdot \left(4.0 \cdot t\right)}}\\

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r33454183 = x;
        double r33454184 = 9.0;
        double r33454185 = r33454183 * r33454184;
        double r33454186 = y;
        double r33454187 = r33454185 * r33454186;
        double r33454188 = z;
        double r33454189 = 4.0;
        double r33454190 = r33454188 * r33454189;
        double r33454191 = t;
        double r33454192 = r33454190 * r33454191;
        double r33454193 = a;
        double r33454194 = r33454192 * r33454193;
        double r33454195 = r33454187 - r33454194;
        double r33454196 = b;
        double r33454197 = r33454195 + r33454196;
        double r33454198 = c;
        double r33454199 = r33454188 * r33454198;
        double r33454200 = r33454197 / r33454199;
        return r33454200;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r33454201 = x;
        double r33454202 = 9.0;
        double r33454203 = r33454201 * r33454202;
        double r33454204 = y;
        double r33454205 = r33454203 * r33454204;
        double r33454206 = z;
        double r33454207 = 4.0;
        double r33454208 = r33454206 * r33454207;
        double r33454209 = t;
        double r33454210 = r33454208 * r33454209;
        double r33454211 = a;
        double r33454212 = r33454210 * r33454211;
        double r33454213 = r33454205 - r33454212;
        double r33454214 = b;
        double r33454215 = r33454213 + r33454214;
        double r33454216 = c;
        double r33454217 = r33454216 * r33454206;
        double r33454218 = r33454215 / r33454217;
        double r33454219 = -inf.0;
        bool r33454220 = r33454218 <= r33454219;
        double r33454221 = 1.0;
        double r33454222 = r33454221 / r33454216;
        double r33454223 = r33454201 / r33454206;
        double r33454224 = r33454204 * r33454223;
        double r33454225 = r33454214 / r33454206;
        double r33454226 = fma(r33454224, r33454202, r33454225);
        double r33454227 = r33454207 * r33454209;
        double r33454228 = r33454211 * r33454227;
        double r33454229 = r33454226 - r33454228;
        double r33454230 = r33454221 / r33454229;
        double r33454231 = r33454222 / r33454230;
        double r33454232 = -5.462426595109968e-122;
        bool r33454233 = r33454218 <= r33454232;
        double r33454234 = 0.0;
        bool r33454235 = r33454218 <= r33454234;
        double r33454236 = fma(r33454203, r33454204, r33454214);
        double r33454237 = r33454236 / r33454206;
        double r33454238 = r33454237 - r33454228;
        double r33454239 = cbrt(r33454238);
        double r33454240 = r33454239 * r33454239;
        double r33454241 = r33454221 / r33454240;
        double r33454242 = r33454221 / r33454241;
        double r33454243 = r33454216 / r33454239;
        double r33454244 = r33454221 / r33454243;
        double r33454245 = r33454242 * r33454244;
        double r33454246 = 9.076115171897018e+306;
        bool r33454247 = r33454218 <= r33454246;
        double r33454248 = r33454247 ? r33454218 : r33454231;
        double r33454249 = r33454235 ? r33454245 : r33454248;
        double r33454250 = r33454233 ? r33454218 : r33454249;
        double r33454251 = r33454220 ? r33454231 : r33454250;
        return r33454251;
}

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.1
Target14.5
Herbie5.0
\[\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 3 regimes
  2. if (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -inf.0 or 9.076115171897018e+306 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c))

    1. Initial program 61.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. Simplified25.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. Using strategy rm
    4. Applied *-un-lft-identity25.6

      \[\leadsto \frac{\frac{\mathsf{fma}\left(y \cdot 9.0, x, b\right)}{z} - \left(a \cdot t\right) \cdot 4.0}{\color{blue}{1 \cdot c}}\]
    5. Applied associate-/r*25.6

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{c}{\frac{\mathsf{fma}\left(x \cdot 9.0, y, b\right)}{z} - \left(4.0 \cdot t\right) \cdot a}}}\]
    9. Using strategy rm
    10. Applied div-inv25.8

      \[\leadsto \frac{1}{\color{blue}{c \cdot \frac{1}{\frac{\mathsf{fma}\left(x \cdot 9.0, y, b\right)}{z} - \left(4.0 \cdot t\right) \cdot a}}}\]
    11. Applied associate-/r*25.8

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

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

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

    if -inf.0 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -5.462426595109968e-122 or 0.0 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 9.076115171897018e+306

    1. Initial program 0.8

      \[\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 -5.462426595109968e-122 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 0.0

    1. Initial program 28.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}\]
    2. Simplified0.7

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

      \[\leadsto \frac{\frac{\mathsf{fma}\left(y \cdot 9.0, x, b\right)}{z} - \left(a \cdot t\right) \cdot 4.0}{\color{blue}{1 \cdot c}}\]
    5. Applied associate-/r*0.7

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{c}{\frac{\mathsf{fma}\left(x \cdot 9.0, y, b\right)}{z} - \left(4.0 \cdot t\right) \cdot a}}}\]
    9. Using strategy rm
    10. Applied add-cube-cbrt2.1

      \[\leadsto \frac{1}{\frac{c}{\color{blue}{\left(\sqrt[3]{\frac{\mathsf{fma}\left(x \cdot 9.0, y, b\right)}{z} - \left(4.0 \cdot t\right) \cdot a} \cdot \sqrt[3]{\frac{\mathsf{fma}\left(x \cdot 9.0, y, b\right)}{z} - \left(4.0 \cdot t\right) \cdot a}\right) \cdot \sqrt[3]{\frac{\mathsf{fma}\left(x \cdot 9.0, y, b\right)}{z} - \left(4.0 \cdot t\right) \cdot a}}}}\]
    11. Applied *-un-lft-identity2.1

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

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{\sqrt[3]{\frac{\mathsf{fma}\left(x \cdot 9.0, y, b\right)}{z} - \left(4.0 \cdot t\right) \cdot a} \cdot \sqrt[3]{\frac{\mathsf{fma}\left(x \cdot 9.0, y, b\right)}{z} - \left(4.0 \cdot t\right) \cdot a}} \cdot \frac{c}{\sqrt[3]{\frac{\mathsf{fma}\left(x \cdot 9.0, y, b\right)}{z} - \left(4.0 \cdot t\right) \cdot a}}}}\]
    13. Applied *-un-lft-identity2.1

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

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

    \[\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} = -\infty:\\ \;\;\;\;\frac{\frac{1}{c}}{\frac{1}{\mathsf{fma}\left(y \cdot \frac{x}{z}, 9.0, \frac{b}{z}\right) - a \cdot \left(4.0 \cdot t\right)}}\\ \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 -5.462426595109968 \cdot 10^{-122}:\\ \;\;\;\;\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{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 0.0:\\ \;\;\;\;\frac{1}{\frac{1}{\sqrt[3]{\frac{\mathsf{fma}\left(x \cdot 9.0, y, b\right)}{z} - a \cdot \left(4.0 \cdot t\right)} \cdot \sqrt[3]{\frac{\mathsf{fma}\left(x \cdot 9.0, y, b\right)}{z} - a \cdot \left(4.0 \cdot t\right)}}} \cdot \frac{1}{\frac{c}{\sqrt[3]{\frac{\mathsf{fma}\left(x \cdot 9.0, y, b\right)}{z} - a \cdot \left(4.0 \cdot t\right)}}}\\ \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.076115171897018 \cdot 10^{+306}:\\ \;\;\;\;\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}:\\ \;\;\;\;\frac{\frac{1}{c}}{\frac{1}{\mathsf{fma}\left(y \cdot \frac{x}{z}, 9.0, \frac{b}{z}\right) - a \cdot \left(4.0 \cdot t\right)}}\\ \end{array}\]

Reproduce

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